Initial Contribution

Signed-off-by: Vinay Vishal <vinay.vishal@oracle.com>
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
new file mode 100644
index 0000000..86e9b7c
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminAdapterTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.junit.Test;
+import org.junit.Before;
+import org.glassfish.api.admin.ParameterMap;
+import com.sun.enterprise.v3.admin.AdminAdapter;
+import java.util.Properties;
+
+
+/**
+ * junit test to test AdminAdapter class
+ */
+public class AdminAdapterTest {
+    private AdminAdapter aa = null;
+
+    @Test
+    public void extractParametersTest() {
+        ParameterMap props = aa.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");
+        correctProps.put("target", "server");
+        correctProps.put("libraries", "foo.jar");
+        correctProps.put("dbvendorname", "test");
+        correctProps.put("deploymentplan", "test");
+        for (String prop : correctProps.stringPropertyNames()) {
+            assertEquals("compare Properties",
+                correctProps.getProperty(prop), props.getOne(prop));
+        }
+    }
+
+    @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
new file mode 100644
index 0000000..7fa0a7a
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AdminCommandContextTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013, 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.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.glassfish.api.ActionReport;
+import org.glassfish.api.admin.AdminCommandContext;
+import org.glassfish.api.admin.AdminCommandContextImpl;
+import org.junit.Test;
+
+import com.sun.enterprise.v3.common.DoNothingActionReporter;
+import com.sun.enterprise.v3.common.PlainTextActionReporter;
+
+public class AdminCommandContextTest {
+
+    @Test
+    public void testSerialization() throws IOException, ClassNotFoundException {
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(os);
+        ActionReport report = new PlainTextActionReporter();
+        AdminCommandContext context = new AdminCommandContextImpl(null /* logger */, report);
+        report.setFailureCause(new RuntimeException("Test"));
+        oos.writeObject(context);
+        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
+    }
+
+}
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AnotherPublicMethod.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AnotherPublicMethod.java
new file mode 100644
index 0000000..838443e
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/AnotherPublicMethod.java
@@ -0,0 +1,34 @@
+/*
+ * 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.annotations.Service;
+import org.glassfish.api.admin.AdminCommand;
+import org.glassfish.api.admin.AdminCommandContext;
+import org.glassfish.api.ActionReport;
+
+/**
+ * public command with no visibility annotation
+ *
+ * @author Jerome Dochez
+ */
+@Service(name="notannoated-public-command")
+public class AnotherPublicMethod implements AdminCommand {
+    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/CommandRunnerTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerTest.java
new file mode 100644
index 0000000..054b46d
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CommandRunnerTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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
new file mode 100644
index 0000000..e499d52
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/ConfigAttributeSetTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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 com.sun.enterprise.v3.admin;
+
+import com.sun.enterprise.v3.common.HTMLActionReporter;
+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.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.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 java.beans.PropertyChangeEvent;
+
+/**
+ * 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 {
+
+    ServiceLocator habitat = Utils.instance.getHabitat(this);
+    PropertyChangeEvent event = null;
+
+    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";
+    }     
+
+    @Test
+     public void simpleAttributeSetTest() {
+
+        CommandRunnerImpl runner = habitat.getService(CommandRunnerImpl.class);
+        assertNotNull(runner);
+
+        // let's find our target
+        NetworkListener listener = null;
+        NetworkListeners service = habitat.getService(NetworkListeners.class);
+        for (NetworkListener l : service.getNetworkListener()) {
+            if ("http-listener-1".equals(l.getName())) {
+                listener = l;
+                break;
+            }
+        }
+        assertNotNull(listener);        
+
+        // Let's register a listener
+        ObservableBean bean = (ObservableBean) ConfigSupport.getImpl(listener);
+        bean.addListener(this);
+
+        // 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");
+
+        // execute the set command.
+        runner.getCommandInvocation("set", new HTMLActionReporter(), adminSubject()).parameters(parameters).execute();
+                                                                                                                                                                                                                           
+        // check the result.
+        String port = listener.getPort();
+        assertEquals(port, "8090");
+
+        // ensure events are delivered.
+        habitat.<Transactions>getService(Transactions.class).waitForDrain();
+        
+        // finally
+        bean.removeListener(this);
+
+        // check we recevied the event
+        assertNotNull(event);
+        assertEquals("8080", event.getOldValue());
+        assertEquals("8090", event.getNewValue());
+        assertEquals("port", event.getPropertyName());
+        
+    }
+
+    public UnprocessedChangeEvents changed(PropertyChangeEvent[] propertyChangeEvents) {
+        assertEquals("Array size", propertyChangeEvents.length, 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
new file mode 100644
index 0000000..70039c3
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/CreateProfilerTest.java
@@ -0,0 +1,291 @@
+/*
+ * 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 com.sun.enterprise.v3.admin;
+
+import com.sun.enterprise.config.serverbeans.JavaConfig;
+import com.sun.enterprise.config.serverbeans.Profiler;
+import com.sun.logging.LogDomains;
+
+import java.beans.PropertyVetoException;
+import java.util.List;
+
+import org.glassfish.api.admin.AdminCommandContextImpl;
+import org.jvnet.hk2.config.types.Property;
+
+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.hk2.api.ServiceLocator;
+import org.glassfish.tests.utils.Utils;
+import org.glassfish.tests.utils.ConfigApiTest;
+import org.jvnet.hk2.config.DomDocument;
+import org.jvnet.hk2.config.ConfigSupport;
+import org.jvnet.hk2.config.SingleConfigCode;
+import org.jvnet.hk2.config.TransactionFailure;
+
+/**
+ *
+ * @author Prashanth
+ */
+@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);
+    
+    @Override
+    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";
+    }    
+    
+    @Before
+    public void setUp() {
+        assertTrue(javaConfig!=null);
+        
+        // Get an instance of the CreateProfiler command
+        command = habitat.getService(CreateProfiler.class);
+        assertTrue(command!=null);
+        
+        context = new AdminCommandContextImpl(
+                LogDomains.getLogger(CreateProfilerTest.class, LogDomains.ADMIN_LOGGER),
+                habitat.<ActionReport>getService(ActionReport.class, "hk2-agent"));
+        
+    }
+
+    @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;
+            }                        
+        }, 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
+        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");
+        
+
+        //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);
+        
+        // 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());               
+    }
+    
+    /**
+     * Test of execute method, of class CreateProfiler with default values.
+     * asadmin create-profiler --nativelibrarypath "myNativeLibraryPath"
+     *          --enabled=true --classpath "myProfilerClasspath" testProfiler
+     */
+    @Test
+    public void testExecuteSuccessDefaultValues() {
+        // Only pass the required option and operand
+        assertTrue(parameters.size() == 0);
+        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
+        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());    
+    }
+
+    /**
+     * Test of execute method, creating a new when there is already one.
+     * asadmin create-profiler --nativelibrarypath "myNativeLibraryPath"
+     *          --enabled=true --classpath "myProfilerClasspath" testProfiler
+     */
+    @Test
+    public void testExecuteSuccessUpdateExisting() {
+        assertTrue(parameters.size() == 0);
+        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
+        assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
+        
+        parameters = new ParameterMap();
+        
+        //Create another profiler, see if it overrides the existing one
+        parameters.set("DEFAULT", "testProfilerNew");
+        
+
+        //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());    
+    }
+
+    /**
+     * Test of execute method, of class CreateProfiler when enabled set to junk
+     * asadmin create-profiler --nativelibrarypath "myNativeLibraryPath"
+     *          --enabled=true --classpath "myProfilerClasspath" testProfiler
+     */
+    @Test
+    public void testExecuteFailInvalidOptionEnabled() {
+        // Set invalid enabled option value: --enabled junk
+        //parameters = new ParameterMap();
+        assertTrue(parameters.size() == 0);
+        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);
+
+        // 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());
+    }
+    
+    /**
+     * Test of execute method, of class CreateProfiler when enabled has no value
+     * asadmin create-profiler --nativelibrarypath "myNativeLibraryPath"
+     *          --enabled=true --classpath "myProfilerClasspath" testProfiler
+     */
+    @Test
+    public void testExecuteSuccessNoValueOptionEnabled() {
+        // Set enabled without a value:  --enabled
+        assertTrue(parameters.size() == 0);
+        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);
+
+        //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());               
+    }
+}
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
new file mode 100644
index 0000000..9c0a936
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/PrivacyTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.junit.Test;
+import org.junit.Assert;
+import org.glassfish.api.admin.AdminCommand;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.tests.utils.Utils;
+
+/**
+ * Test the visibility annotation
+ */
+public class PrivacyTest {
+
+    @Test
+    public void privacyTests() {
+        AdminAdapter publicAdaper = new PublicAdminAdapter();
+        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));
+        adminCommand = habitat.getService(AdminCommand.class, "notannoated-public-command");
+        Assert.assertTrue(publicAdaper.validatePrivacy(adminCommand));
+        Assert.assertFalse(privateAdapter.validatePrivacy(adminCommand));
+        adminCommand = habitat.getService(AdminCommand.class, "simple-private-command");
+        Assert.assertFalse(publicAdaper.validatePrivacy(adminCommand));
+        Assert.assertTrue(privateAdapter.validatePrivacy(adminCommand));
+    }
+}
diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePrivateCommand.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePrivateCommand.java
new file mode 100644
index 0000000..1be8eea
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePrivateCommand.java
@@ -0,0 +1,36 @@
+/*
+ * 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.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.jvnet.hk2.annotations.Service;
+
+/**
+ * simple private command
+ */
+@Service(name="simple-private-command")
+@Visibility(Private.class)
+public class SimplePrivateCommand implements AdminCommand {
+
+    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/com/sun/enterprise/v3/admin/SimplePublicCommand.java
new file mode 100644
index 0000000..94955a9
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/SimplePublicCommand.java
@@ -0,0 +1,35 @@
+/*
+ * 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.annotations.Service;
+import org.glassfish.internal.api.Visibility;
+import org.glassfish.internal.api.Public;
+import org.glassfish.api.admin.AdminCommand;
+import org.glassfish.api.admin.AdminCommandContext;
+import org.glassfish.api.ActionReport;
+
+/**
+ * simple public command
+ */
+@Service(name="simple-public-command")
+@Visibility(Public.class)
+public class SimplePublicCommand implements AdminCommand {
+    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/TestDocument.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/TestDocument.java
new file mode 100644
index 0000000..c8b38b1
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/TestDocument.java
@@ -0,0 +1,47 @@
+/*
+ * 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
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/admin/progress/.gitkeep_empty_dir
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
new file mode 100644
index 0000000..99ebbf9
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/common/PlainTextActionReporterTest.java
@@ -0,0 +1,156 @@
+/*
+ * 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
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.sun.enterprise.v3.common;
+
+import org.glassfish.api.ActionReport;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @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();
+        report.setActionDescription("My Action Description");
+        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
+        ActionReport.MessagePart top = report.getTopMessagePart();
+        top.setMessage("FailureTest Message Here!!");
+        report.setFailureCause(new IndexOutOfBoundsException("Hi I am a phony Exception!!"));
+        report.writeReport(System.out);
+    }
+    @Test
+    public void babyTest() throws Exception {
+        ActionReport report = new PlainTextActionReporter();
+        report.setActionDescription("My Action Description");
+        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
+        ActionReport.MessagePart top = report.getTopMessagePart();
+        top.setMessage("BabyTest Message Here!!");
+        report.writeReport(System.out);
+    }
+
+    @Test
+    public void mamaTest() throws Exception {
+        ActionReport report = new PlainTextActionReporter();
+        report.setActionDescription("My Action Description");
+        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
+        ActionReport.MessagePart top = report.getTopMessagePart();
+        top.setMessage("Mama Test Top Message");
+        top.setChildrenType("Module");
+
+        for(int i = 0; i < 8; i++) {
+            ActionReport.MessagePart childPart = top.addChild();
+            childPart.setMessage("child" + i + " Message here");
+            childPart.addProperty("ChildKey" + i, "ChildValue" + i);
+            childPart.addProperty("AnotherChildKey" + i, "AnotherChildValue" + i);
+
+            ActionReport.MessagePart grandkids = childPart.addChild();
+            grandkids.setMessage("Grand Kids #" + i + " Top Message");
+        }
+        report.writeReport(System.out);
+    }
+
+    @Test
+    public void papaTest() throws Exception {
+        ActionReport report = new PlainTextActionReporter();
+        report.setActionDescription("My Action Description");
+        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
+        ActionReport.MessagePart top = report.getTopMessagePart();
+        top.setMessage("Papa Test Top Message");
+        top.setChildrenType("Module");
+
+        for(int i = 0; i < 8; i++) {
+            ActionReport.MessagePart childPart = top.addChild();
+            childPart.setMessage("child" + i + " Message here");
+            childPart.addProperty("ChildKey" + i, "ChildValue" + i);
+            childPart.addProperty("AnotherChildKey" + i, "AnotherChildValue" + i);
+
+            for(int j = 0; j < 3; j++) {
+                ActionReport.MessagePart grandkids = childPart.addChild();
+                grandkids.setMessage("Grand Kid#" + j + " from child#" + i + " Top Message");
+                grandkids.addProperty("Grand Kid#" + j + " from child#" + i + "key", "value");
+            }
+        }
+        report.writeReport(System.out);
+    }
+
+    @Test
+    public void aggregateTest() {
+        ActionReporter successfulRoot = new PlainTextActionReporter();
+        assert successfulRoot.hasSuccesses();
+        assert !successfulRoot.hasFailures();
+        assert !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();
+        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();
+        ActionReport successfulChild = warningChild.addSubActionsReport();
+        assert failedChild.hasSuccesses();
+        assert warningChild.hasSuccesses();
+        assert !warningChild.hasFailures();
+        StringBuilder sb = new StringBuilder();
+        successfulRoot.setMessage("sr");
+        successfulRoot.getCombinedMessages(successfulRoot, sb);
+        assertEquals("sr", sb.toString());
+        warningChild.setMessage("wc");
+        sb = new StringBuilder();
+        successfulRoot.getCombinedMessages(successfulRoot, sb);
+        assertEquals("sr\nwc", sb.toString());
+        failedChild.setMessage("fc");
+        sb = new StringBuilder();
+        successfulRoot.getCombinedMessages(successfulRoot, sb);
+        assertEquals("sr\nfc\nwc", sb.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
new file mode 100644
index 0000000..3b5d254
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/APIClassLoaderServiceImplTest.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2007, 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.server;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URL;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.sun.enterprise.module.ModuleLifecycleListener;
+import com.sun.enterprise.module.single.SingleModulesRegistry;
+
+public class APIClassLoaderServiceImplTest {
+	int loadClassCalls;
+	int getResourceCalls;
+
+	@Before
+	public void setUp() {
+		loadClassCalls = 0;
+		getResourceCalls = 0;
+	}
+
+	/**
+	 * This test ensures that the ApiClassLoaderService will not attempt to load a class or find a resource after 
+	 * an initial negative result until a module is installed or update. 
+	 */
+	@Test
+	public void testBlackList() {
+		APIClassLoaderServiceImpl apiClassLoaderService = new APIClassLoaderServiceImpl();
+
+		// set up a fake ModulesRegistry to exercise ModulesRegistry lifecycle
+		// events
+		FakeClassLoader classLoader = new FakeClassLoader(getClass()
+				.getClassLoader());
+		FakeModulesRegistry mr = new FakeModulesRegistry(classLoader);
+
+		apiClassLoaderService.mr = mr;
+
+		assertEquals(0, mr.getLifecycleListeners().size());
+
+		apiClassLoaderService.postConstruct();
+
+		List<ModuleLifecycleListener> lifecycleListeners = mr
+				.getLifecycleListeners();
+
+		assertEquals(
+				"apiClassLoaderService should have registered a lifecycle listener",
+				1, mr.getLifecycleListeners().size());
+
+		ModuleLifecycleListener lifecycleListener = lifecycleListeners
+				.iterator().next();
+
+		// assert that the classloader isn't called on to load the same bad
+		// class twice
+		assertEquals(0, loadClassCalls);
+
+		final String BAD_CLASSNAME = "BADCLASS";
+
+		try {
+			apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME);
+		} catch (ClassNotFoundException e) {
+			// ignore
+		}
+
+		assertEquals("Classloader.loadClass not called at all", 1,
+				loadClassCalls);
+
+		try {
+			apiClassLoaderService.getAPIClassLoader().loadClass(BAD_CLASSNAME);
+		} catch (ClassNotFoundException e) {
+			// ignore
+		}
+
+		assertEquals(
+				"blacklist not honored, excessive call to classloader.load", 1,
+				loadClassCalls);
+
+		// try same thing with resources
+
+		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);
+
+	}
+
+	class FakeModulesRegistry extends SingleModulesRegistry {
+		public FakeModulesRegistry(ClassLoader cl) {
+			super(cl);
+		}
+	}
+
+	class FakeClassLoader extends ClassLoader {
+		public FakeClassLoader(ClassLoader parent) {
+			super(parent);
+		}
+
+		@Override
+		public Class<?> loadClass(String arg0) throws ClassNotFoundException {
+			loadClassCalls++;
+			return super.loadClass(arg0);
+		}
+
+		@Override
+		protected URL findResource(String arg0) {
+			getResourceCalls++;
+			return super.findResource(arg0);
+		}
+
+	}
+}
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
new file mode 100644
index 0000000..5dcf885
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/AppServerStartupTest.java
@@ -0,0 +1,612 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.sun.enterprise.v3.server;
+
+
+import com.sun.appserv.server.util.Version;
+import com.sun.enterprise.module.ModulesRegistry;
+import com.sun.enterprise.module.bootstrap.StartupContext;
+import com.sun.enterprise.module.single.StaticModulesRegistry;
+import com.sun.enterprise.util.Result;
+
+import org.glassfish.api.FutureProvider;
+import org.glassfish.api.StartupRunLevel;
+import org.glassfish.api.admin.ServerEnvironment;
+import org.glassfish.api.event.EventListener;
+import org.glassfish.api.event.EventTypes;
+import org.glassfish.hk2.api.Context;
+import org.glassfish.hk2.api.DynamicConfiguration;
+import org.glassfish.hk2.api.DynamicConfigurationService;
+import org.glassfish.hk2.api.PostConstruct;
+import org.glassfish.hk2.api.PreDestroy;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.hk2.api.ServiceLocatorFactory;
+import org.glassfish.hk2.runlevel.RunLevel;
+import org.glassfish.hk2.runlevel.RunLevelContext;
+import org.glassfish.hk2.runlevel.RunLevelController;
+import org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext;
+import org.glassfish.hk2.runlevel.internal.RunLevelControllerImpl;
+import org.glassfish.hk2.utilities.AbstractActiveDescriptor;
+import org.glassfish.hk2.utilities.BuilderHelper;
+import org.glassfish.hk2.utilities.DescriptorBuilder;
+import org.glassfish.internal.api.InitRunLevel;
+import org.glassfish.internal.api.PostStartupRunLevel;
+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.jvnet.hk2.annotations.Service;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.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;
+
+
+/**
+ * AppServerStartup tests.
+ *
+ * @author Tom Beerbower
+ */
+public class AppServerStartupTest {
+
+    // ----- data members ----------------------------------------------------
+
+    /**
+     * The AppServerStartup instance to test.
+     */
+    private AppServerStartup as;
+
+    /**
+     * The test results.
+     */
+    private static Results results;
+
+
+    /**
+     * Map of exceptions to be thrown from the postConstruct.
+     */
+    private static Map<Class, RuntimeException> mapPostConstructExceptions = null;
+
+    /**
+     * 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 ServiceLocator testLocator;
+
+
+    // ----- test initialization ---------------------------------------------
+
+    private void initialize(ServiceLocator testLocator) {
+        DynamicConfigurationService dcs = testLocator.getService(DynamicConfigurationService.class);
+        DynamicConfiguration config = dcs.createDynamicConfiguration();
+
+        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new TestSystemTasks()));
+        
+        // These are services that would normally be started by hk2 core
+        config.addActiveDescriptor(AppServerStartup.AppInstanceListener.class);
+
+        AbstractActiveDescriptor<?> descriptor = BuilderHelper.createConstantDescriptor(new TestModulesRegistry());
+        descriptor.addContractType(ModulesRegistry.class);
+        config.addActiveDescriptor(descriptor);
+
+        descriptor = BuilderHelper.createConstantDescriptor(new ExecutorServiceFactory().provide());
+        descriptor.addContractType(ExecutorService.class);
+        config.addActiveDescriptor(descriptor);
+
+        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new ServerEnvironmentImpl()));
+        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new EventsImpl()));
+        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new Version()));
+        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new StartupContext()));
+
+        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.addUnbindFilter(BuilderHelper.createContractFilter(AsyncRunLevelContext.class.getName()));
+        config.bind(BuilderHelper.link(AsyncRunLevelContext.class).in(Singleton.class).build());
+
+        config.bind(BuilderHelper.link(AppServerStartup.class).build());
+
+        descriptor = BuilderHelper.createConstantDescriptor(testLocator);
+        descriptor.addContractType(ServiceLocator.class);
+        config.addActiveDescriptor(descriptor);
+
+        bindService(config, TestInitRunLevelService.class);
+        bindService(config, TestStartupService.class);
+        bindService(config, TestStartupRunLevelService.class);
+        bindService(config, TestPostStartupRunLevelService.class);
+
+        bindService(config, CommonClassLoaderServiceImpl.class);
+        bindService(config, APIClassLoaderServiceImpl.class);
+
+        bindService(config, APIExporterImpl.class);
+        config.commit();
+    }
+
+    private void bindService(DynamicConfiguration configurator, Class<?> service) {
+        final DescriptorBuilder descriptorBuilder = BuilderHelper.link(service);
+
+        final RunLevel rla = service.getAnnotation(RunLevel.class);
+        if (rla != null) {
+            descriptorBuilder.to(RunLevel.class).
+                    has(RunLevel.RUNLEVEL_VAL_META_TAG, Collections.singletonList(((Integer) rla.value()).toString())).
+                    has(RunLevel.RUNLEVEL_MODE_META_TAG, Collections.singletonList(((Integer) rla.mode()).toString()));
+
+            descriptorBuilder.in(RunLevel.class);
+        }
+        Class clazz = service;
+        while (clazz != null) {
+            Class<?>[] interfaces = clazz.getInterfaces();
+            for (int j = 0; j < interfaces.length; j++) {
+                descriptorBuilder.to(interfaces[j]);
+            }
+            clazz = clazz.getSuperclass();
+        }
+
+        final Named named = service.getAnnotation(Named.class);
+        if (named != null) {
+            descriptorBuilder.named(named.value());
+        }
+
+        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"));
+
+        // create the list of Futures returned from TestStartupService
+        listFutures.add(new TestFuture());
+
+        testRunAppServerStartup();
+    }
+
+
+    // ----- Results inner class ---------------------------------------------
+
+    /**
+     * Test results
+     */
+    private static class Results implements EventListener {
+        /**
+         * Map of constructed run level services to run levels.
+         */
+        private Map<Class, Integer> mapConstructedLevels = new HashMap<Class, Integer>();
+
+        /**
+         * Map of destroyed run level services to run levels.
+         */
+        private Map<Class, Integer> mapDestroyedLevels = new HashMap<Class, Integer>();
+
+        /**
+         * List of server events.
+         */
+        private List<EventTypes> listEvents = new LinkedList<EventTypes>();
+
+        /**
+         * The run level service.
+         */
+        private RunLevelController rls;
+
+        public Results(RunLevelController rls) {
+            this.rls = rls;
+        }
+
+        public void recordConstruction(Class cl) {
+            mapConstructedLevels.put(cl, rls.getCurrentProceeding().getProposedLevel());
+        }
+
+        public void recordDestruction(Class cl) {
+            mapDestroyedLevels.put(cl, rls.getCurrentRunLevel() + 1);
+        }
+
+        public boolean isConstructed(Class cl) {
+            return mapConstructedLevels.keySet().contains(cl);
+        }
+
+        public boolean isConstructed(Class cl, Integer runLevel) {
+            Integer recLevel = mapConstructedLevels.get(cl);
+            return recLevel != null && recLevel.equals(runLevel);
+        }
+
+        public boolean isDestroyed(Class cl) {
+            return mapDestroyedLevels.keySet().contains(cl);
+        }
+
+        public boolean isDestroyed(Class cl, Integer runLevel) {
+            Integer recLevel = mapDestroyedLevels.get(cl);
+            return recLevel != null && recLevel.equals(runLevel);
+        }
+
+        public List<EventTypes> getListEvents() {
+            return listEvents;
+        }
+
+        @Override
+        public void event(Event event) {
+            listEvents.add(event.type());
+        }
+    }
+
+
+    // ----- test services inner classes -------------------------------------
+
+    /**
+     * Abstract service that will update the test results from
+     * {@link PostConstruct#postConstruct()}.
+     */
+    public static abstract class TestService implements PostConstruct, PreDestroy {
+        @Override
+        public void postConstruct() {
+            AppServerStartupTest.results.recordConstruction(this.getClass());
+            if (mapPostConstructExceptions != null) {
+                RuntimeException ex = mapPostConstructExceptions.get(getClass());
+                if (ex != null) {
+                    throw ex;
+                }
+            }
+        }
+
+        @Override
+        public void preDestroy() {
+            AppServerStartupTest.results.recordDestruction(this.getClass());
+        }
+    }
+
+    /**
+     * Init service annotated with the new style {@link InitRunLevel} annotation.
+     */
+    @Service
+    @RunLevel(InitRunLevel.VAL)
+    public static class TestInitRunLevelService extends TestService {
+    }
+
+    /**
+     * Startup service that implements the old style Startup interface.
+     */
+    @RunLevel(StartupRunLevel.VAL)
+    @Service
+    public static class TestStartupService extends TestService implements FutureProvider {
+        // Make sure the other one starts first
+        @SuppressWarnings("unused")
+        @Inject
+        private TestStartupRunLevelService dependency;
+
+        @Override
+        public List getFutures() {
+            return listFutures;
+        }
+    }
+
+    /**
+     * Startup service annotated with the new style {@link StartupRunLevel} annotation.
+     */
+    @Service
+    @RunLevel(StartupRunLevel.VAL)
+    public static class TestStartupRunLevelService extends TestService {
+    }
+
+    /**
+     * Post-startup service annotated with the new style {@link PostStartupRunLevel} annotation.
+     */
+    @Service
+    @RunLevel(PostStartupRunLevel.VAL)
+    public static class TestPostStartupRunLevelService extends TestService {
+    }
+
+
+    // ----- TestSystemTasks inner classes -----------------------------------
+
+    /**
+     * Test {@link SystemTasks} implementation.
+     */
+    public static class TestSystemTasks implements SystemTasks {
+        @Override
+        public void writePidFile() {
+            // do nothing.
+        }
+    }
+
+
+    // ----- TestModulesRegistry inner classes -------------------------------
+
+    /**
+     * Test {@link ModulesRegistry} implementation.
+     */
+    public static class TestModulesRegistry extends StaticModulesRegistry {
+
+        public TestModulesRegistry() {
+            super(TestModulesRegistry.class.getClassLoader());
+        }
+    }
+
+
+    // ----- TestFuture inner classes ----------------------------------------
+
+    /**
+     * Future implementation used for test Startup implementations that
+     * also implement {@link FutureProvider}.
+     */
+    public static class TestFuture implements Future<Result<Thread>> {
+
+        private boolean canceled = false;
+        private boolean done = false;
+        private Exception resultException = null;
+
+        public TestFuture() {
+        }
+
+        public TestFuture(Exception resultException) {
+            this.resultException = resultException;
+        }
+
+        @Override
+        public boolean cancel(boolean b) {
+            if (done) {
+                return false;
+            }
+            canceled = done = true;
+            return true;
+        }
+
+        @Override
+        public boolean isCancelled() {
+            return canceled;
+        }
+
+        @Override
+        public boolean isDone() {
+            return done;
+        }
+
+        @Override
+        public Result<Thread> get() throws InterruptedException, ExecutionException {
+
+            Result<Thread> result = resultException == null ?
+                    new Result<Thread>(Thread.currentThread()) :
+                    new Result<Thread>(resultException);
+            done = true;
+
+            return result;
+        }
+
+        @Override
+        public Result<Thread> get(long l, TimeUnit timeUnit)
+                throws InterruptedException, ExecutionException, TimeoutException {
+            return get();
+        }
+    }
+}
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
new file mode 100644
index 0000000..2e964db
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/admin/CommandRunnerTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 javax.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
new file mode 100644
index 0000000..9fc18c8
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java
@@ -0,0 +1,236 @@
+/*
+ * 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;
+
+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 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.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 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;
+
+/**
+ * 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 {
+
+    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);
+        }
+    };
+
+    public String getFileName() {
+        return "DomainTest";
+    }
+
+    @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;
+                        }
+
+                    }));
+        }
+        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.delete();
+        application.mkdirs();
+
+        Events events = habitat.getService(Events.class);
+        events.register(listener);
+    }
+
+    @AfterClass
+    public static void tearDown() {
+       if (application != null) {
+           application.delete();
+       }
+    }
+
+    public static List<EventTypes> getSingletonModuleSuccessfullDeploymentEvents() {
+        ArrayList<EventTypes> events = new ArrayList<EventTypes>();
+        events.add(Deployment.MODULE_PREPARED);
+        events.add(Deployment.MODULE_LOADED);
+        events.add(Deployment.MODULE_STARTED);
+        events.add(Deployment.APPLICATION_PREPARED);
+        events.add(Deployment.APPLICATION_LOADED);
+        events.add(Deployment.APPLICATION_STARTED);
+        return events;
+    }
+
+    public static List<EventTypes> getSingletonModuleSuccessfullUndeploymentEvents() {
+        ArrayList<EventTypes> events = new ArrayList<EventTypes>();
+        events.add(Deployment.MODULE_STOPPED);
+        events.add(Deployment.MODULE_UNLOADED);
+        events.add(Deployment.MODULE_CLEANED);
+        events.add(Deployment.APPLICATION_STOPPED);
+        events.add(Deployment.APPLICATION_UNLOADED);
+        events.add(Deployment.APPLICATION_CLEANED);
+        return events;
+    }
+
+    public static List<EventTypes> asynchonousEvents() {
+        ArrayList<EventTypes> events = new ArrayList<EventTypes>();
+        events.add(Deployment.DEPLOYMENT_START);
+        events.add(Deployment.DEPLOYMENT_SUCCESS);        
+        events.add(Deployment.UNDEPLOYMENT_START);
+        events.add(Deployment.UNDEPLOYMENT_SUCCESS);
+        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
new file mode 100644
index 0000000..7f5fe4d
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/container/FakeContainer.java
@@ -0,0 +1,39 @@
+/*
+ * 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
new file mode 100644
index 0000000..1509d5e
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/container/FakeSniffer.java
@@ -0,0 +1,100 @@
+/*
+ * 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.Module;
+
+/**
+ * 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 Module[] 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
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/embedded/.gitkeep_empty_dir
diff --git a/nucleus/core/kernel/src/test/resources/DomainTest.xml b/nucleus/core/kernel/src/test/resources/DomainTest.xml
new file mode 100644
index 0000000..cfd9c01
--- /dev/null
+++ b/nucleus/core/kernel/src/test/resources/DomainTest.xml
@@ -0,0 +1,151 @@
+<!--
+
+    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
+
+-->
+
+<domain log-root="${com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}/applications">
+  <applications>
+  </applications>
+  <resources/>
+  <configs>
+    <config name="server-config">
+      <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>
+      </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>
+          <property name="jaas-context" value="fileRealm"></property>
+        </auth-realm>
+        <auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="file">
+          <property name="file" value="${com.sun.aas.instanceRoot}/config/keyfile"></property>
+          <property name="jaas-context" value="fileRealm"></property>
+        </auth-realm>
+        <auth-realm classname="com.sun.enterprise.security.auth.realm.certificate.CertificateRealm" name="certificate"></auth-realm>
+        <jacc-provider policy-provider="com.sun.enterprise.security.provider.PolicyWrapper" name="default" policy-configuration-factory-provider="com.sun.enterprise.security.provider.PolicyConfigurationFactoryImpl">
+          <property name="repository" value="${com.sun.aas.instanceRoot}/generated/policy"></property>
+        </jacc-provider>
+        <audit-module classname="com.sun.enterprise.security.ee.Audit" name="default">
+          <property name="auditOn" value="false"></property>
+        </audit-module>
+        <message-security-config auth-layer="SOAP">
+          <provider-config provider-type="client" provider-id="XWS_ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule">
+            <request-policy auth-source="content"></request-policy>
+            <response-policy auth-source="content"></response-policy>
+            <property name="encryption.key.alias" value="s1as"></property>
+            <property name="signature.key.alias" value="s1as"></property>
+            <property name="dynamic.username.password" value="false"></property>
+            <property name="debug" value="false"></property>
+          </provider-config>
+          <provider-config provider-type="client" provider-id="ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule">
+            <request-policy auth-source="content"></request-policy>
+            <response-policy auth-source="content"></response-policy>
+            <property name="encryption.key.alias" value="s1as"></property>
+            <property name="signature.key.alias" value="s1as"></property>
+            <property name="dynamic.username.password" value="false"></property>
+            <property name="debug" value="false"></property>
+            <property name="security.config" value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml"></property>
+          </provider-config>
+          <provider-config provider-type="server" provider-id="XWS_ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule">
+            <request-policy auth-source="content"></request-policy>
+            <response-policy auth-source="content"></response-policy>
+            <property name="encryption.key.alias" value="s1as"></property>
+            <property name="signature.key.alias" value="s1as"></property>
+            <property name="debug" value="false"></property>
+          </provider-config>
+          <provider-config provider-type="server" provider-id="ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule">
+            <request-policy auth-source="content"></request-policy>
+            <response-policy auth-source="content"></response-policy>
+            <property name="encryption.key.alias" value="s1as"></property>
+            <property name="signature.key.alias" value="s1as"></property>
+            <property name="debug" value="false"></property>
+            <property name="security.config" value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml"></property>
+          </provider-config>
+        </message-security-config>
+      </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>
+        <jvm-options>-Djava.endorsed.dirs=${com.sun.aas.installRoot}/lib/endorsed</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>-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>-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory</jvm-options>
+        <jvm-options>-Dcom.sun.enterprise.taglibs=javax.servlet.jsp.jstl.jar,javax.faces.jar</jvm-options>
+        <jvm-options>-Dcom.sun.enterprise.taglisteners=javax.faces.jar</jvm-options>
+        <jvm-options>-XX:NewRatio=2</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>
+          </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>
+            </http>
+            <ssl ssl2-enabled="true" cert-nickname="s1as" client-auth-enabled="true"></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>
+          </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-listeners>
+        <transports>
+          <transport name="tcp"></transport>
+        </transports>
+      </network-config>
+    </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>
+</domain>