Skip to content

Commit

Permalink
Fixed StatusGenerator + test
Browse files Browse the repository at this point in the history
- the fix is not complete, but at least it doesn't crash with NPE

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Dec 7, 2022
1 parent e95a390 commit 7197b90
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@ManagedJob
public class ProgressPayloadCommand implements AdminCommand {

private final static Logger logger = LogDomains.getLogger(ProgressPayloadCommand.class, LogDomains.ADMIN_LOGGER);
private static final Logger LOG = Logger.getLogger(ProgressPayloadCommand.class.getName());

@Param(name = "down", multiple = false, primary = true, optional = true)
String down;
Expand Down Expand Up @@ -88,7 +88,7 @@ public void execute(AdminCommandContext context) {
out.attachFile("application/octet-stream", URI.create(canonicalPath), f.getName(), f);
}
} catch (IOException ex) {
report.failure(logger, "Can not append " + f.getAbsolutePath());
report.failure(LOG, "Can not append " + f.getAbsolutePath());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ public void testApplicationDeploymentWithDefaultContextRoot() throws URISyntaxEx
}
}

private static String getFileNameWithoutSuffix(final String filename) {
if (filename.contains(".")) {
return filename.substring(0, filename.lastIndexOf("."));
} else {
return filename;
}
}

@Test
public void testApplicationDisableEnable() throws URISyntaxException {
Map<String, String> deployedApp = deployApp(getWar("test"), appName, appName);
Expand Down Expand Up @@ -207,4 +199,11 @@ public void testUndeploySubActionWarnings() throws URISyntaxException {
managementClient.delete("/domain/applications/application/" + appName, Map.of("target", "domain"));
}
}

private static String getFileNameWithoutSuffix(final String filename) {
if (filename.contains(".")) {
return filename.substring(0, filename.lastIndexOf("."));
}
return filename;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.main.admin.test.rest;

import jakarta.ws.rs.core.Response;

import org.glassfish.main.admin.test.tool.DomainAdminRestClient;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.junit.jupiter.api.Assertions.assertAll;

/**
* @author David Matejcek
*/
public class StatusGeneratorITest extends RestTestBase {

@Test
public void testApplicationDeployment() throws Exception {
String url = getBaseAdminUrl() + CONTEXT_ROOT_MANAGEMENT;
try (DomainAdminRestClient statusClient = new DomainAdminRestClient(url, "text/plain")) {
Response response = statusClient.get("/status/");
assertAll(
() -> assertThat(response.getStatus(), equalTo(200)),
() -> assertThat(response.readEntity(String.class),
stringContainsInOrder("All Commands used in REST Admin",
"Missing Commands not used in REST Admin",
"create-instance",
"REST-REDIRECT Commands defined on ConfigBeans",
"Commands to Resources Mapping Usage in REST Admin",
"Resources with Delete Commands in REST Admin (not counting RESTREDIRECT")
)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.logging.Logger;
import jakarta.inject.Inject;
import javax.security.auth.Subject;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.SecurityContext;
import jakarta.ws.rs.core.UriInfo;
Expand All @@ -35,17 +34,17 @@
* @author jdlee
*/
public abstract class AbstractResource {
@Context
@Inject
protected HttpHeaders requestHeaders;
@Context
@Inject
protected UriInfo uriInfo;
@Inject
protected Ref<Subject> subjectRef;
@Inject
protected LocatorBridge locatorBridge;
@Context
@Inject
protected SecurityContext securityContext;
@Context
@Inject
protected ServiceLocator serviceLocator;

private String authenticatedUser;
Expand Down
Loading

0 comments on commit 7197b90

Please sign in to comment.