[jboss-cvs] JBossAS SVN: r105719 - projects/weld-int/branches/Deployment_WELDINT-1/deployer/src/test/java/org/jboss/test/deployers/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 4 08:37:08 EDT 2010


Author: flavia.rainone at jboss.com
Date: 2010-06-04 08:37:07 -0400 (Fri, 04 Jun 2010)
New Revision: 105719

Modified:
   projects/weld-int/branches/Deployment_WELDINT-1/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java
Log:
[WELDINT-1] ArchiveInfoDeployer test case with multiple scenarios.

Modified: projects/weld-int/branches/Deployment_WELDINT-1/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java
===================================================================
--- projects/weld-int/branches/Deployment_WELDINT-1/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java	2010-06-04 12:20:31 UTC (rev 105718)
+++ projects/weld-int/branches/Deployment_WELDINT-1/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java	2010-06-04 12:37:07 UTC (rev 105719)
@@ -23,8 +23,12 @@
 
 import junit.framework.Test;
 
+import org.jboss.classloader.spi.ClassLoaderSystem;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.deployers.support.jar.PlainJavaBean;
+import org.jboss.test.deployers.support.web.ServletWebBean;
+import org.jboss.vfs.VFS;
 import org.jboss.vfs.VirtualFile;
 import org.jboss.weld.integration.deployer.env.bda.ArchiveInfo;
 import org.jboss.weld.integration.deployer.env.bda.Classpath;
@@ -37,6 +41,9 @@
  */
 public class ArchiveInfoDeploymentTestCase extends AbstractWeldTest
 {
+   // the name of a classpath should always coincide with the name of the corresponding domain
+   private static String DEFAULT_CLASSPATH_NAME = ClassLoaderSystem.getInstance().getDefaultDomain().getName();
+   
    public ArchiveInfoDeploymentTestCase(String name)
    {
       super(name);
@@ -46,37 +53,143 @@
    {
       return suite(ArchiveInfoDeploymentTestCase.class);
    }
+   
+   private Classpath defaultClasspath;
+   private VFSDeploymentUnit unit;
+   
+   public void tearDown() throws Exception
+   {
+      undeploy(unit);
+      super.tearDown();
+   }
 
-   public void testSimpleUsage() throws Exception
+   public void testEjbJar() throws Exception
    {
-      VirtualFile ear = createBasicEar();
-      VFSDeploymentUnit topUnit = assertDeploy(ear);
-      try
+      VirtualFile ejbJar = createEjbJar("simple.jar", PlainJavaBean.class);
+      unit = assertDeploy(ejbJar);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      assertEmpty(unit.getChildren());
+   }
+
+   public void testWar() throws Exception
+   {
+      VirtualFile war = createWar("simple.war", ServletWebBean.class);
+      unit = assertDeploy(war);
+      assertArchiveInfoWithWarClasspath(unit);
+   }
+
+   public void testEjbJarinEar() throws Exception
+   {
+      VirtualFile ejbJar = createJarInEar();
+      unit = assertDeploy(ejbJar);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
       {
-         ArchiveInfo archiveInfo = topUnit.getAttachment(ArchiveInfo.class);
-         assertNotNull("Null ArchiveInfo", archiveInfo);
-         Classpath defaultClasspath = archiveInfo.getClasspath();
-         assertNotNull(defaultClasspath);
-         assertEquals("DefaultDomain", defaultClasspath.getName());
-         for (DeploymentUnit unit: topUnit.getChildren())
+         assertNull(childUnit.getAttachment(ArchiveInfo.class));
+      }
+   }
+
+   public void testWarinEar() throws Exception
+   {
+      VirtualFile warInEar = createWarInEar();
+      unit = assertDeploy(warInEar);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         assertArchiveInfoWithWarClasspath(childUnit);
+      }
+   }
+
+   public void testEarWithUtil() throws Exception
+   {
+      VirtualFile ear = createTopLevelWithUtil("/weld/earwithutil");
+      unit = assertDeploy(ear);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         assertNull(childUnit.getAttachment(ArchiveInfo.class));
+      }
+   }
+
+   public void testJarWarInEar() throws Exception
+   {
+      VirtualFile ear = VFS.getChild("jar-in-ear.ear"); 
+      createAssembledDirectory(ear)
+      .addPath("/weld/jarwarinear")
+      .addPackage("simple.jar", PlainJavaBean.class)
+      .addPackage("simple.war/WEB-INF/classes", PlainJavaBean.class)
+      .addPath("simple.war", "/weld/warwowb/web");
+      unit = assertDeploy(ear);
+      
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         if (childUnit.getName().endsWith("simple.jar/"))
          {
-            archiveInfo = unit.getAttachment(ArchiveInfo.class);
-            if (unit.getName().endsWith(".war/"))
-            {
-               assertNotNull("Null ArchiveInfo", archiveInfo);
-               Classpath bdaClasspath = archiveInfo.getClasspath();
-               assertNotNull(bdaClasspath);
-               assertNotSame(defaultClasspath, bdaClasspath);
-            }
-            else
-            {
-               assertNull("ArchiveInfo for unit " + unit.getName() + " is not null", archiveInfo);
-            }
+            assertNull(childUnit.getAttachment(ArchiveInfo.class));
          }
+         else if (childUnit.getName().endsWith("simple.war/"))
+         {
+            assertArchiveInfoWithWarClasspath(childUnit);
+         }
+         else
+         {
+            fail("Unexpected unit name: " + childUnit.getName());
+         }
       }
-      finally
+   }
+
+   public void testEar() throws Exception
+   {
+      VirtualFile ear = createBasicEar();
+      unit = assertDeploy(ear);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
       {
-         undeploy(topUnit);
+         ArchiveInfo archiveInfo = childUnit.getAttachment(ArchiveInfo.class);
+         if (childUnit.getName().endsWith(".war/"))
+         {
+            assertNotNull("Null ArchiveInfo", archiveInfo);
+            assertNonDefaultClasspath(childUnit.getName(), archiveInfo.getClasspath());
+         }
+         else
+         {
+            assertNull("ArchiveInfo for unit " + childUnit.getName() + " is not null", archiveInfo);
+         }
       }
    }
+
+   private void assertArchiveInfoWithDefaultClasspath(VFSDeploymentUnit unit)
+   {
+      ArchiveInfo archiveInfo = unit.getAttachment(ArchiveInfo.class);
+      assertNotNull("Null ArchiveInfo", archiveInfo);
+      assertDefaultClasspath(archiveInfo.getClasspath());
+   }
+
+   private void assertArchiveInfoWithWarClasspath(DeploymentUnit unit)
+   {
+      ArchiveInfo archiveInfo = unit.getAttachment(ArchiveInfo.class);
+      assertNotNull("Null ArchiveInfo for unit " + unit, archiveInfo);
+      assertClasspath(unit.getName(), archiveInfo.getClasspath());
+      assertEmpty(unit.getChildren());
+   }
+
+   private void assertDefaultClasspath(Classpath classpath)
+   {
+      assertClasspath(DEFAULT_CLASSPATH_NAME, classpath);
+      this.defaultClasspath = classpath;
+   }
+
+   private void assertNonDefaultClasspath(String name, Classpath classpath)
+   {
+      assertClasspath(name, classpath);
+      assertNotSame(defaultClasspath, classpath);
+   }
+
+   private void assertClasspath(String name, Classpath classpath)
+   {
+      assertNotNull(classpath);
+      assertFalse(classpath.iterator().hasNext());
+      assertEquals(name, classpath.getName());
+   }
 }



More information about the jboss-cvs-commits mailing list