Issue #23507 kernel now uses JUnit5 instead Junit4 + enabled and fixed tests

- lesson: whatever you will annotate with @Service will be discovered
- lesson: whatever annotated with @Secure cannot be instantiated in tests
- lesson: @Secured services can be mocked
- resolution: ConfigApiTest must die, HK2Junit5Extension must be extensible
  to allow customizations for the module (own dependencies)
- tests were enabled, fixed and extended, I hope they are stable enough
- mocks and examples were moved to the package based on the name of the module
- several classes in tests removed, because they weren't used.
- DomainTest.xml was updated - based on real domain.xml from current
  GlassFish 6.2.1

Signed-off-by: David Matějček <dmatej@seznam.cz>
diff --git a/nucleus/core/kernel/pom.xml b/nucleus/core/kernel/pom.xml
index 1c5d48c..bc00c72 100755
--- a/nucleus/core/kernel/pom.xml
+++ b/nucleus/core/kernel/pom.xml
@@ -167,14 +167,25 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.glassfish.hk2</groupId>
-            <artifactId>hk2-junitrunner</artifactId>
-            <scope>test</scope>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
         </dependency>
         <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest</artifactId>
         </dependency>
+        <!-- Dependency of Hibernate Validator -->
+        <dependency>
+            <groupId>org.glassfish</groupId>
+            <artifactId>jakarta.el</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <!-- Required by the cluster replication despite we don't do any - ConfigAttributeSetTest fails without it -->
+        <dependency>
+            <groupId>org.codehaus.jettison</groupId>
+            <artifactId>jettison</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
@@ -212,7 +223,6 @@
                     </archive>
                 </configuration>
             </plugin>
-
         </plugins>
     </build>
 </project>
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminAdapterTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminAdapterTest.java
index b6864df..b0ecf6c 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminAdapterTest.java
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminAdapterTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,22 +17,32 @@
 
 package com.sun.enterprise.v3.admin;
 
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.junit.Before;
-import org.glassfish.api.admin.ParameterMap;
 import java.util.Properties;
 
+import org.glassfish.api.admin.ParameterMap;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 
 /**
  * junit test to test AdminAdapter class
  */
 public class AdminAdapterTest {
-    private AdminAdapter aa = null;
+    private AdminAdapter adapter;
+
+
+    @BeforeEach
+    public void setup() {
+        adapter = new PublicAdminAdapter();
+    }
+
 
     @Test
     public void extractParametersTest() {
-        ParameterMap props = aa.extractParameters("uniquetablenames=false&createtables=true&target=server&libraries=foo.jar&dbvendorname=test&deploymentplan=test");
+        ParameterMap props = adapter.extractParameters(
+            "uniquetablenames=false&createtables=true&target=server&libraries=foo.jar&dbvendorname=test&deploymentplan=test");
         Properties correctProps = new Properties();
         correctProps.put("uniquetablenames", "false");
         correctProps.put("createtables", "true");
@@ -40,13 +51,7 @@
         correctProps.put("dbvendorname", "test");
         correctProps.put("deploymentplan", "test");
         for (String prop : correctProps.stringPropertyNames()) {
-            assertEquals("compare Properties",
-                correctProps.getProperty(prop), props.getOne(prop));
+            assertEquals(correctProps.getProperty(prop), props.getOne(prop), "compare Properties");
         }
     }
-
-    @Before
-    public void setup() {
-        aa = new PublicAdminAdapter();
-    }
 }
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminCommandContextTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminCommandContextTest.java
index 7fa0a7a..3abc5c3 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminCommandContextTest.java
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminCommandContextTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,7 +17,7 @@
 
 package com.sun.enterprise.v3.admin;
 
-import static org.junit.Assert.assertEquals;
+import com.sun.enterprise.v3.common.PlainTextActionReporter;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -27,10 +28,9 @@
 import org.glassfish.api.ActionReport;
 import org.glassfish.api.admin.AdminCommandContext;
 import org.glassfish.api.admin.AdminCommandContextImpl;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import com.sun.enterprise.v3.common.DoNothingActionReporter;
-import com.sun.enterprise.v3.common.PlainTextActionReporter;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class AdminCommandContextTest {
 
@@ -45,8 +45,7 @@
         ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
         ObjectInputStream ois = new ObjectInputStream(is);
         AdminCommandContext restored = (AdminCommandContextImpl) ois.readObject();
-        assertEquals("failureCause", "Test", restored.getActionReport().getFailureCause().getMessage());
-        // context.setPayload
+        assertEquals("Test", restored.getActionReport().getFailureCause().getMessage());
     }
 
 }
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerImplServiceTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerImplServiceTest.java
new file mode 100644
index 0000000..c974a31
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerImplServiceTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
+ *
+ * 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 com.sun.enterprise.v3.admin;
+
+import com.sun.enterprise.admin.util.InstanceStateService;
+import com.sun.enterprise.config.serverbeans.Domain;
+
+import org.glassfish.api.ActionReport;
+import org.glassfish.api.ActionReport.ExitCode;
+import org.glassfish.api.admin.CommandRunner.CommandInvocation;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.api.InternalSystemAdministrator;
+import org.glassfish.security.services.api.authorization.AuthorizationService;
+import org.glassfish.tests.utils.ExcludeClasses;
+import org.glassfish.tests.utils.HK2Extension;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import jakarta.inject.Inject;
+
+import static org.glassfish.hk2.utilities.ServiceLocatorUtilities.addOneDescriptor;
+import static org.glassfish.tests.utils.Utils.createMockDescriptor;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * Test the command runner implementation: {@link CommandRunnerImpl}
+ *
+ * @author Jerome Dochez
+ * @author David Matejcek
+ */
+@ExtendWith(HK2Extension.class)
+@ExcludeClasses({ObjectInputStreamWithServiceLocator.class})
+public class CommandRunnerImplServiceTest {
+
+    @Inject
+    private ServiceLocator locator;
+
+    private CommandRunnerImpl commandRunner;
+    private InternalSystemAdministrator sysAdmin;
+
+
+    @BeforeEach
+    public void init() {
+        addOneDescriptor(locator, createMockDescriptor(Domain.class));
+        addOneDescriptor(locator, createMockDescriptor(AuthorizationService.class));
+        addOneDescriptor(locator, createMockDescriptor(InstanceStateService.class));
+
+        commandRunner = locator.getService(CommandRunnerImpl.class);
+        sysAdmin = locator.getService(InternalSystemAdministrator.class);
+    }
+
+
+    @Test
+    public void nonExistingCommand() {
+        assertNotNull(commandRunner);
+        assertNotNull(sysAdmin.getSubject());
+        assertThat(sysAdmin.getSubject().getPrivateCredentials(), hasSize(1));
+
+        ActionReport report = commandRunner.getActionReport("plain");
+        CommandInvocation inv = commandRunner.getCommandInvocation("doesnt-exist", report, sysAdmin.getSubject());
+        inv.execute();
+
+        assertAll(
+            () -> assertNull(report.getFailureCause()),
+            () -> assertEquals(ExitCode.FAILURE, report.getActionExitCode()),
+            () -> assertEquals("text/plain", report.getContentType()),
+            () -> assertEquals(
+                "Command doesnt-exist not found. \n"
+                + "Check the entry of command name. This command may be provided by a package that is not installed.",
+                report.getMessage()),
+            () -> assertNotNull(report.getTopMessagePart()),
+            () -> assertThat(report.getTopMessagePart().getChildren(), hasSize(0))
+        );
+    }
+}
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerImplTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerImplTest.java
new file mode 100644
index 0000000..ceeb82e
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerImplTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
+ *
+ * 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 com.sun.enterprise.v3.admin;
+
+import org.glassfish.api.Param;
+import org.glassfish.api.admin.AdminCommand;
+import org.glassfish.api.admin.AdminCommandContext;
+import org.glassfish.api.admin.CommandModel;
+import org.glassfish.api.admin.ParameterMap;
+import org.glassfish.common.util.admin.CommandModelImpl;
+import org.glassfish.hk2.api.MultiException;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hk2.annotations.Service;
+
+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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * junit test to test {@link CommandRunnerImpl} class
+ */
+public class CommandRunnerImplTest {
+
+    @Test
+    public void getUsageTextTest() {
+        String expectedUsageText = "Usage: dummy-admin --foo=foo [--bar=false] --hello=there world ";
+        CommandModel model = new CommandModelImpl(DummyAdminCommand.class);
+        String actualUsageText = CommandRunnerImpl.getUsageText(model);
+        assertEquals(expectedUsageText, actualUsageText);
+    }
+
+    @Test
+    public void validateParametersTest() {
+        ParameterMap params = new ParameterMap();
+        params.set("foo", "bar");
+        params.set("hello", "world");
+        params.set("one", "two");
+        MultiException ce = assertThrows(MultiException.class,
+            () -> CommandRunnerImpl.validateParameters(new CommandModelImpl(DummyAdminCommand.class), params));
+        assertThat(ce.getMessage(), stringContainsInOrder(" Invalid option: one"));
+    }
+
+    @Test
+    public void skipValidationTest() {
+        DummyAdminCommand dac = new DummyAdminCommand();
+        assertFalse(CommandRunnerImpl.skipValidation(dac));
+        SkipValidationCommand svc = new SkipValidationCommand();
+        assertTrue(CommandRunnerImpl.skipValidation(svc));
+    }
+
+    /** Mock - does nothing */
+    private static class SkipValidationCommand implements AdminCommand {
+
+        /**
+         *  This field is used via reflection!
+         *  See {@link CommandRunnerImpl#skipValidation(AdminCommand)}
+         */
+        @SuppressWarnings("unused")
+        boolean skipParamValidation = true;
+
+        @Override
+        public void execute(AdminCommandContext context) {
+            // ignore everything
+        }
+    }
+
+
+    @Service(name="dummy-admin")
+    public static class DummyAdminCommand implements AdminCommand {
+        @Param(optional=false)
+        String foo;
+
+        @Param(name="bar", defaultValue="false", optional=true)
+        String foobar;
+
+        @Param(optional=false, defaultValue="there")
+        String hello;
+
+        @Param(optional=false, primary=true)
+        String world;
+
+        @Override
+        public void execute(AdminCommandContext context) {
+            // ignore everything
+        }
+    }
+}
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerTest.java
deleted file mode 100644
index 6ff0d76..0000000
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2008, 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 com.sun.enterprise.v3.admin;
-
-import static org.junit.Assert.*;
-
-import org.glassfish.common.util.admin.CommandModelImpl;
-import org.glassfish.hk2.api.MultiException;
-import org.junit.Test;
-import org.junit.Before;
-import org.glassfish.api.Param;
-import org.glassfish.api.admin.ParameterMap;
-
-import org.glassfish.api.admin.AdminCommand;
-import org.glassfish.api.admin.AdminCommandContext;
-import org.glassfish.api.admin.CommandModel;
-import org.jvnet.hk2.annotations.Service;
-
-/**
- * junit test to test CommandRunner class
- */
-public class CommandRunnerTest {
-    private CommandRunnerImpl cr = null;
-
-    @Test
-    public void getUsageTextTest() {
-        String expectedUsageText = "Usage: dummy-admin --foo=foo [--bar=false] --hello=there world ";
-        DummyAdminCommand dac = new DummyAdminCommand();
-        CommandModel model = new CommandModelImpl(DummyAdminCommand.class);
-        String actualUsageText = cr.getUsageText(model);
-        assertEquals(expectedUsageText, actualUsageText);
-    }
-
-    @Test
-    public void validateParametersTest() {
-        ParameterMap params = new ParameterMap();
-        params.set("foo", "bar");
-        params.set("hello", "world");
-        params.set("one", "two");
-        try {
-            cr.validateParameters(new CommandModelImpl(DummyAdminCommand.class), params);
-        }
-        catch (MultiException ce) {
-            String expectedMessage = " Invalid option: one";
-            assertTrue(ce.getMessage().contains(expectedMessage));
-        }
-    }
-
-    @Test
-    public void skipValidationTest() {
-        DummyAdminCommand dac = new DummyAdminCommand();
-        assertFalse(cr.skipValidation(dac));
-        SkipValidationCommand svc = new SkipValidationCommand();
-        assertTrue(cr.skipValidation(svc));
-    }
-
-    @Before
-    public void setup() {
-        cr = new CommandRunnerImpl();
-    }
-
-        //mock-up DummyAdminCommand object
-    @Service(name="dummy-admin")
-    public class DummyAdminCommand implements AdminCommand {
-        @Param(optional=false)
-        String foo;
-
-        @Param(name="bar", defaultValue="false", optional=true)
-        String foobar;
-
-        @Param(optional=false, defaultValue="there")
-        String hello;
-
-        @Param(optional=false, primary=true)
-        String world;
-
-        @Override
-        public void execute(AdminCommandContext context) {}
-    }
-
-        //mock-up SkipValidationCommand
-    public class SkipValidationCommand implements AdminCommand {
-        boolean skipParamValidation=true;
-        @Override
-        public void execute(AdminCommandContext context) {}
-    }
-
-
-}
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/ConfigAttributeSetTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/ConfigAttributeSetTest.java
index 2819ec5..99aee8e 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/ConfigAttributeSetTest.java
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/ConfigAttributeSetTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,60 +17,69 @@
 
 package com.sun.enterprise.v3.admin;
 
-import com.sun.enterprise.v3.common.HTMLActionReporter;
+import com.sun.enterprise.admin.util.InstanceStateService;
+import com.sun.enterprise.v3.common.PlainTextActionReporter;
+
+import java.beans.PropertyChangeEvent;
+
+import javax.security.auth.Subject;
+
+import org.glassfish.api.ActionReport.ExitCode;
+import org.glassfish.api.admin.CommandRunner.CommandInvocation;
+import org.glassfish.api.admin.ParameterMap;
 import org.glassfish.grizzly.config.dom.NetworkListener;
 import org.glassfish.grizzly.config.dom.NetworkListeners;
 import org.glassfish.hk2.api.ServiceLocator;
-import org.glassfish.api.admin.*;
-import org.glassfish.tests.utils.ConfigApiTest;
+import org.glassfish.security.services.api.authentication.AuthenticationService;
+import org.glassfish.tests.utils.CustomConfiguration;
+import org.glassfish.tests.utils.ExcludeClasses;
+import org.glassfish.tests.utils.HK2Extension;
 import org.glassfish.tests.utils.Utils;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.jvnet.hk2.config.ConfigListener;
 import org.jvnet.hk2.config.ConfigSupport;
-import org.jvnet.hk2.config.DomDocument;
 import org.jvnet.hk2.config.ObservableBean;
 import org.jvnet.hk2.config.Transactions;
 import org.jvnet.hk2.config.UnprocessedChangeEvents;
+import jakarta.inject.Inject;
 
-import java.beans.PropertyChangeEvent;
+import static org.glassfish.hk2.utilities.ServiceLocatorUtilities.addOneDescriptor;
+import static org.glassfish.tests.utils.Utils.createMockDescriptor;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 /**
  * test the set command
  * @author Jerome Dochez
  */
-// Ignored temporarily because it fails to inject CommandRunnerImpl as ModulesRegistry is not available
-@Ignore
-public class ConfigAttributeSetTest  extends ConfigApiTest implements ConfigListener {
+@ExtendWith(HK2Extension.class)
+@ExcludeClasses({ObjectInputStreamWithServiceLocator.class})
+@CustomConfiguration("DomainTest.xml")
+public class ConfigAttributeSetTest implements ConfigListener {
 
-    ServiceLocator habitat = Utils.instance.getHabitat(this);
-    PropertyChangeEvent event = null;
+    @Inject
+    private ServiceLocator locator;
+    private PropertyChangeEvent event;
 
-    public DomDocument getDocument(ServiceLocator habitat) {
-        return new TestDocument(habitat);
-    }
-
-    /**
-     * Returns the DomainTest file name without the .xml extension to load the test configuration
-     * from.
-     *
-     * @return the configuration file name
-     */
-    public String getFileName() {
-        return "DomainTest";
+    @BeforeEach
+    public void addMissingServices() {
+        addOneDescriptor(locator, createMockDescriptor(AuthenticationService.class));
+        addOneDescriptor(locator, createMockDescriptor(InstanceStateService.class));
     }
 
     @Test
-     public void simpleAttributeSetTest() {
-
-        CommandRunnerImpl runner = habitat.getService(CommandRunnerImpl.class);
+    public void simpleAttributeSetTest() {
+        CommandRunnerImpl runner = locator.getService(CommandRunnerImpl.class);
         assertNotNull(runner);
 
         // let's find our target
         NetworkListener listener = null;
-        NetworkListeners service = habitat.getService(NetworkListeners.class);
+        NetworkListeners service = locator.getService(NetworkListeners.class);
         for (NetworkListener l : service.getNetworkListener()) {
             if ("http-listener-1".equals(l.getName())) {
                 listener = l;
@@ -84,32 +94,37 @@
 
         // parameters to the command
         ParameterMap parameters = new ParameterMap();
-        parameters.set("value", "8090");
-        parameters.set("DEFAULT", "configs.config.server-config.http-service.http-listener.http-listener-1.port");
-
+        parameters.set("DEFAULT",
+            "configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.port=8090");
+        Subject adminSubject = Utils.createInternalAsadminSubject();
         // execute the set command.
-        runner.getCommandInvocation("set", new HTMLActionReporter(), adminSubject()).parameters(parameters).execute();
+        PlainTextActionReporter reporter = new PlainTextActionReporter();
+        CommandInvocation invocation = runner.getCommandInvocation("set", reporter, adminSubject).parameters(parameters);
+        invocation.execute();
+
+        assertEquals(ExitCode.SUCCESS, reporter.getActionExitCode());
+        assertEquals("", reporter.getMessage());
+
+        // ensure events are delivered.
+        locator.<Transactions>getService(Transactions.class).waitForDrain();
 
         // check the result.
         String port = listener.getPort();
-        assertEquals(port, "8090");
-
-        // ensure events are delivered.
-        habitat.<Transactions>getService(Transactions.class).waitForDrain();
-
-        // finally
-        bean.removeListener(this);
+        assertEquals("8090", port);
 
         // check we recevied the event
         assertNotNull(event);
-        assertEquals("8080", event.getOldValue());
-        assertEquals("8090", event.getNewValue());
-        assertEquals("port", event.getPropertyName());
+        assertAll(
+            () -> assertEquals("8080", event.getOldValue()),
+            () -> assertEquals("8090", event.getNewValue()),
+            () -> assertEquals("port", event.getPropertyName())
+        );
 
     }
 
+    @Override
     public UnprocessedChangeEvents changed(PropertyChangeEvent[] propertyChangeEvents) {
-        assertEquals("Array size", propertyChangeEvents.length, 1 );
+        assertThat(propertyChangeEvents, arrayWithSize(1));
         event = propertyChangeEvents[0];
         return null;
     }
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CreateProfilerTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CreateProfilerTest.java
index c2ade51..365fa29 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CreateProfilerTest.java
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CreateProfilerTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,139 +17,147 @@
 
 package com.sun.enterprise.v3.admin;
 
+import com.sun.enterprise.admin.util.InstanceStateService;
+import com.sun.enterprise.config.serverbeans.Config;
 import com.sun.enterprise.config.serverbeans.JavaConfig;
 import com.sun.enterprise.config.serverbeans.Profiler;
+import com.sun.enterprise.v3.common.PlainTextActionReporter;
 import com.sun.logging.LogDomains;
 
-import java.beans.PropertyVetoException;
-import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
 
-import org.glassfish.api.admin.AdminCommandContextImpl;
-import org.jvnet.hk2.config.types.Property;
+import javax.security.auth.Subject;
 
-import org.glassfish.api.admin.AdminCommandContext;
-import org.glassfish.api.admin.ParameterMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Ignore;
-import static org.junit.Assert.*;
 import org.glassfish.api.ActionReport;
+import org.glassfish.api.admin.AdminCommandContext;
+import org.glassfish.api.admin.AdminCommandContextImpl;
+import org.glassfish.api.admin.ParameterMap;
 import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.security.services.api.authentication.AuthenticationService;
+import org.glassfish.tests.utils.CustomConfiguration;
+import org.glassfish.tests.utils.ExcludeClasses;
+import org.glassfish.tests.utils.HK2Extension;
 import org.glassfish.tests.utils.Utils;
-import org.glassfish.tests.utils.ConfigApiTest;
-import org.jvnet.hk2.config.DomDocument;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.jvnet.hk2.config.ConfigSupport;
-import org.jvnet.hk2.config.SingleConfigCode;
 import org.jvnet.hk2.config.TransactionFailure;
 
+import jakarta.inject.Inject;
+
+import static org.glassfish.api.admin.ServerEnvironment.DEFAULT_INSTANCE_NAME;
+import static org.glassfish.hk2.utilities.BuilderHelper.createConstantDescriptor;
+import static org.glassfish.hk2.utilities.ServiceLocatorUtilities.addOneDescriptor;
+import static org.glassfish.tests.utils.Utils.createMockDescriptor;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
 /**
- *
  * @author Prashanth
+ * @author David Matejcek
  */
-@Ignore
-public class CreateProfilerTest extends ConfigApiTest {
-    // Get Resources config bean
-    ServiceLocator habitat = Utils.instance.getHabitat(this);
-    private JavaConfig javaConfig = habitat.getService(JavaConfig.class);
-    private CreateProfiler command = null;
-    private ParameterMap parameters = new ParameterMap();
-    private AdminCommandContext context = null;
-    private CommandRunnerImpl cr = habitat.getService(CommandRunnerImpl.class);
+@ExtendWith(HK2Extension.class)
+@ExcludeClasses({ObjectInputStreamWithServiceLocator.class})
+@CustomConfiguration("DomainTest.xml")
+public class CreateProfilerTest {
 
-    @Override
-    public DomDocument getDocument(ServiceLocator habitat) {
+    @Inject
+    private ServiceLocator locator;
+    @Inject
+    private Logger logger;
 
-        return new TestDocument(habitat);
-    }
+    private JavaConfig javaConfig;
+    private CommandRunnerImpl commandRunner;
+    private CreateProfiler command;
+    private AdminCommandContext context;
+    private Subject adminSubject;
 
-    /**
-     * Returns the DomainTest file name without the .xml extension to load the test configuration
-     * from.
-     *
-     * @return the configuration file name
-     */
-    public String getFileName() {
-        return "DomainTest";
-    }
 
-    @Before
-    public void setUp() {
-        assertTrue(javaConfig!=null);
+    @BeforeEach
+    public void init() {
+        assertEquals("CreateProfilerTestServiceLocator", locator.getName());
 
-        // Get an instance of the CreateProfiler command
-        command = habitat.getService(CreateProfiler.class);
-        assertTrue(command!=null);
+        final Config config = locator.getService(Config.class);
+        assertNotNull(config, "config");
+        addOneDescriptor(locator, createConstantDescriptor(config, DEFAULT_INSTANCE_NAME, Config.class));
+        addOneDescriptor(locator, createMockDescriptor(AuthenticationService.class));
+        addOneDescriptor(locator, createMockDescriptor(InstanceStateService.class));
 
+        javaConfig = locator.getService(JavaConfig.class);
+        assertNotNull(javaConfig);
+
+        adminSubject = Utils.createInternalAsadminSubject();
         context = new AdminCommandContextImpl(
-                LogDomains.getLogger(CreateProfilerTest.class, LogDomains.ADMIN_LOGGER),
-                habitat.<ActionReport>getService(ActionReport.class, "hk2-agent"));
+            LogDomains.getLogger(CreateProfilerTest.class, LogDomains.ADMIN_LOGGER),
+            locator.<ActionReport>getService(PlainTextActionReporter.class));
+        commandRunner = locator.getService(CommandRunnerImpl.class);
+        assertNotNull(commandRunner);
+
+        command = locator.getService(CreateProfiler.class);
+        assertNotNull(command);
 
     }
 
-    @After
-    public void tearDown() throws TransactionFailure {
-       // Delete the created profiler
-       ConfigSupport.apply(new SingleConfigCode<JavaConfig>() {
-            public Object run(JavaConfig param) throws PropertyVetoException, TransactionFailure {
-                if (param.getProfiler() != null){
-                    param.setProfiler(null);
-                }
-                return null;
+
+    @AfterEach
+    public void deleteProfiler() throws TransactionFailure {
+        ConfigSupport.apply(param -> {
+            if (param.getProfiler() != null) {
+                param.setProfiler(null);
             }
+            return null;
         }, javaConfig);
-
-        parameters = new ParameterMap();
     }
 
+
     /**
      * Test of execute method, of class CreateProfiler.
      * asadmin create-profiler --nativelibrarypath "myNativeLibraryPath"
      *          --enabled=true --classpath "myProfilerClasspath" testProfiler
      */
     @Test
-    public void testExecuteSuccess() {
-        // Set the options and operand to pass to the command
+    public void properties() {
+        ParameterMap parameters = new ParameterMap();
         parameters.set("classpath", "myProfilerClasspath");
         parameters.set("enabled", "true");
         parameters.set("nativelibrarypath", "myNativeLibraryPath");
         parameters.set("property","a=x:b=y:c=z");
         parameters.set("DEFAULT", "testProfiler");
 
+        commandRunner.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject)
+            .parameters(parameters).execute(command);
 
-        //Call CommandRunnerImpl.doCommand(..) to execute the command
-        cr.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
-
-        // Check the exit code is SUCCESS
         assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
 
-        //Check that the profiler is created
-        boolean isCreated = false;
-        int propertyCount = 0;
         Profiler profiler = javaConfig.getProfiler();
-        if (profiler.getName().equals("testProfiler")) {
-            assertEquals("myProfilerClasspath", profiler.getClasspath());
-            assertEquals("true", profiler.getEnabled());
-            assertEquals("myNativeLibraryPath", profiler.getNativeLibraryPath());
-            List<Property> properties = profiler.getProperty();
-            for (Property property:properties){
-                if (property.getName().equals("a")) assertEquals("x",property.getValue());
-                if (property.getName().equals("b")) assertEquals("y",property.getValue());
-                if (property.getName().equals("c")) assertEquals("z",property.getValue());
-                propertyCount++;
-            }
-            isCreated = true;
-            logger.fine("Profiler element myProfiler is created.");
-        }
-        assertTrue(isCreated);
-        assertEquals(propertyCount, 3);
+        assertAll(
+            () -> assertEquals("testProfiler", profiler.getName()),
+            () -> assertEquals("myProfilerClasspath", profiler.getClasspath()),
+            () -> assertEquals("true", profiler.getEnabled()),
+            () -> assertEquals("myNativeLibraryPath", profiler.getNativeLibraryPath()),
+            () -> assertThat(profiler.getProperty(), hasSize(3)),
+            () -> assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode()),
+            () -> assertEquals("", context.getActionReport().getMessage(), "message")
+        );
 
-        // Check the exit code is SUCCESS
-        assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
+        Map<String, String> properties = profiler.getProperty().stream().map(p -> Map.entry(p.getName(), p.getValue()))
+            .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+        assertAll(
+            () -> assertThat(properties, hasEntry("a", "x")),
+            () -> assertThat(properties, hasEntry("b", "y")),
+            () -> assertThat(properties, hasEntry("c", "z"))
+        );
 
-        // Check the success message
-        //assertEquals("Command create-profiler executed successfully.", context.getActionReport().getMessage());
-        logger.fine("msg: " + context.getActionReport().getMessage());
     }
 
     /**
@@ -157,33 +166,22 @@
      *          --enabled=true --classpath "myProfilerClasspath" testProfiler
      */
     @Test
-    public void testExecuteSuccessDefaultValues() {
-        // Only pass the required option and operand
-        assertTrue(parameters.size() == 0);
+    public void defaults() {
+        ParameterMap parameters = new ParameterMap();
         parameters.set("DEFAULT", "myProfilerAllDefaults");
 
-
-        //Call CommandRunnerImpl.doCommand(..) to execute the command
-        cr.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
-
-        // Check the exit code is SUCCESS
+        commandRunner.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject)
+            .parameters(parameters).execute(command);
         assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
 
-        //Check that the resource was created
-        boolean isCreated = false;
         Profiler profiler = javaConfig.getProfiler();
-        if (profiler.getName().equals("myProfilerAllDefaults")) {
-            //assertEquals("myProfilerClasspath", profiler.getClasspath());
-            assertEquals("true", profiler.getEnabled());
-            //assertEquals("nativelibrarypath", profiler.getNativeLibraryPath());
-            isCreated = true;
-            logger.fine("Profiler element myProfilerAllDefaults is created.");
-        }
-        assertTrue(isCreated);
-
-        // Check the success message
-        //assertEquals("Command create-profiler executed successfully.", context.getActionReport().getMessage());
-        logger.fine("msg: " + context.getActionReport().getMessage());
+        assertAll(
+            () -> assertEquals("myProfilerAllDefaults", profiler.getName()),
+            () -> assertNull(profiler.getClasspath()),
+            () -> assertEquals("true", profiler.getEnabled()),
+            () -> assertNull(profiler.getNativeLibraryPath()),
+            () -> assertEquals("", context.getActionReport().getMessage(), "message")
+        );
     }
 
     /**
@@ -192,44 +190,32 @@
      *          --enabled=true --classpath "myProfilerClasspath" testProfiler
      */
     @Test
-    public void testExecuteSuccessUpdateExisting() {
-        assertTrue(parameters.size() == 0);
+    public void twoProfilersForbidden() {
+        ParameterMap parameters = new ParameterMap();
         parameters.set("DEFAULT", "testProfiler");
 
-
-        //Call CommandRunnerImpl.doCommand(..) to execute the command
-        cr.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
-
-        // Check the exit code is SUCCESS
+        commandRunner.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject)
+            .parameters(parameters).execute(command);
         assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
 
+        // try to create another profile
         parameters = new ParameterMap();
-
-        //Create another profiler, see if it overrides the existing one
         parameters.set("DEFAULT", "testProfilerNew");
 
+        commandRunner.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject)
+            .parameters(parameters).execute(command);
+        assertAll(
+            () -> assertEquals(ActionReport.ExitCode.FAILURE, context.getActionReport().getActionExitCode()),
+            () -> assertEquals("profiler exists. Please delete it first", context.getActionReport().getMessage())
+        );
 
-        //Call CommandRunnerImpl.doCommand(..) to execute the command
-        cr.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
-
-        // Check the exit code is SUCCESS
-        assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
-
-        //Check that the resource was created
-        boolean isCreated = false;
         Profiler profiler = javaConfig.getProfiler();
-        if (profiler.getName().equals("testProfilerNew")) {
-            //assertEquals("myProfilerClasspath", profiler.getClasspath());
-            assertEquals("true", profiler.getEnabled());
-            //assertEquals("nativelibrarypath", profiler.getNativeLibraryPath());
-            isCreated = true;
-            logger.fine("Profiler element testProfilerNew is created.");
-        }
-        assertTrue(isCreated);
-
-        // Check the success message
-        //assertEquals("Command create-profiler executed successfully.", context.getActionReport().getMessage());
-        logger.fine("msg: " + context.getActionReport().getMessage());
+        assertAll(
+            () -> assertEquals("testProfiler", profiler.getName()),
+            () -> assertNull(profiler.getClasspath(), "classpath"),
+            () -> assertEquals("true", profiler.getEnabled()),
+            () -> assertNull(profiler.getNativeLibraryPath(), "nativelibrarypath")
+        );
     }
 
     /**
@@ -238,22 +224,21 @@
      *          --enabled=true --classpath "myProfilerClasspath" testProfiler
      */
     @Test
-    public void testExecuteFailInvalidOptionEnabled() {
-        // Set invalid enabled option value: --enabled junk
-        //parameters = new ParameterMap();
-        assertTrue(parameters.size() == 0);
+    public void invalidOption() {
+        ParameterMap parameters = new ParameterMap();
         parameters.set("enabled", "junk");
         parameters.set("DEFAULT", "myProfiler");
 
-        // Call CommandRunnerImpl.doCommand(..) to execute the command
-        cr.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
+        commandRunner.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject)
+            .parameters(parameters).execute(command);
 
-        // Check the exit code is Failure - test fails, need bug fix before uncommenting
-        assertEquals(ActionReport.ExitCode.FAILURE, context.getActionReport().getActionExitCode());
-
-        // Check the error message - test fails
-        assertEquals("Invalid parameter: enabled.  This boolean option must be set (case insensitive) to true or false.  Its value was set to junk",
-                        context.getActionReport().getMessage());
+        assertAll(
+            () -> assertEquals(ActionReport.ExitCode.FAILURE, context.getActionReport().getActionExitCode()),
+            () -> assertEquals(
+                "Invalid parameter: enabled."
+                    + "  This boolean option must be set (case insensitive) to true or false."
+                    + "  Its value was set to junk",
+                context.getActionReport().getMessage()));
     }
 
     /**
@@ -262,30 +247,20 @@
      *          --enabled=true --classpath "myProfilerClasspath" testProfiler
      */
     @Test
-    public void testExecuteSuccessNoValueOptionEnabled() {
-        // Set enabled without a value:  --enabled
-        assertTrue(parameters.size() == 0);
+    public void noValueOptionEnabled() {
+        ParameterMap parameters = new ParameterMap();
         parameters.set("enabled", "");
         parameters.set("DEFAULT", "testProfiler");
 
-        // Call CommandRunnerImpl.doCommand(..) to execute the command
-        cr.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
+        commandRunner.getCommandInvocation("create-profiler", context.getActionReport(), adminSubject)
+            .parameters(parameters).execute(command);
 
-        //Check that the profiler is created
-        boolean isCreated = false;
         Profiler profiler = javaConfig.getProfiler();
-        if (profiler.getName().equals("testProfiler")) {
-            assertEquals("true", profiler.getEnabled());
-            isCreated = true;
-            logger.fine("msg: " + context.getActionReport().getMessage());
-        }
-        assertTrue(isCreated);
-
-        // Check the exit code is SUCCESS
-        assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
-
-        // Check the success message
-        //assertEquals("Command create-profiler executed successfully.", context.getActionReport().getMessage());
-        logger.fine("msg: " + context.getActionReport().getMessage());
+        assertAll(
+            () -> assertEquals("testProfiler", profiler.getName()),
+            () -> assertEquals("true", profiler.getEnabled()),
+            () -> assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode()),
+            () -> assertEquals("", context.getActionReport().getMessage())
+        );
     }
 }
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/PrivacyTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/PrivacyTest.java
index 9c0a936..8d09d3d 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/PrivacyTest.java
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/PrivacyTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,11 +17,13 @@
 
 package com.sun.enterprise.v3.admin;
 
-import org.junit.Test;
-import org.junit.Assert;
 import org.glassfish.api.admin.AdminCommand;
 import org.glassfish.hk2.api.ServiceLocator;
 import org.glassfish.tests.utils.Utils;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Test the visibility annotation
@@ -33,13 +36,13 @@
         AdminAdapter privateAdapter = new PrivateAdminAdapter();
         ServiceLocator habitat = Utils.getNewHabitat();
         AdminCommand adminCommand = habitat.getService(AdminCommand.class, "simple-public-command");
-        Assert.assertTrue(publicAdaper.validatePrivacy(adminCommand));
-        Assert.assertFalse(privateAdapter.validatePrivacy(adminCommand));
+        assertTrue(publicAdaper.validatePrivacy(adminCommand));
+        assertFalse(privateAdapter.validatePrivacy(adminCommand));
         adminCommand = habitat.getService(AdminCommand.class, "notannoated-public-command");
-        Assert.assertTrue(publicAdaper.validatePrivacy(adminCommand));
-        Assert.assertFalse(privateAdapter.validatePrivacy(adminCommand));
+        assertTrue(publicAdaper.validatePrivacy(adminCommand));
+        assertFalse(privateAdapter.validatePrivacy(adminCommand));
         adminCommand = habitat.getService(AdminCommand.class, "simple-private-command");
-        Assert.assertFalse(publicAdaper.validatePrivacy(adminCommand));
-        Assert.assertTrue(privateAdapter.validatePrivacy(adminCommand));
+        assertFalse(publicAdaper.validatePrivacy(adminCommand));
+        assertTrue(privateAdapter.validatePrivacy(adminCommand));
     }
 }
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/TestDocument.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/TestDocument.java
deleted file mode 100644
index c8b38b1..0000000
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/TestDocument.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2008, 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 com.sun.enterprise.v3.admin;
-
-import org.jvnet.hk2.config.DomDocument;
-import org.jvnet.hk2.config.Dom;
-import org.jvnet.hk2.config.ConfigModel;
-import org.glassfish.config.support.GlassFishConfigBean;
-import org.glassfish.hk2.api.ServiceLocator;
-import org.junit.Ignore;
-
-import javax.xml.stream.XMLStreamReader;
-
-/**
- *
- * This document will create the appropriate ConfigBean implementation but will
- * not save the modified config tree.
- *
- * User: Jerome Dochez
- */
-@Ignore
-public class TestDocument extends DomDocument<GlassFishConfigBean> {
-
-    public TestDocument(ServiceLocator habitat) {
-        super(habitat);
-    }
-
-    @Override
-    public Dom make(final ServiceLocator habitat, XMLStreamReader xmlStreamReader, GlassFishConfigBean dom, ConfigModel configModel) {
-        // by default, people get the translated view.
-        return new GlassFishConfigBean(habitat, this, dom, configModel, xmlStreamReader);
-    }
-}
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/progress/.gitkeep_empty_dir b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/progress/.gitkeep_empty_dir
deleted file mode 100644
index e69de29..0000000
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/progress/.gitkeep_empty_dir
+++ /dev/null
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/common/PlainTextActionReporterTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/common/PlainTextActionReporterTest.java
index 99ebbf9..363237a 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/common/PlainTextActionReporterTest.java
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/common/PlainTextActionReporterTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -14,39 +15,27 @@
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
  */
 
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
 package com.sun.enterprise.v3.common;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
 import org.glassfish.api.ActionReport;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.stringContainsInOrder;
+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 bnevins
  */
 public class PlainTextActionReporterTest {
 
-    public PlainTextActionReporterTest() {
-    }
-
-    @Before
-    public void beforeTest() throws Exception {
-        System.out.println(
-            "\n-------------------------------------------------------------------------------");
-    }
-    @AfterClass
-    public static void afterTest() throws Exception {
-        System.out.println(
-            "-------------------------------------------------------------------------------");
-    }
-
     @Test
     public void failureTest() throws Exception {
         ActionReport report = new PlainTextActionReporter();
@@ -55,8 +44,11 @@
         ActionReport.MessagePart top = report.getTopMessagePart();
         top.setMessage("FailureTest Message Here!!");
         report.setFailureCause(new IndexOutOfBoundsException("Hi I am a phony Exception!!"));
-        report.writeReport(System.out);
+        String text = printReport(report);
+        assertThat(text, equalTo("PlainTextActionReporterFAILURE"
+            + "java.lang.IndexOutOfBoundsException: Hi I am a phony Exception!!FailureTest Message Here!!"));
     }
+
     @Test
     public void babyTest() throws Exception {
         ActionReport report = new PlainTextActionReporter();
@@ -64,7 +56,8 @@
         report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
         ActionReport.MessagePart top = report.getTopMessagePart();
         top.setMessage("BabyTest Message Here!!");
-        report.writeReport(System.out);
+        String text = printReport(report);
+        assertThat(text, stringContainsInOrder("PlainTextActionReporter", "SUCCESS", "BabyTest Message Here!!"));
     }
 
     @Test
@@ -85,7 +78,10 @@
             ActionReport.MessagePart grandkids = childPart.addChild();
             grandkids.setMessage("Grand Kids #" + i + " Top Message");
         }
-        report.writeReport(System.out);
+        String text = printReport(report);
+        assertThat(text,
+            stringContainsInOrder("PlainTextActionReporter", "SUCCESS", "Description", "My Action Description",
+                "Mama Test Top Message", "child7", "[ChildKey7=ChildValue7", "Grand Kids #7 Top Message"));
     }
 
     @Test
@@ -109,37 +105,44 @@
                 grandkids.addProperty("Grand Kid#" + j + " from child#" + i + "key", "value");
             }
         }
-        report.writeReport(System.out);
+        String text = printReport(report);
+        assertThat(text,
+            stringContainsInOrder("PlainTextActionReporter", "SUCCESS", "Description", "My Action Description",
+                "Papa Test Top Message", "child7", "[ChildKey7=ChildValue7", "[Grand Kid#2 from child#7key=value"));
     }
 
     @Test
     public void aggregateTest() {
         ActionReporter successfulRoot = new PlainTextActionReporter();
-        assert successfulRoot.hasSuccesses();
-        assert !successfulRoot.hasFailures();
-        assert !successfulRoot.hasWarnings();
+        assertTrue(successfulRoot.hasSuccesses());
+        assertFalse(successfulRoot.hasFailures());
+        assertFalse(successfulRoot.hasWarnings());
         ActionReport failedChild = successfulRoot.addSubActionsReport();
         failedChild.setActionExitCode(ActionReport.ExitCode.FAILURE);
-        assert successfulRoot.hasSuccesses();
-        assert successfulRoot.hasFailures();
-        assert !successfulRoot.hasWarnings();
-        assert !failedChild.hasSuccesses();
-        assert !failedChild.hasWarnings();
-        assert failedChild.hasFailures();
+        assertTrue(successfulRoot.hasSuccesses());
+        assertTrue(successfulRoot.hasFailures());
+        assertFalse(successfulRoot.hasWarnings());
+        assertFalse(failedChild.hasSuccesses());
+        assertFalse(failedChild.hasWarnings());
+        assertTrue(failedChild.hasFailures());
+
         ActionReport warningChild = failedChild.addSubActionsReport();
         warningChild.setActionExitCode(ActionReport.ExitCode.WARNING);
-        assert successfulRoot.hasSuccesses();
-        assert successfulRoot.hasFailures();
-        assert successfulRoot.hasWarnings();
-        assert !failedChild.hasSuccesses();
-        assert failedChild.hasWarnings();
-        assert failedChild.hasFailures();
-        assert warningChild.hasWarnings();
-        assert !warningChild.hasSuccesses();
+        assertTrue(successfulRoot.hasSuccesses());
+        assertTrue(successfulRoot.hasFailures());
+        assertTrue(successfulRoot.hasWarnings());
+        assertFalse(failedChild.hasSuccesses());
+        assertTrue(failedChild.hasWarnings());
+        assertTrue(failedChild.hasFailures());
+        assertTrue(warningChild.hasWarnings());
+        assertFalse(warningChild.hasSuccesses());
+
         ActionReport successfulChild = warningChild.addSubActionsReport();
-        assert failedChild.hasSuccesses();
-        assert warningChild.hasSuccesses();
-        assert !warningChild.hasFailures();
+        assertTrue(successfulChild.hasSuccesses());
+        assertTrue(failedChild.hasSuccesses());
+        assertTrue(warningChild.hasSuccesses());
+        assertFalse(warningChild.hasFailures());
+
         StringBuilder sb = new StringBuilder();
         successfulRoot.setMessage("sr");
         successfulRoot.getCombinedMessages(successfulRoot, sb);
@@ -153,4 +156,13 @@
         successfulRoot.getCombinedMessages(successfulRoot, sb);
         assertEquals("sr\nfc\nwc", sb.toString());
     }
+
+
+    private String printReport(ActionReport report) throws IOException {
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        try (PrintStream stream = new PrintStream(outputStream)) {
+            report.writeReport(stream);
+        }
+        return outputStream.toString();
+    }
 }
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/APIClassLoaderServiceImplTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/APIClassLoaderServiceImplTest.java
index bbdf1eb..fc25805 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/APIClassLoaderServiceImplTest.java
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/APIClassLoaderServiceImplTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,22 +17,25 @@
 
 package com.sun.enterprise.v3.server;
 
-import static org.junit.Assert.assertEquals;
+import com.sun.enterprise.module.ModuleLifecycleListener;
+import com.sun.enterprise.module.single.SingleModulesRegistry;
 
 import java.net.URL;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-import com.sun.enterprise.module.ModuleLifecycleListener;
-import com.sun.enterprise.module.single.SingleModulesRegistry;
+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.assertThrows;
 
 public class APIClassLoaderServiceImplTest {
-    int loadClassCalls;
-    int getResourceCalls;
+    private int loadClassCalls;
+    private int getResourceCalls;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         loadClassCalls = 0;
         getResourceCalls = 0;
@@ -43,103 +47,64 @@
      */
     @Test
     public void testBlackList() {
-        try {
-            APIClassLoaderServiceImpl apiClassLoaderService = new APIClassLoaderServiceImpl();
+        APIClassLoaderServiceImpl apiClassLoaderService = new APIClassLoaderServiceImpl();
 
-            // Set up a fake ModulesRegistry to exercise ModulesRegistry lifecycle events
-            FakeClassLoader classLoader = new FakeClassLoader(getClass().getClassLoader());
-            FakeModulesRegistry fakeModulesRegistry = new FakeModulesRegistry(classLoader);
+        // Set up a fake ModulesRegistry to exercise ModulesRegistry lifecycle events
+        FakeClassLoader classLoader = new FakeClassLoader(getClass().getClassLoader());
+        FakeModulesRegistry fakeModulesRegistry = new FakeModulesRegistry(classLoader);
+        assertThat(fakeModulesRegistry.getLifecycleListeners(), hasSize(0));
 
-            apiClassLoaderService.modulesRegistry = fakeModulesRegistry;
+        apiClassLoaderService.modulesRegistry = fakeModulesRegistry;
+        apiClassLoaderService.postConstruct();
 
-            assertEquals(0, fakeModulesRegistry.getLifecycleListeners().size());
+        List<ModuleLifecycleListener> lifecycleListeners = fakeModulesRegistry.getLifecycleListeners();
+        assertThat("apiClassLoaderService should have registered a lifecycle listener",
+            fakeModulesRegistry.getLifecycleListeners(), hasSize(1));
 
-            apiClassLoaderService.postConstruct();
+        ModuleLifecycleListener lifecycleListener = lifecycleListeners.iterator().next();
 
-            List<ModuleLifecycleListener> lifecycleListeners = fakeModulesRegistry.getLifecycleListeners();
+        // assert that the classloader isn't called on to load the same bad class twice
+        assertEquals(0, loadClassCalls);
 
-            assertEquals("apiClassLoaderService should have registered a lifecycle listener", 1, fakeModulesRegistry.getLifecycleListeners().size());
+        final String BAD_CLASSNAME = "BADCLASS";
+        assertThrows(ClassNotFoundException.class,
+            () -> apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME));
+        assertEquals(1, loadClassCalls, "Classloader.loadClass not called at all");
+        assertThrows(ClassNotFoundException.class,
+            () -> apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME));
 
-            ModuleLifecycleListener lifecycleListener = lifecycleListeners.iterator().next();
+        assertEquals(1, loadClassCalls, "blacklist not honored, excessive call to classloader.load");
 
+        // try same thing with resources
+        assertEquals(0, getResourceCalls); // sanity
+        final String BAD_RESOURCE = "BADRESOURCE";
+        apiClassLoaderService.getAPIClassLoader().getResource(BAD_RESOURCE);
+        assertEquals(1, getResourceCalls, "Classloader.findResource not called at all");
 
-            // assert that the classloader isn't called on to load the same bad
-            // class twice
-            assertEquals(0, loadClassCalls);
+        apiClassLoaderService.getAPIClassLoader().getResource(BAD_RESOURCE);
+        assertEquals(1, getResourceCalls, "blacklist not honored, excessive call to classloader.getResource");
 
-            final String BAD_CLASSNAME = "BADCLASS";
+        // Now signal that a new module has been loaded, clearing the blacklist
+        lifecycleListener.moduleInstalled(null);
 
-            try {
-                apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME);
-            } catch (ClassNotFoundException e) {
-                // ignore
-            }
+        apiClassLoaderService.getAPIClassLoader().getResource(BAD_RESOURCE);
+        assertEquals(2, getResourceCalls, "blacklist did not clear after a module was installed");
 
-            assertEquals("Classloader.loadClass not called at all", 1, loadClassCalls);
+        assertThrows(ClassNotFoundException.class,
+            () -> apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME));
 
-            try {
-                apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME);
-            } catch (ClassNotFoundException e) {
-                // ignore
-            }
+        assertEquals(2, loadClassCalls, "blacklist did not clear after a module was installed");
 
-            assertEquals("blacklist not honored, excessive call to classloader.load", 1, loadClassCalls);
+        // Now signal that a new module has been updated, clearing the blacklist
+        lifecycleListener.moduleUpdated(null);
 
+        apiClassLoaderService.getAPIClassLoader().getResource(BAD_RESOURCE);
+        assertEquals(3, getResourceCalls, "blacklist did not clear after a module was updated");
 
-            // try same thing with resources
+        assertThrows(ClassNotFoundException.class,
+            () -> apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME));
 
-            assertEquals(0, getResourceCalls); // sanity
-
-            final String BAD_RESOURCE = "BADRESOURCE";
-
-            apiClassLoaderService.getAPIClassLoader().getResource(BAD_RESOURCE);
-
-            assertEquals("Classloader.findResource not called at all", 1, getResourceCalls);
-
-            apiClassLoaderService.getAPIClassLoader().getResource(BAD_RESOURCE);
-
-            assertEquals("blacklist not honored, excessive call to classloader.getResource", 1, getResourceCalls);
-
-
-            //
-            // Now signal that a new module has been loaded, clearing the blacklist
-            //
-
-            lifecycleListener.moduleInstalled(null);
-
-            apiClassLoaderService.getAPIClassLoader().getResource(BAD_RESOURCE);
-            assertEquals("blacklist did not clear after a module was installed", 2, getResourceCalls);
-
-            try {
-                apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME);
-            } catch (ClassNotFoundException e) {
-                // ignore
-            }
-
-            assertEquals("blacklist did not clear after a module was installed", 2, loadClassCalls);
-
-
-            //
-            // Now signal that a new module has been updated, clearing the blacklist
-            //
-
-            lifecycleListener.moduleUpdated(null);
-
-            apiClassLoaderService.getAPIClassLoader().getResource(BAD_RESOURCE);
-            assertEquals("blacklist did not clear after a module was updated", 3, getResourceCalls);
-
-            try {
-                apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME);
-            } catch (ClassNotFoundException e) {
-                // ignore
-            }
-
-            assertEquals("blacklist did not clear after a module was updated", 3, loadClassCalls);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw e;
-        }
-
+        assertEquals(3, loadClassCalls, "blacklist did not clear after a module was updated");
     }
 
     class FakeModulesRegistry extends SingleModulesRegistry {
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/AppServerStartupTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/AppServerStartupTest.java
index 1e8531e..4ccff7c 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/AppServerStartupTest.java
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/AppServerStartupTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -23,6 +24,17 @@
 import com.sun.enterprise.module.single.StaticModulesRegistry;
 import com.sun.enterprise.util.Result;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
 import org.glassfish.api.FutureProvider;
 import org.glassfish.api.StartupRunLevel;
 import org.glassfish.api.admin.ServerEnvironment;
@@ -48,38 +60,34 @@
 import org.glassfish.kernel.event.EventsImpl;
 import org.glassfish.main.core.apiexporter.APIExporterImpl;
 import org.glassfish.server.ServerEnvironmentImpl;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.jvnet.hk2.annotations.Service;
 
 import jakarta.inject.Inject;
 import jakarta.inject.Named;
 import jakarta.inject.Singleton;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItem;
+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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
  * AppServerStartup tests.
+ * <p>
+ * If test failed, look into logs, because exceptions are not thrown outside the
+ * {@link AppServerStartup} implementation.
  *
  * @author Tom Beerbower
  */
 public class AppServerStartupTest {
 
-    // ----- data members ----------------------------------------------------
-
     /**
      * The AppServerStartup instance to test.
      */
@@ -94,20 +102,23 @@
     /**
      * Map of exceptions to be thrown from the postConstruct.
      */
-    private static Map<Class, RuntimeException> mapPostConstructExceptions = null;
+    private static Map<Class, RuntimeException> mapPostConstructExceptions;
 
     /**
      * List of {@link Future}s returned from {@link FutureProvider#getFutures()} by the Startup
      * services during progression to the start up run level.
      */
-    private static List<TestFuture> listFutures = null;
+    private static List<TestFuture> listFutures;
 
     private ServiceLocator testLocator;
 
 
-    // ----- test initialization ---------------------------------------------
-
-    private void initialize(ServiceLocator testLocator) {
+    /**
+     * Reset the results prior to each test.
+     */
+    @BeforeEach
+    public void beforeTest() {
+        testLocator = ServiceLocatorFactory.getInstance().create("AppServerStartupTest");
         DynamicConfigurationService dcs = testLocator.getService(DynamicConfigurationService.class);
         DynamicConfiguration config = dcs.createDynamicConfiguration();
 
@@ -132,7 +143,8 @@
         config.bind(BuilderHelper.link(RunLevelControllerImpl.class).to(RunLevelController.class).build());
 
         config.addUnbindFilter(BuilderHelper.createContractFilter(RunLevelContext.class.getName()));
-        config.bind(BuilderHelper.link(RunLevelContext.class).to(Context.class).in(Singleton.class).build());
+        config.bind(BuilderHelper.link(RunLevelContext.class).named(RunLevelContext.CONTEXT_NAME).to(Context.class)
+            .in(Singleton.class).build());
 
         config.addUnbindFilter(BuilderHelper.createContractFilter(AsyncRunLevelContext.class.getName()));
         config.bind(BuilderHelper.link(AsyncRunLevelContext.class).in(Singleton.class).build());
@@ -153,8 +165,171 @@
 
         bindService(config, APIExporterImpl.class);
         config.commit();
+
+        as = testLocator.getService(AppServerStartup.class);
+        assertNotNull(as);
+
+        mapPostConstructExceptions = new HashMap<>();
+        listFutures = new LinkedList<>();
+        results = new Results(as.runLevelController);
+
+        as.events.register(results);
+        assertEquals(ServerEnvironment.Status.starting, as.env.getStatus());
     }
 
+    /**
+     * Ensure that things are stopped after the test... if not then call stop.
+     */
+    @AfterEach
+    public void afterTest() {
+        if (as != null) {
+            // force a stop to ensure that the services are released
+            if (as.runLevelController.getCurrentRunLevel() > 0) {
+                as.env.setStatus(ServerEnvironment.Status.started);
+                as.stop();
+            }
+
+            as.events.unregister(results);
+        }
+        results = null;
+        listFutures = null;
+        mapPostConstructExceptions = null;
+
+        ServiceLocatorFactory.getInstance().destroy(testLocator);
+        testLocator = null;
+    }
+
+
+    /**
+     * Call the {@link AppServerStartup#run} method and make sure that
+     * the run level services are constructed and destroyed at the proper
+     * run levels.
+     */
+    @Test
+    public void testRunLevelServices() {
+        // create the list of Futures returned from TestStartupService
+        listFutures.add(new TestFuture());
+        listFutures.add(new TestFuture());
+        listFutures.add(new TestFuture());
+
+        testRunAppServerStartup();
+
+        assertEquals(ServerEnvironment.Status.started, as.env.getStatus());
+
+        assertThat(results.getListEvents(), hasSize(2));
+        assertEquals(EventTypes.SERVER_STARTUP, results.getListEvents().get(0));
+        assertEquals(EventTypes.SERVER_READY, results.getListEvents().get(1));
+
+        // assert that the run level services have been constructed
+        assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
+        assertTrue(results.isConstructed(TestStartupService.class, StartupRunLevel.VAL));
+        assertTrue(results.isConstructed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
+        assertTrue(results.isConstructed(TestPostStartupRunLevelService.class, PostStartupRunLevel.VAL));
+
+        as.stop();
+        assertEquals(ServerEnvironment.Status.stopped, as.env.getStatus());
+
+        assertThat(results.getListEvents(), hasSize(4));
+        assertEquals(EventTypes.PREPARE_SHUTDOWN, results.getListEvents().get(2));
+        assertEquals(EventTypes.SERVER_SHUTDOWN, results.getListEvents().get(3));
+
+        // assert that the run level services have been destroyed
+        assertTrue(results.isDestroyed(TestPostStartupRunLevelService.class, PostStartupRunLevel.VAL));
+        assertTrue(results.isDestroyed(TestStartupService.class, StartupRunLevel.VAL));
+        assertTrue(results.isDestroyed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
+        assertTrue(results.isDestroyed(TestInitRunLevelService.class, InitRunLevel.VAL));
+    }
+
+    /**
+     * Test the {@link AppServerStartup#run} method with an exception thrown from an init
+     * service that should cause a failure during init.  Make sure that the init run level
+     * services are constructed at the proper run levels.
+     */
+    @Test
+    public void testRunLevelServicesWithInitException() {
+        testRunLevelServicesWithException(TestInitRunLevelService.class);
+
+        // make sure that the server has not been started
+        assertEquals(ServerEnvironment.Status.starting, as.env.getStatus());
+
+        // assert that the run level services have been constructed
+        assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
+        // assert that startup & post-startup services are not constructed since the failure occurs during init
+        assertFalse(results.isConstructed(TestStartupService.class));
+        assertFalse(results.isConstructed(TestStartupRunLevelService.class));
+        assertFalse(results.isConstructed(TestPostStartupRunLevelService.class));
+    }
+
+    /**
+     * Test the {@link AppServerStartup#run} method with an exception thrown from a startup
+     * service that should cause a failure during startup.  Make sure that the init and
+     * startup run level services are constructed at the proper run levels.
+     */
+    @Test
+    public void testRunLevelServicesWithStartupException() {
+        testRunLevelServicesWithException(TestStartupService.class);
+
+        // make sure that the server has not been started
+        assertEquals(ServerEnvironment.Status.starting, as.env.getStatus());
+
+        assertTrue(results.getListEvents().contains(EventTypes.SERVER_SHUTDOWN));
+
+        // assert that the run level services have been constructed
+        assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
+        assertTrue(results.isConstructed(TestStartupService.class, StartupRunLevel.VAL));
+        assertTrue(results.isConstructed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
+        // assert that the post-startup service is not constructed since shutdown occurs during startup
+        assertFalse(results.isConstructed(TestPostStartupRunLevelService.class));
+    }
+
+    /**
+     * Test the {@link AppServerStartup#run} method with an exception thrown from a
+     * post-startup service that should cause a failure during post-startup.  Make sure
+     * that the run level services are constructed at the proper run levels.
+     */
+    @Test
+    public void testRunLevelServicesWithPostStartupException() {
+        testRunLevelServicesWithException(TestPostStartupRunLevelService.class);
+
+        assertEquals(ServerEnvironment.Status.started, as.env.getStatus());
+
+        // assert that the run level services have been constructed
+        assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
+        assertTrue(results.isConstructed(TestStartupService.class, StartupRunLevel.VAL));
+        assertTrue(results.isConstructed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
+        assertTrue(results.isConstructed(TestPostStartupRunLevelService.class, PostStartupRunLevel.VAL));
+    }
+
+    /**
+     * Test the {@link AppServerStartup#run} method with an exception thrown from a
+     * {@link Future} should cause a failed result during startup.  Make sure that the init
+     * and startup run level services are constructed at the proper run levels.  Also ensure
+     * that the failed {@link Future} causes a shutdown.
+     */
+    @Test
+    public void testRunLevelServicesWithFuturesException() {
+
+        // create the list of Futures returned from TestStartupService
+        listFutures.add(new TestFuture());
+        listFutures.add(new TestFuture(new Exception("Exception from Future.")));
+        listFutures.add(new TestFuture());
+
+        testRunAppServerStartup();
+
+        // make sure that the server has not been started
+        assertEquals(ServerEnvironment.Status.starting, as.env.getStatus());
+
+        assertThat(results.getListEvents(), hasItem(EventTypes.SERVER_SHUTDOWN));
+
+        // assert that the run level services have been constructed
+        assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
+        assertTrue(results.isConstructed(TestStartupService.class, StartupRunLevel.VAL));
+        assertTrue(results.isConstructed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
+        // assert that the post-startup service is not constructed since shutdown occurs during startup
+        assertFalse(results.isConstructed(TestPostStartupRunLevelService.class));
+    }
+
+
     private void bindService(DynamicConfiguration configurator, Class<?> service) {
         final DescriptorBuilder descriptorBuilder = BuilderHelper.link(service);
 
@@ -169,8 +344,8 @@
         Class clazz = service;
         while (clazz != null) {
             Class<?>[] interfaces = clazz.getInterfaces();
-            for (int j = 0; j < interfaces.length; j++) {
-                descriptorBuilder.to(interfaces[j]);
+            for (Class<?> element : interfaces) {
+                descriptorBuilder.to(element);
             }
             clazz = clazz.getSuperclass();
         }
@@ -183,210 +358,16 @@
         configurator.bind(descriptorBuilder.build());
     }
 
-
-    /**
-     * Reset the results prior to each test.
-     */
-    @Before
-    public void beforeTest() {
-        testLocator = ServiceLocatorFactory.getInstance().create("AppServerStartupTest");
-        initialize(testLocator);
-
-        as = testLocator.getService(AppServerStartup.class);
-        Assert.assertNotNull(as);
-
-        mapPostConstructExceptions = new HashMap<Class, RuntimeException>();
-        listFutures = new LinkedList<TestFuture>();
-        results = new Results(as.runLevelController);
-
-        as.events.register(results);
-    }
-
-    /**
-     * Ensure that things are stopped after the test... if not then call stop.
-     */
-    @After
-    public void afterTest() {
-        if (as != null) {
-            if (as.runLevelController.getCurrentRunLevel() > 0) {
-                // force a stop to ensure that the services are released
-                as.env.setStatus(ServerEnvironment.Status.started);
-                as.stop();
-            }
-
-            as.events.unregister(results);
-        }
-        results = null;
-        listFutures = null;
-        mapPostConstructExceptions = null;
-
-        ServiceLocatorFactory.getInstance().destroy(testLocator);
-        testLocator = null;
-    }
-
-    // ----- tests -----------------------------------------------------------
-
-    /**
-     * Call the {@link AppServerStartup#run} method and make sure that
-     * the run level services are constructed and destroyed at the proper
-     * run levels.
-     */
-    //Ignored these tests and raised an issue(#22374) to track.
-    @Ignore
-    @Test
-    public void testRunLevelServices() {
-        // create the list of Futures returned from TestStartupService
-        listFutures.add(new TestFuture());
-        listFutures.add(new TestFuture());
-        listFutures.add(new TestFuture());
-
-        testRunAppServerStartup();
-
-        Assert.assertTrue(as.env.getStatus() == ServerEnvironment.Status.started);
-
-        Assert.assertEquals(2, results.getListEvents().size());
-        Assert.assertEquals(EventTypes.SERVER_STARTUP, results.getListEvents().get(0));
-        Assert.assertEquals(EventTypes.SERVER_READY, results.getListEvents().get(1));
-
-        // assert that the run level services have been constructed
-        Assert.assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestStartupService.class, StartupRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestPostStartupRunLevelService.class, PostStartupRunLevel.VAL));
-
-        as.stop();
-
-        Assert.assertFalse(as.env.getStatus() == ServerEnvironment.Status.started);
-
-        Assert.assertEquals(4, results.getListEvents().size());
-        Assert.assertEquals(EventTypes.PREPARE_SHUTDOWN, results.getListEvents().get(2));
-        Assert.assertEquals(EventTypes.SERVER_SHUTDOWN, results.getListEvents().get(3));
-
-        // assert that the run level services have been destroyed
-        Assert.assertTrue(results.isDestroyed(TestPostStartupRunLevelService.class, PostStartupRunLevel.VAL));
-        Assert.assertTrue(results.isDestroyed(TestStartupService.class, StartupRunLevel.VAL));
-        Assert.assertTrue(results.isDestroyed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
-        Assert.assertTrue(results.isDestroyed(TestInitRunLevelService.class, InitRunLevel.VAL));
-    }
-
-    /**
-     * Test the {@link AppServerStartup#run} method with an exception thrown from an init
-     * service that should cause a failure during init.  Make sure that the init run level
-     * services are constructed at the proper run levels.
-     */
-    @Ignore
-    @Test
-    public void testRunLevelServicesWithInitException() {
-        testRunLevelServicesWithException(TestInitRunLevelService.class);
-
-        // make sure that the server has not been started
-        Assert.assertFalse(as.env.getStatus() == ServerEnvironment.Status.started);
-
-        // assert that the run level services have been constructed
-        Assert.assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
-        // assert that startup & post-startup services are not constructed since the failure occurs during init
-        Assert.assertFalse(results.isConstructed(TestStartupService.class));
-        Assert.assertFalse(results.isConstructed(TestStartupRunLevelService.class));
-        Assert.assertFalse(results.isConstructed(TestPostStartupRunLevelService.class));
-    }
-
-    /**
-     * Test the {@link AppServerStartup#run} method with an exception thrown from a startup
-     * service that should cause a failure during startup.  Make sure that the init and
-     * startup run level services are constructed at the proper run levels.
-     */
-    @Ignore
-    @Test
-    public void testRunLevelServicesWithStartupException() {
-        testRunLevelServicesWithException(TestStartupService.class);
-
-        // make sure that the server has not been started
-        Assert.assertFalse(as.env.getStatus() == ServerEnvironment.Status.started);
-
-        Assert.assertTrue(results.getListEvents().contains(EventTypes.SERVER_SHUTDOWN));
-
-        // assert that the run level services have been constructed
-        Assert.assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestStartupService.class, StartupRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
-        // assert that the post-startup service is not constructed since shutdown occurs during startup
-        Assert.assertFalse(results.isConstructed(TestPostStartupRunLevelService.class));
-    }
-
-    /**
-     * Test the {@link AppServerStartup#run} method with an exception thrown from a
-     * post-startup service that should cause a failure during post-startup.  Make sure
-     * that the run level services are constructed at the proper run levels.
-     */
-    @Ignore
-    @Test
-    public void testRunLevelServicesWithPostStartupException() {
-        testRunLevelServicesWithException(TestPostStartupRunLevelService.class);
-
-        // assert that the run level services have been constructed
-        Assert.assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestStartupService.class, StartupRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestPostStartupRunLevelService.class, PostStartupRunLevel.VAL));
-    }
-
-    /**
-     * Test the {@link AppServerStartup#run} method with an exception thrown from a
-     * {@link Future} should cause a failed result during startup.  Make sure that the init
-     * and startup run level services are constructed at the proper run levels.  Also ensure
-     * that the failed {@link Future} causes a shutdown.
-     */
-    @Ignore
-    @Test
-    public void testRunLevelServicesWithFuturesException() {
-
-        // create the list of Futures returned from TestStartupService
-        listFutures.add(new TestFuture());
-        listFutures.add(new TestFuture(new Exception("Exception from Future.")));
-        listFutures.add(new TestFuture());
-
-        testRunAppServerStartup();
-
-        // make sure that the server has not been started
-        Assert.assertFalse(as.env.getStatus() == ServerEnvironment.Status.started);
-
-        Assert.assertTrue(results.getListEvents().contains(EventTypes.SERVER_SHUTDOWN));
-
-        // assert that the run level services have been constructed
-        Assert.assertTrue(results.isConstructed(TestInitRunLevelService.class, InitRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestStartupService.class, StartupRunLevel.VAL));
-        Assert.assertTrue(results.isConstructed(TestStartupRunLevelService.class, StartupRunLevel.VAL));
-        // assert that the post-startup service is not constructed since shutdown occurs during startup
-        Assert.assertFalse(results.isConstructed(TestPostStartupRunLevelService.class));
-    }
-
-
-    // ----- helper methods --------------------------------------------------
-
-    /**
-     * Helper method to run the app server after asserting that the results are clean.
-     */
-    private void testRunAppServerStartup() {
-        // assert that we have clean results to start
-        Assert.assertFalse(results.isConstructed(TestInitRunLevelService.class));
-        Assert.assertFalse(results.isConstructed(TestStartupService.class));
-        Assert.assertFalse(results.isConstructed(TestStartupRunLevelService.class));
-        Assert.assertFalse(results.isConstructed(TestPostStartupRunLevelService.class));
-
-        as.run();
-    }
-
     /**
      * Helper method to call {@link AppServerStartup#run()}.  Sets up an exception
      * to be thrown from {@link PostConstruct#postConstruct()} of the given class.
      *
      * @param badServiceClass the service class that the exception will be thrown from
      */
-    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
     private void testRunLevelServicesWithException(Class badServiceClass) {
         // set an exception to be thrown from TestStartupService.postConstruct()
         mapPostConstructExceptions.put(badServiceClass,
-                new RuntimeException("Exception from " + badServiceClass.getSimpleName() + ".postConstruct"));
+            new RuntimeException("Exception from " + badServiceClass.getSimpleName() + ".postConstruct"));
 
         // create the list of Futures returned from TestStartupService
         listFutures.add(new TestFuture());
@@ -395,7 +376,19 @@
     }
 
 
-    // ----- Results inner class ---------------------------------------------
+    /**
+     * Helper method to run the app server after asserting that the results are clean.
+     */
+    private void testRunAppServerStartup() {
+        // assert that we have clean results to start
+        assertFalse(results.isConstructed(TestInitRunLevelService.class));
+        assertFalse(results.isConstructed(TestStartupService.class));
+        assertFalse(results.isConstructed(TestStartupRunLevelService.class));
+        assertFalse(results.isConstructed(TestPostStartupRunLevelService.class));
+
+        as.run();
+    }
+
 
     /**
      * Test results
@@ -404,22 +397,22 @@
         /**
          * Map of constructed run level services to run levels.
          */
-        private Map<Class, Integer> mapConstructedLevels = new HashMap<Class, Integer>();
+        private final Map<Class, Integer> mapConstructedLevels = new HashMap<>();
 
         /**
          * Map of destroyed run level services to run levels.
          */
-        private Map<Class, Integer> mapDestroyedLevels = new HashMap<Class, Integer>();
+        private final Map<Class, Integer> mapDestroyedLevels = new HashMap<>();
 
         /**
          * List of server events.
          */
-        private List<EventTypes> listEvents = new LinkedList<EventTypes>();
+        private final List<EventTypes> listEvents = new LinkedList<>();
 
         /**
          * The run level service.
          */
-        private RunLevelController rls;
+        private final RunLevelController rls;
 
         public Results(RunLevelController rls) {
             this.rls = rls;
@@ -501,7 +494,6 @@
     @Service
     public static class TestStartupService extends TestService implements FutureProvider {
         // Make sure the other one starts first
-        @SuppressWarnings("unused")
         @Inject
         private TestStartupRunLevelService dependency;
 
@@ -562,9 +554,9 @@
      */
     public static class TestFuture implements Future<Result<Thread>> {
 
-        private boolean canceled = false;
-        private boolean done = false;
-        private Exception resultException = null;
+        private boolean canceled;
+        private boolean done;
+        private Exception resultException;
 
         public TestFuture() {
         }
@@ -596,8 +588,8 @@
         public Result<Thread> get() throws InterruptedException, ExecutionException {
 
             Result<Thread> result = resultException == null ?
-                    new Result<Thread>(Thread.currentThread()) :
-                    new Result<Thread>(resultException);
+                    new Result<>(Thread.currentThread()) :
+                    new Result<>(resultException);
             done = true;
 
             return result;
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AnotherPublicMethod.java b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/AnotherPublicMethod.java
similarity index 90%
rename from nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AnotherPublicMethod.java
rename to nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/AnotherPublicMethod.java
index 838443e..bd86cb9 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AnotherPublicMethod.java
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/AnotherPublicMethod.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -14,7 +15,7 @@
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
  */
 
-package com.sun.enterprise.v3.admin;
+package org.glassfish.main.core.kernel.test.example;
 
 import org.jvnet.hk2.annotations.Service;
 import org.glassfish.api.admin.AdminCommand;
@@ -28,6 +29,8 @@
  */
 @Service(name="notannoated-public-command")
 public class AnotherPublicMethod implements AdminCommand {
+
+    @Override
     public void execute(AdminCommandContext context) {
         context.getActionReport().setActionExitCode(ActionReport.ExitCode.SUCCESS);
     }
diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/AuthorizationServiceMock.java b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/AuthorizationServiceMock.java
new file mode 100644
index 0000000..ffad499
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/AuthorizationServiceMock.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2021 Eclipse Foundation and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.main.core.kernel.test.example;
+
+import java.net.URI;
+import java.security.Permission;
+import java.util.Collections;
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.glassfish.security.services.api.authorization.AuthorizationService;
+import org.glassfish.security.services.api.authorization.AzAction;
+import org.glassfish.security.services.api.authorization.AzAttributeResolver;
+import org.glassfish.security.services.api.authorization.AzResource;
+import org.glassfish.security.services.api.authorization.AzResult;
+import org.glassfish.security.services.api.authorization.AzSubject;
+import org.glassfish.security.services.api.authorization.AzResult.Decision;
+import org.glassfish.security.services.api.authorization.AzResult.Status;
+import org.glassfish.security.services.config.SecurityConfiguration;
+import org.glassfish.security.services.impl.authorization.AuthorizationServiceImpl;
+import org.glassfish.security.services.impl.authorization.AzActionImpl;
+import org.glassfish.security.services.impl.authorization.AzObligationsImpl;
+import org.glassfish.security.services.impl.authorization.AzResourceImpl;
+import org.glassfish.security.services.impl.authorization.AzResultImpl;
+import org.glassfish.security.services.impl.authorization.AzSubjectImpl;
+import org.jvnet.hk2.annotations.Service;
+
+
+/**
+ * Alternative implementation to {@link AuthorizationServiceImpl} which depends on secure
+ * environment - JUnit tests don't fulfill this requirement.
+ *
+ * @author David Matejcek
+ */
+@Service
+public class AuthorizationServiceMock implements AuthorizationService {
+
+    @Override
+    public void initialize(SecurityConfiguration securityServiceConfiguration) {
+    }
+
+
+    @Override
+    public boolean isPermissionGranted(Subject subject, Permission permission) {
+        return true;
+    }
+
+
+    @Override
+    public boolean isAuthorized(Subject subject, URI resource) {
+        return true;
+    }
+
+
+    @Override
+    public boolean isAuthorized(Subject subject, URI resource, String action) {
+        return true;
+    }
+
+
+    @Override
+    public AzResult getAuthorizationDecision(AzSubject subject, AzResource resource, AzAction action) {
+        return new AzResultImpl(Decision.PERMIT, Status.OK, new AzObligationsImpl());
+    }
+
+
+    @Override
+    public AzSubject makeAzSubject(Subject subject) {
+        return new AzSubjectImpl(subject);
+    }
+
+
+    @Override
+    public AzResource makeAzResource(URI resource) {
+        return new AzResourceImpl(resource);
+    }
+
+
+    @Override
+    public AzAction makeAzAction(String action) {
+        return new AzActionImpl(action);
+    }
+
+
+    @Override
+    public PolicyDeploymentContext findOrCreateDeploymentContext(String appContext) {
+        return null;
+    }
+
+
+    @Override
+    public boolean appendAttributeResolver(AzAttributeResolver resolver) {
+        return false;
+    }
+
+
+    @Override
+    public void setAttributeResolvers(List<AzAttributeResolver> resolverList) {
+    }
+
+
+    @Override
+    public List<AzAttributeResolver> getAttributeResolvers() {
+        return Collections.emptyList();
+    }
+
+
+    @Override
+    public boolean removeAllAttributeResolvers() {
+        return false;
+    }
+
+}
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePrivateCommand.java b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/SimplePrivateCommand.java
similarity index 87%
rename from nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePrivateCommand.java
rename to nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/SimplePrivateCommand.java
index 1be8eea..364fe2a 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePrivateCommand.java
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/SimplePrivateCommand.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -14,22 +15,23 @@
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
  */
 
-package com.sun.enterprise.v3.admin;
+package org.glassfish.main.core.kernel.test.example;
 
+import org.glassfish.api.ActionReport;
 import org.glassfish.api.admin.AdminCommand;
 import org.glassfish.api.admin.AdminCommandContext;
-import org.glassfish.api.ActionReport;
-import org.glassfish.internal.api.Visibility;
 import org.glassfish.internal.api.Private;
+import org.glassfish.internal.api.Visibility;
 import org.jvnet.hk2.annotations.Service;
 
 /**
  * simple private command
  */
-@Service(name="simple-private-command")
+@Service(name = "simple-private-command")
 @Visibility(Private.class)
 public class SimplePrivateCommand implements AdminCommand {
 
+    @Override
     public void execute(AdminCommandContext context) {
         context.getActionReport().setActionExitCode(ActionReport.ExitCode.SUCCESS);
     }
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePublicCommand.java b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/SimplePublicCommand.java
similarity index 87%
rename from nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePublicCommand.java
rename to nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/SimplePublicCommand.java
index 94955a9..35555c8 100644
--- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePublicCommand.java
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/example/SimplePublicCommand.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -14,21 +15,23 @@
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
  */
 
-package com.sun.enterprise.v3.admin;
+package org.glassfish.main.core.kernel.test.example;
 
-import org.jvnet.hk2.annotations.Service;
-import org.glassfish.internal.api.Visibility;
-import org.glassfish.internal.api.Public;
+import org.glassfish.api.ActionReport;
 import org.glassfish.api.admin.AdminCommand;
 import org.glassfish.api.admin.AdminCommandContext;
-import org.glassfish.api.ActionReport;
+import org.glassfish.internal.api.Public;
+import org.glassfish.internal.api.Visibility;
+import org.jvnet.hk2.annotations.Service;
 
 /**
  * simple public command
  */
-@Service(name="simple-public-command")
+@Service(name = "simple-public-command")
 @Visibility(Public.class)
 public class SimplePublicCommand implements AdminCommand {
+
+    @Override
     public void execute(AdminCommandContext context) {
         context.getActionReport().setActionExitCode(ActionReport.ExitCode.SUCCESS);
     }
diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/admin/CommandRunnerTest.java b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/admin/CommandRunnerTest.java
deleted file mode 100644
index 2b089af..0000000
--- a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/admin/CommandRunnerTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.tests.kernel.admin;
-
-import com.sun.enterprise.config.serverbeans.Domain;
-import com.sun.enterprise.module.ModulesRegistry;
-import com.sun.enterprise.module.bootstrap.StartupContext;
-import com.sun.enterprise.module.single.SingleModulesRegistry;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import junit.framework.Assert;
-import org.glassfish.api.ActionReport;
-import org.glassfish.api.admin.CommandRunner;
-import org.glassfish.hk2.utilities.BuilderHelper;
-import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import jakarta.inject.Inject;
-import org.glassfish.internal.api.InternalSystemAdministrator;
-import org.jvnet.hk2.testing.junit.HK2Runner;
-
-/**
- * Test the command runner implementation.
- *
- * @author Jerome Dochez
- */
-@Ignore
-public class CommandRunnerTest extends HK2Runner {
-
-    @Inject
-    CommandRunner commandRunner;
-
-    @Inject
-    InternalSystemAdministrator kernelIdentity;
-
-    @BeforeClass
-    public void setup() {
-
-        /*
-         * The CommandRunnerImpl now injects Domain but these tests do not
-         * exercise the code path that requires the domain.  So register a
-         * dummy Domain instance with the habitat so injection will work.
-         */
-        ServiceLocatorUtilities.addOneDescriptor(testLocator,
-                BuilderHelper.createConstantDescriptor(simpleDomain(), null, Domain.class));
-        ServiceLocatorUtilities.addOneConstant(testLocator, new StartupContext());
-        ServiceLocatorUtilities.addOneDescriptor(testLocator,
-                BuilderHelper.createConstantDescriptor(new SingleModulesRegistry(CommandRunnerTest.class.getClassLoader()),
-                        null, ModulesRegistry.class));
-    }
-
-    private static Domain simpleDomain() {
-        InvocationHandler handler = new InvocationHandler() {
-
-            @Override
-            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-                throw new UnsupportedOperationException("Feature-free dummy implementation for injection only");
-            }
-        };
-        Domain d = (Domain) Proxy.newProxyInstance(Domain.class.getClassLoader(),
-                                          new Class[] { Domain.class },
-                                          handler);
-        return d;
-    }
-
-    @Test
-    public void tryOut() {
-        Assert.assertTrue(commandRunner!=null);
-        try {
-            ActionReport report = commandRunner.getActionReport("plain");
-            CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("list-contracts", report, kernelIdentity.getSubject());
-            inv.execute();
-            System.out.println(report.getTopMessagePart().getMessage());
-            for (ActionReport.MessagePart child : report.getTopMessagePart().getChildren()) {
-                System.out.println(child.getMessage());
-            }
-        } catch(Exception e) {
-            e.printStackTrace();
-        }
-    }
-}
diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java
index 26046e5..53c55a5 100644
--- a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,114 +17,142 @@
 
 package org.glassfish.tests.kernel.deployment;
 
-import org.junit.*;
-import org.glassfish.api.event.Events;
-import org.glassfish.api.event.EventListener;
-import org.glassfish.api.event.EventTypes;
-import org.glassfish.api.deployment.DeployCommandParameters;
-import org.glassfish.api.deployment.UndeployCommandParameters;
+import com.sun.enterprise.config.serverbeans.Server;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+
 import org.glassfish.api.ActionReport;
 import org.glassfish.api.admin.ServerEnvironment;
-import org.glassfish.tests.utils.ConfigApiTest;
-import org.glassfish.hk2.api.ActiveDescriptor;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.api.deployment.UndeployCommandParameters;
+import org.glassfish.api.event.EventListener;
+import org.glassfish.api.event.EventListener.Event;
+import org.glassfish.api.event.EventTypes;
+import org.glassfish.api.event.Events;
 import org.glassfish.hk2.api.ServiceLocator;
-import org.glassfish.hk2.utilities.BuilderHelper;
 import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
 import org.glassfish.internal.deployment.Deployment;
 import org.glassfish.internal.deployment.ExtendedDeploymentContext;
-import org.glassfish.config.support.GlassFishDocument;
-import org.jvnet.hk2.config.DomDocument;
+import org.glassfish.tests.utils.CustomConfiguration;
+import org.glassfish.tests.utils.HK2Extension;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+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 org.junit.jupiter.api.extension.ExtendWith;
+import jakarta.inject.Inject;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.logging.Logger;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import com.sun.enterprise.config.serverbeans.Server;
-import com.sun.enterprise.module.bootstrap.StartupContext;
+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.assertNotNull;
 
 /**
- * Created by IntelliJ IDEA.
  * User: dochez
  * Date: Mar 12, 2009
  * Time: 9:26:57 AM
- * To change this template use File | Settings | File Templates.
  */
-public class EventsTest extends ConfigApiTest {
+@TestMethodOrder(OrderAnnotation.class)
+@ExtendWith(HK2Extension.class)
+@CustomConfiguration("DomainTest.xml")
+public class EventsTest {
 
-    static ServiceLocator habitat;
-    static File application;
-    static List<EventListener.Event> allEvents = new ArrayList<EventListener.Event>();
-    static private EventListener listener = new EventListener() {
-        public void event(Event event) {
-            //System.out.println("Received event " + event.name());
-            allEvents.add(event);
-        }
-    };
+    private static List<Event> allEvents = new ArrayList<>();
 
-    public String getFileName() {
-        return "DomainTest";
-    }
+    @Inject
+    private ServiceLocator locator;
+    private File application;
+    private final EventListener listener = event -> allEvents.add(event);
 
-    @Override
-    public DomDocument getDocument(ServiceLocator habitat) {
-       DomDocument doc = habitat.getService(GlassFishDocument.class);
-        if (doc==null) {
-            return new GlassFishDocument(habitat, Executors.newCachedThreadPool(new ThreadFactory() {
 
-                        public Thread newThread(Runnable r) {
-                            Thread t = Executors.defaultThreadFactory().newThread(r);
-                            t.setDaemon(true);
-                            return t;
-                        }
+    @BeforeEach
+    public void setup() throws Exception {
+        Server server = locator.getService(Server.class, "server");
+        assertNotNull(server, "server");
+        ServiceLocatorUtilities.addOneConstant(locator, server, ServerEnvironment.DEFAULT_INSTANCE_NAME, Server.class);
 
-                    }));
-        }
-        return doc;
-    }
-
-    @Before
-    public void setup() throws IOException {
-
-        // cludge to run only once yet not depend on a static method.
-        if (habitat!=null) {
-            return;
-        }
-        habitat  = super.getHabitat();
-
-        Server server = habitat.getService(Server.class, "server");
-        ActiveDescriptor<Server> descriptor = BuilderHelper.createConstantDescriptor(server,
-                ServerEnvironment.DEFAULT_INSTANCE_NAME, Server.class);
-        ServiceLocatorUtilities.addOneDescriptor(habitat, descriptor);
-
-        try {
-            application = File.createTempFile("kerneltest", "tmp");
-        } catch (IOException e) {
-            e.printStackTrace();
-            throw e;
-
-        }
-
+        application = File.createTempFile("kerneltest", "tmp");
         application.delete();
         application.mkdirs();
 
-        Events events = habitat.getService(Events.class);
+        Events events = locator.getService(Events.class);
         events.register(listener);
     }
 
-    @AfterClass
-    public static void tearDown() {
+    @AfterEach
+    public void deleteApplications() {
        if (application != null) {
            application.delete();
        }
     }
 
-    public static List<EventTypes> getSingletonModuleSuccessfullDeploymentEvents() {
-        ArrayList<EventTypes> events = new ArrayList<EventTypes>();
+
+    @Test
+    @Order(1)
+    public void deployUndeployTest() throws Exception {
+        final List<EventTypes> myTestEvents = getSingletonModuleSuccessfullDeploymentEvents();
+        Events events = locator.getService(Events.class);
+        EventListener listenerRemovingEvents = event -> {
+            if (myTestEvents.contains(event.type())) {
+                myTestEvents.remove(event.type());
+            }
+        };
+        events.register(listenerRemovingEvents);
+        Deployment deployment = locator.getService(Deployment.class);
+        DeployCommandParameters params = new DeployCommandParameters(application);
+        params.name = "fakeApplication";
+        params.target = "server";
+        ActionReport report = locator.getService(ActionReport.class, "hk2-agent");
+        ExtendedDeploymentContext dc = deployment.getBuilder(Logger.getAnonymousLogger(), params, report).source(application).build();
+        deployment.deploy(dc);
+        events.unregister(listenerRemovingEvents);
+        assertThat(myTestEvents.toString(), myTestEvents, hasSize(6));
+
+        final List<EventTypes> myTestEvents2 = getSingletonModuleSuccessfullUndeploymentEvents();
+        EventListener listener2 = event -> {
+            if (myTestEvents2.contains(event.type())) {
+                myTestEvents2.remove(event.type());
+            }
+        };
+        events.register(listener2);
+        UndeployCommandParameters params2 = new UndeployCommandParameters("fakeApplication");
+        params2.target = "server";
+        ActionReport report2 = locator.getService(ActionReport.class, "hk2-agent");
+        ExtendedDeploymentContext dc2 = deployment.getBuilder(Logger.getAnonymousLogger(), params2, report2).source(application).build();
+        deployment.undeploy("fakeApplication", dc2);
+        events.unregister(listener2);
+        assertThat(myTestEvents.toString(), myTestEvents2, hasSize(6));
+    }
+
+    @Test
+    @Order(2)
+    public void badUndeployTest() throws Exception {
+        Deployment deployment = locator.getService(Deployment.class);
+        UndeployCommandParameters params = new UndeployCommandParameters("notavalidname");
+        params.target = "server";
+        ActionReport report = locator.getService(ActionReport.class, "hk2-agent");
+        ExtendedDeploymentContext dc = deployment.getBuilder(Logger.getAnonymousLogger(), params, report).source(application).build();
+        deployment.undeploy("notavalidname", dc);
+        assertEquals(ActionReport.ExitCode.FAILURE, report.getActionExitCode());
+    }
+
+    @Test
+    @Order(3)
+    public void asynchronousEvents() {
+        List<EventTypes> remaining = asynchonousEvents().stream()
+            .filter(et -> allEvents.stream().anyMatch(event -> event.is(et))).collect(Collectors.toList());
+        assertThat(remaining.toString(), remaining, hasSize(2));
+    }
+
+
+    private static List<EventTypes> getSingletonModuleSuccessfullDeploymentEvents() {
+        ArrayList<EventTypes> events = new ArrayList<>();
         events.add(Deployment.MODULE_PREPARED);
         events.add(Deployment.MODULE_LOADED);
         events.add(Deployment.MODULE_STARTED);
@@ -133,8 +162,8 @@
         return events;
     }
 
-    public static List<EventTypes> getSingletonModuleSuccessfullUndeploymentEvents() {
-        ArrayList<EventTypes> events = new ArrayList<EventTypes>();
+    private static List<EventTypes> getSingletonModuleSuccessfullUndeploymentEvents() {
+        ArrayList<EventTypes> events = new ArrayList<>();
         events.add(Deployment.MODULE_STOPPED);
         events.add(Deployment.MODULE_UNLOADED);
         events.add(Deployment.MODULE_CLEANED);
@@ -144,8 +173,8 @@
         return events;
     }
 
-    public static List<EventTypes> asynchonousEvents() {
-        ArrayList<EventTypes> events = new ArrayList<EventTypes>();
+    private static List<EventTypes> asynchonousEvents() {
+        ArrayList<EventTypes> events = new ArrayList<>();
         events.add(Deployment.DEPLOYMENT_START);
         events.add(Deployment.DEPLOYMENT_SUCCESS);
         events.add(Deployment.UNDEPLOYMENT_START);
@@ -153,84 +182,4 @@
         events.add(Deployment.UNDEPLOYMENT_FAILURE);
         return events;
     }
-
-    @Test
-    public void deployUndeployTest() throws Exception {
-
-        final List<EventTypes> myTestEvents = getSingletonModuleSuccessfullDeploymentEvents();
-        Events events = habitat.getService(Events.class);
-        EventListener listener = new EventListener() {
-            public void event(Event event) {
-                if (myTestEvents.contains(event.type())) {
-                    myTestEvents.remove(event.type());
-                }
-            }
-        };
-        events.register(listener);
-        Deployment deployment = habitat.getService(Deployment.class);
-        DeployCommandParameters params = new DeployCommandParameters(application);
-        params.name = "fakeApplication";
-        params.target = "server";
-        ActionReport report = habitat.getService(ActionReport.class, "hk2-agent");
-        ExtendedDeploymentContext dc = deployment.getBuilder(Logger.getAnonymousLogger(), params, report).source(application).build();
-        deployment.deploy(dc);
-        events.unregister(listener);
-        for (EventTypes et : myTestEvents) {
-            System.out.println("An expected event of type " + et.type() + " was not received");
-        }
-
-        try {
-        final List<EventTypes> myTestEvents2 = getSingletonModuleSuccessfullUndeploymentEvents();
-        EventListener listener2 = new EventListener() {
-            public void event(Event event) {
-                if (myTestEvents2.contains(event.type())) {
-                    myTestEvents2.remove(event.type());
-                }
-            }
-        };
-        events.register(listener2);
-        UndeployCommandParameters params2 = new UndeployCommandParameters("fakeApplication");
-        params2.target = "server";
-        ActionReport report2 = habitat.getService(ActionReport.class, "hk2-agent");
-        ExtendedDeploymentContext dc2 = deployment.getBuilder(Logger.getAnonymousLogger(), params2, report2).source(application).build();
-        deployment.undeploy("fakeApplication", dc2);
-        events.unregister(listener2);
-        for (EventTypes et : myTestEvents2) {
-            System.out.println("An expected event of type " + et.type() + " was not received");
-        }
-        } catch(Throwable t) {
-            t.printStackTrace();
-        }
-
-    }
-
-    @Test
-    public void badUndeployTest() throws Exception {
-        Deployment deployment = habitat.getService(Deployment.class);
-        UndeployCommandParameters params = new UndeployCommandParameters("notavalidname");
-        params.target = "server";
-        ActionReport report = habitat.getService(ActionReport.class, "hk2-agent");
-        ExtendedDeploymentContext dc = deployment.getBuilder(Logger.getAnonymousLogger(), params, report).source(application).build();
-        deployment.undeploy("notavalidname", dc);
-        Assert.assertEquals(report.getActionExitCode(), ActionReport.ExitCode.FAILURE);
-    }
-
-    @Test
-    @Ignore
-    public void asynchronousEvents() {
-        List<EventTypes> asyncEvents =  asynchonousEvents();
-        Iterator<EventTypes> itr = asyncEvents.iterator();
-        while (itr.hasNext()) {
-            EventTypes et = itr.next();
-            for (EventListener.Event evt : allEvents) {
-                if (evt.is(et)) {
-                    itr.remove();
-                }
-            }
-        }
-        for (EventTypes et : asyncEvents) {
-            System.out.println("Asynchronous event " + et.type() + " was not received");
-        }
-        Assert.assertTrue(asyncEvents.size()==0);
-    }
 }
diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/container/FakeContainer.java b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/container/FakeContainer.java
deleted file mode 100644
index 7f5fe4d..0000000
--- a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/container/FakeContainer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 1997, 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.tests.kernel.deployment.container;
-
-import org.glassfish.api.container.Container;
-import org.glassfish.api.deployment.Deployer;
-import org.glassfish.internal.deployment.GenericDeployer;
-import org.jvnet.hk2.annotations.Service;
-
-/**
- * Fake container for testing purposes
- *
- * @author Jerome Dochez
- */
-@Service(name="FakeContainer")
-public class FakeContainer implements Container {
-
-    public Class<? extends Deployer> getDeployer() {
-        return GenericDeployer.class;
-    }
-
-    public String getName() {
-        return "Fake";
-    }
-}
diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/container/FakeSniffer.java b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/container/FakeSniffer.java
deleted file mode 100644
index b33a013..0000000
--- a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/container/FakeSniffer.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2009, 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.tests.kernel.deployment.container;
-
-import org.jvnet.hk2.annotations.Service;
-import org.glassfish.api.container.Sniffer;
-import org.glassfish.api.deployment.archive.ReadableArchive;
-import org.glassfish.api.deployment.archive.ArchiveType;
-import org.glassfish.api.deployment.DeploymentContext;
-
-import java.lang.annotation.Annotation;
-import java.util.logging.Logger;
-import java.util.Map;
-import java.io.IOException;
-
-import com.sun.enterprise.module.HK2Module;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dochez
- * Date: Mar 12, 2009
- * Time: 9:20:37 AM
- * To change this template use File | Settings | File Templates.
- */
-@Service
-public class FakeSniffer implements Sniffer {
-
-    public boolean handles(ReadableArchive source) {
-        // I handle everything
-        return true;
-    }
-
-    public boolean handles(DeploymentContext context) {
-        // I handle everything
-        return true;
-    }
-
-    public String[] getURLPatterns() {
-        return new String[0];  //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    public Class<? extends Annotation>[] getAnnotationTypes() {
-        return null;
-    }
-
-    public String[] getAnnotationNames(DeploymentContext context) {
-        return null;
-    }
-
-    public String getModuleType() {
-        return "fake";
-    }
-
-    public HK2Module[] setup(String containerHome, Logger logger) throws IOException {
-        return null;
-    }
-
-    public void tearDown() {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    public String[] getContainersNames() {
-        return new String[] { "FakeContainer" };
-    }
-
-    public boolean isUserVisible() {
-        return false;
-    }
-
-   public boolean isJavaEE() {
-        return false;
-    }
-
-    public Map<String, String> getDeploymentConfigurations(ReadableArchive source) throws IOException {
-        return null;
-    }
-
-    public String[] getIncompatibleSnifferTypes() {
-        return new String[0];
-    }
-
-    public boolean supportsArchiveType(ArchiveType archiveType) {
-        return true;
-    }
-
-}
diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/embedded/.gitkeep_empty_dir b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/embedded/.gitkeep_empty_dir
deleted file mode 100644
index e69de29..0000000
--- a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/embedded/.gitkeep_empty_dir
+++ /dev/null
diff --git a/nucleus/core/kernel/src/test/resources/DomainTest.xml b/nucleus/core/kernel/src/test/resources/DomainTest.xml
index 9cba3c3..a099b6d 100644
--- a/nucleus/core/kernel/src/test/resources/DomainTest.xml
+++ b/nucleus/core/kernel/src/test/resources/DomainTest.xml
@@ -1,6 +1,7 @@
 <!--
 
-    Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2008, 2019 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2021 Contributors to the Eclipse Foundation
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -13,22 +14,43 @@
     https://www.gnu.org/software/classpath/license.html.
 
     SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
 -->
 
-<domain log-root="${com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}/applications">
-  <applications>
-  </applications>
-  <resources/>
+<domain application-root="${com.sun.aas.instanceRoot}/applications" version="master-2021-08-26T23:45:22+0000" log-root="${com.sun.aas.instanceRoot}/logs">
+  <security-configurations>
+    <authorization-service default="true" name="authorizationService">
+      <security-provider provider-name="simpleAuthorizationProvider" name="simpleAuthorization" type="Simple">
+        <authorization-provider-config name="simpleAuthorizationProviderConfig" support-policy-deploy="false"></authorization-provider-config>
+      </security-provider>
+    </authorization-service>
+  </security-configurations>
+  <managed-job-config></managed-job-config>
+  <system-applications></system-applications>
+  <resources />
+  <servers>
+    <server config-ref="server-config" name="server">
+      <resource-ref ref="jdbc/__TimerPool"></resource-ref>
+      <resource-ref ref="jdbc/__default"></resource-ref>
+    </server>
+  </servers>
+  <nodes>
+    <node name="localhost-domain1" install-dir="${com.sun.aas.productRoot}" type="CONFIG" node-host="localhost"></node>
+  </nodes>
   <configs>
     <config name="server-config">
+      <system-property name="JMS_PROVIDER_PORT" description="Port Number that JMS Service will listen for remote clients connection." value="7676"></system-property>
+      <http-service>
+        <access-log></access-log>
+        <virtual-server network-listeners="http-listener-1,http-listener-2" id="server"></virtual-server>
+        <virtual-server network-listeners="admin-listener" id="__asadmin"></virtual-server>
+      </http-service>
       <admin-service system-jmx-connector-name="system" type="das-and-server">
-        <jmx-connector port="8686" address="0.0.0.0" security-enabled="false" name="system" auth-realm-name="admin-realm"></jmx-connector>
-        <das-config dynamic-reload-enabled="true" deploy-xml-validation="full" autodeploy-dir="${com.sun.aas.instanceRoot}/autodeploy" autodeploy-enabled="true"></das-config>
+        <jmx-connector address="0.0.0.0" port="8686" name="system" auth-realm-name="admin-realm" security-enabled="false"></jmx-connector>
+        <property name="adminConsoleContextRoot" value="/admin"></property>
+        <property name="adminConsoleDownloadLocation" value="${com.sun.aas.installRoot}/lib/install/applications/admingui.war"></property>
+        <property name="ipsRoot" value="${com.sun.aas.installRoot}/.."></property>
+        <das-config></das-config>
       </admin-service>
-      <log-service log-rotation-limit-in-bytes="2000000" file="${com.sun.aas.instanceRoot}/logs/server.log">
-        <module-log-levels></module-log-levels>
-      </log-service>
       <security-service>
         <auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="admin-realm">
           <property name="file" value="${com.sun.aas.instanceRoot}/config/admin-keyfile"></property>
@@ -42,6 +64,7 @@
         <jacc-provider policy-provider="org.glassfish.exousia.modules.locked.SimplePolicyProvider" name="default" policy-configuration-factory-provider="org.glassfish.exousia.modules.locked.SimplePolicyConfigurationFactory">
           <property name="repository" value="${com.sun.aas.instanceRoot}/generated/policy"></property>
         </jacc-provider>
+        <jacc-provider policy-provider="org.glassfish.exousia.modules.locked.SimplePolicyProvider" name="simple" policy-configuration-factory-provider="org.glassfish.exousia.modules.locked.SimplePolicyConfigurationFactory"></jacc-provider>
         <audit-module classname="com.sun.enterprise.security.ee.Audit" name="default">
           <property name="auditOn" value="false"></property>
         </audit-module>
@@ -79,72 +102,102 @@
             <property name="security.config" value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml"></property>
           </provider-config>
         </message-security-config>
+        <message-security-config auth-layer="HttpServlet">
+          <provider-config provider-type="server" provider-id="GFConsoleAuthModule" class-name="org.glassfish.admingui.common.security.AdminConsoleAuthModule">
+            <request-policy auth-source="sender"></request-policy>
+            <response-policy></response-policy>
+            <property name="loginPage" value="/login.jsf"></property>
+            <property name="loginErrorPage" value="/loginError.jsf"></property>
+          </provider-config>
+        </message-security-config>
+        <property name="default-digest-algorithm" value="SHA-256"></property>
       </security-service>
-      <monitoring-service>
-        <module-monitoring-levels></module-monitoring-levels>
-      </monitoring-service>
-      <diagnostic-service></diagnostic-service>
-      <java-config debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009" system-classpath="${com.sun.aas.installRoot}/lib/appserv-launch.jar" classpath-suffix="">
-        <jvm-options>-client</jvm-options>
+      <java-config classpath-suffix="" debug-options="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:9009" system-classpath="">
+        <jvm-options>-Djava.awt.headless=true</jvm-options>
+        <jvm-options>-Djdk.corba.allowOutputStreamSubclass=true</jvm-options>
+        <jvm-options>-Djdk.tls.rejectClientInitiatedRenegotiation=true</jvm-options>
+        <jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options>
+        <jvm-options>-Djavax.management.builder.initial=com.sun.enterprise.v3.admin.AppServerMBeanServerBuilder</jvm-options>
+        <jvm-options>-XX:+UnlockDiagnosticVMOptions</jvm-options>
         <jvm-options>-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy</jvm-options>
         <jvm-options>-Djava.security.auth.login.config=${com.sun.aas.instanceRoot}/config/login.conf</jvm-options>
-        <jvm-options>-Dsun.rmi.dgc.server.gcInterval=3600000</jvm-options>
-        <jvm-options>-Dsun.rmi.dgc.client.gcInterval=3600000</jvm-options>
+        <jvm-options>-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as</jvm-options>
         <jvm-options>-Xmx512m</jvm-options>
         <jvm-options>-Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/config/keystore.jks</jvm-options>
         <jvm-options>-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/cacerts.jks</jvm-options>
-        <jvm-options>-Djava.ext.dirs=${com.sun.aas.javaRoot}/lib/ext${path.separator}${com.sun.aas.javaRoot}/jre/lib/ext${path.separator}${com.sun.aas.instanceRoot}/lib/ext${path.separator}${com.sun.aas.derbyRoot}/lib</jvm-options>
         <jvm-options>-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver</jvm-options>
+        <jvm-options>-DANTLR_USE_DIRECT_CLASS_LOADING=true</jvm-options>
         <jvm-options>-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory</jvm-options>
-        <jvm-options>-Dcom.sun.enterprise.taglibs=jakarta.servlet.jsp.jstl.jar,jakarta.faces.jar</jvm-options>
-        <jvm-options>-Dcom.sun.enterprise.taglisteners=jakarta.faces.jar</jvm-options>
+        <jvm-options>-Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.shell.remote,org.apache.felix.fileinstall</jvm-options>
+        <jvm-options>-Dosgi.shell.telnet.port=6666</jvm-options>
+        <jvm-options>-Dosgi.shell.telnet.maxconn=1</jvm-options>
+        <jvm-options>-Dosgi.shell.telnet.ip=127.0.0.1</jvm-options>
+        <jvm-options>-Dgosh.args=--nointeractive</jvm-options>
+        <jvm-options>-Dfelix.fileinstall.dir=${com.sun.aas.installRoot}/modules/autostart/</jvm-options>
+        <jvm-options>-Dfelix.fileinstall.poll=5000</jvm-options>
+        <jvm-options>-Dfelix.fileinstall.log.level=2</jvm-options>
+        <jvm-options>-Dfelix.fileinstall.bundles.new.start=true</jvm-options>
+        <jvm-options>-Dfelix.fileinstall.bundles.startTransient=true</jvm-options>
+        <jvm-options>-Dfelix.fileinstall.disableConfigSave=false</jvm-options>
+        <jvm-options>-Dorg.glassfish.gmbal.no.multipleUpperBoundsException=true</jvm-options>
+        <jvm-options>-Dcom.ctc.wstx.returnNullForDefaultNamespace=true</jvm-options>
         <jvm-options>-XX:NewRatio=2</jvm-options>
+        <jvm-options>-Xbootclasspath/a:${com.sun.aas.installRoot}/lib/grizzly-npn-api.jar</jvm-options>
+        <jvm-options>--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED</jvm-options>
+        <jvm-options>--add-opens=java.base/sun.net.www.protocol.jrt=ALL-UNNAMED</jvm-options>
+        <jvm-options>--add-opens=java.base/java.lang=ALL-UNNAMED</jvm-options>
+        <jvm-options>--add-opens=java.base/java.util=ALL-UNNAMED</jvm-options>
+        <jvm-options>--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED</jvm-options>
+        <jvm-options>--add-opens=java.naming/javax.naming.spi=ALL-UNNAMED</jvm-options>
       </java-config>
-      <thread-pools>
-        <thread-pool thread-pool-id="thread-pool-1"></thread-pool>
-      </thread-pools>
       <network-config>
         <protocols>
           <protocol name="http-listener-1">
-            <http header-buffer-length="8192" forced-response-type="text/plain; charset=iso-8859-1" default-virtual-server="server" max-connections="250" server-name="" default-response-type="text/plain; charset=iso-8859-1">
-              <file-cache enabled="false"></file-cache>
+            <http max-connections="250" default-virtual-server="server">
+              <file-cache></file-cache>
             </http>
           </protocol>
-          <protocol security-enabled="true" name="http-listener-2">
-            <http header-buffer-length="8192" forced-response-type="text/plain; charset=iso-8859-1" default-virtual-server="server" max-connections="250" server-name="" default-response-type="text/plain; charset=iso-8859-1">
-              <file-cache enabled="false"></file-cache>
+          <protocol name="http-listener-2" security-enabled="true">
+            <http max-connections="250" default-virtual-server="server">
+              <file-cache></file-cache>
             </http>
-            <ssl ssl2-enabled="true" cert-nickname="s1as" client-auth-enabled="true"></ssl>
+            <ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" cert-nickname="s1as"></ssl>
           </protocol>
           <protocol name="admin-listener">
-            <http header-buffer-length="8192" forced-response-type="text/plain; charset=iso-8859-1" default-virtual-server="__asadmin" max-connections="250" server-name="" default-response-type="text/plain; charset=iso-8859-1">
-              <file-cache enabled="false"></file-cache>
+            <http encoded-slash-enabled="true" max-connections="250" default-virtual-server="__asadmin">
+              <file-cache></file-cache>
             </http>
           </protocol>
         </protocols>
         <network-listeners>
-          <thread-pool max-thread-pool-size="20" min-thread-pool-size="2" thread-pool-id="http-thread-pool" max-queue-size="4096"></thread-pool>
-          <network-listener port="8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
-          <network-listener port="8181" protocol="http-listener-2" transport="tcp" name="http-listener-2" thread-pool="http-thread-pool"></network-listener>
-          <network-listener port="4848" enabled="false" protocol="admin-listener" transport="tcp" name="admin-listener" thread-pool="http-thread-pool"></network-listener>
+          <network-listener protocol="http-listener-1" port="8080" name="http-listener-1" thread-pool="http-thread-pool" transport="tcp"></network-listener>
+          <network-listener protocol="http-listener-2" port="8181" name="http-listener-2" thread-pool="http-thread-pool" transport="tcp"></network-listener>
+          <network-listener protocol="admin-listener" port="4848" name="admin-listener" thread-pool="admin-thread-pool" transport="tcp"></network-listener>
         </network-listeners>
         <transports>
           <transport name="tcp"></transport>
         </transports>
       </network-config>
+      <thread-pools>
+        <thread-pool name="admin-thread-pool" max-queue-size="256" max-thread-pool-size="50"></thread-pool>
+        <thread-pool name="http-thread-pool"></thread-pool>
+        <thread-pool name="thread-pool-1" max-thread-pool-size="200"></thread-pool>
+      </thread-pools>
+      <group-management-service>
+        <failure-detection></failure-detection>
+      </group-management-service>
+      <monitoring-service>
+        <module-monitoring-levels></module-monitoring-levels>
+      </monitoring-service>
+      <availability-service></availability-service>
     </config>
   </configs>
-  <servers>
-    <server name="server" config-ref="server-config">
-      <application-ref ref="adminapp" virtual-servers="__asadmin"></application-ref>
-      <application-ref ref="admingui" virtual-servers="__asadmin"></application-ref>
-      <application-ref ref="JBIFramework"></application-ref>
-      <application-ref ref="WSTXServices"></application-ref>
-      <application-ref ref="WSTCPConnectorLCModule"></application-ref>
-      <resource-ref ref="jdbc/__TimerPool"></resource-ref>
-      <resource-ref ref="jdbc/__CallFlowPool"></resource-ref>
-      <resource-ref ref="jdbc/__default"></resource-ref>
-    </server>
-  </servers>
   <property name="administrative.domain.name" value="domain1"></property>
+  <secure-admin special-admin-indicator="39e72cac-e399-453c-8232-6a0cebf10709">
+    <secure-admin-principal dn="CN=localhost,OU=GlassFish,O=Eclipse.org Foundation Inc,L=Ottawa,ST=Ontario,C=CA"></secure-admin-principal>
+    <secure-admin-principal dn="CN=localhost-instance,OU=GlassFish,O=Eclipse.org Foundation Inc,L=Ottawa,ST=Ontario,C=CA"></secure-admin-principal>
+  </secure-admin>
+  <clusters></clusters>
+  <applications></applications>
 </domain>
+