[jboss-cvs] JBossAS SVN: r93304 - in projects/embedded/trunk: testsuite-full-dep/src/test/java/org/jboss and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 8 23:28:22 EDT 2009


Author: ALRubinger
Date: 2009-09-08 23:28:22 -0400 (Tue, 08 Sep 2009)
New Revision: 93304

Modified:
   projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServerImpl.java
   projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java
   projects/embedded/trunk/testsuite-full-dep/src/test/resources/persistence/persistenceEmbedded.xml
Log:
[EMB-46] Refactor to latest TMPARCH work

Modified: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServerImpl.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServerImpl.java	2009-09-08 22:33:31 UTC (rev 93303)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServerImpl.java	2009-09-09 03:28:22 UTC (rev 93304)
@@ -33,7 +33,6 @@
 import org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler;
 import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
 import org.jboss.declarchive.api.Archive;
-import org.jboss.declarchive.spi.vfs.VfsArchive;
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.deployers.client.spi.Deployment;
@@ -267,7 +266,7 @@
     * @see org.jboss.tmpdpl.api.container.Container#deploy(org.jboss.declarchive.api.Archive[])
     */
    @Override
-   public void deploy(final Archive... archives) throws DeploymentException, IllegalArgumentException
+   public void deploy(final Archive<?>... archives) throws DeploymentException, IllegalArgumentException
    {
       // Precondition checks and obtain as array of Deployables
       final Deployable[] deployables = this.asDeployableArray(archives);
@@ -280,7 +279,7 @@
     * @see org.jboss.tmpdpl.api.container.Container#undeploy(org.jboss.declarchive.api.Archive[])
     */
    @Override
-   public void undeploy(final Archive... archives) throws DeploymentException, IllegalArgumentException
+   public void undeploy(final Archive<?>... archives) throws DeploymentException, IllegalArgumentException
    {
       // Precondition checks and obtain as array of Deployables
       final Deployable[] deployables = this.asDeployableArray(archives);
@@ -364,16 +363,19 @@
     * @throws IllegalArgumentException If the specified archives are not specified or not of acceptable
     * (VFS) backing type
     */
-   private Deployable[] asDeployableArray(final Archive... archives) throws IllegalArgumentException
+   private Deployable[] asDeployableArray(final Archive<?>... archives) throws IllegalArgumentException
    {
-      // Precondition checks and obtain as VFS archives
-      final Collection<VfsArchive> vfsArchives = this.asVfsArchives(archives);
+      // Precondition check
+      if (archives == null || archives.length == 0)
+      {
+         throw new IllegalArgumentException("At least one archive must be specified");
+      }
 
       // Make a deployable from each archive
       final Collection<Deployable> deployables = new ArrayList<Deployable>();
-      for (final VfsArchive vfsArchive : vfsArchives)
+      for (final Archive<?> archive : archives)
       {
-         final Deployable deployable = new VfsVdfDeployableImpl(vfsArchive);
+         final Deployable deployable = new VfsVdfDeployableImpl(archive);
          deployables.add(deployable);
       }
 
@@ -419,19 +421,6 @@
    }
 
    /**
-    * Returns a view of the specified VirtualArchive as {@link VirtualVfsArchive}s.
-    *  
-    * @param archives
-    * @return
-    * @throws IllegalArgumentException If the archives are either null, empty, or
-    *   contain any non-VFS types
-    */
-   private Collection<VfsArchive> asVfsArchives(final Archive... archives) throws IllegalArgumentException
-   {
-      return this.asExpectedTypeCollection(VfsArchive.class, archives);
-   }
-
-   /**
     * Obtains the specified array of objects as a Collection of the specified
     * type.  Each object in the array must be assignable to the target type.
     * 

Modified: projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java
===================================================================
--- projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java	2009-09-08 22:33:31 UTC (rev 93303)
+++ projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java	2009-09-09 03:28:22 UTC (rev 93304)
@@ -25,7 +25,6 @@
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.net.URI;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -54,8 +53,13 @@
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.message.BasicNameValuePair;
 import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
-import org.jboss.declarchive.api.Archive;
-import org.jboss.declarchive.api.VfsMemoryArchiveFactory;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.spec.JavaArchive;
+import org.jboss.declarchive.api.spec.WebArchive;
+import org.jboss.declarchive.impl.base.MemoryMapArchiveImpl;
+import org.jboss.declarchive.impl.base.path.BasicPath;
+import org.jboss.declarchive.impl.base.spec.JavaArchiveImpl;
+import org.jboss.declarchive.impl.base.spec.WebArchiveImpl;
 import org.jboss.embedded.core.server.JBossASEmbeddedServer;
 import org.jboss.embedded.core.server.JBossASEmbeddedServerImpl;
 import org.jboss.embedded.testsuite.fulldep.ejb3.entity.Jbossian;
@@ -154,7 +158,7 @@
    /**
     * Path, relative to the deployment root, of a persistence.xml file
     */
-   private static final String PATH_DESTINATION_PERSISTENCE_XML = "META-INF/persistence.xml";
+   private static final String PATH_DESTINATION_PERSISTENCE_XML = "persistence.xml";
 
    /**
     * Path, relative to the resources base, of the directory containing DataSource resources
@@ -248,8 +252,8 @@
 
       // Make a deployment
       final String name = "slsb.jar";
-      final Archive archive = VfsMemoryArchiveFactory.createVirtualArchive(name).addClasses(OutputBean.class,
-            OutputLocalBusiness.class);
+      final JavaArchive archive = new JavaArchiveImpl(new MemoryMapArchiveImpl(name)).addClasses(OutputBean.class,
+            OutputLocalBusiness.class); //TODO Use factory when available
       log.info(archive.toString(true));
       final Deployable deployable = VfsVdfDeployableFactory.createDeployable(archive);
 
@@ -283,22 +287,15 @@
       // Log
       log.info("testWarServletJsp");
 
-      // Get the base
-      final URL base = this.getBase();
-
       // Get the path to the test web.xml file and JSP 
-      final URL locationWebXml = new URL(base, PATH_ACTUAL_WEB_XML);
-      final URL locationJsp = new URL(base, PATH_JSP);
+      final Path targetPathWebXml = new BasicPath("web.xml");
 
-      // Define the new path
-      final String newPathWebXml = PATH_WEB_INF + SEPARATOR + FILENAME_WEB_XML;
-
       // Make a deployment
       final String appName = "testServletJsp";
       final String name = appName + ".war";
       final Class<?> servletClass = JspForwardingServlet.class;
-      final Archive archive = VfsMemoryArchiveFactory.createVirtualArchive(name).addResource(locationWebXml,
-            newPathWebXml).addResource(locationJsp, PATH_JSP).addClass(servletClass);
+      final WebArchive archive = new WebArchiveImpl(new MemoryMapArchiveImpl(name)); // TODO Use factory when avail
+      archive.addWebResource(targetPathWebXml, PATH_ACTUAL_WEB_XML).addResource(PATH_JSP).addClass(servletClass);
       log.info(archive.toString(true));
 
       // Deploy
@@ -351,8 +348,9 @@
 
       // Create a virtual archive for the MDB deployment
       final String name = "jms-mdb-test.jar";
-      final Archive archive = VfsMemoryArchiveFactory.createVirtualArchive(name).addClass(MessageStoringMdb.class)
-            .addResource(new URL(this.getBase(), PATH_QUEUE_SERVICE_XML), FILENAME_QUEUE_SERVICE_XML);
+      final JavaArchive archive = new JavaArchiveImpl(new MemoryMapArchiveImpl(name)); // TODO Use factory when available
+      final Path queuesTargetPath = new BasicPath(FILENAME_QUEUE_SERVICE_XML);
+      archive.addClass(MessageStoringMdb.class).addResource(queuesTargetPath, PATH_QUEUE_SERVICE_XML);
 
       // Deploy
       log.info(archive.toString(true));
@@ -415,11 +413,13 @@
       log.info("testDataSourceAndEntity");
 
       // Create a virtual archive for DS, persistence.xml, Entity, and SLSB
-      final URL base = this.getBase();
-      final Archive archive = VfsMemoryArchiveFactory.createVirtualArchive("datasource-entity-test.jar").addClasses(
-            Jbossian.class, JbossianRegistrarLocalBusiness.class, JbossianRegistrarBean.class).addResource(
-            new URL(base, PATH_RESOURCE_DS_XML_EMBEDDED), FILENAME_EMBEDDED_DS).addResource(
-            new URL(base, PATH_RESOURCE_PERSISTENCE_XML_EMBEDDED), PATH_DESTINATION_PERSISTENCE_XML);
+      final String name = "datasource-entity-test.jar";
+      final Path targetDsPath = new BasicPath(FILENAME_EMBEDDED_DS); //TODO Use factory when available
+      final Path targetPersistencePath = new BasicPath(PATH_DESTINATION_PERSISTENCE_XML); //TODO Use factory when available
+      final JavaArchive archive = new JavaArchiveImpl(new MemoryMapArchiveImpl(name)); // TODO Use factory when available
+      archive.addClasses(Jbossian.class, JbossianRegistrarLocalBusiness.class, JbossianRegistrarBean.class)
+            .addResource(targetDsPath, PATH_RESOURCE_DS_XML_EMBEDDED).addManifestResource(targetPersistencePath,
+                  PATH_RESOURCE_PERSISTENCE_XML_EMBEDDED);
 
       // Deploy
       log.info(archive.toString(true));
@@ -505,12 +505,4 @@
       sendSession.close();
       connection.close();
    }
-
-   /**
-    * Obtains the test resources base
-    */
-   private URL getBase() throws Exception
-   {
-      return this.getClass().getProtectionDomain().getCodeSource().getLocation();
-   }
 }

Modified: projects/embedded/trunk/testsuite-full-dep/src/test/resources/persistence/persistenceEmbedded.xml
===================================================================
--- projects/embedded/trunk/testsuite-full-dep/src/test/resources/persistence/persistenceEmbedded.xml	2009-09-08 22:33:31 UTC (rev 93303)
+++ projects/embedded/trunk/testsuite-full-dep/src/test/resources/persistence/persistenceEmbedded.xml	2009-09-09 03:28:22 UTC (rev 93304)
@@ -4,17 +4,6 @@
   version="1.0">
   <persistence-unit name="embeddedPU">
     <jta-data-source>java:/EmbeddedDS</jta-data-source>
-    <!-- TODO: Necessary because Hibernate is not scanning virtual deployments -->
-    <!-- 
-    
-    Probably need a new scanning implementation:
-    
-    @see JarVisitorFactory.getVisitor, NativeScanner
-    http://anonsvn.jboss.org/repos/hibernate/core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/Scanner.java
-    http://anonsvn.jboss.org/repos/hibernate/core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/NativeScanner.java
-    
-     -->
-    <class>org.jboss.embedded.testsuite.fulldep.ejb3.entity.Jbossian</class>
     <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
       <property name="hibernate.hbm2ddl.auto" value="create-drop" />




More information about the jboss-cvs-commits mailing list