[jboss-cvs] JBossAS SVN: r99519 - projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jan 17 23:48:10 EST 2010


Author: ALRubinger
Date: 2010-01-17 23:48:10 -0500 (Sun, 17 Jan 2010)
New Revision: 99519

Added:
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/BootstrapXmlTestBase.java
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/BootstrapXmlUrlTestCase.java
Removed:
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerUnitTestCase.java
Log:
[JBBOOT-118] Rename tests to be clearer in impl-as, remove duplicate tests

Deleted: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java	2010-01-18 04:36:16 UTC (rev 99518)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java	2010-01-18 04:48:10 UTC (rev 99519)
@@ -1,224 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.bootstrap.impl.as.server;
-
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
-import org.jboss.bootstrap.api.as.server.JBossASServer;
-import org.jboss.bootstrap.api.lifecycle.LifecycleState;
-import org.jboss.bootstrap.impl.as.config.BasicJBossASServerConfig;
-import org.jboss.bootstrap.spi.as.server.MCJBossASServerProvider;
-import org.jboss.bootstrap.spi.server.ServerInitializer;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.logging.Logger;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * AbstractMCServerTest
- * 
- * Abstract test class used to setup basic functionality for MCServer testing
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
- * @version $Revision: $
- */
-public class AbstractMCServerTest
-{
-   //-------------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   private static final Logger log = Logger.getLogger(AbstractMCServerTest.class);
-
-   //-------------------------------------------------------------------------------------||
-   // Instance Members -------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * The server to test
-    */
-   private JBossASServer server;
-
-   //-------------------------------------------------------------------------------------||
-   // Lifecycle --------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Creates the server
-    */
-   @Before
-   public void createServer() throws Throwable
-   {
-      // Create the server
-      final JBossASServerConfig config = createServerConfig();
-      this.server = new NoOpJBossASServer();
-      this.server.setConfiguration(config);
-      log.info("Created: " + this.server);
-   }
-
-   /**
-    * If started, shuts down the server
-    * @throws Throwable
-    */
-   @After
-   public void shutdownServerAndClear() throws Throwable
-   {
-      final JBossASServer server = this.server;
-      if (server.getState().equals(LifecycleState.STARTED))
-      {
-         server.shutdown();
-      }
-      // Server didn't start up cleanly, so manually run init cleanup
-      else
-      {
-         final MCJBossASServerProvider provider = (MCJBossASServerProvider) server;
-         final ServerInitializer<JBossASServer, JBossASServerConfig> initializer = provider.getServerInitializer();
-         if (initializer != null)
-         {
-            initializer.cleanup(provider);
-         }
-      }
-
-      // Clear the server
-      this.server = null;
-      log.info("Server cleared");
-   }
-
-   //-------------------------------------------------------------------------------------||
-   // Internal Helper Methods ------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Return the configured {@link JBossASServer}
-    * @return The server
-    */
-   protected JBossASServer getServer()
-   {
-      return server;
-   }
-
-   /**
-    * Obtains a server configuration populated with all URLs and name
-    */
-   private JBossASServerConfig createServerConfig()
-   {
-      // Get the home
-      final URL home = this.getHome();
-
-      // Populate and return
-      return new BasicJBossASServerConfig().bootstrapHome(home);
-   }
-
-   /**
-    * Obtains the home relative to this test location
-    * @return
-    */
-   protected URL getHome()
-   {
-      return this.getClass().getProtectionDomain().getCodeSource().getLocation();
-   }
-
-   /**
-    * Installs a POJO into the specified server
-    * 
-    * @param server
-    * @throws Throwable
-    */
-   protected void installPojo(final MCJBossASServerProvider server, final String mcBindName) throws Throwable
-   {
-      // Construct BeanMetaData
-      final Pojo pojo = new Pojo();
-      final BeanMetaData beanMD = BeanMetaDataBuilder.createBuilder(mcBindName, pojo.getClass().getName())
-            .getBeanMetaData();
-
-      // Get the controller and install
-      log.info("Installing test POJO under name " + mcBindName + " into " + server + "...");
-      server.getKernel().getController().install(beanMD, pojo);
-   }
-
-   /**
-    * Ensures that the POJO is installed at {@link AbstractMCServerTest#BIND_NAME_POJO}
-    * and has no expected value
-    * 
-    * @param mcBindName
-    * @throws Throwable
-    */
-   protected void assertPojo(final String mcBindName) throws Throwable
-   {
-      this.assertPojo(mcBindName, null);
-   }
-
-   /**
-    * Ensures that the POJO is installed in the provided bind name
-    * and has the expected value
-    * 
-    * @param mcBindName
-    * @param expectedValue
-    * @throws Throwable
-    */
-   protected void assertPojo(final String mcBindName, final String expectedValue) throws Throwable
-   {
-      // Log
-      log.trace("Asserting POJO installed as expected...");
-
-      // Get the underlying bean context
-      final KernelController controller = ((MCJBossASServerProvider) this.server).getKernel().getController();
-      final ControllerContext beanContext = controller.getContext(mcBindName, null);
-      TestCase.assertNotNull("beanContext from " + mcBindName + " is null", beanContext);
-      final ControllerState beanState = beanContext.getState();
-      TestCase.assertEquals("POJO did not properly install, error was: " + beanContext.getError(),
-            ControllerState.INSTALLED, beanState);
-
-      // Get Pojo
-      final Object target = beanContext.getTarget();
-      TestCase.assertNotNull("POJO could not be found in MC at: " + mcBindName, target);
-      Pojo pojo = null;
-      try
-      {
-         pojo = Pojo.class.cast(target);
-      }
-      catch (ClassCastException cce)
-      {
-         TestCase.fail("Test pojo was not expected type: " + cce);
-      }
-
-      // Test Lifecycle was invoked by MC
-      final boolean pojoStarted = pojo.isStarted();
-      TestCase.assertTrue("Start lifecycle was not called upon the POJO", pojoStarted);
-
-      // Test expected value
-      final String actualvalue = pojo.getValue();
-      TestCase.assertEquals("POJO did not have expected value", expectedValue, actualvalue);
-
-      // Log
-      log.info("POJO installed as expected with value: " + actualvalue);
-   }
-}

Copied: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/BootstrapXmlTestBase.java (from rev 99518, projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java)
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/BootstrapXmlTestBase.java	                        (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/BootstrapXmlTestBase.java	2010-01-18 04:48:10 UTC (rev 99519)
@@ -0,0 +1,224 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.api.as.server.JBossASServer;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.impl.as.config.BasicJBossASServerConfig;
+import org.jboss.bootstrap.spi.as.server.MCJBossASServerProvider;
+import org.jboss.bootstrap.spi.server.ServerInitializer;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * Base support for tests to ensure that the main bootstrap.xml (by URL) is parsed 
+ * and its referents deployed as expected during the server start 
+ * lifecycle
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class BootstrapXmlTestBase
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(BootstrapXmlTestBase.class);
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * The server to test
+    */
+   private JBossASServer server;
+
+   //-------------------------------------------------------------------------------------||
+   // Lifecycle --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates the server
+    */
+   @Before
+   public void createServer() throws Throwable
+   {
+      // Create the server
+      final JBossASServerConfig config = createServerConfig();
+      this.server = new NoOpJBossASServer();
+      this.server.setConfiguration(config);
+      log.info("Created: " + this.server);
+   }
+
+   /**
+    * If started, shuts down the server
+    * @throws Throwable
+    */
+   @After
+   public void shutdownServerAndClear() throws Throwable
+   {
+      final JBossASServer server = this.server;
+      if (server.getState().equals(LifecycleState.STARTED))
+      {
+         server.shutdown();
+      }
+      // Server didn't start up cleanly, so manually run init cleanup
+      else
+      {
+         final MCJBossASServerProvider provider = (MCJBossASServerProvider) server;
+         final ServerInitializer<JBossASServer, JBossASServerConfig> initializer = provider.getServerInitializer();
+         if (initializer != null)
+         {
+            initializer.cleanup(provider);
+         }
+      }
+
+      // Clear the server
+      this.server = null;
+      log.info("Server cleared");
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Internal Helper Methods ------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Return the configured {@link JBossASServer}
+    * @return The server
+    */
+   protected JBossASServer getServer()
+   {
+      return server;
+   }
+
+   /**
+    * Obtains a server configuration populated with all URLs and name
+    */
+   private JBossASServerConfig createServerConfig()
+   {
+      // Get the home
+      final URL home = this.getHome();
+
+      // Populate and return
+      return new BasicJBossASServerConfig().bootstrapHome(home);
+   }
+
+   /**
+    * Obtains the home relative to this test location
+    * @return
+    */
+   protected URL getHome()
+   {
+      return this.getClass().getProtectionDomain().getCodeSource().getLocation();
+   }
+
+   /**
+    * Installs a POJO into the specified server
+    * 
+    * @param server
+    * @throws Throwable
+    */
+   protected void installPojo(final MCJBossASServerProvider server, final String mcBindName) throws Throwable
+   {
+      // Construct BeanMetaData
+      final Pojo pojo = new Pojo();
+      final BeanMetaData beanMD = BeanMetaDataBuilder.createBuilder(mcBindName, pojo.getClass().getName())
+            .getBeanMetaData();
+
+      // Get the controller and install
+      log.info("Installing test POJO under name " + mcBindName + " into " + server + "...");
+      server.getKernel().getController().install(beanMD, pojo);
+   }
+
+   /**
+    * Ensures that the POJO is installed at {@link BootstrapXmlTestBase#BIND_NAME_POJO}
+    * and has no expected value
+    * 
+    * @param mcBindName
+    * @throws Throwable
+    */
+   protected void assertPojo(final String mcBindName) throws Throwable
+   {
+      this.assertPojo(mcBindName, null);
+   }
+
+   /**
+    * Ensures that the POJO is installed in the provided bind name
+    * and has the expected value
+    * 
+    * @param mcBindName
+    * @param expectedValue
+    * @throws Throwable
+    */
+   protected void assertPojo(final String mcBindName, final String expectedValue) throws Throwable
+   {
+      // Log
+      log.trace("Asserting POJO installed as expected...");
+
+      // Get the underlying bean context
+      final KernelController controller = ((MCJBossASServerProvider) this.server).getKernel().getController();
+      final ControllerContext beanContext = controller.getContext(mcBindName, null);
+      TestCase.assertNotNull("beanContext from " + mcBindName + " is null", beanContext);
+      final ControllerState beanState = beanContext.getState();
+      TestCase.assertEquals("POJO did not properly install, error was: " + beanContext.getError(),
+            ControllerState.INSTALLED, beanState);
+
+      // Get Pojo
+      final Object target = beanContext.getTarget();
+      TestCase.assertNotNull("POJO could not be found in MC at: " + mcBindName, target);
+      Pojo pojo = null;
+      try
+      {
+         pojo = Pojo.class.cast(target);
+      }
+      catch (ClassCastException cce)
+      {
+         TestCase.fail("Test pojo was not expected type: " + cce);
+      }
+
+      // Test Lifecycle was invoked by MC
+      final boolean pojoStarted = pojo.isStarted();
+      TestCase.assertTrue("Start lifecycle was not called upon the POJO", pojoStarted);
+
+      // Test expected value
+      final String actualvalue = pojo.getValue();
+      TestCase.assertEquals("POJO did not have expected value", expectedValue, actualvalue);
+
+      // Log
+      log.info("POJO installed as expected with value: " + actualvalue);
+   }
+}

Copied: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/BootstrapXmlUrlTestCase.java (from rev 99509, projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java)
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/BootstrapXmlUrlTestCase.java	                        (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/BootstrapXmlUrlTestCase.java	2010-01-18 04:48:10 UTC (rev 99519)
@@ -0,0 +1,355 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.bootstrap.api.as.server.JBossASServer;
+import org.jboss.bootstrap.impl.base.config.InvalidBootstrapURLException;
+import org.jboss.logging.Logger;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+
+/**
+ * Test Cases to ensure that the MC Server Implementation handles the 
+ * bootstrapUrl correctly.
+ * 
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $    
+ */
+public class BootstrapXmlUrlTestCase extends BootstrapXmlTestBase
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(BootstrapXmlUrlTestCase.class);
+
+   private static final String NAME_BOOTSTRAP_POJO = "bootstrap-pojo.xml";
+
+   private static final String NAME_BOOTSTRAP_URLS = "bootstrap-urls.xml";
+
+   private static final String NAME_BOOTSTRAP_SLASH = "bootstrap-starting-slash.xml";
+
+   private static final String BIND_NAME_POJO = "org.jboss.bootstrap.test.POJO";
+
+   private static final String BIND_NAME_POJO_TWO = "org.jboss.bootstrap.test.POJO_2";
+
+   private static final int HTTP_TEST_BIND_PORT = 12345;
+
+   private static final String CONTENT_TYPE_XML = "text/xml";
+
+   private static final String TEST_HTTP_ROOT = "http://localhost:" + HTTP_TEST_BIND_PORT;
+
+   private static final String TEST_HTTP_PATH_BASE = "/path/";
+
+   private static final String TEST_HTTP_URL = TEST_HTTP_ROOT + TEST_HTTP_PATH_BASE + NAME_BOOTSTRAP_POJO;
+
+   private static final String TEST_HTTP_MULTI_URL = TEST_HTTP_ROOT + TEST_HTTP_PATH_BASE + NAME_BOOTSTRAP_URLS;
+
+   private static Server httpServer;
+
+   //-------------------------------------------------------------------------------------||
+   // Lifecycle --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Starts up an embedded HTTP Server to serve out the Mock 
+    * 
+    * file:/ URLs)
+    */
+   @BeforeClass
+   public static void startHttpServer()
+   {
+      // Start an Embedded HTTP Server
+      final Handler handler = new StaticFileHandler();
+      httpServer = new Server(HTTP_TEST_BIND_PORT);
+      httpServer.setHandler(handler);
+      try
+      {
+         httpServer.start();
+      }
+      catch (final Exception e)
+      {
+         throw new RuntimeException("Could not start server");
+      }
+      log.info("HTTP Server Started: " + httpServer);
+   }
+
+   /**
+    * Shuts down and clears the Embedded HTTP Server
+    */
+   @AfterClass
+   public static void shutdownHttpServer()
+   {
+      if (httpServer != null)
+      {
+         try
+         {
+            httpServer.stop();
+         }
+         catch (final Exception e)
+         {
+            // Swallow
+            log.error("Could not stop HTTP Server cleanly", e);
+         }
+         log.info("HTTP Server Stopped: " + httpServer);
+         httpServer = null;
+      }
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Tests ------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Ensures that any valid http:// URL can be processed as a bootstrapUrl.
+    * 
+    * @throws Throwable
+    */
+   @Test
+   public void testBootstrapHttpUrl() throws Throwable
+   {
+      // Log
+      log.info("testBootstrapHttpUrl");
+
+      final JBossASServer server = getServer();
+
+      // Initialize
+      server.getConfiguration().bootstrapUrl(TEST_HTTP_URL);
+
+      // Start the server
+      server.start();
+
+      assertPojo(BIND_NAME_POJO);
+   }
+
+   /**
+    * Ensures that <url> elements support both relative and fully qualified format
+    * 
+    * @throws Throwable
+    */
+   @Test
+   public void testBootstrapHttpUrlMultiNested() throws Throwable
+   {
+      // Log
+      log.info("testBootstrapHttpUrlMultiNested");
+
+      final JBossASServer server = getServer();
+
+      // Initialize
+      server.getConfiguration().bootstrapUrl(TEST_HTTP_MULTI_URL);
+
+      // Start the server
+      server.start();
+
+      assertPojo(BIND_NAME_POJO);
+      assertPojo(BIND_NAME_POJO_TWO);
+   }
+
+   /**
+    * Ensures that any valid file:// URL can be processed as a bootstrapUrl.
+    * 
+    * @throws Throwable
+    */
+   @Test
+   public void testBootstrapFileUrl() throws Throwable
+   {
+      // Log
+      log.info("testBootstrapFileUrl");
+
+      final JBossASServer server = getServer();
+
+      URL bootstrapUrl = new URL(getHome(), NAME_BOOTSTRAP_POJO);
+
+      // Initialize
+      server.getConfiguration().bootstrapUrl(bootstrapUrl);
+
+      // Start the server
+      server.start();
+
+      assertPojo(BIND_NAME_POJO);
+   }
+
+   /**
+    * Ensures that any valid file:// URL can be processed as a bootstrapUrl and will 
+    * correctly handle both relative and fully qualified <url> elements.
+    * 
+    * @throws Throwable
+    */
+   @Test
+   public void testBootstrapFileUrlMultiNested() throws Throwable
+   {
+      // Log
+      log.info("testBootstrapFileUrlMultiNested");
+
+      final JBossASServer server = getServer();
+
+      URL bootstrapUrl = new URL(getHome(), NAME_BOOTSTRAP_URLS);
+
+      // Initialize
+      server.getConfiguration().bootstrapUrl(bootstrapUrl);
+
+      // Start the server
+      server.start();
+
+      assertPojo(BIND_NAME_POJO);
+      assertPojo(BIND_NAME_POJO_TWO);
+   }
+
+   /**
+    * Ensures a bootstrapUrl created by the bootstrapHome property functions correctly for both 
+    * relative and fully qualified <url> elements  
+    * 
+    * @throws Throwable
+    */
+   @Test
+   public void testBootstrapUrlFromBootstrapHome() throws Throwable
+   {
+      // Log
+      log.info("testBootstrapUrlFromBootstrapHome");
+
+      final JBossASServer server = getServer();
+
+      // Set name to deploy a test POJO via XML
+      server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_URLS);
+
+      // Start the server
+      server.start();
+
+      assertPojo(BIND_NAME_POJO);
+      assertPojo(BIND_NAME_POJO_TWO);
+   }
+
+   /**
+    * Test to show relative URL will not function with a starting slash in the bootstrapUrl. 
+    * 
+    * @throws Throwable
+    */
+   @Test
+   public void testBootstrapUrlStartsWithSlash() throws Throwable
+   {
+      // Log
+      log.info("testBootstrapUrlStartsWithSlash");
+
+      final JBossASServer server = getServer();
+
+      server.getConfiguration().bootstrapName("/" + NAME_BOOTSTRAP_POJO);
+
+      try
+      {
+         // Start the server
+         server.start();
+         fail("Should have thrown InvalidBootstrapUrlFormatException");
+      }
+      catch (final InvalidBootstrapURLException expectedException)
+      {
+         // Ignore expected InvalidBootstrapUrlFormatException
+      }
+   }
+
+   /**
+    * Test to show relative URL will not function with a starting slash in a <url> element  
+    * 
+    * @throws Throwable
+    */
+   @Test
+   public void testNestedUrlStartsWithSlash() throws Throwable
+   {
+      // Log
+      log.info("testNestedUrlStartsWithSlash");
+
+      final JBossASServer server = getServer();
+
+      server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_SLASH);
+
+      try
+      {
+         // Start the server
+         server.start();
+         fail("Should have thrown InvalidBootstrapUrlFormatException");
+      }
+      catch (final InvalidBootstrapURLException iburle)
+      {
+         // Good
+      }
+
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Internal Classes--------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Jetty Handler to serve a file contents over HTTP
+    */
+   private static class StaticFileHandler extends AbstractHandler implements Handler
+   {
+      /*
+       * (non-Javadoc)
+       * @see org.mortbay.jetty.Handler#handle(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
+       */
+      public void handle(final String target, final HttpServletRequest request, final HttpServletResponse response,
+            final int dispatch) throws IOException, ServletException
+      {
+         // Set content type and status before we write anything to the stream
+         response.setContentType(CONTENT_TYPE_XML);
+         response.setStatus(HttpServletResponse.SC_OK);
+
+         // Get local path (removed /path from the target)
+         final String localPath = target.replace(TEST_HTTP_PATH_BASE, "/");
+
+         //  Get local stream
+         final InputStream stream = this.getClass().getResourceAsStream(localPath);
+
+         // Write out each line
+         final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+         final PrintWriter writer = response.getWriter();
+         String line = null;
+         while ((line = reader.readLine()) != null)
+         {
+            writer.println(line);
+         }
+         writer.flush();
+         reader.close();
+         writer.close();
+      }
+   }
+
+}

Deleted: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java	2010-01-18 04:36:16 UTC (rev 99518)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java	2010-01-18 04:48:10 UTC (rev 99519)
@@ -1,355 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.bootstrap.impl.as.server;
-
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.net.URL;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.bootstrap.api.as.server.JBossASServer;
-import org.jboss.bootstrap.impl.base.config.InvalidBootstrapURLException;
-import org.jboss.logging.Logger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.AbstractHandler;
-
-/**
- * MCServerBootstrapUrlTestCase
- * 
- * Test Cases to ensure that the MC Server Implementation handles the bootstrapUrl correctly.
- * 
- * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
- * @version $Revision: $    
- */
-public class MCServerBootstrapUrlTestCase extends AbstractMCServerTest
-{
-   //-------------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   private static final Logger log = Logger.getLogger(MCServerBootstrapUrlTestCase.class);
-
-   private static final String NAME_BOOTSTRAP_POJO = "bootstrap-pojo.xml";
-
-   private static final String NAME_BOOTSTRAP_URLS = "bootstrap-urls.xml";
-
-   private static final String NAME_BOOTSTRAP_SLASH = "bootstrap-starting-slash.xml";
-
-   private static final String BIND_NAME_POJO = "org.jboss.bootstrap.test.POJO";
-
-   private static final String BIND_NAME_POJO_TWO = "org.jboss.bootstrap.test.POJO_2";
-
-   private static final int HTTP_TEST_BIND_PORT = 12345;
-
-   private static final String CONTENT_TYPE_XML = "text/xml";
-
-   private static final String TEST_HTTP_ROOT = "http://localhost:" + HTTP_TEST_BIND_PORT;
-
-   private static final String TEST_HTTP_PATH_BASE = "/path/";
-
-   private static final String TEST_HTTP_URL = TEST_HTTP_ROOT + TEST_HTTP_PATH_BASE + NAME_BOOTSTRAP_POJO;
-
-   private static final String TEST_HTTP_MULTI_URL = TEST_HTTP_ROOT + TEST_HTTP_PATH_BASE + NAME_BOOTSTRAP_URLS;
-
-   private static Server httpServer;
-
-   //-------------------------------------------------------------------------------------||
-   // Lifecycle --------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Starts up an embedded HTTP Server to serve out the Mock 
-    * 
-    * file:/ URLs)
-    */
-   @BeforeClass
-   public static void startHttpServer()
-   {
-      // Start an Embedded HTTP Server
-      final Handler handler = new StaticFileHandler();
-      httpServer = new Server(HTTP_TEST_BIND_PORT);
-      httpServer.setHandler(handler);
-      try
-      {
-         httpServer.start();
-      }
-      catch (final Exception e)
-      {
-         throw new RuntimeException("Could not start server");
-      }
-      log.info("HTTP Server Started: " + httpServer);
-   }
-
-   /**
-    * Shuts down and clears the Embedded HTTP Server
-    */
-   @AfterClass
-   public static void shutdownHttpServer()
-   {
-      if (httpServer != null)
-      {
-         try
-         {
-            httpServer.stop();
-         }
-         catch (final Exception e)
-         {
-            // Swallow
-            log.error("Could not stop HTTP Server cleanly", e);
-         }
-         log.info("HTTP Server Stopped: " + httpServer);
-         httpServer = null;
-      }
-   }
-
-   //-------------------------------------------------------------------------------------||
-   // Tests ------------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Ensures that any valid http:// URL can be processed as a bootstrapUrl.
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testBootstrapHttpUrl() throws Throwable
-   {
-      // Log
-      log.info("testBootstrapHttpUrl");
-
-      final JBossASServer server = getServer();
-
-      // Initialize
-      server.getConfiguration().bootstrapUrl(TEST_HTTP_URL);
-
-      // Start the server
-      server.start();
-
-      assertPojo(BIND_NAME_POJO);
-   }
-
-   /**
-    * Ensures that <url> elements support both relative and fully qualified format
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testBootstrapHttpUrlMultiNested() throws Throwable
-   {
-      // Log
-      log.info("testBootstrapHttpUrlMultiNested");
-
-      final JBossASServer server = getServer();
-
-      // Initialize
-      server.getConfiguration().bootstrapUrl(TEST_HTTP_MULTI_URL);
-
-      // Start the server
-      server.start();
-
-      assertPojo(BIND_NAME_POJO);
-      assertPojo(BIND_NAME_POJO_TWO);
-   }
-
-   /**
-    * Ensures that any valid file:// URL can be processed as a bootstrapUrl.
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testBootstrapFileUrl() throws Throwable
-   {
-      // Log
-      log.info("testBootstrapFileUrl");
-
-      final JBossASServer server = getServer();
-
-      URL bootstrapUrl = new URL(getHome(), NAME_BOOTSTRAP_POJO);
-
-      // Initialize
-      server.getConfiguration().bootstrapUrl(bootstrapUrl);
-
-      // Start the server
-      server.start();
-
-      assertPojo(BIND_NAME_POJO);
-   }
-
-   /**
-    * Ensures that any valid file:// URL can be processed as a bootstrapUrl and will 
-    * correctly handle both relative and fully qualified <url> elements.
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testBootstrapFileUrlMultiNested() throws Throwable
-   {
-      // Log
-      log.info("testBootstrapFileUrlMultiNested");
-
-      final JBossASServer server = getServer();
-
-      URL bootstrapUrl = new URL(getHome(), NAME_BOOTSTRAP_URLS);
-
-      // Initialize
-      server.getConfiguration().bootstrapUrl(bootstrapUrl);
-
-      // Start the server
-      server.start();
-
-      assertPojo(BIND_NAME_POJO);
-      assertPojo(BIND_NAME_POJO_TWO);
-   }
-
-   /**
-    * Ensures a bootstrapUrl created by the bootstrapHome property functions correctly for both 
-    * relative and fully qualified <url> elements  
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testBootstrapUrlFromBootstrapHome() throws Throwable
-   {
-      // Log
-      log.info("testBootstrapUrlFromBootstrapHome");
-
-      final JBossASServer server = getServer();
-
-      // Set name to deploy a test POJO via XML
-      server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_URLS);
-
-      // Start the server
-      server.start();
-
-      assertPojo(BIND_NAME_POJO);
-      assertPojo(BIND_NAME_POJO_TWO);
-   }
-
-   /**
-    * Test to show relative URL will not function with a starting slash in the bootstrapUrl. 
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testBootstrapUrlStartsWithSlash() throws Throwable
-   {
-      // Log
-      log.info("testBootstrapUrlStartsWithSlash");
-
-      final JBossASServer server = getServer();
-
-      server.getConfiguration().bootstrapName("/" + NAME_BOOTSTRAP_POJO);
-
-      try
-      {
-         // Start the server
-         server.start();
-         fail("Should have thrown InvalidBootstrapUrlFormatException");
-      }
-      catch (final InvalidBootstrapURLException expectedException)
-      {
-         // Ignore expected InvalidBootstrapUrlFormatException
-      }
-   }
-
-   /**
-    * Test to show relative URL will not function with a starting slash in a <url> element  
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testNestedUrlStartsWithSlash() throws Throwable
-   {
-      // Log
-      log.info("testNestedUrlStartsWithSlash");
-
-      final JBossASServer server = getServer();
-
-      server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_SLASH);
-
-      try
-      {
-         // Start the server
-         server.start();
-         fail("Should have thrown InvalidBootstrapUrlFormatException");
-      }
-      catch (final InvalidBootstrapURLException iburle)
-      {
-         // Good
-      }
-
-   }
-
-   //-------------------------------------------------------------------------------------||
-   // Internal Classes--------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Jetty Handler to serve a file contents over HTTP
-    */
-   private static class StaticFileHandler extends AbstractHandler implements Handler
-   {
-      /*
-       * (non-Javadoc)
-       * @see org.mortbay.jetty.Handler#handle(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
-       */
-      public void handle(final String target, final HttpServletRequest request, final HttpServletResponse response,
-            final int dispatch) throws IOException, ServletException
-      {
-         // Set content type and status before we write anything to the stream
-         response.setContentType(CONTENT_TYPE_XML);
-         response.setStatus(HttpServletResponse.SC_OK);
-
-         // Get local path (removed /path from the target)
-         final String localPath = target.replace(TEST_HTTP_PATH_BASE, "/");
-
-         //  Get local stream
-         final InputStream stream = this.getClass().getResourceAsStream(localPath);
-
-         // Write out each line
-         final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
-         final PrintWriter writer = response.getWriter();
-         String line = null;
-         while ((line = reader.readLine()) != null)
-         {
-            writer.println(line);
-         }
-         writer.flush();
-         reader.close();
-         writer.close();
-      }
-   }
-
-}

Deleted: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerUnitTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerUnitTestCase.java	2010-01-18 04:36:16 UTC (rev 99518)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerUnitTestCase.java	2010-01-18 04:48:10 UTC (rev 99519)
@@ -1,196 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.bootstrap.impl.as.server;
-
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.jboss.bootstrap.api.as.server.JBossASServer;
-import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
-import org.jboss.bootstrap.api.descriptor.ClassLoaderResourceBootstrapDescriptor;
-import org.jboss.bootstrap.api.lifecycle.LifecycleState;
-import org.jboss.bootstrap.api.mc.server.MCServer;
-import org.jboss.bootstrap.spi.as.server.MCJBossASServerProvider;
-import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.logging.Logger;
-import org.junit.Test;
-
-/**
- * MCServerUnitTestCase
- * 
- * Test Cases to ensure that the MC Server Implementation is 
- * working as contracted
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class MCServerUnitTestCase extends AbstractMCServerTest
-{
-   //-------------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   private static final Logger log = Logger.getLogger(MCServerUnitTestCase.class);
-
-   private static final String NAME_BOOTSTRAP_POJO = "pojo.xml";
-
-   private static final String BIND_NAME_POJO = "org.jboss.bootstrap.test.POJO";
-
-   //-------------------------------------------------------------------------------------||
-   // Tests ------------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Ensures that the server starts and that a simple bean 
-    * may be installed into the underlying KernelController
-    * 
-    * Uses standard MC APIs via the MCServer interface
-    */
-   @Test
-   public void testMcIntegration() throws Throwable
-   {
-      // Log
-      log.info("testMcIntegration");
-
-      // Initialize
-      final JBossASServer server = getServer();
-
-      // Precondition check
-      LifecycleState state = server.getState();
-      TestCase.assertTrue("Server should not yet be started", !state.equals(LifecycleState.STARTED));
-
-      // Start
-      server.start();
-
-      // Get state
-      state = server.getState();
-
-      // Ensure reports as started
-      TestCase.assertTrue("Server should report as started", state.equals(LifecycleState.STARTED));
-
-      // Get the internals/SPI view
-      final MCJBossASServerProvider provider = (MCJBossASServerProvider) server;
-
-      /*
-       * Install a test MC bean into the Server, ensure MC takes
-       * over and lifecycle is invoked
-       */
-      this.installPojo(provider, BIND_NAME_POJO);
-      this.assertPojo(BIND_NAME_POJO);
-   }
-
-   /**
-    * Ensures that a deployed bean is available via 
-    * {@link MCServer#getDeployments()}
-    */
-   @Test
-   public void testKernelDeployments() throws Throwable
-   {
-      // Log
-      log.info("testKernelDeployments");
-
-      // Initialize
-      final JBossASServer server = getServer();
-
-      // Set name to deploy a test POJO via XML
-      final BootstrapDescriptor descriptor = new ClassLoaderResourceBootstrapDescriptor(NAME_BOOTSTRAP_POJO);
-      server.getConfiguration().getBootstrapDescriptors().add(descriptor);
-
-      // Start
-      server.start();
-
-      // Get the internals/SPI view
-      final MCJBossASServerProvider provider = (MCJBossASServerProvider) server;
-
-      // Get the Deployment
-      final Map<String, KernelDeployment> deployments = provider.getDeployments();
-
-      // Ensure the deployment is there
-      TestCase.assertEquals("Wrong number of expected kernel deployments", 1, deployments.size());
-   }
-
-   /**
-    * Ensures that deployment from a bootstrap.xml succeeds as expected
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testBootstrapDeployment() throws Throwable
-   {
-      // Log
-      log.info("testBootstrapDeployment");
-
-      // Initialize
-      final JBossASServer server = getServer();
-
-      // Set name to deploy a test POJO via XML
-      final BootstrapDescriptor descriptor = new ClassLoaderResourceBootstrapDescriptor(NAME_BOOTSTRAP_POJO);
-      server.getConfiguration().getBootstrapDescriptors().add(descriptor);
-
-      // Start the server
-      server.start();
-
-      // Test the POJO
-      this.assertPojo(BIND_NAME_POJO);
-   }
-
-   /**
-    * Ensures that the MC Server may restart
-    * 
-    * JBBOOT-74
-    * 
-    * @throws Throwable
-    */
-   @Test
-   public void testRestart() throws Throwable
-   {
-      // Log
-      log.info("testRestart");
-
-      // Initialize
-      final JBossASServer server = getServer();
-
-      // Start the server
-      server.start();
-
-      // Stop the server
-      server.shutdown();
-
-      // Restart
-      boolean restartedOk = true;
-      try
-      {
-         server.start();
-      }
-      catch (final Exception e)
-      {
-         log.error("Server could not restart, exception was:", e);
-         restartedOk = false;
-      }
-
-      // Test that restart was OK
-      TestCase.assertTrue("The server did not restart as expected", restartedOk);
-   }
-
-}




More information about the jboss-cvs-commits mailing list