#23507 Fixed admin-tests
- now they detect bugs, see next commits
- 2 tests are reproducers of bugs I could not fix easily
- new test dependency - ShrinkWrap
Signed-off-by: David Matějček <dmatej@seznam.cz>
diff --git a/appserver/tests/admin/admin-extension/pom.xml b/appserver/tests/admin/admin-extension/pom.xml
index 4066d53..a6ad15d 100644
--- a/appserver/tests/admin/admin-extension/pom.xml
+++ b/appserver/tests/admin/admin-extension/pom.xml
@@ -25,31 +25,33 @@
<version>7.0.0-SNAPSHOT</version>
</parent>
<artifactId>test-progress-admin-extension</artifactId>
- <name>GlassFish Admin Tests - Progress Admin Extension</name>
<packaging>glassfish-jar</packaging>
+
+ <name>GlassFish Admin Tests - Progress Admin Extension</name>
+
<dependencies>
<dependency>
<groupId>org.glassfish.main.common</groupId>
<artifactId>glassfish-api</artifactId>
<version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.common</groupId>
<artifactId>common-util</artifactId>
<version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.glassfish.main.admin</groupId>
- <artifactId>config-api</artifactId>
- <version>${project.version}</version>
- </dependency>
+
<dependency>
<groupId>org.glassfish.hk2</groupId>
- <artifactId>hk2</artifactId>
+ <artifactId>hk2-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.glassfish.hk2</groupId>
- <artifactId>hk2-junitrunner</artifactId>
+ <groupId>jakarta.inject</groupId>
+ <artifactId>jakarta.inject-api</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressComplexCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressComplexCommand.java
index 8f61b6f..7e095ae 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressComplexCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressComplexCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,24 +17,22 @@
package com.sun.enterprise.tests.progress;
-import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.logging.LogDomains;
-import java.util.logging.Level;
+
import java.util.logging.Logger;
+
import org.glassfish.api.I18n;
-import org.glassfish.api.Param;
import org.glassfish.api.admin.AdminCommand;
import org.glassfish.api.admin.AdminCommandContext;
import org.glassfish.api.admin.CommandLock;
import org.glassfish.api.admin.ManagedJob;
import org.glassfish.api.admin.Progress;
import org.glassfish.api.admin.ProgressStatus;
-import org.glassfish.api.admin.RestEndpoint;
-import org.glassfish.api.admin.RestEndpoints;
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;
-/** Basic progress status example.
+/**
+ * Basic progress status example.
* Contains 10 steps
*
* @author mmares
@@ -137,6 +136,7 @@
this.message = message;
}
+ @Override
public void run() {
doProgress(ps, count, interval, message);
}
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressCustomCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressCustomCommand.java
index 974c6f1..7d30c49 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressCustomCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressCustomCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -19,6 +20,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.regex.Pattern;
+
import org.glassfish.api.ActionReport;
import org.glassfish.api.I18n;
import org.glassfish.api.Param;
@@ -31,7 +33,6 @@
import org.jvnet.hk2.annotations.Service;
/**
- *
* @author mmares
*/
@Service(name = "progress-custom")
@@ -51,14 +52,14 @@
private static class Interval {
private boolean valid = true;
- private String origInteval;
+ private String origInterval;
private int multiplicator = 1;
private int minSec = -1;
private int maxSec = 0;
private boolean spin = false;
private Interval(String interval) {
- origInteval = interval;
+ origInterval = interval;
try {
if (!keyPattern.matcher(interval).matches()) {
valid = false;
@@ -99,13 +100,8 @@
public int getMultiplicator() {
if (valid) {
return multiplicator;
- } else {
- return 1;
}
- }
-
- public String getOrigInteval() {
- return origInteval;
+ return 1;
}
public boolean isValid() {
@@ -128,7 +124,7 @@
@Override
public String toString() {
- return origInteval;
+ return origInterval;
}
}
@@ -149,7 +145,7 @@
@Override
public void execute(AdminCommandContext context) {
ProgressStatus ps = context.getProgressStatus();
- parsedIntervals = new ArrayList<Interval>(intervals != null ? intervals.length : 0);
+ parsedIntervals = new ArrayList<>(intervals != null ? intervals.length : 0);
ActionReport report = context.getActionReport();
for (String interval : intervals) {
parsedIntervals.add(new Interval(interval));
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressDoubleTotalsCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressDoubleTotalsCommand.java
index 08d5ba7..698a113 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressDoubleTotalsCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressDoubleTotalsCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -26,7 +27,8 @@
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;
-/** Basic progress status example.
+/**
+ * Basic progress status example.
* Contains 10 steps
*
* @author mmares
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressExecOtherCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressExecOtherCommand.java
index 042eaf9..1ef602e 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressExecOtherCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressExecOtherCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -55,15 +56,11 @@
}
// Execute other command
- commandRunner.getCommandInvocation(
- "progress-simple",
- context.getActionReport()
- .addSubActionsReport(),
+ // Number 20 is little bit tricky. Please see javadoc of ProgressStatus
+ commandRunner.getCommandInvocation("progress-simple",
+ context.getActionReport().addSubActionsReport(),
context.getSubject())
- .progressStatusChild(
- // Number 20 is little bit tricky. Please see javadoc of ProgressStatus
- progressStatus.createChild("subcommand", 20))
- .execute();
+ .progressStatusChild(progressStatus.createChild("subcommand", 20)).execute();
// Do some after logic
progressStatus.progress("Finishing outer command");
@@ -73,8 +70,6 @@
}
progressStatus.complete("Finished outer command");
-
- System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
}
private void doSomeLogic() {
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressFailInHalfCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressFailInHalfCommand.java
index 029930e..eae9750 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressFailInHalfCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressFailInHalfCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressFullAnnotCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressFullAnnotCommand.java
index 84c4e07..f19189f 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressFullAnnotCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressFullAnnotCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -42,5 +43,4 @@
cmd.noTotalSteps = true;
cmd.execute(context);
}
-
}
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressPayloadCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressPayloadCommand.java
index 4892191..09f2e60 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressPayloadCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressPayloadCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -18,10 +19,12 @@
import com.sun.enterprise.util.StringUtils;
import com.sun.logging.LogDomains;
+
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Logger;
+
import org.glassfish.api.ActionReport;
import org.glassfish.api.I18n;
import org.glassfish.api.Param;
@@ -35,7 +38,8 @@
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;
-/** Doing progress and send some payload.
+/**
+ * Doing progress and send some payload.
*
* @author mmares
*/
@@ -47,8 +51,7 @@
@ManagedJob
public class ProgressPayloadCommand implements AdminCommand {
- private final static Logger logger =
- LogDomains.getLogger(ProgressPayloadCommand.class, LogDomains.ADMIN_LOGGER);
+ private final static Logger logger = LogDomains.getLogger(ProgressPayloadCommand.class, LogDomains.ADMIN_LOGGER);
@Param(name = "down", multiple = false, primary = true, optional = true)
String down;
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressSimpleCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressSimpleCommand.java
index 41b0df8..c6e81cb 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressSimpleCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressSimpleCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressStepBackCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressStepBackCommand.java
index 614d59d..27fd174 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressStepBackCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressStepBackCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -26,7 +27,8 @@
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;
-/** Basic progress status example.
+/**
+ * Basic progress status example.
* Contains 10 steps
*
* @author mmares
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressWithSupplementCommand.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressWithSupplementCommand.java
index 37273cc..c49b1e7 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressWithSupplementCommand.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/ProgressWithSupplementCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,7 +17,6 @@
package com.sun.enterprise.tests.progress;
-import com.sun.enterprise.universal.i18n.LocalStringsImpl;
import org.glassfish.api.I18n;
import org.glassfish.api.admin.AdminCommand;
import org.glassfish.api.admin.AdminCommandContext;
@@ -26,7 +26,8 @@
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;
-/** Same as {@code ProgressSimpleCommand} but this one has supplements.
+/**
+ * Same as {@code ProgressSimpleCommand} but this one has supplements.
* It also does not specify totalStepCount in annotation but using API.
* Percentage can be printed after {@code SupplementBefore} will be done.
*
@@ -38,12 +39,9 @@
@PerLookup
@CommandLock(CommandLock.LockType.NONE)
@I18n("progress")
-@Progress()
+@Progress
public class ProgressWithSupplementCommand implements AdminCommand {
- private static final LocalStringsImpl strings =
- new LocalStringsImpl(ProgressWithSupplementCommand.class);
-
@Override
public void execute(AdminCommandContext context) {
ProgressStatus ps = context.getProgressStatus();
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/SupplementAfter.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/SupplementAfter.java
index f24e876..f094f54 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/SupplementAfter.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/SupplementAfter.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
diff --git a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/SupplementBefore.java b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/SupplementBefore.java
index 2faed1d..f0f6866 100644
--- a/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/SupplementBefore.java
+++ b/appserver/tests/admin/admin-extension/src/main/java/com/sun/enterprise/tests/progress/SupplementBefore.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
diff --git a/appserver/tests/admin/tests/pom.xml b/appserver/tests/admin/tests/pom.xml
index 0a6794a..43aea7f 100644
--- a/appserver/tests/admin/tests/pom.xml
+++ b/appserver/tests/admin/tests/pom.xml
@@ -31,16 +31,13 @@
<name>GlassFish Admin Tests</name>
<dependencies>
- <dependency>
- <groupId>org.glassfish.hk2</groupId>
- <artifactId>hk2-api</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-server</artifactId>
+ <artifactId>jersey-client</artifactId>
<scope>test</scope>
</dependency>
+ <!-- Used by the jersey-client -->
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
@@ -53,18 +50,28 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.glassfish.main.admin</groupId>
- <artifactId>rest-service</artifactId>
- <version>${project.version}</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.glassfish.main.common</groupId>
<artifactId>common-util</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.glassfish.main.security</groupId>
+ <artifactId>security</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.main.security</groupId>
+ <artifactId>security-ee</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.glassfish.main.distributions</groupId>
@@ -79,6 +86,7 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
@@ -87,14 +95,9 @@
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
-
<dependency>
- <groupId>jakarta.xml.bind</groupId>
- <artifactId>jakarta.xml.bind-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-osgi</artifactId>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
</dependency>
</dependencies>
@@ -127,14 +130,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <properties>
- <runOrder>alphabetical</runOrder>
- </properties>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/ClusterTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/ClusterITest.java
similarity index 61%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/ClusterTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/ClusterITest.java
index dc1b66b..1a8f196 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/ClusterTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/ClusterITest.java
@@ -35,30 +35,28 @@
*/
@TestMethodOrder(OrderAnnotation.class)
@ExtendWith(DomainLifecycleExtension.class)
-public class ClusterTest {
+public class ClusterITest {
- private final String tn = "QLCluster";
- private final String port1 = "55123";
- private final String port2 = "55124";
- private final String cname = "eec1";
- private final String i1name = "eein1-with-a-very-very-very-long-name";
- private final String i2name = "eein2";
- private final String i1url = "http://localhost:" + port1;
- private final String i2url = "http://localhost:" + port2;
+ private static final String PORT1 = "55123";
+ private static final String PORT2 = "55124";
+ private static final String CLUSTER_NAME = "eec1";
+ private static final String INSTANCE_NAME_1 = "eein1-with-a-very-very-very-long-name";
+ private static final String INSTANCE_NAME_2 = "eein2";
+ private static final String URL1 = "http://localhost:" + PORT1;
+ private static final String URL2 = "http://localhost:" + PORT2;
@Test
@Order(1)
public void createClusterTest() {
- // create a cluster and two instances
- assertTrue(nadmin("create-cluster", cname), "create cluster");
+ assertTrue(nadmin("create-cluster", CLUSTER_NAME), "create cluster");
}
@Test
@Order(2)
public void createInstancesTest() {
assertTrue(
- nadmin("create-local-instance", "--cluster", cname, "--systemproperties",
- "HTTP_LISTENER_PORT=" + port1 + ":" +
+ nadmin("create-local-instance", "--cluster", CLUSTER_NAME, "--systemproperties",
+ "HTTP_LISTENER_PORT=" + PORT1 + ":" +
"HTTP_SSL_LISTENER_PORT=18181:" +
"IIOP_SSL_LISTENER_PORT=13800:" +
"IIOP_LISTENER_PORT=13700:" +
@@ -66,52 +64,49 @@
"IIOP_SSL_MUTUALAUTH_PORT=13801:" +
"JMS_PROVIDER_PORT=18686:" +
"ASADMIN_LISTENER_PORT=14848",
- i1name), "create instance1");
+ INSTANCE_NAME_1), "create instance1");
assertTrue(
- nadmin("create-local-instance", "--cluster", cname, "--systemproperties",
- "HTTP_LISTENER_PORT=" + port2 +
+ nadmin("create-local-instance", "--cluster", CLUSTER_NAME, "--systemproperties",
+ "HTTP_LISTENER_PORT=" + PORT2 +
":HTTP_SSL_LISTENER_PORT=28181:IIOP_SSL_LISTENER_PORT=23800:" +
"IIOP_LISTENER_PORT=23700:JMX_SYSTEM_CONNECTOR_PORT=27676:IIOP_SSL_MUTUALAUTH_PORT=23801:" +
"JMS_PROVIDER_PORT=28686:ASADMIN_LISTENER_PORT=24848",
- i2name), "create instance2");
+ INSTANCE_NAME_2), "create instance2");
}
@Test
@Order(3)
public void startInstancesTest() {
- // start the instances
- assertTrue(nadmin("start-local-instance", i1name), "start instance1");
- assertTrue(nadmin("start-local-instance", i2name), "start instance2");
+ assertTrue(nadmin("start-local-instance", INSTANCE_NAME_1), "start instance1");
+ assertTrue(nadmin("start-local-instance", INSTANCE_NAME_2), "start instance2");
}
@Test
@Order(4)
public void checkClusterTest() {
- // check that the instances are there
assertTrue(nadmin("list-instances"), "list-instances");
- assertThat(getURL(i1url), stringContainsInOrder("GlassFish Server"));
- assertThat(getURL(i2url), stringContainsInOrder("GlassFish Server"));
+ assertThat(getURL(URL1), stringContainsInOrder("GlassFish Server"));
+ assertThat(getURL(URL2), stringContainsInOrder("GlassFish Server"));
}
@Test
@Order(5)
public void stopInstancesTest() {
- // stop and delete the instances and cluster
- assertTrue(nadmin("stop-local-instance", "--kill", i1name), "stop instance1");
- assertTrue(nadmin("stop-local-instance", "--kill", i2name), "stop instance2");
+ assertTrue(nadmin("stop-local-instance", "--kill", INSTANCE_NAME_1), "stop instance1");
+ assertTrue(nadmin("stop-local-instance", "--kill", INSTANCE_NAME_2), "stop instance2");
}
@Test
@Order(6)
public void deleteInstancesTest() {
- assertTrue(nadmin("delete-local-instance", i1name), "delete instance1");
- assertTrue(nadmin("delete-local-instance", i2name), "delete instance2");
+ assertTrue(nadmin("delete-local-instance", INSTANCE_NAME_1), "delete instance1");
+ assertTrue(nadmin("delete-local-instance", INSTANCE_NAME_2), "delete instance2");
}
@Test
@Order(7)
public void deleteClusterTest() {
- assertTrue(nadmin("delete-cluster", cname), "delete cluster");
+ assertTrue(nadmin("delete-cluster", CLUSTER_NAME), "delete cluster");
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/MiscCommandsTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/MiscCommandsITest.java
similarity index 97%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/MiscCommandsTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/MiscCommandsITest.java
index 1771a4b..97d7e4b 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/MiscCommandsTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/MiscCommandsITest.java
@@ -33,7 +33,7 @@
*/
@ExtendWith(DomainLifecycleExtension.class)
@TestMethodOrder(OrderAnnotation.class)
-public class MiscCommandsTest {
+public class MiscCommandsITest {
@Test
@Order(1)
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/OSGiCommandsTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/OSGiCommandsITest.java
similarity index 93%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/OSGiCommandsTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/OSGiCommandsITest.java
index 35bab2a..fa20972 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/OSGiCommandsTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/OSGiCommandsITest.java
@@ -45,41 +45,13 @@
* @author sanjeeb.sahoo@oracle.com
*/
@ExtendWith(DomainLifecycleExtension.class)
-public class OSGiCommandsTest {
+public class OSGiCommandsITest {
@Test
public void basicOsgiCmd() {
assertTrue(nadmin("osgi", "lb"));
}
- private List<String> runCmd(String... cmd) throws Exception {
- NadminReturn value = nadminWithOutput(cmd);
- if (!value.returnValue) {
- throw new Exception("Cmd failed: \n" + value.outAndErr);
- }
- List<String> output = new ArrayList<>();
- for (String line : value.out.split("\\n")) {
- line = line.trim();
- if (line.isEmpty() || line.startsWith("nadmin") || line.startsWith("Command")) {
- continue;
- }
- output.add(line);
- }
- return output;
- }
-
- private String newCmdSession() throws Exception {
- List<String> value = runCmd("osgi", "--session", "new");
- if (value.size() != 1) {
- throw new Exception("Unexpected output: \n " + value);
- }
- return value.get(0);
- }
-
- private Set<String> listCmdSessions() throws Exception {
- List<String> sessions = runCmd("osgi", "--session", "list");
- return new HashSet<>(sessions);
- }
/**
* Tests functionality of session handling of osgi command.
@@ -99,8 +71,7 @@
assertEquals(sessions, actual, "listed sessions do not match with created sessions");
// Let's set the same variable in each command session with a different value and make sure
- // the variables
- // are scoped to sessions.
+ // the variables are scoped to sessions.
for (String sessionId : sessions) {
List<String> result = runCmd("osgi", "--session", "execute", "--session-id", sessionId, "var=" + sessionId);
assertThat(result, IsEmptyCollection.empty());
@@ -129,18 +100,41 @@
public void osgiShell() throws IOException {
File cmdFile = File.createTempFile("osgi-commands", ".txt");
cmdFile.deleteOnExit();
- PrintStream ps = new PrintStream(new FileOutputStream(cmdFile));
- try {
+ try (PrintStream ps = new PrintStream(new FileOutputStream(cmdFile))) {
ps.println("help");
ps.println("lb");
NucleusTestUtils.NadminReturn value = nadminWithOutput("osgi-shell", "--file", cmdFile.getAbsolutePath());
assertTrue(value.out.contains("System Bundle"));
- } finally {
- try {
- ps.close();
- } catch (Exception e) {
- // ignore
- }
}
}
+
+
+ private List<String> runCmd(String... cmd) throws Exception {
+ NadminReturn value = nadminWithOutput(cmd);
+ if (!value.returnValue) {
+ throw new Exception("Cmd failed: \n" + value.outAndErr);
+ }
+ List<String> output = new ArrayList<>();
+ for (String line : value.out.split("\\n")) {
+ line = line.trim();
+ if (line.isEmpty() || line.startsWith("nadmin") || line.startsWith("Command")) {
+ continue;
+ }
+ output.add(line);
+ }
+ return output;
+ }
+
+ private String newCmdSession() throws Exception {
+ List<String> value = runCmd("osgi", "--session", "new");
+ if (value.size() != 1) {
+ throw new Exception("Unexpected output: \n " + value);
+ }
+ return value.get(0);
+ }
+
+ private Set<String> listCmdSessions() throws Exception {
+ List<String> sessions = runCmd("osgi", "--session", "list");
+ return new HashSet<>(sessions);
+ }
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/RestTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/RestITest.java
similarity index 99%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/RestTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/RestITest.java
index fd3985e..9112ad4 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/RestTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/RestITest.java
@@ -33,7 +33,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(DomainLifecycleExtension.class)
-public class RestTest {
+public class RestITest {
@Test
public void testManagementEndpoint() throws Exception {
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/DetachAttachTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/DetachAttachITest.java
similarity index 99%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/DetachAttachTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/DetachAttachITest.java
index fe64fec..c8a89d9 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/DetachAttachTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/DetachAttachITest.java
@@ -51,7 +51,7 @@
* @author martinmares
*/
@ExtendWith(DomainLifecycleExtension.class)
-public class DetachAttachTest {
+public class DetachAttachITest {
@AfterEach
public void cleanUp() throws Exception {
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/JobManagerTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/JobManagerITest.java
similarity index 99%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/JobManagerTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/JobManagerITest.java
index 1474268..8c5ebfa 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/JobManagerTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/JobManagerITest.java
@@ -42,7 +42,7 @@
*/
@TestMethodOrder(OrderAnnotation.class)
@ExtendWith(DomainLifecycleExtension.class)
-public class JobManagerTest {
+public class JobManagerITest {
private static final String COMMAND_PROGRESS_SIMPLE = "progress-simple";
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressMessage.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressMessage.java
index ed36b1c..0be7e34 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressMessage.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressMessage.java
@@ -18,6 +18,7 @@
package org.glassfish.nucleus.admin.progress;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
@@ -26,6 +27,8 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.hamcrest.CustomTypeSafeMatcher;
+
/**
* Parse progress status message.
*
@@ -75,6 +78,11 @@
return message;
}
+ @Override
+ public String toString() {
+ return Arrays.toString(new Object[] {value, percentage, scope, message});
+ }
+
public static List<ProgressMessage> grepProgressMessages(String txt) {
StringTokenizer stok = new StringTokenizer(txt, System.lineSeparator());
return Collections.list(stok).stream().map(Object::toString).filter(PREDICATE).map(ProgressMessage::new)
@@ -95,18 +103,24 @@
return messages.toArray(result);
}
- public static boolean isNonDecreasing(List<ProgressMessage> pms) {
- if (pms == null) {
- return false;
- }
- int lastVal = Integer.MIN_VALUE;
- for (ProgressMessage pm : pms) {
- if (pm.getValue() < lastVal) {
- return false;
+ public static CustomTypeSafeMatcher<List<ProgressMessage>> isIncreasing() {
+ return new CustomTypeSafeMatcher<>("is increasing") {
+
+ @Override
+ protected boolean matchesSafely(List<ProgressMessage> pms) {
+ if (pms == null) {
+ return false;
+ }
+ int lastVal = Integer.MIN_VALUE;
+ for (ProgressMessage pm : pms) {
+ if (pm.getValue() < lastVal) {
+ return false;
+ }
+ lastVal = pm.getValue();
+ }
+ return true;
}
- lastVal = pm.getValue();
- }
- return true;
+ };
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusBasicTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusBasicITest.java
similarity index 87%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusBasicTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusBasicITest.java
index 4e0047c..609c997 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusBasicTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusBasicITest.java
@@ -24,7 +24,10 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import static org.glassfish.nucleus.admin.progress.ProgressMessage.isIncreasing;
import static org.glassfish.nucleus.test.tool.NucleusTestUtils.nadminWithOutput;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -33,19 +36,19 @@
* @author martinmares
*/
@ExtendWith(DomainLifecycleExtension.class)
-public class ProgressStatusBasicTest {
+public class ProgressStatusBasicITest {
@Test
public void simple() {
NadminReturn result = nadminWithOutput("progress-simple");
assertTrue(result.returnValue);
List<ProgressMessage> prgs = ProgressMessage.grepProgressMessages(result.out);
+ assertThat(prgs, isIncreasing());
assertEquals(12, prgs.size());
for (int i = 0; i < 11; i++) {
assertEquals(10 * i, prgs.get(i + 1).getValue());
assertTrue(prgs.get(i + 1).isPercentage());
}
- assertTrue(ProgressMessage.isNonDecreasing(prgs));
}
@Test
@@ -53,6 +56,7 @@
NadminReturn result = nadminWithOutput("progress-simple", "--nototalsteps");
assertTrue(result.returnValue);
List<ProgressMessage> prgs = ProgressMessage.grepProgressMessages(result.out);
+ assertThat(prgs, isIncreasing());
boolean nonPercentageExists = false;
for (ProgressMessage prg : prgs) {
if (prg.getValue() != 0 && prg.getValue() != 100) {
@@ -61,7 +65,6 @@
}
}
assertTrue(nonPercentageExists);
- assertTrue(ProgressMessage.isNonDecreasing(prgs));
}
@Test
@@ -69,12 +72,12 @@
NadminReturn result = nadminWithOutput("progress-full-annotated");
assertTrue(result.returnValue);
List<ProgressMessage> prgs = ProgressMessage.grepProgressMessages(result.out);
- assertEquals(12, prgs.size());
+ assertThat(prgs, hasSize(12));
+ assertThat(prgs, isIncreasing());
for (int i = 0; i < 11; i++) {
assertEquals(10 * i, prgs.get(i + 1).getValue());
assertTrue(prgs.get(i + 1).isPercentage());
}
- assertTrue(ProgressMessage.isNonDecreasing(prgs));
assertEquals("annotated:", prgs.get(5).getScope());
}
@@ -83,6 +86,6 @@
NadminReturn result = nadminWithOutput("--terse", "progress-simple");
assertTrue(result.returnValue);
List<ProgressMessage> prgs = ProgressMessage.grepProgressMessages(result.out);
- assertTrue(prgs.isEmpty());
+ assertThat(prgs, hasSize(0));
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusComplexTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusComplexITest.java
similarity index 85%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusComplexTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusComplexITest.java
index c92044b..069081a 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusComplexTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusComplexITest.java
@@ -22,14 +22,18 @@
import org.glassfish.nucleus.test.tool.DomainLifecycleExtension;
import org.glassfish.nucleus.test.tool.NucleusTestUtils;
import org.glassfish.nucleus.test.tool.NucleusTestUtils.NadminReturn;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static org.glassfish.nucleus.admin.progress.ProgressMessage.grepProgressMessages;
-import static org.glassfish.nucleus.admin.progress.ProgressMessage.isNonDecreasing;
+import static org.glassfish.nucleus.admin.progress.ProgressMessage.isIncreasing;
import static org.glassfish.nucleus.admin.progress.ProgressMessage.uniqueMessages;
import static org.glassfish.nucleus.test.tool.NucleusTestUtils.nadminWithOutput;
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -39,54 +43,46 @@
* @author martinmares
*/
@ExtendWith(DomainLifecycleExtension.class)
-public class ProgressStatusComplexTest {
+public class ProgressStatusComplexITest {
@Test
public void executeCommandFromCommand() {
NadminReturn result = nadminWithOutput("progress-exec-other");
-
assertTrue(result.returnValue);
-
assertArrayEquals(new String[] {
"Starting", "Preparing", "Parsing", "Working on main part",
"Cleaning", "Finished", "Finishing outer command", "Finished outer command" },
-
uniqueMessages(grepProgressMessages(result.out)));
}
@Test
- @Disabled
public void executeCommandWithSupplements() {
NadminReturn result = nadminWithOutput("progress-supplement");
assertTrue(result.returnValue);
List<ProgressMessage> prgs = grepProgressMessages(result.out);
-
assertArrayEquals(new String[] {
"Starting", "2 seconds supplemental command", "Parsing",
"Working on main part", "Finished", "3 seconds supplemental" },
-
uniqueMessages(prgs));
- assertTrue(prgs.size() > 10);
+ assertThat(prgs, hasSize(21));
+ assertThat(prgs, isIncreasing());
assertFalse(prgs.get(4).isPercentage());
assertTrue(prgs.get(10).isPercentage());
- assertTrue(isNonDecreasing(prgs));
}
- // Test disabled till intermittent failures are fixed
@Test
- @Disabled
public void executeVeryComplexCommand() {
NucleusTestUtils.NadminReturn result = nadminWithOutput("progress-complex");
-
assertTrue(result.returnValue);
List<ProgressMessage> prgs = ProgressMessage.grepProgressMessages(result.out);
- assertTrue(prgs.size() > 40);
- assertTrue(scopeCount(prgs, "complex:") >= 4);
+ assertThat(prgs, hasSize(greaterThanOrEqualTo(100)));
+ assertThat(prgs, isIncreasing());
+ assertEquals(5, scopeCount(prgs, "complex:"));
assertEquals(0, scopeCount(prgs, "complex.ch1:"));
- assertEquals(5, scopeCount(prgs, "complex.ch2-paral:"));
+ assertThat(scopeCount(prgs, "complex.ch2-paral:"), anyOf(equalTo(5), equalTo(6)));
assertEquals(4, scopeCount(prgs, "complex.ch3:"));
assertEquals(5, scopeCount(prgs, "complex.ch1.ch11:"));
assertEquals(6, scopeCount(prgs, "complex.ch1.ch12:"));
@@ -96,7 +92,6 @@
assertEquals(25, scopeCount(prgs, "complex.ch2-paral.ch24:"));
assertEquals(5, scopeCount(prgs, "complex.ch3.ch31:"));
assertEquals(5, scopeCount(prgs, "complex.ch3.ch32:"));
- assertTrue(ProgressMessage.isNonDecreasing(prgs));
}
private int scopeCount(List<ProgressMessage> prgs, String scope) {
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusFailTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusFailITest.java
similarity index 97%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusFailTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusFailITest.java
index b6890ee..7d9fe7b 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusFailTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusFailITest.java
@@ -32,7 +32,7 @@
* @author martinmares
*/
@ExtendWith(DomainLifecycleExtension.class)
-public class ProgressStatusFailTest {
+public class ProgressStatusFailITest {
@Test
public void failDuringExecution() {
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusSpecialTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusSpecialITest.java
similarity index 77%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusSpecialTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusSpecialITest.java
index 3825f7d..68573f0 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusSpecialTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/progress/ProgressStatusSpecialITest.java
@@ -25,22 +25,26 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import static org.glassfish.nucleus.admin.progress.ProgressMessage.isIncreasing;
import static org.glassfish.nucleus.test.tool.NucleusTestUtils.nadminWithOutput;
-import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author martinmares
*/
@ExtendWith(DomainLifecycleExtension.class)
-public class ProgressStatusSpecialTest {
+public class ProgressStatusSpecialITest {
@Test
public void stepBackCommand() {
NadminReturn result = nadminWithOutput("progress-step-back");
assertTrue(result.returnValue);
List<ProgressMessage> prgs = ProgressMessage.grepProgressMessages(result.out);
- assertFalse(ProgressMessage.isNonDecreasing(prgs));
+ assertThat(prgs, not(isIncreasing()));
Iterator<ProgressMessage> itr = prgs.iterator();
while (itr.hasNext()) {
ProgressMessage prg = itr.next();
@@ -48,17 +52,17 @@
break;
}
}
- assertTrue(itr.hasNext()); //Exist more record
+ assertTrue(itr.hasNext(), "Exist more records");
while (itr.hasNext()) {
ProgressMessage prg = itr.next();
- assertTrue(prg.getValue() <= 80);
+ assertThat(prg.getValue(), lessThanOrEqualTo(80));
if (prg.getValue() < 80) {
break;
}
}
- assertTrue(itr.hasNext()); //Exist more record
+ assertTrue(itr.hasNext(), "Exist more records");
ProgressMessage prg = itr.next();
- assertTrue(prg.getValue() < 80);
+ assertThat(prg.getValue(), lessThan(80));
}
@Test
@@ -66,7 +70,7 @@
NadminReturn result = nadminWithOutput("progress-double-totals");
assertTrue(result.returnValue);
List<ProgressMessage> prgs = ProgressMessage.grepProgressMessages(result.out);
- assertFalse(ProgressMessage.isNonDecreasing(prgs));
+ assertThat(prgs, not(isIncreasing()));
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ApplicationITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ApplicationITest.java
new file mode 100644
index 0000000..bb91938
--- /dev/null
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ApplicationITest.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
+ * Copyright (c) 2010, 2018 Oracle 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.nucleus.admin.rest;
+
+import jakarta.ws.rs.core.Response;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.glassfish.nucleus.test.webapp.HelloServlet;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+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.assertEquals;
+
+/**
+ * @author jasonlee
+ */
+public class ApplicationITest extends RestTestBase {
+
+ @Test
+ public void testApplicationDeployment() throws URISyntaxException {
+ final String appName = "testApp" + generateRandomString();
+
+ try {
+ Map<String, String> deployedApp = deployApp(getWar("test"), appName, appName);
+ assertEquals(appName, deployedApp.get("name"));
+ assertEquals("/" + appName, deployedApp.get("contextRoot"));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ undeployApp(appName);
+ }
+ }
+
+ @Test
+ public void testApplicationDisableEnable() throws URISyntaxException {
+ final String appName = "testApp" + generateRandomString();
+
+ Map<String, String> deployedApp = deployApp(getWar("test"), appName, appName);
+ assertEquals(appName, deployedApp.get("name"));
+
+ assertEquals("/" + appName, deployedApp.get("contextRoot"));
+
+ try {
+ String appUrl = getBaseInstanceUrl() + appName;
+ Response response = get(appUrl);
+ assertEquals ("Hello!", response.readEntity(String.class));
+
+ response = post(URL_APPLICATION_DEPLOY + "/" + appName + "/disable");
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = get(appUrl);
+ assertEquals(404, response.getStatus());
+
+ response = post(URL_APPLICATION_DEPLOY + "/" + appName + "/enable");
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = get(appUrl);
+ assertEquals ("Hello!", response.readEntity(String.class).trim());
+ } finally {
+ undeployApp(appName);
+ }
+ }
+
+ @Test
+ public void listSubComponents() throws URISyntaxException {
+ final String appName = "testApp" + generateRandomString();
+
+ try {
+ deployApp(getEar("simple"), appName, appName);
+ Response response = get(URL_APPLICATION_DEPLOY +"/" + appName + "/list-sub-components?id=" + appName);
+ assertThat(response.getStatus(), equalTo(200));
+ String subComponents = response.readEntity(String.class);
+ assertThat(subComponents, stringContainsInOrder("simple"));
+
+ response = get(URL_APPLICATION_DEPLOY +"/" + appName + "/list-sub-components?id=simple.war&appname=" + appName);
+ assertThat(response.getStatus(), equalTo(200));
+ subComponents = response.readEntity(String.class);
+ assertThat(subComponents, stringContainsInOrder(HelloServlet.class.getName()));
+ } finally {
+ undeployApp(appName);
+ }
+ }
+
+ @Test
+ public void testCreatingAndDeletingApplicationRefs() throws URISyntaxException {
+ final String instanceName = "instance_" + generateRandomString();
+ final String appName = "testApp" + generateRandomString();
+ final String appRefUrl = "domain/servers/server/" + instanceName + "/application-ref";
+
+ Map<String, String> newInstance = Map.of("id", instanceName, "node", "localhost-domain1");
+ Map<String, String> applicationRef = Map.of("id", appName, "target", instanceName);
+
+ try {
+ Response response = post(URL_CREATE_INSTANCE, newInstance);
+ assertThat(response.getStatus(), equalTo(200));
+
+ deployApp(getWar("test"), appName, appName);
+
+ response = post (appRefUrl, applicationRef);
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = get(appRefUrl + "/" + appName);
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = delete(appRefUrl + "/" + appName, Map.of("target", instanceName));
+ assertThat(response.getStatus(), equalTo(200));
+ } finally {
+ Response response = delete("domain/servers/server/" + instanceName + "/delete-instance");
+ assertThat(response.getStatus(), equalTo(200));
+ response = get("domain/servers/server/" + instanceName);
+ assertEquals(404, response.getStatus());
+ undeployApp(appName);
+ }
+ }
+
+ @Test
+ public void testGetContextRoot() throws URISyntaxException {
+ final String appName = "testApp" + generateRandomString();
+ try {
+ Map<String, String> deployedApp = deployApp(getEar("simple"), appName, appName);
+ assertEquals(appName, deployedApp.get("name"));
+ Map<String, String> contextRootPayload = Map.of("appname", appName, "modulename", "simple");
+ Response response = get("domain/applications/application/" + appName + "/get-context-root", contextRootPayload);
+ assertThat(response.getStatus(), equalTo(200));
+ assertThat(response.readEntity(String.class),
+ stringContainsInOrder("command", "_get-context-root AdminCommand", "exit_code", "SUCCESS",
+ "--appname", appName, "--modulename", "simple", "method", "GET"));
+ } finally {
+ undeployApp(appName);
+ }
+ }
+
+ @Test
+ public void testUndeploySubActionWarnings() throws URISyntaxException {
+ final String appName = "testApp" + generateRandomString();
+ final String serverName = "in" + generateRandomNumber();
+ try {
+ Response response = post ("domain/create-instance", Map.of("id", serverName, "node", "localhost-domain1"));
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = post("domain/servers/server/" + serverName + "/start-instance");
+ assertThat(response.getStatus(), equalTo(200));
+
+ deployApp(getWar("test"), appName, appName);
+ addAppRef(appName, serverName);
+
+ response = post("domain/servers/server/" + serverName + "/stop-instance");
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = delete("domain/applications/application/" + appName, Map.of("target", "domain"));
+ assertThat(response.readEntity(String.class),
+ stringContainsInOrder("deleted successfully", "exit_code", "SUCCESS"));
+ } finally {
+ delete("domain/applications/application/" + appName, Map.of("target", "domain"));
+ }
+ }
+}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ApplicationTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ApplicationTest.java
deleted file mode 100644
index 5abb8de..0000000
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ApplicationTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (c) 2022 Contributors to the Eclipse Foundation
- * Copyright (c) 2010, 2018 Oracle 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.nucleus.admin.rest;
-
-import jakarta.ws.rs.core.Response;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * @author jasonlee
- */
-@Disabled("Missing test application")
-public class ApplicationTest extends RestTestBase {
-
- @Test
- public void testApplicationDeployment() throws URISyntaxException {
- final String appName = "testApp" + generateRandomString();
-
- try {
- Map<String, String> deployedApp = deployApp(getFile("test.war"), appName, appName);
- assertEquals(appName, deployedApp.get("name"));
-
- assertEquals("/" + appName, deployedApp.get("contextRoot"));
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- undeployApp(appName);
- }
- }
-
- @Test
- public void testApplicationDisableEnable() throws URISyntaxException {
- final String appName = "testApp" + generateRandomString();
-
- Map<String, String> deployedApp = deployApp(getFile("test.war"), appName, appName);
- assertEquals(appName, deployedApp.get("name"));
-
- assertEquals("/" + appName, deployedApp.get("contextRoot"));
-
- try {
- String appUrl = getBaseAdminUrl() + appName;
- Response response = get(appUrl);
- assertEquals ("Test", response.readEntity(String.class).trim());
-
- response = post(URL_APPLICATION_DEPLOY + "/" + appName + "/disable");
- checkStatus(response);
-
- response = get(appUrl);
- assertEquals(404, response.getStatus());
-
- response = post(URL_APPLICATION_DEPLOY + "/" + appName + "/enable");
- checkStatus(response);
-
- response = get(appUrl);
- assertEquals ("Test", response.readEntity(String.class).trim());
- } finally {
- undeployApp(appName);
- }
- }
-
- @Test
- public void listSubComponents() throws URISyntaxException {
- final String appName = "testApp" + generateRandomString();
-
- try {
- deployApp(getFile("stateless-simple.ear"), appName, appName);
- Response response = get(URL_APPLICATION_DEPLOY +"/" + appName + "/list-sub-components?id=" + appName);
- checkStatus(response);
- String subComponents = response.readEntity(String.class);
- assertTrue(subComponents.contains("stateless-simple.war"));
-
- response = get(URL_APPLICATION_DEPLOY +"/" + appName + "/list-sub-components?id=stateless-simple.war&appname=" + appName);
- checkStatus(response);
- subComponents = response.readEntity(String.class);
- assertTrue(subComponents.contains("GreeterServlet"));
- } finally {
- undeployApp(appName);
- }
- }
-
- @Test
- public void testCreatingAndDeletingApplicationRefs() throws URISyntaxException {
- final String instanceName = "instance_" + generateRandomString();
- final String appName = "testApp" + generateRandomString();
- final String appRefUrl = "domain/servers/server/" + instanceName + "/application-ref";
-
- Map<String, String> newInstance = new HashMap<>() {{
- put("id", instanceName);
- put("node", "localhost-domain1");
- }};
- Map<String, String> applicationRef = new HashMap<>() {{
- put("id", appName);
- put("target", instanceName);
- }};
-
- try {
- Response response = post(URL_CREATE_INSTANCE, newInstance);
- checkStatus(response);
-
- deployApp(getFile("test.war"), appName, appName);
-
- response = post (appRefUrl, applicationRef);
- checkStatus(response);
-
- response = get(appRefUrl + "/" + appName);
- checkStatus(response);
-
- response = delete(appRefUrl + "/" + appName, new HashMap<String, String>() {{ put("target", instanceName); }});
- checkStatus(response);
- } finally {
- Response response = delete("domain/servers/server/" + instanceName + "/delete-instance");
- checkStatus(response);
- response = get("domain/servers/server/" + instanceName);
- assertEquals(404, response.getStatus());
- undeployApp(appName);
- }
- }
-
- @Test
- public void testGetContextRoot() throws URISyntaxException {
- final String appName = "testApp" + generateRandomString();
-
- try {
- Map<String, String> deployedApp = deployApp(getFile("stateless-simple.ear"), appName, appName);
- assertEquals(appName, deployedApp.get("name"));
- Map<String, String> contextRootPayload = new HashMap<>() {{
- put("appname", appName);
- put("modulename", "stateless-simple.war");
- }};
-
- Response response = get("domain/applications/application/" +appName + "/get-context-root", contextRootPayload);
- checkStatus(response);
- assertTrue(response.readEntity(String.class).contains("helloworld"));
- } finally {
- undeployApp(appName);
- }
- }
-
- @Test
- public void testUndeploySubActionWarnings() throws URISyntaxException {
- final String appName = "testApp" + generateRandomString();
- final String serverName = "in" + generateRandomNumber();
- try {
- Response response = post ("domain/create-instance", new HashMap<String, String>() {{
- put("id", serverName);
- put("node", "localhost-domain1");
- }});
- checkStatus(response);
-
- response = post("domain/servers/server/" + serverName + "/start-instance");
- checkStatus(response);
-
- deployApp(getFile("test.war"), appName, appName);
- addAppRef(appName, serverName);
-
- response = post("domain/servers/server/" + serverName + "/stop-instance");
- checkStatus(response);
-
- response = delete ("domain/applications/application/"+appName, new HashMap<String, String>() {{
- put("target", "domain");
- }});
- assertTrue(response.readEntity(String.class).contains("WARNING: Instance " + serverName + " seems to be offline"));
- } finally {
- delete ("domain/applications/application/" + appName, new HashMap<String, String>() {{
- put("target", "domain");
- }});
- }
- }
-
- private File getFile(String fileName) throws URISyntaxException {
- final URL resource = getClass().getResource("/" + fileName);
- return new File(resource.toURI());
- }
-}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/AuthRealmTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/AuthRealmITest.java
similarity index 98%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/AuthRealmTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/AuthRealmITest.java
index 281092d..02033d7 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/AuthRealmTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/AuthRealmITest.java
@@ -43,7 +43,7 @@
import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
import static org.junit.jupiter.api.Assertions.assertEquals;
-public class AuthRealmTest extends RestTestBase {
+public class AuthRealmITest extends RestTestBase {
private static final String URL_LIST_GROUP_NAMES = "domain/configs/config/server-config/security-service/auth-realm/admin-realm/list-group-names";
private static final String URL_SUPPORTS_USER_MANAGEMENT = "domain/configs/config/server-config/security-service/auth-realm/admin-realm/supports-user-management";
private static final String URL_LIST_ADMIN_REALM_USERS = "domain/configs/config/server-config/security-service/auth-realm/admin-realm/list-users";
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ClusterTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ClusterITest.java
similarity index 85%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ClusterTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ClusterITest.java
index 243b19a..68a72f6 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ClusterTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ClusterITest.java
@@ -23,12 +23,14 @@
import org.junit.jupiter.api.Test;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author jasonlee
*/
-public class ClusterTest extends RestTestBase {
+public class ClusterITest extends RestTestBase {
@Test
public void testClusterCreationAndDeletion() {
@@ -45,13 +47,13 @@
public void testListLifecycleModules() {
final String clusterName = "cluster_" + generateRandomString();
Response response = post(URL_CLUSTER, Map.of("id", clusterName));
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
response = get(URL_CLUSTER + "/" + clusterName + "/list-lifecycle-modules");
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
response = delete(URL_CLUSTER + "/" + clusterName);
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
response = get(URL_CLUSTER + "/" + clusterName);
assertEquals(404, response.getStatus());
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ConfigITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ConfigITest.java
new file mode 100644
index 0000000..4f9cb1f
--- /dev/null
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ConfigITest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
+ * Copyright (c) 2010, 2018 Oracle 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.nucleus.admin.rest;
+
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.Response;
+
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * @author jasonlee
+ */
+public class ConfigITest extends RestTestBase {
+
+ @Test
+ public void testConfigCopy() {
+ String configName = "config-" + generateRandomString();
+ MultivaluedHashMap<String, String> formData = new MultivaluedHashMap<>();
+ formData.add("id", "default-config");
+ formData.add("id", configName);
+ createAndVerifyConfig(configName, formData);
+ deleteAndVerifyConfig(configName);
+ }
+
+ @Test
+ public void duplicitCopyShouldFail() {
+ MultivaluedHashMap<String, String> formData = new MultivaluedHashMap<>();
+ formData.add("id", "default-config");
+ formData.add("id", "server-config");
+ Response response = post(URL_CONFIGS + "/copy-config", formData);
+ // FIXME: causes HTTP 500 without any log, should be 422.
+ assertThat(response.getStatus(), equalTo(500));
+ }
+}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ConfigTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ConfigTest.java
deleted file mode 100644
index 945aaf3..0000000
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ConfigTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2022 Contributors to the Eclipse Foundation
- * Copyright (c) 2010, 2018 Oracle 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.nucleus.admin.rest;
-
-import jakarta.ws.rs.core.MultivaluedHashMap;
-import jakarta.ws.rs.core.MultivaluedMap;
-import jakarta.ws.rs.core.Response;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-/**
- * @author jasonlee
- */
-public class ConfigTest extends RestTestBase {
-
- public static final String BASE_CONFIGS_URL = "domain/configs";
-
- @Test
- public void testConfigCopy() {
- String configName = "config-" + generateRandomString();
- MultivaluedHashMap<String, String> formData = new MultivaluedHashMap<>();
- formData.add("id", "default-config");
- formData.add("id", configName);
- createAndVerifyConfig(configName, formData);
- deleteAndVerifyConfig(configName);
- }
-
- @Test
- public void duplicitCopyShouldFail() {
- MultivaluedHashMap<String, String> formData = new MultivaluedHashMap<>();
- formData.add("id", "default-config");
- formData.add("id", "server-config");
- Response response = post(BASE_CONFIGS_URL + "/copy-config", formData);
- // FIXME: causes HTTP 500 without any log
- assertThat(response.getStatus(), greaterThanOrEqualTo(400));
- }
-
- public void createAndVerifyConfig(String configName, MultivaluedMap<String, String> configData) {
- Response response = post(BASE_CONFIGS_URL + "/copy-config", configData);
- checkStatus(response);
-
- response = get(BASE_CONFIGS_URL + "/config/" + configName);
- checkStatus(response);
- }
-
- public void deleteAndVerifyConfig(String configName) {
- Response response = post(BASE_CONFIGS_URL + "/config/" + configName + "/delete-config");
- checkStatus(response);
-
- response = get(BASE_CONFIGS_URL + "/config/" + configName);
- assertEquals(404, response.getStatus());
- }
-}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/DomainTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/DomainITest.java
similarity index 85%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/DomainTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/DomainITest.java
index 1b24391..532094e 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/DomainTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/DomainITest.java
@@ -27,13 +27,17 @@
import org.junit.jupiter.api.Test;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
-public class DomainTest extends RestTestBase {
+public class DomainITest extends RestTestBase {
@Test
public void testDomainGet() throws Exception {
- Map<String, String> current = getEntityValues(get("/domain"));
+ Response response0 = get("domain");
+ assertThat(response0.getStatus(), equalTo(200));
+ Map<String, String> current = getEntityValues(response0);
// Select a random locale so we're not setting the locale to its current value
List<String> locales = new ArrayList<>(List.of("en_US", "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr__MAC"));
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ElementStarTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ElementStarITest.java
similarity index 61%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ElementStarTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ElementStarITest.java
index 780a569..c10e9a1 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ElementStarTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ElementStarITest.java
@@ -20,61 +20,60 @@
import jakarta.ws.rs.core.Response;
import java.net.URISyntaxException;
-import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.aMapWithSize;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* This class tests the changes to the handling of @Element("*") instances
+ *
* @author jasonlee
*/
-public class ElementStarTest extends RestTestBase {
- protected static final String URL_CREATE_INSTANCE = "domain/create-instance";
+public class ElementStarITest extends RestTestBase {
+ private static final String URL_CREATE_INSTANCE = "domain/create-instance";
- protected String instanceName1;
- protected String instanceName2;
+ private String instanceName1;
+ private String instanceName2;
@BeforeEach
public void before() {
instanceName1 = "instance_" + generateRandomString();
instanceName2 = "instance_" + generateRandomString();
- Response response = post(URL_CREATE_INSTANCE, new HashMap<String, String>() {{ put("id", instanceName1); put("node", "localhost-domain1"); }});
- checkStatus(response);
- response = post(URL_CREATE_INSTANCE, new HashMap<String, String>() {{ put("id", instanceName2); put("node", "localhost-domain1"); }});
- checkStatus(response);
+ Response response = post(URL_CREATE_INSTANCE, Map.of("id", instanceName1, "node", "localhost-domain1"));
+ assertThat(response.getStatus(), equalTo(200));
+ response = post(URL_CREATE_INSTANCE, Map.of("id", instanceName2, "node", "localhost-domain1"));
+ assertEquals(200, response.getStatus());
}
@AfterEach
public void after() {
- Response response = delete("domain/servers/server/" + instanceName1 + "/delete-instance"); // FIXME: This url should be fixed
- checkStatus(response);
+ Response response = delete("domain/servers/server/" + instanceName1 + "/delete-instance");
+ assertEquals(200, response.getStatus());
response = delete("domain/servers/server/" + instanceName2 + "/delete-instance");
- checkStatus(response);
+ assertEquals(200, response.getStatus());
}
@Test
- @Disabled("Unavailable webapp")
public void testApplications() throws URISyntaxException {
final String app1 = "app" + generateRandomString();
final String app2 = "app" + generateRandomString();
- // FIXME: we need some example webapp
-// deployApp("test.war", app1, app1);
-// deployApp("test.war", app2, app2);
+ deployApp(getWar("test"), app1, app1);
+ deployApp(getWar("test"), app2, app2);
addAppRef(app1, instanceName1);
addAppRef(app2, instanceName1);
Response response = get("domain/servers/server/" + instanceName1 + "/application-ref");
Map<String, String> children = this.getChildResources(response);
- assertEquals(2, children.size());
+ assertThat(children, aMapWithSize(2));
}
@Test
@@ -82,28 +81,20 @@
// The DAS should already have two resource-refs (jdbc/__TimerPool and jdbc/__default)
Response response = get ("domain/servers/server/server/resource-ref");
Map<String, String> children = this.getChildResources(response);
- assertTrue(children.size() >= 2);
+ assertThat(children, aMapWithSize(7));
}
@Test
- @Disabled
public void testLoadBalancerConfigs() {
final String lbName = "lbconfig-" + generateRandomString();
- Response response = post ("domain/lb-configs/lb-config/",
- new HashMap<String, String>() {{
- put("id", lbName);
- put("target", instanceName1);
- }});
- checkStatus(response);
+ Response response = post("domain/lb-configs/lb-config/", Map.of("id", lbName, "target", instanceName1));
+ assertEquals(200, response.getStatus());
- response = post("domain/lb-configs/lb-config/" + lbName + "/create-http-lb-ref",
- new HashMap<String,String>() {{
- put ("id", instanceName2);
- }});
- checkStatus(response);
+ response = post("domain/lb-configs/lb-config/" + lbName + "/create-http-lb-ref", Map.of("id", instanceName2));
+ assertEquals(200, response.getStatus());
response = get ("domain/lb-configs/lb-config/" + lbName + "/server-ref");
- Map<String, String> children = this.getChildResources(response);
- assertTrue(!children.isEmpty());
+ Map<String, String> children = getChildResources(response);
+ assertThat(children, aMapWithSize(1));
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ExternalResourceTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ExternalResourceITest.java
similarity index 65%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ExternalResourceTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ExternalResourceITest.java
index 50a5671..be1425e 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ExternalResourceTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ExternalResourceITest.java
@@ -19,40 +19,37 @@
import jakarta.ws.rs.core.Response;
-import java.util.HashMap;
import java.util.Map;
-import org.glassfish.resources.custom.factory.PrimitivesAndStringFactory;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
/**
* @author jasonlee
*/
-@Disabled
-public class ExternalResourceTest extends RestTestBase {
+public class ExternalResourceITest extends RestTestBase {
- protected static final String URL_EXTERNAL_RESOURCE = "domain/resources/external-jndi-resource";
+ private static final String URL_EXTERNAL_RESOURCE = "domain/resources/external-jndi-resource";
@Test
public void createAndDeleteExternalResource() {
final String resourceName = "resource_" + generateRandomString();
final String jndiName = "jndi/" + resourceName;
- Map<String, String> newResource = new HashMap<>() {
- {
- put("id", resourceName);
- put("jndilookupname", jndiName);
- put("factoryClass", PrimitivesAndStringFactory.class.getName());
- put("restype", Double.class.getName());
- }
- };
+ Map<String, String> newResource = Map.of(
+ "id", resourceName,
+ "jndilookupname", jndiName,
+ "factoryClass", "org.glassfish.resources.custom.factory.PrimitivesAndStringFactory",
+ "restype", Double.class.getName()
+ );
Response response = post(URL_EXTERNAL_RESOURCE, newResource);
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
response = get(URL_EXTERNAL_RESOURCE + "/" + resourceName);
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
response = delete(URL_EXTERNAL_RESOURCE + "/" + resourceName);
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JdbcITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JdbcITest.java
new file mode 100644
index 0000000..4cb903e
--- /dev/null
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JdbcITest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
+ * Copyright (c) 2010, 2018 Oracle 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.nucleus.admin.rest;
+
+import jakarta.ws.rs.core.Response;
+
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * @author jasonlee
+ */
+public class JdbcITest extends RestTestBase {
+
+ @Test
+ public void testReadingPoolEntity() {
+ Map<String, String> entity = getEntityValues(get(URL_JDBC_CONNECTION_POOL + "/__TimerPool"));
+ assertEquals("__TimerPool", entity.get("name"));
+ }
+
+
+ @Test
+ public void testCreateAndDeletePool() {
+ String poolName = "TestPool" + generateRandomString();
+ Map<String, String> params = new HashMap<>();
+ params.put("name", poolName);
+ params.put("datasourceClassname", "org.apache.derby.jdbc.ClientDataSource");
+ Response response = post(URL_JDBC_CONNECTION_POOL, params);
+ assertEquals(200, response.getStatus());
+
+ Map<String, String> entity = getEntityValues(get(URL_JDBC_CONNECTION_POOL + "/" + poolName));
+ assertThat(entity, aMapWithSize(greaterThan(40)));
+
+ response = delete(URL_JDBC_CONNECTION_POOL + "/" + poolName, Map.of());
+ assertEquals(200, response.getStatus());
+
+ response = get(URL_JDBC_CONNECTION_POOL + "/" + poolName);
+ assertEquals(404, response.getStatus());
+ }
+
+
+ @Test
+ public void testBackslashValidation() {
+ String poolName = "TestPool\\" + generateRandomString();
+ String encodedPoolName = URLEncoder.encode(poolName, StandardCharsets.UTF_8);
+ Map<String, String> params = new HashMap<>();
+ params.put("name", poolName);
+ params.put("poolName", "DerbyPool");
+
+ Response response = post(URL_JDBC_RESOURCE, params);
+ assertEquals(500, response.getStatus());
+
+ Response responseGet = get(URL_JDBC_CONNECTION_POOL + "/" + encodedPoolName);
+ assertEquals(500, response.getStatus());
+ Map<String, String> entity = getEntityValues(responseGet);
+ assertNull(entity);
+
+ response = delete("/" + encodedPoolName, Map.of());
+ assertEquals(500, response.getStatus());
+
+ response = get(URL_JDBC_CONNECTION_POOL + "/" + encodedPoolName);
+ assertEquals(500, response.getStatus());
+ }
+
+
+ @Test
+ public void createDuplicateResource() {
+ final String resourceName = "jdbc/__default";
+ Map<String, String> params = Map.of("id", resourceName, "poolName", "DerbyPool");
+ Response response = post(URL_JDBC_RESOURCE, params);
+ assertEquals(500, response.getStatus());
+ }
+
+
+ @Test
+ public void createDuplicateConnectionPool() {
+ final String poolName = "DerbyPool";
+ Map<String, String> params = Map.of("id", poolName, "datasourceClassname",
+ "org.apache.derby.jdbc.ClientDataSource");
+ Response response = post(URL_JDBC_CONNECTION_POOL, params);
+ assertEquals(500, response.getStatus());
+ }
+}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JdbcTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JdbcTest.java
deleted file mode 100644
index 74a5130..0000000
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JdbcTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2022 Contributors to the Eclipse Foundation
- * Copyright (c) 2010, 2018 Oracle 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.nucleus.admin.rest;
-
-import jakarta.ws.rs.core.Response;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-
-/**
- * @author jasonlee
- */
-@Disabled
-public class JdbcTest extends RestTestBase {
- public static final String BASE_JDBC_RESOURCE_URL = "domain/resources/jdbc-resource";
- public static final String BASE_JDBC_CONNECTION_POOL_URL = "domain/resources/jdbc-connection-pool";
-
- @Test
- public void testReadingPoolEntity() {
- Map<String, String> entity = getEntityValues(get(BASE_JDBC_CONNECTION_POOL_URL + "/__TimerPool"));
- assertEquals("__TimerPool", entity.get("name"));
- }
-
- @Test
- public void testCreateAndDeletePool() {
- String poolName = "TestPool" + generateRandomString();
- Map<String, String> params = new HashMap<>();
- params.put("name", poolName);
- params.put("datasourceClassname","org.apache.derby.jdbc.ClientDataSource");
- Response response = post(BASE_JDBC_CONNECTION_POOL_URL, params);
- assertEquals(200, response.getStatus());
-
- Map<String, String> entity = getEntityValues(get(BASE_JDBC_CONNECTION_POOL_URL + "/"+poolName));
- assertNotSame(0, entity.size());
-
- response = delete(BASE_JDBC_CONNECTION_POOL_URL+"/"+poolName, new HashMap<String, String>());
- assertEquals(200, response.getStatus());
-
- response = get(BASE_JDBC_CONNECTION_POOL_URL + "/" + poolName);
- assertEquals(404, response.getStatus());
- }
-
- @Test
- public void testCreateResourceWithBackslash() {
- String poolName = "TestPool\\" + generateRandomString();
- String encodedPoolName = poolName;
- try {
- encodedPoolName = URLEncoder.encode(poolName, "UTF-8");
- } catch (UnsupportedEncodingException ex) {
- Logger.getLogger(JdbcTest.class.getName()).log(Level.SEVERE, null, ex);
- }
- Map<String, String> params = new HashMap<>();
- params.put("name", poolName);
- params.put("poolName", "DerbyPool");
-
- Response response = post (BASE_JDBC_RESOURCE_URL, params);
- assertEquals(200, response.getStatus());
-
- Map<String, String> entity = getEntityValues(get(BASE_JDBC_CONNECTION_POOL_URL + "/" + encodedPoolName));
- assertNotSame(0, entity.size());
-
- response = delete("/" + encodedPoolName, new HashMap<String, String>());
- assertEquals(200, response.getStatus());
-
- response = get(BASE_JDBC_CONNECTION_POOL_URL + "/" + encodedPoolName);
- assertEquals(404, response.getStatus());
- }
-
- @Test
- public void createDuplicateResource() {
- final String resourceName = "jdbc/__default";
- Map<String, String> params = new HashMap<>() {{
- put("id", resourceName);
- put("poolName", "DerbyPool");
- }};
-
- Response response = post (BASE_JDBC_RESOURCE_URL, params);
- assertEquals(404, response.getStatus());
- }
-
- @Test
- public void createDuplicateConnectionPool() {
- final String poolName = "DerbyPool";
- Map<String, String> params = new HashMap<>() {{
- put("id", poolName);
- put("datasourceClassname", "org.apache.derby.jdbc.ClientDataSource");
- }};
-
- Response response = post (BASE_JDBC_CONNECTION_POOL_URL, params);
- assertEquals(404, response.getStatus());
- }
-}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JmsITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JmsITest.java
new file mode 100644
index 0000000..748ac67
--- /dev/null
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JmsITest.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
+ * Copyright (c) 2010, 2020 Oracle 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.nucleus.admin.rest;
+
+import jakarta.ws.rs.core.Response;
+
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.stringContainsInOrder;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * @author jasonlee
+ * @since May 26, 2010
+ */
+public class JmsITest extends RestTestBase {
+ static final String URL_ADMIN_OBJECT_RESOURCE = "domain/resources/admin-object-resource";
+ static final String URL_CONNECTOR_CONNECTION_POOL = "domain/resources/connector-connection-pool";
+ static final String URL_CONNECTOR_RESOURCE = "domain/resources/connector-resource";
+ static final String URL_JMS_HOST = "domain/configs/config/server-config/jms-service/jms-host";
+ static final String URL_SEVER_JMS_DEST = "domain/servers/server/server";
+ static final String DEST_TYPE = "topic";
+
+ @Test
+ public void testJmsConnectionFactories() {
+ // Create connection pool
+ final String poolName = "JmsConnectionFactory" + generateRandomString();
+ Map<String, String> ccp_attrs = Map.of("name", poolName, "connectiondefinition",
+ "jakarta.jms.ConnectionFactory", "raname", "jmsra");
+ Response response = post(URL_CONNECTOR_CONNECTION_POOL, ccp_attrs);
+ assertThat(response.getStatus(), equalTo(200));
+
+ // Check connection pool creation
+ Map<String, String> pool = getEntityValues(get(URL_CONNECTOR_CONNECTION_POOL + "/" + poolName));
+ assertThat(pool, aMapWithSize(greaterThanOrEqualTo(26)));
+
+ // Create connector resource
+ String resourceName = poolName + "Resource";
+ Map<String, String> cr_attrs = Map.of("name", resourceName, "poolname", poolName);
+ response = post(URL_CONNECTOR_RESOURCE, cr_attrs);
+ assertThat(response.getStatus(), equalTo(200));
+
+ // Check connector resource
+ Map<String, String> resource = getEntityValues(get(URL_CONNECTOR_RESOURCE + "/" + resourceName));
+ assertThat(resource, aMapWithSize(6));
+
+ // Edit and check ccp
+ response = post(URL_CONNECTOR_CONNECTION_POOL + "/" + poolName, Map.of("description", poolName));
+ assertThat(response.getStatus(), equalTo(200));
+
+ pool = getEntityValues(get(URL_CONNECTOR_CONNECTION_POOL + "/" + poolName));
+ assertTrue(pool.get("description").equals(poolName));
+
+ // Edit and check cr
+ response = post(URL_CONNECTOR_RESOURCE + "/" + resourceName, Map.of("description", poolName));
+ assertThat(response.getStatus(), equalTo(200));
+
+ resource = getEntityValues(get(URL_CONNECTOR_RESOURCE + "/" + resourceName));
+ assertTrue(pool.get("description").equals(poolName));
+
+ // Delete objects
+ response = delete(URL_CONNECTOR_CONNECTION_POOL + "/" + poolName, Map.of("cascade", "true"));
+ assertThat(response.getStatus(), equalTo(200));
+ }
+
+ @Test
+ public void testJmsDestinationResources() {
+ final String jndiName = "jndi/" + generateRandomString();
+ String encodedJndiName = URLEncoder.encode(jndiName, StandardCharsets.UTF_8);
+
+ Map<String, String> attrs = Map.of("id", jndiName, "raname", "jmsra", "restype", "jakarta.jms.Topic");
+
+ Response response = post(URL_ADMIN_OBJECT_RESOURCE, attrs);
+ assertThat(response.getStatus(), equalTo(200));
+
+ Map<String, String> entity = getEntityValues(get(URL_ADMIN_OBJECT_RESOURCE + "/" + encodedJndiName));
+ assertThat(entity, aMapWithSize(8));
+
+ response = delete(URL_ADMIN_OBJECT_RESOURCE + "/" + encodedJndiName);
+ assertThat(response.getStatus(), equalTo(200));
+ }
+
+ @Test
+ public void testJmsPhysicalDestination() {
+ final String destName = "jmsDest" + generateRandomString();
+ final int maxNumMsgs = generateRandomNumber(500);
+ final int consumerFlowLimit = generateRandomNumber(500);
+
+ createJmsPhysicalDestination(destName, DEST_TYPE, URL_SEVER_JMS_DEST);
+
+ final Map<String, String> newDest = Map.of("id", destName, "desttype", DEST_TYPE);
+ Map<String, String> destProps = new HashMap<>(newDest);
+ destProps.putAll(Map.of("property", "MaxNumMsgs=" + maxNumMsgs + ":ConsumerFlowLimit=" + consumerFlowLimit));
+
+ Response response = get(URL_SEVER_JMS_DEST + "/__get-jmsdest", newDest);
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = post(URL_SEVER_JMS_DEST + "/__update-jmsdest", destProps);
+ assertThat(response.getStatus(), equalTo(200));
+ response = get(URL_SEVER_JMS_DEST + "/__get-jmsdest", newDest);
+ assertThat(response.getStatus(), equalTo(200));
+ Map<String, String> entity = getEntityValues(response);
+ assertEquals(maxNumMsgs, entity.get("MaxNumMsgs"));
+ assertEquals(consumerFlowLimit, entity.get("ConsumerFlowLimit"));
+
+ deleteJmsPhysicalDestination(destName, URL_SEVER_JMS_DEST);
+ }
+
+ @Test
+ @Disabled("Enable and fix OpenMQ - require more detailed message and probably to fix the cause:"
+ + " MQJMSRA_RA4001: getJMXServiceURLList:Exception:Message=Caught exception when contacing portmapper.]]")
+ public void testJmsPhysicalDestionationsWithClusters() {
+ final String destName = "jmsDest" + generateRandomString();
+ final String clusterName = createCluster();
+ createClusterInstance(clusterName, "in1_" + clusterName);
+ startCluster(clusterName);
+ final String endpoint = "domain/clusters/cluster/" + clusterName;
+ try {
+ createJmsPhysicalDestination(destName, "topic", endpoint);
+ final Map<String, String> newDest = Map.of("id", destName, "desttype", DEST_TYPE);
+ Response response = get(endpoint + "/__get-jmsdest", newDest);
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = get(URL_SEVER_JMS_DEST + "/__get-jmsdest", newDest);
+ assertThat(response.getStatus(), equalTo(200));
+ } finally {
+ deleteJmsPhysicalDestination(destName, endpoint);
+ stopCluster(clusterName);
+ deleteCluster(clusterName);
+ }
+ }
+
+ @Test
+ public void testJmsPing() {
+ String results = get(URL_SEVER_JMS_DEST + "/jms-ping").readEntity(String.class);
+ assertThat(results, stringContainsInOrder("JMS-ping command executed successfully"));
+ }
+
+ @Test
+ public void testJmsFlush() {
+ Map<String, String> payload = Map.of("id", "mq.sys.dmq", "destType", "queue");
+ Response response = post(URL_SEVER_JMS_DEST + "/flush-jmsdest", payload);
+ assertThat(response.getStatus(), equalTo(200));
+ }
+
+ @Test
+ public void testJmsHosts() {
+ final String jmsHostName = "jmshost" + generateRandomString();
+ Map<String, String> newHost = Map.of("id", jmsHostName, "adminPassword", "admin", "port", "7676",
+ "adminUserName", "admin", "host", "localhost");
+
+ // Test create
+ Response response = post(URL_JMS_HOST, newHost);
+ assertThat(response.getStatus(), equalTo(200));
+
+ // Test edit
+ Map<String, String> entity = getEntityValues(get(URL_JMS_HOST + "/" + jmsHostName));
+ assertThat(entity, aMapWithSize(greaterThanOrEqualTo(6)));
+ assertEquals(jmsHostName, entity.get("name"));
+ entity.put("port", "8686");
+ response = post(URL_JMS_HOST + "/" + jmsHostName, entity);
+ assertThat(response.getStatus(), equalTo(200));
+ entity = getEntityValues(get(URL_JMS_HOST + "/" + jmsHostName));
+ assertEquals("8686", entity.get("port"));
+
+ // Test delete
+ response = delete(URL_JMS_HOST + "/" + jmsHostName);
+ assertThat(response.getStatus(), equalTo(200));
+ }
+
+ public void createJmsPhysicalDestination(final String destName, final String type, final String endpoint) {
+ final Map<String, String> newDest = Map.of("id", destName, "desttype", type);
+ Response response = post(endpoint + "/create-jmsdest", newDest);
+ assertThat(response.getStatus(), equalTo(200));
+ }
+
+ public void deleteJmsPhysicalDestination(final String destName, final String endpoint) {
+ final Map<String, String> newDest = Map.of("id", destName, "desttype", DEST_TYPE);
+ Response response = delete(endpoint + "/delete-jmsdest", newDest);
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = get(endpoint + "__get-jmsdest", newDest);
+ assertThat(response.getStatus(), equalTo(404));
+ }
+}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JmsTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JmsTest.java
deleted file mode 100644
index 88d085b..0000000
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JmsTest.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 2022 Contributors to the Eclipse Foundation
- * Copyright (c) 2010, 2020 Oracle 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.nucleus.admin.rest;
-
-import jakarta.ws.rs.core.Response;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * @author jasonlee
- * @since May 26, 2010
- */
-@Disabled
-public class JmsTest extends RestTestBase {
- static final String URL_ADMIN_OBJECT_RESOURCE = "domain/resources/admin-object-resource";
- static final String URL_CONNECTOR_CONNECTION_POOL = "domain/resources/connector-connection-pool";
- static final String URL_CONNECTOR_RESOURCE = "domain/resources/connector-resource";
- static final String URL_JMS_HOST = "domain/configs/config/server-config/jms-service/jms-host";
- static final String URL_SEVER_JMS_DEST = "domain/servers/server/server";
- static final String DEST_TYPE = "topic";
-
- @Test
- public void testJmsConnectionFactories() {
- final String poolName = "JmsConnectionFactory" + generateRandomString();
- Map<String, String> ccp_attrs = new HashMap<>() {
- {
- put("name", poolName);
- put("connectiondefinition", "jakarta.jms.ConnectionFactory");
- put("raname", "jmsra");
- }
- };
- Map<String, String> cr_attrs = new HashMap<>() {
- {
- put("id", poolName);
- put("poolname", poolName);
- }
- };
-
- // Create connection pool
- Response response = post(URL_CONNECTOR_CONNECTION_POOL, ccp_attrs);
- checkStatus(response);
-
- // Check connection pool creation
- Map<String, String> pool = getEntityValues(get(URL_CONNECTOR_CONNECTION_POOL + "/" + poolName));
- assertFalse(pool.isEmpty());
-
- // Create connector resource
- response = post(URL_CONNECTOR_RESOURCE, cr_attrs);
- checkStatus(response);
-
- // Check connector resource
- Map<String, String> resource = getEntityValues(get(URL_CONNECTOR_RESOURCE + "/" + poolName));
- assertFalse(resource.isEmpty());
-
- // Edit and check ccp
- response = post(URL_CONNECTOR_CONNECTION_POOL + "/" + poolName, new HashMap<String, String>() {
- {
- put("description", poolName);
- }
- });
- checkStatus(response);
-
- pool = getEntityValues(get(URL_CONNECTOR_CONNECTION_POOL + "/" + poolName));
- assertTrue(pool.get("description").equals(poolName));
-
- // Edit and check cr
- response = post(URL_CONNECTOR_RESOURCE + "/" + poolName, new HashMap<String, String>() {
- {
- put("description", poolName);
- }
- });
- checkStatus(response);
-
- resource = getEntityValues(get(URL_CONNECTOR_RESOURCE + "/" + poolName));
- assertTrue(pool.get("description").equals(poolName));
-
- // Delete objects
- response = delete(URL_CONNECTOR_CONNECTION_POOL + "/" + poolName, new HashMap<String, String>() {
- {
- put("cascade", "true");
- }
- });
- checkStatus(response);
- }
-
- @Test
- public void testJmsDestinationResources() {
- final String jndiName = "jndi/" + generateRandomString();
- String encodedJndiName = jndiName;
- try {
- encodedJndiName = URLEncoder.encode(jndiName, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- }
-
- Map<String, String> attrs = new HashMap<>() {
- {
- put("id", jndiName);
- put("raname", "jmsra");
- put("restype", "jakarta.jms.Topic");
- }
- };
-
- Response response = post(URL_ADMIN_OBJECT_RESOURCE, attrs);
- checkStatus(response);
-
- Map<String, String> entity = getEntityValues(get(URL_ADMIN_OBJECT_RESOURCE + "/" + encodedJndiName));
- assertFalse(entity.isEmpty());
-
- response = delete(URL_ADMIN_OBJECT_RESOURCE + "/" + encodedJndiName);
- checkStatus(response);
- }
-
- @Test
- public void testJmsPhysicalDestination() {
- final String destName = "jmsDest" + generateRandomString();
- final int maxNumMsgs = generateRandomNumber(500);
- final int consumerFlowLimit = generateRandomNumber(500);
-
- createJmsPhysicalDestination(destName, DEST_TYPE, URL_SEVER_JMS_DEST);
-
- final HashMap<String, String> newDest = new HashMap<>() {
- {
- put("id", destName);
- put("desttype", DEST_TYPE);
- }
- };
- Map<String, String> destProps = new HashMap<>() {
- {
- putAll(newDest);
- put("property", "MaxNumMsgs=" + maxNumMsgs + ":ConsumerFlowLimit=" + consumerFlowLimit);
- }
- };
-
- Response response = get(URL_SEVER_JMS_DEST + "/__get-jmsdest", newDest);
- checkStatus(response);
-
- response = post(URL_SEVER_JMS_DEST + "/__update-jmsdest", destProps);
- checkStatus(response);
- response = get(URL_SEVER_JMS_DEST + "/__get-jmsdest", newDest);
- checkStatus(response);
- Map<String, String> entity = this.getEntityValues(response);
- assertEquals(maxNumMsgs, entity.get("MaxNumMsgs"));
- assertEquals(consumerFlowLimit, entity.get("ConsumerFlowLimit"));
-
- deleteJmsPhysicalDestination(destName, URL_SEVER_JMS_DEST);
- }
-
- @Test
- public void testJmsPhysicalDestionationsWithClusters() {
- final String destName = "jmsDest" + generateRandomString();
- ClusterTest ct = getTestClass(ClusterTest.class);
- final String clusterName = ct.createCluster();
- ct.createClusterInstance(clusterName, "in1_"+clusterName);
- ct.startCluster(clusterName);
- final String endpoint = "/domain/clusters/cluster/" + clusterName;
- try {
-
- createJmsPhysicalDestination(destName, "topic", endpoint);
- final HashMap<String, String> newDest = new HashMap<>() {
- {
- put("id", destName);
- put("desttype", DEST_TYPE);
- }
- };
-
- Response response = get(endpoint + "/__get-jmsdest", newDest);
- checkStatus(response);
-
- response = get(URL_SEVER_JMS_DEST + "/__get-jmsdest", newDest);
- checkStatus(response);
- }
- finally {
- deleteJmsPhysicalDestination(destName, endpoint);
- ct.stopCluster(clusterName);
- ct.deleteCluster(clusterName);
- }
- }
-
- @Test
- public void testJmsPing() {
- String results = get(URL_SEVER_JMS_DEST + "/jms-ping").readEntity(String.class);
- assertTrue(results.contains("JMS-ping command executed successfully"));
- }
-
- @Test
- public void testJmsFlush() {
- Map<String, String> payload = new HashMap<>() {
- {
- put("id", "mq.sys.dmq");
- put("destType", "queue");
- }
- };
-
- Response response = post(URL_SEVER_JMS_DEST + "/flush-jmsdest", payload);
- checkStatus(response);
- }
-
- @Test
- public void testJmsHosts() {
- final String jmsHostName = "jmshost" + generateRandomString();
- Map<String, String> newHost = new HashMap<>() {
- {
- put("id", jmsHostName);
- put("adminPassword", "admin");
- put("port", "7676");
- put("adminUserName", "admin");
- put("host", "localhost");
- }
- };
-
- // Test create
- Response response = post(URL_JMS_HOST, newHost);
- checkStatus(response);
-
- // Test edit
- Map<String, String> entity = getEntityValues(get(URL_JMS_HOST + "/" + jmsHostName));
- assertFalse(entity.isEmpty());
- assertEquals(jmsHostName, entity.get("name"));
- entity.put("port", "8686");
- response = post(URL_JMS_HOST + "/" + jmsHostName, entity);
- checkStatus(response);
- entity = getEntityValues(get(URL_JMS_HOST + "/" + jmsHostName));
- assertEquals("8686", entity.get("port"));
-
- // Test delete
- response = delete(URL_JMS_HOST + "/" + jmsHostName);
- checkStatus(response);
- }
-
- public void createJmsPhysicalDestination(final String destName, final String type, String endpoint) {
- final Map<String, String> newDest = new HashMap<>() {
- {
- put("id", destName);
- put("desttype", type);
- }
- };
-
- // Test Create
- Response response = post(endpoint + "/create-jmsdest", newDest);
- // This command returns 200 instead of 201, for some reason. Odd.
- checkStatus(response);
- }
-
- public void deleteJmsPhysicalDestination(final String destName, String endpoint) {
- final HashMap<String, String> newDest = new HashMap<>() {
- {
- put("id", destName);
- put("desttype", DEST_TYPE);
- }
- };
-
- // Test deletion
- Response response = delete(endpoint + "/delete-jmsdest", newDest); // You POST to commands
- checkStatus(response);
-
- response = get(endpoint + "__get-jmsdest", newDest);
- assertFalse(response.getStatus() == 200);
- }
-}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JobsResourceTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JobsResourceITest.java
similarity index 74%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JobsResourceTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JobsResourceITest.java
index 122aa0e..c56b008 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JobsResourceTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JobsResourceITest.java
@@ -19,25 +19,22 @@
import jakarta.ws.rs.core.Response;
-import java.util.Locale;
-
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
-import org.glassfish.admin.rest.Constants;
-import org.glassfish.admin.rest.composite.CompositeUtil;
-import org.glassfish.admin.rest.resources.composite.Job;
import org.junit.jupiter.api.Test;
import static org.glassfish.nucleus.test.tool.NucleusTestUtils.nadminWithOutput;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author jdlee
*/
-public class JobsResourceTest extends RestTestBase {
+public class JobsResourceITest extends RestTestBase {
public static final String URL_JOBS = "jobs";
@Test
@@ -46,9 +43,9 @@
}
@Test
- public void testGetJob() throws JSONException {
- // make sure we have at least one job
- issueDetachedCommand();
+ public void testGetJob() throws Exception {
+ // make sure we have at least one detached job
+ nadminWithOutput("--detach", "uptime");
// verify getting the collection
Response response = get(URL_JOBS);
@@ -58,10 +55,10 @@
JSONObject json = response.readEntity(JSONObject.class);
JSONArray resources = json.getJSONArray("resources");
assertNotNull(resources);
- assertTrue(resources.length() > 0);
+ assertThat(resources.length(), equalTo(1));
JSONArray items = json.getJSONArray("items");
assertNotNull(items);
- assertTrue(items.length() > 0);
+ assertThat(items.length(), equalTo(1));
// unlike most resources that also return a parent link,
// the jobs resource only returns child links.
@@ -72,7 +69,7 @@
assertEquals("job", resource.getString("rel"));
String jobId = resource.getString("title");
assertNotNull(jobId);
- assertTrue(uri.endsWith(URL_JOBS + "/id/" + jobId));
+ assertThat(uri, endsWith(URL_JOBS + "/id/" + jobId));
// verify the job it refers to by following the link.
// it should only have a parent link
@@ -80,13 +77,14 @@
assertEquals(200, response.getStatus());
json = response.readEntity(JSONObject.class);
JSONObject item = json.getJSONObject("item");
+ System.out.println(item.toString());
verifyItem(jobId, item);
resources = json.getJSONArray("resources");
assertNotNull(resources);
- assertTrue(resources.length() == 1);
+ assertThat(resources.length(), equalTo(1));
resource = resources.getJSONObject(0);
assertEquals("parent", resource.getString("rel"));
- assertTrue(resource.getString("uri").endsWith(URL_JOBS));
+ assertThat(resource.getString("uri"), endsWith(URL_JOBS));
// verify that the collection returned the item too
item = null;
@@ -99,20 +97,13 @@
verifyItem(jobId, item);
}
- private void verifyItem(String jobIdWant, JSONObject itemHave) throws JSONException {
- assertNotNull(itemHave);
- Locale locale = null;
- Job job = CompositeUtil.instance().unmarshallClass(locale, Job.class, itemHave);
- assertNotNull(job);
- assertEquals(jobIdWant, job.getJobId());
- }
-
- private void issueDetachedCommand() {
- nadminWithOutput("--detach", "uptime");
+ private void verifyItem(String expectedJobId, JSONObject jobJsonObject) throws JSONException {
+ assertNotNull(jobJsonObject);
+ assertEquals(expectedJobId, jobJsonObject.getString("jobId"));
}
@Override
protected String getResponseType() {
- return Constants.MEDIA_TYPE_JSON;
+ return "application/vnd.oracle.glassfish+json";
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JvmOptionsTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JvmOptionsITest.java
similarity index 75%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JvmOptionsTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JvmOptionsITest.java
index 542149c..24e0260 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JvmOptionsTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/JvmOptionsITest.java
@@ -27,6 +27,7 @@
import org.glassfish.admin.rest.client.utils.MarshallingUtils;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -40,7 +41,7 @@
/**
* @author jasonlee
*/
-public class JvmOptionsTest extends RestTestBase {
+public class JvmOptionsITest extends RestTestBase {
private static final String URL_SERVER_JVM_OPTIONS = "domain/configs/config/server-config/java-config/jvm-options";
private static final String URL_DEFAULT_JVM_OPTIONS = "domain/configs/config/default-config/java-config/jvm-options";
@@ -52,31 +53,31 @@
private static final String URL_DEFAULT_CONFIG_DELETE_PROFILER = "domain/configs/config/default-config/java-config/profiler/delete-profiler";
private static final String URL_DEFAULT_CONFIG_PROFILER_JVM_OPTIONS = "domain/configs/config/default-config/java-config/profiler/jvm-options";
- private ConfigTest configTest;
+ private static RestTestBase configManagement;
private String testConfigName;
- private String URL_TEST_CONFIG;
- private String URL_TEST_CONFIG_JVM_OPTIONS;
+ private String testConfigUrl;
+ private String testConfigJvmOptionsUrl;
+
+ @BeforeAll
+ public static void initConfig() {
+ configManagement = new RestTestBase();
+ }
@BeforeEach
public void createConfig() {
- if (configTest == null) {
- configTest = getTestClass(ConfigTest.class);
- }
-
testConfigName = "config-" + generateRandomString();
- MultivaluedMap formData = new MultivaluedHashMap() {{
+ MultivaluedMap<String, String> formData = new MultivaluedHashMap<>() {{
add("id", "default-config");
add("id", testConfigName);
}};
- configTest.createAndVerifyConfig(testConfigName, formData);
-
- URL_TEST_CONFIG = "domain/configs/config/" + testConfigName;
- URL_TEST_CONFIG_JVM_OPTIONS = URL_TEST_CONFIG + "/java-config/jvm-options";
+ configManagement.createAndVerifyConfig(testConfigName, formData);
+ testConfigUrl = "domain/configs/config/" + testConfigName;
+ testConfigJvmOptionsUrl = testConfigUrl + "/java-config/jvm-options";
}
@AfterEach
public void deleteConfig() {
- configTest.deleteAndVerifyConfig(testConfigName);
+ configManagement.deleteAndVerifyConfig(testConfigName);
}
@@ -96,20 +97,19 @@
put(option1Name, "someValue");
}};
- Response response = post(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ Response response = post(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
+ response = get(testConfigJvmOptionsUrl);
List<String> jvmOptions = getJvmOptions(response);
assertTrue(jvmOptions.contains(option1Name+"=someValue"));
- response = delete(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ response = delete(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
+ response = get(testConfigJvmOptionsUrl);
jvmOptions = getJvmOptions(response);
assertFalse(jvmOptions.contains(option1Name+"=someValue"));
}
- // http://java.net/jira/browse/GLASSFISH-19069
@Test
public void createAndDeleteOptionsWithBackslashes() {
final String optionName = "-Dfile" + generateRandomString();
@@ -118,15 +118,15 @@
put(optionName, escape(optionValue));
}};
- Response response = post(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ Response response = post(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
+ response = get(testConfigJvmOptionsUrl);
List<String> jvmOptions = getJvmOptions(response);
assertTrue(jvmOptions.contains(optionName+"="+optionValue));
- response = delete(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ response = delete(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
+ response = get(testConfigJvmOptionsUrl);
jvmOptions = getJvmOptions(response);
assertFalse(jvmOptions.contains(optionName+"="+optionValue));
}
@@ -140,18 +140,18 @@
put(option2Name, "");
}};
- Response response = post(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ Response response = post(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
+ response = get(testConfigJvmOptionsUrl);
List<String> jvmOptions = getJvmOptions(response);
assertTrue(jvmOptions.contains(option1Name));
assertFalse(jvmOptions.contains(option1Name+"="));
assertTrue(jvmOptions.contains(option2Name));
assertFalse(jvmOptions.contains(option2Name+"="));
- response = delete(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ response = delete(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
+ response = get(testConfigJvmOptionsUrl);
jvmOptions = getJvmOptions(response);
assertFalse(jvmOptions.contains(option1Name));
assertFalse(jvmOptions.contains(option2Name));
@@ -167,9 +167,9 @@
}};
// Test new config to make sure option is there
- Response response = post(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ Response response = post(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
+ response = get(testConfigJvmOptionsUrl);
List<String> jvmOptions = getJvmOptions(response);
assertTrue(jvmOptions.contains(optionName));
@@ -183,29 +183,21 @@
public void testProfilerJvmOptions() {
final String profilerName = "profiler" + generateRandomString();
final String optionName = "-Doption" + generateRandomString();
- Map<String, String> attrs = new HashMap<>() {{
- put("name", profilerName);
- put("target", testConfigName);
- }};
- Map<String, String> newOptions = new HashMap<>() {{
-// put("target", testConfigName);
-// put("profiler", "true");
- put(optionName, "");
- }};
+ Map<String, String> attrs = Map.of("name", profilerName, "target", testConfigName);
+ Map<String, String> newOptions = Map.of(optionName, "");
+ deleteProfiler(testConfigUrl + "/java-config/profiler/delete-profiler", testConfigName, false);
- deleteProfiler(URL_TEST_CONFIG + "/java-config/profiler/delete-profiler", testConfigName, false);
-
- Response response = post(URL_TEST_CONFIG + "/java-config/create-profiler", attrs);
+ Response response = post(testConfigUrl + "/java-config/create-profiler", attrs);
assertEquals(200, response.getStatus());
- response = post(URL_TEST_CONFIG + "/java-config/profiler/jvm-options", newOptions);
+ response = post(testConfigUrl + "/java-config/profiler/jvm-options", newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG + "/java-config/profiler/jvm-options");
+ response = get(testConfigUrl + "/java-config/profiler/jvm-options");
List<String> jvmOptions = getJvmOptions(response);
assertTrue(jvmOptions.contains(optionName));
- deleteProfiler(URL_TEST_CONFIG + "/java-config/profiler/delete-profiler", testConfigName, true);
+ deleteProfiler(testConfigUrl + "/java-config/profiler/delete-profiler", testConfigName, true);
}
@Test
@@ -216,16 +208,16 @@
put(escape(optionName), optionValue);
}};
- Response response = post(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ Response response = post(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
-// assertEquals(200, response.getStatus());
+ response = get(testConfigJvmOptionsUrl);
+ assertEquals(200, response.getStatus());
List<String> jvmOptions = getJvmOptions(response);
assertTrue(jvmOptions.contains(optionName+"="+optionValue));
- response = delete(URL_TEST_CONFIG_JVM_OPTIONS, newOptions);
+ response = delete(testConfigJvmOptionsUrl, newOptions);
assertEquals(200, response.getStatus());
- response = get(URL_TEST_CONFIG_JVM_OPTIONS);
+ response = get(testConfigJvmOptionsUrl);
jvmOptions = getJvmOptions(response);
assertFalse(jvmOptions.contains(optionName+"="+optionValue));
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MetadataTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MetadataITest.java
similarity index 82%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MetadataTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MetadataITest.java
index 24afd79..27dcde0 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MetadataTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MetadataITest.java
@@ -24,14 +24,15 @@
import org.glassfish.admin.rest.client.utils.MarshallingUtils;
import org.junit.jupiter.api.Test;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author jasonlee
*/
-public class MetadataTest extends RestTestBase {
+public class MetadataITest extends RestTestBase {
private static final String URL_CONFIG = "domain/configs/config.json";
private static final String URL_UPTIMECOMMAND = "domain/uptime.json";
@@ -46,11 +47,12 @@
// Another dumb test to make sure that "name" shows up on the HTML page
response = getClient().target(getAddress(URL_CONFIG)).request().get(Response.class);
- assertTrue(response.readEntity(String.class).contains("extraProperties"));
+ String data = response.readEntity(String.class);
+ assertThat(data, stringContainsInOrder("extraProperties"));
}
@Test
- public void UpTimeMetadaDataTest() {
+ public void upTimeMetadaDataTest() {
Response response = options(URL_UPTIMECOMMAND);
assertEquals(200, response.getStatus());
@@ -60,10 +62,10 @@
// Another dumb test to make sure that "extraProperties" shows up on the HTML page
response = getClient().target(getAddress(URL_UPTIMECOMMAND)).request().get(Response.class);
String resp = response.readEntity(String.class);
- assertTrue(resp.contains("extraProperties"));
+ assertThat(resp, stringContainsInOrder("extraProperties"));
// test to see if we get the milliseconds parameter description which is an
//optional param metadata for the uptime command
- assertTrue(resp.contains("milliseconds"));
- assertTrue(resp.contains("GET"));
+ assertThat(resp, stringContainsInOrder("milliseconds"));
+ assertThat(resp, stringContainsInOrder("GET"));
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MonitoringITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MonitoringITest.java
new file mode 100644
index 0000000..0ad5cdf
--- /dev/null
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MonitoringITest.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation
+ * Copyright (c) 2011, 2018 Oracle 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.nucleus.admin.rest;
+
+
+import jakarta.ws.rs.core.Response;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * @author Mitesh Meswani
+ */
+@TestMethodOrder(OrderAnnotation.class)
+public class MonitoringITest extends RestTestBase {
+ private static final String MONITORING_RESOURCE_URL = "domain/configs/config/server-config/monitoring-service/module-monitoring-levels";
+ private static final String JDBC_CONNECTION_POOL_URL = "domain/resources/jdbc-connection-pool";
+ private static final String PING_CONNECTION_POOL_URL = "domain/resources/ping-connection-pool";
+ private static final String CONTEXT_ROOT_MONITORING = "monitoring";
+
+ @Test
+ @Order(1)
+ public void enableMonitoring() {
+ String url = getManagementURL(MONITORING_RESOURCE_URL);
+ Map<String, String> payLoad = new HashMap<>() {
+ {
+ put("ThreadPool", "HIGH");
+ put("Orb", "HIGH");
+ put("EjbContainer", "HIGH");
+ put("WebContainer", "HIGH");
+ put("Deployment", "HIGH");
+ put("TransactionService", "HIGH");
+ put("HttpService", "HIGH");
+ put("JdbcConnectionPool", "HIGH");
+ put("ConnectorConnectionPool", "HIGH");
+ put("ConnectorService", "HIGH");
+ put("JmsService", "HIGH");
+ put("Jvm", "HIGH");
+ put("Security", "HIGH");
+ put("WebServicesContainer", "HIGH");
+ put("Jpa", "HIGH");
+ put("Jersey", "HIGH");
+ }
+ };
+ Response response = post(url, payLoad);
+ assertEquals(202, response.getStatus());
+ }
+
+ /**
+ * Objective - Verify that basic monitoring is working
+ * Strategy - Call /monitoring/domain and assert that "server" is present as child element
+ */
+ @Test
+ @Order(2)
+ public void testBaseURL() {
+ Response response = get("domain");
+ assertEquals(200, response.getStatus());
+ // monitoring/domain
+ Map<String, String> entity = getChildResources(response);
+ assertNull(entity.get("server"), entity.toString());
+ }
+
+ /**
+ * Objective - Verify that invalid resources returns 404
+ * Strategy - Request an invalid resource under monitoring and ensure that 404 is returned
+ */
+ @Test
+ @Order(10)
+ public void testInvalidResource() {
+ Response response = get("domain/server/foo");
+ assertEquals(404, response.getStatus(), "Did not receive ");
+ }
+
+ /**
+ * Objective - Verify that resources with dot work
+ * Strategy - create a resource with "." in name and then try to access it
+ */
+ @Test
+ @Order(20)
+ public void testDot() {
+ // Step 1- Create a resource with "."
+ final String poolNameWithDot = "poolNameWith.dot";
+
+ // Clean up from leftover from previous run
+ String url = getManagementURL(JDBC_CONNECTION_POOL_URL + '/' + poolNameWithDot);
+ Response responseDel = delete(url);
+ assertEquals(202, responseDel.getStatus());
+
+ url = getManagementURL(JDBC_CONNECTION_POOL_URL);
+ Map<String, String> payLoad = new HashMap<>() {
+ {
+ put("name", poolNameWithDot);
+ put("resType", "javax.sql.DataSource");
+ put("datasourceClassname", "foo.bar");
+ }
+ };
+ Response response = post(url, payLoad);
+ assertEquals(202, response.getStatus());
+
+
+ // Step 2- Ping the connection pool to generate some monitoring data
+ url = getManagementURL(PING_CONNECTION_POOL_URL);
+ Response responsePing = get(url, Map.of("id", poolNameWithDot));
+ assertEquals(202, responsePing.getStatus());
+
+ // Step 3 - Access monitoring tree to assert it is accessible
+ // FIXME: As of 03.04.2022 Utils.getJerseyClient here throws exception:
+ // java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.client.ClientBuilder cannot be found
+// Response responsePool = get("domain/server/resources/" + poolNameWithDot);
+// assertEquals(200, responsePool.getStatus());
+// Map<String, String> responseEntity = getEntityValues(responsePool);
+// assertThat("No Monitoring data found for pool " + poolNameWithDot, responseEntity, aMapWithSize(2));
+ }
+
+
+ @Test
+ @Order(1000)
+ public void testCleanup() {
+ String url = getManagementURL(MONITORING_RESOURCE_URL);
+ Map<String, String> payLoad = new HashMap<>() {
+ {
+ put("ThreadPool", "LOW");
+ put("Orb", "LOW");
+ put("EjbContainer", "LOW");
+ put("WebContainer", "LOW");
+ put("Deployment", "LOW");
+ put("TransactionService", "LOW");
+ put("HttpService", "LOW");
+ put("JdbcConnectionPool", "LOW");
+ put("ConnectorConnectionPool", "LOW");
+ put("ConnectorService", "LOW");
+ put("JmsService", "LOW");
+ put("Jvm", "LOW");
+ put("Security", "LOW");
+ put("WebServicesContainer", "LOW");
+ put("Jpa", "LOW");
+ put("Jersey", "LOW");
+ }
+ };
+ Response response = post(url, payLoad);
+ assertEquals(202, response.getStatus());
+ }
+
+ @Override
+ protected String getContextRoot() {
+ return CONTEXT_ROOT_MONITORING;
+ }
+
+ private String getManagementURL(String targetResourceURL) {
+ return getBaseAdminUrl() + CONTEXT_ROOT_MANAGEMENT + targetResourceURL;
+ }
+}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MonitoringTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MonitoringTest.java
deleted file mode 100644
index 42a40a9..0000000
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/MonitoringTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2022 Contributors to the Eclipse Foundation
- * Copyright (c) 2011, 2018 Oracle 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.nucleus.admin.rest;
-
-
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.Response.Status;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * @author Mitesh Meswani
- */
-@Disabled
-public class MonitoringTest extends RestTestBase {
- private static final String MONITORING_RESOURCE_URL = "/domain/configs/config/server-config/monitoring-service/module-monitoring-levels";
- private static final String JDBC_CONNECTION_POOL_URL = "/domain/resources/jdbc-connection-pool";
- private static final String PING_CONNECTION_POOL_URL = "/domain/resources/ping-connection-pool";
- private static final String CONTEXT_ROOT_MONITORING = "monitoring";
-
- @Override
- protected String getContextRoot() {
- return CONTEXT_ROOT_MONITORING;
- }
-
- @Test
- public void initializeMonitoring() {
- // Enable monitoring
- String url = getManagementURL(MONITORING_RESOURCE_URL);
- Map<String, String> payLoad = new HashMap<>() {
- {
- put("ThreadPool", "HIGH");
- put("Orb", "HIGH");
- put("EjbContainer", "HIGH");
- put("WebContainer", "HIGH");
- put("Deployment", "HIGH");
- put("TransactionService", "HIGH");
- put("HttpService", "HIGH");
- put("JdbcConnectionPool", "HIGH");
- put("ConnectorConnectionPool", "HIGH");
- put("ConnectorService", "HIGH");
- put("JmsService", "HIGH");
- put("Jvm", "HIGH");
- put("Security", "HIGH");
- put("WebServicesContainer", "HIGH");
- put("Jpa", "HIGH");
- put("Jersey", "HIGH");
- }
- };
- Response response = post(url, payLoad);
- assertEquals(200, response.getStatus());
- }
-
- /**
- * Objective - Verify that basic monitoring is working
- * Strategy - Call /monitoring/domain and assert that "server" is present as child element
- */
- @Test
- public void testBaseURL() {
- Map<String, String> entity = getChildResources(get("domain")); // monitoring/domain
- assertNotNull(entity.get("server"));
- }
-
- /**
- * Objective - Verify that resources with dot work
- * Strategy - create a resource with "." in name and then try to access it
- */
- @Test
- public void testDot() {
- // Step 1- Create a resource with "."
- final String POOL_NAME = "poolNameWith.dot";
-
- // Clean up from leftover from previous run
- String url = getManagementURL(JDBC_CONNECTION_POOL_URL + '/' + POOL_NAME);
- delete(url);
-
- url = getManagementURL(JDBC_CONNECTION_POOL_URL);
- Map<String, String> payLoad = new HashMap<>() {
- {
- put("name", POOL_NAME);
- put("resType", "javax.sql.DataSource");
- put("datasourceClassname", "foo.bar");
- }
- };
- Response response = post(url, payLoad);
- assertEquals(200, response.getStatus());
-
-
- // Step 2- Ping the connection pool to generate some monitoring data
- url = getManagementURL(PING_CONNECTION_POOL_URL);
- payLoad.clear();
- payLoad.put("id", POOL_NAME);
- get(url, payLoad);
-
- // Step 3 - Access monitoring tree to assert it is accessible
- response = get("domain/server/resources/"+ POOL_NAME);
- assertEquals(200, response.getStatus());
- Map<String, String> responseEntity = getEntityValues(response);
- assertTrue(responseEntity.size() > 0, "No Monitoring data found for pool " + POOL_NAME);
- }
-
- /**
- * Objective - Verify that invalid resources returns 404
- * Strategy - Request an invalid resource under monitoring and ensure that 404 is returned
- */
- @Test
- public void testInvalidResource() {
- Response response = get("domain/server/foo");
- assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus(), "Did not receive ");
- }
-
-
- private String getManagementURL(String targetResourceURL) {
- return getBaseAdminUrl() + CONTEXT_ROOT_MANAGEMENT + targetResourceURL;
-
- }
-
-
-}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NetworkListenerTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NetworkListenerITest.java
similarity index 66%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NetworkListenerTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NetworkListenerITest.java
index d51c7d9..46cb690 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NetworkListenerTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NetworkListenerITest.java
@@ -23,34 +23,30 @@
import java.util.Map;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
- *
* @author jasonlee
*/
-public class NetworkListenerTest extends RestTestBase {
+public class NetworkListenerITest extends RestTestBase {
protected static final String URL_PROTOCOL = "domain/configs/config/server-config/network-config/protocols/protocol";
protected static final String URL_SSL = "domain/configs/config/server-config/network-config/protocols/protocol/http-listener-2/ssl";
@Test
- @Disabled
public void createHttpListener() {
- final String redirectProtocolName = "http-redirect"; //protocol_" + generateRandomString();
- final String portUniProtocolName = "pu-protocol"; //protocol_" + generateRandomString();
+ final String redirectProtocolName = "http-redirect";
+ final String portUniProtocolName = "pu-protocol";
- final String redirectFilterName = "redirect-filter"; //filter_" + generateRandomString();
- final String finderName1 = "http-finder"; //finder" + generateRandomString();
- final String finderName2 = "http-redirect"; //finder" + generateRandomString();
+ final String redirectFilterName = "redirect-filter";
+ final String finderName1 = "http-finder";
+ final String finderName2 = "http-redirect";
try {
- Response response = post("domain/set", new HashMap<String, String>() {{
- put("configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.protocol", "http-listener-1");
- }});
+ Response response = post("domain/set", Map.of("configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.protocol", "http-listener-1"));
assertEquals(200, response.getStatus());
delete(URL_PROTOCOL + "/" + portUniProtocolName);
assertEquals(200, response.getStatus());
@@ -59,18 +55,15 @@
// asadmin commands taken from: http://www.antwerkz.com/port-unification-in-glassfish-3-part-1/
// asadmin create-protocol --securityenabled=false http-redirect
// asadmin create-protocol --securityenabled=false pu-protocol
- response = post(URL_PROTOCOL, new HashMap<String, String>() {{ put ("securityenabled", "false"); put("id", redirectProtocolName); }});
+ response = post(URL_PROTOCOL, Map.of("securityenabled", "false", "id", redirectProtocolName));
assertEquals(200, response.getStatus());
- response = post(URL_PROTOCOL, new HashMap<String, String>() {{ put ("securityenabled", "false"); put("id", portUniProtocolName); }});
+ response = post(URL_PROTOCOL, Map.of("securityenabled", "false", "id", portUniProtocolName));
assertEquals(200, response.getStatus());
// asadmin create-protocol-filter --protocol http-redirect --classname org.glassfish.grizzly.config.portunif.HttpRedirectFilter redirect-filter
- response = post (URL_PROTOCOL + "/" + redirectProtocolName + "/create-protocol-filter",
- new HashMap<String, String>() {{
- put ("id", redirectFilterName);
- put ("protocol", redirectProtocolName);
- put ("classname", "org.glassfish.grizzly.config.portunif.HttpRedirectFilter");
- }});
+ response = post(URL_PROTOCOL + "/" + redirectProtocolName + "/create-protocol-filter",
+ Map.of("id", redirectFilterName, "protocol", redirectProtocolName,
+ "classname", "org.glassfish.grizzly.config.portunif.HttpRedirectFilter"));
assertEquals(200, response.getStatus());
// asadmin create-protocol-finder --protocol pu-protocol --targetprotocol http-listener-2 --classname org.glassfish.grizzly.config.portunif.HttpProtocolFinder http-finder
@@ -94,40 +87,33 @@
// asadmin set configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.protocol=pu-protocol
- response = post("/domain/configs/config/server-config/network-config/network-listeners/network-listener/http-listener-1", new HashMap<String, String>() {{
- put("protocol", portUniProtocolName);
- }});
+ response = post("domain/configs/config/server-config/network-config/network-listeners/network-listener/http-listener-1",
+ Map.of("protocol", portUniProtocolName));
assertEquals(200, response.getStatus());
- response = get("/domain/configs/config/server-config/network-config/network-listeners/network-listener/http-listener-1/find-http-protocol");
- assertTrue(response.readEntity(String.class).contains("http-listener-2"));
+ response = get("domain/configs/config/server-config/network-config/network-listeners/network-listener/http-listener-1/find-http-protocol");
+ assertThat(response.readEntity(String.class), stringContainsInOrder("http-listener-2"));
} finally {
-// ClientResponse response = post("/domain/set", new HashMap<String, String>() {{
- Response response = post("/domain/configs/config/server-config/network-config/network-listeners/network-listener/http-listener-1", new HashMap<String, String>() {{
- put("protocol", "http-listener-1");
- }});
+ Response response = post(
+ "domain/configs/config/server-config/network-config/network-listeners/network-listener/http-listener-1",
+ Map.of("protocol", "http-listener-1"));
assertEquals(200, response.getStatus());
response = delete(URL_PROTOCOL + "/" + portUniProtocolName + "/delete-protocol-finder",
- new HashMap<String, String>() {{
- put("protocol", portUniProtocolName);
- put("id", finderName1);
- }} );
+ Map.of("protocol", portUniProtocolName, "id", finderName1));
assertEquals(200, response.getStatus());
response = delete(URL_PROTOCOL + "/" + portUniProtocolName + "/delete-protocol-finder",
- new HashMap<String, String>() {{
- put("protocol", portUniProtocolName);
- put("id", finderName2);
- }} );
+ Map.of("protocol", portUniProtocolName, "id", finderName2));
assertEquals(200, response.getStatus());
- response = delete(URL_PROTOCOL + "/" + redirectProtocolName + "/protocol-chain-instance-handler/protocol-chain/protocol-filter/" + redirectFilterName,
- new HashMap<String, String>() {{ put("protocol", redirectProtocolName); }} );
+ response = delete(
+ URL_PROTOCOL + "/" + redirectProtocolName
+ + "/protocol-chain-instance-handler/protocol-chain/protocol-filter/" + redirectFilterName,
+ Map.of("protocol", redirectProtocolName));
assertEquals(200, response.getStatus());
response = delete(URL_PROTOCOL + "/" + portUniProtocolName);
assertEquals(200, response.getStatus());
response = delete(URL_PROTOCOL + "/" + redirectProtocolName);
assertEquals(200, response.getStatus());
}
-
}
@Test
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NoCLICommandResourceCreationTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NoCLICommandResourceCreationITest.java
similarity index 76%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NoCLICommandResourceCreationTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NoCLICommandResourceCreationITest.java
index 6aa002a..e248c4b 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NoCLICommandResourceCreationTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/NoCLICommandResourceCreationITest.java
@@ -24,21 +24,20 @@
import java.util.HashMap;
import java.util.Map;
-import org.glassfish.admin.rest.client.utils.MarshallingUtils;
import org.junit.jupiter.api.Test;
+import static org.glassfish.admin.rest.client.utils.MarshallingUtils.getXmlForProperties;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Mitesh Meswani
*/
-public class NoCLICommandResourceCreationTest extends RestTestBase {
+public class NoCLICommandResourceCreationITest extends RestTestBase {
private static final String URL_SERVER_PROPERTY = "domain/servers/server/server/property";
@Test
public void testPropertyCreation() {
- final String propertyKey = "propertyName" + generateRandomString();
+ final String propertyKey = "propertyName" + generateRandomString();
String propertyValue = generateRandomString();
//Create a property
@@ -47,7 +46,7 @@
param.put("value",propertyValue);
Response response = getClient().target(getAddress(URL_SERVER_PROPERTY))
.request(RESPONSE_TYPE)
- .post(Entity.entity(MarshallingUtils.getXmlForProperties(param), MediaType.APPLICATION_XML), Response.class);
+ .post(Entity.entity(getXmlForProperties(param), MediaType.APPLICATION_XML), Response.class);
assertEquals(200, response.getStatus());
//Verify the property got created
@@ -55,21 +54,21 @@
response = get (propertyURL);
assertEquals(200, response.getStatus());
Map<String, String> entity = getEntityValues(response);
- assertTrue(entity.get("name").equals(propertyKey));
- assertTrue(entity.get("value").equals(propertyValue));
+ assertEquals(propertyKey, entity.get("name"));
+ assertEquals(propertyValue, entity.get("value"));
// Verify property update
propertyValue = generateRandomString();
param.put("value", propertyValue);
response = getClient().target(getAddress(URL_SERVER_PROPERTY))
.request(RESPONSE_TYPE)
- .put(Entity.entity(MarshallingUtils.getXmlForProperties(param), MediaType.APPLICATION_XML), Response.class);
+ .put(Entity.entity(getXmlForProperties(param), MediaType.APPLICATION_XML), Response.class);
assertEquals(200, response.getStatus());
response = get (propertyURL);
assertEquals(200, response.getStatus());
entity = getEntityValues(response);
- assertTrue(entity.get("name").equals(propertyKey));
- assertTrue(entity.get("value").equals(propertyValue));
+ assertEquals(propertyKey, entity.get("name"));
+ assertEquals(propertyValue, entity.get("value"));
//Clean up to leave domain.xml good for next run
response = delete(propertyURL, new HashMap<String, String>());
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PartialUpdateTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PartialUpdateITest.java
similarity index 83%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PartialUpdateTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PartialUpdateITest.java
index 1759439..797c086 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PartialUpdateTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PartialUpdateITest.java
@@ -17,10 +17,10 @@
package org.glassfish.nucleus.admin.rest;
-import java.util.HashMap;
+import jakarta.ws.rs.core.Response;
+
import java.util.Map;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -28,18 +28,15 @@
/**
* @author jasonlee
*/
-public class PartialUpdateTest extends RestTestBase {
+public class PartialUpdateITest extends RestTestBase {
@Test
- @Disabled
- // TODO: rework this to use something nucleus-friendly
public void testPartialUpdate() {
- final String endpoint = JdbcTest.BASE_JDBC_CONNECTION_POOL_URL + "/DerbyPool";
+ final String endpoint = URL_JDBC_CONNECTION_POOL + "/DerbyPool";
final String newDesc = generateRandomString();
Map<String, String> origAttrs = getEntityValues(get(endpoint));
- Map<String, String> newAttrs = new HashMap<>() {{
- put ("description", newDesc);
- }};
- post(endpoint, newAttrs);
+ Map<String, String> newAttrs = Map.of("description", newDesc);
+ Response response = post(endpoint, newAttrs);
+ assertEquals(200, response.getStatus());
Map<String, String> updatedAttrs = getEntityValues(get(endpoint));
assertEquals(newDesc, updatedAttrs.get("description"));
assertEquals(origAttrs.get("driverClassname"), updatedAttrs.get("driverClassname"));
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PropertiesBagTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PropertiesBagITest.java
similarity index 94%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PropertiesBagTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PropertiesBagITest.java
index 9555897..9ca20a4 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PropertiesBagTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/PropertiesBagITest.java
@@ -28,20 +28,22 @@
import org.codehaus.jettison.json.JSONArray;
import org.glassfish.admin.rest.client.utils.MarshallingUtils;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author jasonlee
*/
-public class PropertiesBagTest extends RestTestBase {
+public class PropertiesBagITest extends RestTestBase {
private static final String PROP_DOMAIN_NAME = "administrative.domain.name";
private static final String URL_DOMAIN_PROPERTIES = "domain/property";
@@ -69,7 +71,6 @@
}
@Test
- @Disabled
public void propsWithEmptyValues() {
List<Map<String, String>> properties = new ArrayList<>();
final String empty = "empty" + generateRandomNumber();
@@ -99,7 +100,6 @@
}
@Test
- @Disabled
public void testOptimizedPropertyHandling() {
// First, test changing one property and adding a new
List<Map<String, String>> properties = new ArrayList<>();
@@ -160,19 +160,19 @@
// FIXME: the prop name can not contain .
// need to remove the . test when http://java.net/jira/browse/GLASSFISH-15418 is fixed
@Test
- @Disabled
public void testPropertiesWithDots() {
List<Map<String, String>> properties = new ArrayList<>();
- final String prop = "some.property.with.dots." + generateRandomNumber();
+ final String key = "some.property.with.dots." + generateRandomNumber();
final String description = "This is the description";
final String value = generateRandomString();
- properties.add(createProperty(prop, value, description));
+ properties.add(createProperty(key, value, description));
createProperties(URL_DERBYPOOL_PROPERTIES, properties);
+
List<Map<String, String>> newProperties = getProperties(get(URL_DERBYPOOL_PROPERTIES));
- Map<String, String> newProp = getProperty(newProperties, prop);
- assertTrue(newProp != null);
- assertTrue(value.equals(newProp.get("value")));
- assertTrue(description.equals(newProp.get("description")));
+ Map<String, String> newProp = getProperty(newProperties, key);
+ assertNotNull(newProp);
+ assertEquals(value, newProp.get("value"));
+ assertNull(newProp.get("description"), "Descriptions are not returned at this moment: " + newProp);
}
// This operation is taking a REALLY long time from the console, probably due
@@ -183,7 +183,6 @@
// then update only one the object's properties, which should be a very quick,
// inexpensive operation.
@Test
- @Disabled
public void testJmsRaCreateAndUpdate() {
List<Map<String, String>> props = new ArrayList<>(){{
add(createProperty("AddressListBehavior", "random"));
@@ -238,7 +237,6 @@
delete(URL+"/jmsra");
}
- @Disabled("Disable this test for now. The functionality this tests is not available in nucleus")
@Test
public void test20810() {
Map<String, String> payload = new HashMap<>();
@@ -251,18 +249,17 @@
payload.put("ssoFailoverEnabled","false");
final String wcaUri = "domain/configs/config/default-config/availability-service/web-container-availability";
- Response r = post(wcaUri, payload);
- checkStatus(r);
+ Response response = post(wcaUri, payload);
+ assertThat(response.getStatus(), equalTo(200));
- checkStatus(get(wcaUri));
+ assertThat(get(wcaUri).getStatus(), equalTo(200));
- r = getClient()
+ response = getClient()
.target(getAddress("domain/configs/config/default-config/availability-service/web-container-availability/property")).
request(getResponseType())
.post(Entity.json(new JSONArray()), Response.class);
- checkStatus(r);
-
- checkStatus(get(wcaUri));
+ assertThat(response.getStatus(), equalTo(200));
+ assertThat(get(wcaUri).getStatus(), equalTo(200));
}
private String buildPropertyList(List<Map<String, String>> props) {
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ProvidersTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ProvidersITest.java
similarity index 98%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ProvidersTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ProvidersITest.java
index c5b219f..e6b2fc9 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ProvidersTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ProvidersITest.java
@@ -26,7 +26,7 @@
/**
* @author jasonlee
*/
-public class ProvidersTest extends RestTestBase {
+public class ProvidersITest extends RestTestBase {
private static final String URL_ACTION_REPORT_RESULT = "domain/uptime";
private static final String URL_COMMAND_RESOURCE_GET_RESULT = "domain/stop";
private static final String URL_GET_RESULT = "domain";
@@ -35,7 +35,7 @@
private static final String URL_STRING_LIST_RESULT = "domain/configs/config/server-config/java-config/jvm-options";
private static String URL_TREE_NODE;
- public ProvidersTest() {
+ public ProvidersITest() {
URL_TREE_NODE = "http://localhost:" + getParameter("admin.port", "4848") + "/monitoring/domain";
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ResourceRefTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ResourceRefITest.java
similarity index 90%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ResourceRefTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ResourceRefITest.java
index 826f071..ce658d3 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ResourceRefTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ResourceRefITest.java
@@ -22,7 +22,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -30,13 +29,12 @@
/**
* @author jasonlee
*/
-public class ResourceRefTest extends RestTestBase {
+public class ResourceRefITest extends RestTestBase {
private static final String URL_CREATE_INSTANCE = "domain/create-instance";
private static final String URL_JDBC_RESOURCE = "domain/resources/jdbc-resource";
private static final String URL_RESOURCE_REF = "domain/servers/server/server/resource-ref";
@Test
- @Disabled
public void testCreatingResourceRef() {
final String instanceName = "instance_" + generateRandomString();
final String jdbcResourceName = "jdbc_" + generateRandomString();
@@ -63,12 +61,9 @@
response = post(URL_RESOURCE_REF, resourceRef);
assertEquals(200, response.getStatus());
- } catch (Exception e) {
- e.printStackTrace();
} finally {
- Response response = delete("domain/servers/server/" + instanceName + "/resource-ref/" + jdbcResourceName, new HashMap<String, String>() {{
- put("target", instanceName);
- }});
+ Response response = delete("domain/servers/server/" + instanceName + "/resource-ref/" + jdbcResourceName,
+ Map.of("target", instanceName));
assertEquals(200, response.getStatus());
response = get("domain/servers/server/" + instanceName + "/resource-ref/" + jdbcResourceName);
assertEquals(404, response.getStatus());
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/RestTestBase.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/RestTestBase.java
index 44a54e5..3cc5ef7 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/RestTestBase.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/RestTestBase.java
@@ -29,6 +29,7 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileWriter;
+import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.file.Path;
@@ -53,6 +54,11 @@
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
import org.glassfish.nucleus.test.tool.DomainLifecycleExtension;
import org.glassfish.nucleus.test.tool.NucleusTestUtils;
+import org.glassfish.nucleus.test.webapp.HelloServlet;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
@@ -62,20 +68,25 @@
import static org.glassfish.nucleus.test.tool.NucleusTestUtils.ADMIN_PASSWORD;
import static org.glassfish.nucleus.test.tool.NucleusTestUtils.ADMIN_USER;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThan;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(DomainLifecycleExtension.class)
public class RestTestBase {
+
+ private static final Logger LOG = Logger.getLogger(RestTestBase.class.getName());
+
protected static final String RESPONSE_TYPE = MediaType.APPLICATION_JSON;
protected static final String CONTEXT_ROOT_MANAGEMENT = "management";
+
protected static final String URL_CLUSTER = "domain/clusters/cluster";
protected static final String URL_APPLICATION_DEPLOY = "domain/applications/application";
protected static final String URL_CREATE_INSTANCE = "domain/create-instance";
+ protected static final String URL_CONFIGS = "domain/configs";
+ protected static final String URL_JDBC_RESOURCE = "domain/resources/jdbc-resource";
+ protected static final String URL_JDBC_CONNECTION_POOL = "domain/resources/jdbc-connection-pool";
private static String adminHost;
private static String adminPort;
@@ -131,6 +142,21 @@
client = null;
}
+ public void createAndVerifyConfig(String configName, MultivaluedMap<String, String> configData) {
+ Response response = post(URL_CONFIGS + "/copy-config", configData);
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = get(URL_CONFIGS + "/config/" + configName);
+ assertEquals(200, response.getStatus());
+ }
+
+ public void deleteAndVerifyConfig(String configName) {
+ Response response = post(URL_CONFIGS + "/config/" + configName + "/delete-config");
+ assertThat(response.getStatus(), equalTo(200));
+
+ response = get(URL_CONFIGS + "/config/" + configName);
+ assertEquals(404, response.getStatus());
+ }
public String createCluster() {
final String clusterName = "cluster_" + generateRandomString();
@@ -141,23 +167,23 @@
public void createCluster(final String clusterName) {
Map<String, String> newCluster = Map.of("id", clusterName);
Response response = post(URL_CLUSTER, newCluster);
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
}
public void startCluster(String clusterName) {
Response response = post(URL_CLUSTER + "/" + clusterName + "/start-cluster");
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
}
public void stopCluster(String clusterName) {
Response response = post(URL_CLUSTER + "/" + clusterName + "/stop-cluster");
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
}
public void createClusterInstance(final String clusterName, final String instanceName) {
Response response = post("domain/create-instance",
Map.of("cluster", clusterName, "id", instanceName, "node", "localhost-domain1"));
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
}
public void deleteCluster(String clusterName) {
@@ -172,10 +198,10 @@
String instanceName = instance.get("name");
if (!"NOT_RUNNING".equalsIgnoreCase(status)) {
response = post("domain/servers/server/" + instanceName + "/stop-instance");
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
}
response = delete("domain/servers/server/" + instanceName + "/delete-instance");
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
}
}
}
@@ -185,26 +211,26 @@
assertEquals(404, response.getStatus());
}
- public Map<String, String> deployApp (final File archive, final String contextRoot, final String name) {
+ public Map<String, String> deployApp(final File archive, final String contextRoot, final String name) {
Map<String, Object> app = Map.of(
"id", archive,
"contextroot", contextRoot,
"name", name
);
Response response = postWithUpload(URL_APPLICATION_DEPLOY, app);
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
return getEntityValues(get(URL_APPLICATION_DEPLOY + "/" + app.get("name")));
}
public void addAppRef(final String applicationName, final String targetName){
- Response cr = post("domain/servers/server/" + targetName + "/application-ref",
+ Response response = post("domain/servers/server/" + targetName + "/application-ref",
Map.of("id", applicationName, "target", targetName));
- checkStatus(cr);
+ assertThat(response.getStatus(), equalTo(200));
}
public Response undeployApp(String appName) {
Response response = delete(URL_APPLICATION_DEPLOY + "/" + appName);
- checkStatus(response);
+ assertThat(response.getStatus(), equalTo(200));
return response;
}
@@ -234,13 +260,6 @@
return Math.abs(r.nextInt(max - 1)) + 1;
}
- protected void checkStatus(Response response) {
- assertAll("response status",
- () -> assertThat(response.getStatus(), greaterThanOrEqualTo(200)),
- () -> assertThat(response.getStatus(), lessThan(300))
- );
- }
-
protected String getResponseType() {
return RESPONSE_TYPE;
}
@@ -325,7 +344,7 @@
protected Response postWithUpload(String address, Map<String, Object> payload) {
FormDataMultiPart form = new FormDataMultiPart();
for (Map.Entry<String, Object> entry : payload.entrySet()) {
- if ((entry.getValue() instanceof File)) {
+ if (entry.getValue() instanceof File) {
form.getBodyParts().
add((new FileDataBodyPart(entry.getKey(), (File) entry.getValue())));
} else {
@@ -357,16 +376,16 @@
* @return
*/
protected Map<String, String> getEntityValues(Response response) {
- Map<String, String> map = new HashMap<>();
-
String xml = response.readEntity(String.class);
- Map responseMap = MarshallingUtils.buildMapFromDocument(xml);
- Object obj = responseMap.get("extraProperties");
- if (obj != null) {
- return (Map) ((Map) obj).get("entity");
- } else {
- return map;
+ Map<String, Object> responseMap = MarshallingUtils.buildMapFromDocument(xml);
+ if (responseMap == null) {
+ return null;
}
+ Map<String, Object> obj = (Map<String, Object>) responseMap.get("extraProperties");
+ if (obj == null) {
+ return null;
+ }
+ return (Map<String, String>) obj.get("entity");
}
protected List<String> getCommandResults(Response response) {
@@ -394,6 +413,7 @@
protected Map<String, String> getChildResources(Response response) {
Map responseMap = MarshallingUtils.buildMapFromDocument(response.readEntity(String.class));
+ LOG.log(Level.INFO, "responseMap: \n{0}", responseMap);
Map<String, Map> extraProperties = (Map<String, Map>) responseMap.get("extraProperties");
if (extraProperties != null) {
return extraProperties.get("childResources");
@@ -453,4 +473,30 @@
return value;
}
+
+
+ protected static File getEar(final String appName) {
+ final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class).addAsModule(getWar(appName), "simple.war");
+ LOG.info(ear.toString(true));
+ try {
+ File tempFile = File.createTempFile(appName, ".ear");
+ ear.as(ZipExporter.class).exportTo(tempFile, true);
+ return tempFile;
+ } catch (IOException e) {
+ throw new IllegalStateException("Deployment failed - cannot load the input archive!", e);
+ }
+ }
+
+ protected static File getWar(final String appName) {
+ final WebArchive war = ShrinkWrap.create(WebArchive.class).addPackage(HelloServlet.class.getPackage());
+ LOG.info(war.toString(true));
+ try {
+ File tempFile = File.createTempFile(appName, ".war");
+ war.as(ZipExporter.class).exportTo(tempFile, true);
+ return tempFile;
+ } catch (IOException e) {
+ throw new IllegalStateException("Deployment failed - cannot load the input archive!", e);
+ }
+ }
+
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/SystemPropertiesTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/SystemPropertiesITest.java
similarity index 92%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/SystemPropertiesTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/SystemPropertiesITest.java
index f29a0c2..a5e79f4 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/SystemPropertiesTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/SystemPropertiesITest.java
@@ -32,7 +32,7 @@
/**
* @author jasonlee
*/
-public class SystemPropertiesTest extends RestTestBase {
+public class SystemPropertiesITest extends RestTestBase {
public static final String URL_CONFIG_SYSTEM_PROPERTIES = "domain/configs/config/%config%/system-properties";
public static final String URL_CLUSTER_SYSTEM_PROPERTIES = "domain/clusters/cluster/%clusterName%/system-properties";
public static final String URL_INSTANCE_SYSTEM_PROPERTIES = "domain/servers/server/%instanceName%/system-properties";
@@ -45,7 +45,7 @@
Response response = get(URL_DAS_SYSTEM_PROPERTIES);
assertEquals(200, response.getStatus());
List<Map<String, String>> systemProperties = getSystemProperties(MarshallingUtils.buildMapFromDocument(response.readEntity(String.class)));
- assertNotNull(systemProperties); // This may or may not be empty, depending on whether or not other tests failed
+ assertNotNull(systemProperties);
}
@Test
@@ -60,7 +60,7 @@
assertEquals(200, response.getStatus());
response = get(URL_DAS_SYSTEM_PROPERTIES);
List<Map<String, String>> systemProperties = getSystemProperties(MarshallingUtils.buildMapFromDocument(response.readEntity(String.class)));
- assertNotNull(systemProperties); // This may or may not be empty, depending on whether or not other tests failed
+ assertNotNull(systemProperties);
int testPropsFound = 0;
for (Map<String, String> systemProperty : systemProperties) {
@@ -87,8 +87,9 @@
Response response = post(URL_DAS_SYSTEM_PROPERTIES, payload);
assertEquals(200, response.getStatus());
response = get(URL_DAS_SYSTEM_PROPERTIES);
- List<Map<String, String>> systemProperties = getSystemProperties(MarshallingUtils.buildMapFromDocument(response.readEntity(String.class)));
- assertNotNull(systemProperties); // This may or may not be empty, depending on whether or not other tests failed
+ List<Map<String, String>> systemProperties = getSystemProperties(
+ MarshallingUtils.buildMapFromDocument(response.readEntity(String.class)));
+ assertNotNull(systemProperties);
int testPropsFound = 0;
for (Map<String, String> systemProperty : systemProperties) {
@@ -100,7 +101,7 @@
assertEquals(1, testPropsFound);
- response = delete(URL_DAS_SYSTEM_PROPERTIES+"/"+prop1);
+ response = delete(URL_DAS_SYSTEM_PROPERTIES + "/" + prop1);
assertEquals(200, response.getStatus());
}
@@ -150,7 +151,7 @@
List<Map<String, String>> systemProperties = getSystemProperties(MarshallingUtils.buildMapFromDocument(response.readEntity(String.class)));
Map<String, String> sysProp = getSystemProperty(propertyName, systemProperties);
assertNotNull(sysProp);
- assertEquals(sysProp.get("value"), propertyValue);
+ assertEquals(propertyValue, sysProp.get("value"));
}
private void createAndTestClusterOverride(final String propertyName, final String defaultValue, final String propertyValue, final String clusterName) {
@@ -191,8 +192,8 @@
systemProperties = getSystemProperties(MarshallingUtils.buildMapFromDocument(response.readEntity(String.class)));
sysProp = getSystemProperty(propertyName, systemProperties);
assertNotNull(sysProp);
- assertEquals(sysProp.get("value"), propertyValue);
- assertEquals(sysProp.get("defaultValue"), defaultValue);
+ assertEquals(propertyValue, sysProp.get("value"));
+ assertEquals(defaultValue, sysProp.get("defaultValue"));
}
private List<Map<String, String>> getSystemProperties(Map<String, ?> map) {
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/TokenAuthenticationTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/TokenAuthenticationITest.java
similarity index 98%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/TokenAuthenticationTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/TokenAuthenticationITest.java
index 18b4fe7..92a3619 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/TokenAuthenticationTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/TokenAuthenticationITest.java
@@ -38,7 +38,7 @@
/**
* @author Mitesh Meswani
*/
-public class TokenAuthenticationTest extends RestTestBase {
+public class TokenAuthenticationITest extends RestTestBase {
private static final String URL_DOMAIN_SESSIONS = "sessions";
private static final String URL_CREATE_USER = "domain/configs/config/server-config/security-service/auth-realm/admin-realm/create-user";
private static final String URL_DELETE_USER = "domain/configs/config/server-config/security-service/auth-realm/admin-realm/delete-user";
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ZeroConfigTest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ZeroConfigITest.java
similarity index 95%
rename from appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ZeroConfigTest.java
rename to appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ZeroConfigITest.java
index 875461b..5016830 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ZeroConfigTest.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/admin/rest/ZeroConfigITest.java
@@ -21,7 +21,6 @@
import java.util.Map;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -37,7 +36,7 @@
* data.
* @author jdlee
*/
-public class ZeroConfigTest extends RestTestBase {
+public class ZeroConfigITest extends RestTestBase {
public static final String BASE_SERVER_CONFIG_URL = "domain/configs/config/server-config";
/**
* Currently (6/29/2012), the transaction-service element is missing from
@@ -45,7 +44,6 @@
* zero-config is fully implemented and integrated.
*/
@Test
- @Disabled
public void testTransactionService() {
final Response response = get(BASE_SERVER_CONFIG_URL + "/transaction-service");
assertEquals(200, response.getStatus());
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/test/tool/DomainLifecycleExtension.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/test/tool/DomainLifecycleExtension.java
index c80f703..866c4a0 100644
--- a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/test/tool/DomainLifecycleExtension.java
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/test/tool/DomainLifecycleExtension.java
@@ -28,6 +28,6 @@
@Override
public void beforeAll(ExtensionContext context) throws Exception {
- NucleusTestUtils.nadmin(20000, "start-domain", "domain1");
+ NucleusTestUtils.nadmin(20000, "start-domain", "--debug", "domain1");
}
}
diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/test/webapp/HelloServlet.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/test/webapp/HelloServlet.java
new file mode 100644
index 0000000..7db815e
--- /dev/null
+++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/nucleus/test/webapp/HelloServlet.java
@@ -0,0 +1,38 @@
+/*
+ * 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.nucleus.test.webapp;
+
+import jakarta.servlet.annotation.WebServlet;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+
+/**
+ * @author David Matejcek
+ */
+@WebServlet(urlPatterns = "/")
+public class HelloServlet extends HttpServlet {
+
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ response.getOutputStream().print("Hello!");
+ }
+
+}
diff --git a/nucleus/parent/pom.xml b/nucleus/parent/pom.xml
index ac84d55..88f6de5 100644
--- a/nucleus/parent/pom.xml
+++ b/nucleus/parent/pom.xml
@@ -411,6 +411,12 @@
<artifactId>gmbal</artifactId>
<version>${gmbal.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
+ <version>3.1.4</version>
+ <scope>test</scope>
+ </dependency>
<!-- GlassFish Shoal -->
<dependency>