[jboss-cvs] JBossAS SVN: r70737 - in projects/jboss-deployers/trunk/deployers-vfs/src: tests/org/jboss/test/deployers/vfs/structure and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 11 10:50:25 EDT 2008


Author: alesj
Date: 2008-03-11 10:50:25 -0400 (Tue, 11 Mar 2008)
New Revision: 70737

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/ear/archive.ear
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/support/WrapperMockEarStructureDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/AbstractEARStructureTest.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/EARStructureRecognizeTestCase.java
Modified:
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/EARStructureUnitTestCase.java
Log:
JBDEPLOY-12; moving recognision to new test class, adding packaged .ear test.

Added: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/ear/archive.ear
===================================================================
(Binary files differ)


Property changes on: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/ear/archive.ear
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java	2008-03-11 12:41:03 UTC (rev 70736)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java	2008-03-11 14:50:25 UTC (rev 70737)
@@ -146,7 +146,7 @@
    protected void assertClassPath(VFSDeploymentContext context, VFSDeploymentContext reference, String... paths) throws Exception
    {
       List<VirtualFile> classPath = context.getClassPath();
-      if (paths == null)
+      if (paths == null || paths.length == 0)
       {
          if (classPath != null)
             assertEmpty(classPath);

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java	2008-03-11 12:41:03 UTC (rev 70736)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java	2008-03-11 14:50:25 UTC (rev 70737)
@@ -26,6 +26,7 @@
 import junit.textui.TestRunner;
 
 import org.jboss.test.deployers.vfs.structure.ear.test.EARStructureUnitTestCase;
+import org.jboss.test.deployers.vfs.structure.ear.test.EARStructureRecognizeTestCase;
 import org.jboss.test.deployers.vfs.structure.explicit.test.DeclaredStructureUnitTestCase;
 import org.jboss.test.deployers.vfs.structure.file.test.CombinedFileStructureUnitTestCase;
 import org.jboss.test.deployers.vfs.structure.file.test.ConfiguredSuffixFileStructureUnitTestCase;
@@ -64,6 +65,7 @@
       suite.addTest(FileMatcherTestCase.suite());
       suite.addTest(DeclaredStructureUnitTestCase.suite());
       suite.addTest(EARStructureUnitTestCase.suite());
+      suite.addTest(EARStructureRecognizeTestCase.suite());
       suite.addTest(CombinedJARStructureUnitTestCase.suite());
       suite.addTest(CombinedWARStructureUnitTestCase.suite());
       suite.addTest(CombinedFileStructureUnitTestCase.suite());

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java	2008-03-11 12:41:03 UTC (rev 70736)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java	2008-03-11 14:50:25 UTC (rev 70737)
@@ -74,7 +74,7 @@
    /**
     * Set the earLibFilter.
     * 
-    * @param earLibFilter
+    * @param earLibFilter the filter
     * @throws IllegalArgumentException for a null filter
     */
    public void setEarLibFilter(VirtualFileFilter earLibFilter)
@@ -86,8 +86,8 @@
 
    public boolean determineStructure(VirtualFile root, VirtualFile parent, VirtualFile file, StructureMetaData metaData, VFSStructuralDeployers deployers) throws DeploymentException
    {
-      ContextInfo context = null;
-      boolean valid = false;
+      ContextInfo context;
+      boolean valid;
       try
       {
          if (file.isLeaf() == true || file.getName().endsWith(".ear") == false)
@@ -115,10 +115,9 @@
             }
          }
          // Add the ear lib contents to the classpath
-         String libDir = "lib";
          try
          {
-            VirtualFile lib = file.findChild(libDir);
+            VirtualFile lib = file.getChild("lib");
             if (lib != null)
             {
                List<VirtualFile> archives = lib.getChildren(earLibFilter);
@@ -149,7 +148,7 @@
                {
                   try
                   {
-                     VirtualFile module = file.findChild(fileName);
+                     VirtualFile module = file.getChild(fileName);
                      if (module == null)
                      {
                         throw new RuntimeException(fileName
@@ -189,9 +188,9 @@
       VirtualFile metaFile = null;
       try
       {
-         metaFile = file.findChild(path);
+         metaFile = file.getChild(path);
       }
-      catch (IOException e)
+      catch (IOException ignored)
       {
       }
       return metaFile;

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/support/WrapperMockEarStructureDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/support/WrapperMockEarStructureDeployer.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/support/WrapperMockEarStructureDeployer.java	2008-03-11 14:50:25 UTC (rev 70737)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.test.deployers.vfs.structure.ear.support;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.structure.VFSStructuralDeployers;
+
+/**
+ * @author ales.justin at jboss.org
+ */
+public class WrapperMockEarStructureDeployer extends MockEarStructureDeployer
+{
+   private boolean touched;
+   private boolean valid;
+
+   public boolean determineStructure(VirtualFile root, VirtualFile parent, VirtualFile file, StructureMetaData metaData, VFSStructuralDeployers deployers) throws DeploymentException
+   {
+      touched = true;
+      valid = super.determineStructure(root, parent, file, metaData, deployers);
+      return valid;
+   }
+
+   public void reset()
+   {
+      touched = false;
+      valid = false;
+   }
+
+   public boolean isTouched()
+   {
+      return touched;
+   }
+
+   public boolean isValid()
+   {
+      return valid;
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/AbstractEARStructureTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/AbstractEARStructureTest.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/AbstractEARStructureTest.java	2008-03-11 14:50:25 UTC (rev 70737)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.test.deployers.vfs.structure.ear.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.deployers.vfs.plugins.structure.file.FileStructure;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.deployers.vfs.plugins.structure.war.WARStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
+import org.jboss.test.deployers.vfs.structure.AbstractStructureTest;
+import org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+
+/**
+ * Abstract ear structure deployer tests
+ *
+ * @author ales.justin at jboss.org
+ */
+public abstract class AbstractEARStructureTest extends AbstractStructureTest
+{
+   protected AbstractEARStructureTest(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      enableTrace("org.jboss.deployers");
+   }
+
+   protected StructureDeployer createEarStructureDeployer()
+   {
+      return new MockEarStructureDeployer();
+   }
+
+   protected VFSDeploymentContext determineStructure(VFSDeployment deployment) throws Exception
+   {
+      Set<String> defaultSuffixes = JarUtils.getSuffixes();
+      JARStructure jarStructure = new JARStructure();
+      try
+      {
+         Set<String> suffixes = new HashSet<String>(jarStructure.getSuffixes());
+         suffixes.add(".ejb3");
+         jarStructure.setSuffixes(suffixes);
+         return determineStructureWithStructureDeployers(deployment, new FileStructure(), new WARStructure(), jarStructure, createEarStructureDeployer());
+      }
+      finally
+      {
+         jarStructure.setSuffixes(defaultSuffixes);
+      }
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/EARStructureRecognizeTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/EARStructureRecognizeTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/EARStructureRecognizeTestCase.java	2008-03-11 14:50:25 UTC (rev 70737)
@@ -0,0 +1,88 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.test.deployers.vfs.structure.ear.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
+import org.jboss.test.deployers.vfs.structure.ear.support.WrapperMockEarStructureDeployer;
+
+/**
+ * Mock ear structure deployer tests
+ *
+ * @author ales.justin at jboss.org
+ */
+public class EARStructureRecognizeTestCase extends AbstractEARStructureTest
+{
+   private WrapperMockEarStructureDeployer earStructureDeployer;
+
+   public static Test suite()
+   {
+      return new TestSuite(EARStructureRecognizeTestCase.class);
+   }
+
+   public EARStructureRecognizeTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      earStructureDeployer = new WrapperMockEarStructureDeployer();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      earStructureDeployer = null;
+      super.tearDown();
+   }
+
+   protected StructureDeployer createEarStructureDeployer()
+   {
+      return earStructureDeployer;
+   }
+
+   protected void reset()
+   {
+      if (earStructureDeployer != null)
+         earStructureDeployer.reset();
+   }
+
+   public void testNotAnEAR() throws Throwable
+   {
+      try
+      {
+         VFSDeploymentContext context = assertDeployNoChildren("/structure/ear", "notanear");
+         assertNoMetaDataFile(context, "META-INF");
+         assertClassPath(context, "");
+         assertTrue(earStructureDeployer.isTouched());
+         assertFalse(earStructureDeployer.isValid());
+      }
+      finally
+      {
+         reset();
+      }
+   }
+}

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/EARStructureUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/EARStructureUnitTestCase.java	2008-03-11 12:41:03 UTC (rev 70736)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/ear/test/EARStructureUnitTestCase.java	2008-03-11 14:50:25 UTC (rev 70737)
@@ -21,28 +21,19 @@
 */
 package org.jboss.test.deployers.vfs.structure.ear.test;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import org.jboss.deployers.vfs.plugins.structure.file.FileStructure;
-import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
-import org.jboss.deployers.vfs.plugins.structure.war.WARStructure;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
-import org.jboss.test.deployers.vfs.structure.AbstractStructureTest;
-import org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
 
 /**
  * Mock ear structure deployer tests
  * 
+ * @author Ales.Justin at jboss.org
  * @author Scott.Stark at jboss.org
  * @author adrian at jboss.org
  * @version $Revision: 61684 $
  */
-public class EARStructureUnitTestCase extends AbstractStructureTest
+public class EARStructureUnitTestCase extends AbstractEARStructureTest
 {
    public static Test suite()
    {
@@ -54,35 +45,17 @@
       super(name);
    }
 
-   @Override
-   protected void setUp() throws Exception
+   /**
+    * Validate packaged ear.
+    * @throws Throwable for any error
+    */
+   public void testPackedEAR() throws Throwable
    {
-      super.setUp();
-      enableTrace("org.jboss.deployers");
+      VFSDeploymentContext ear = assertDeploy("/structure/ear", "archive.ear");
+      assertClassPath(ear, "lib/log5j.jar");
+      assertChildContexts(ear, "module-bean1ejb.jar");
    }
 
-   protected VFSDeploymentContext determineStructure(VFSDeployment deployment) throws Exception
-   {
-      Set<String> defaultSuffixes = JarUtils.getSuffixes();
-      JARStructure jarStructure = new JARStructure();
-      try
-      {
-         Set<String> suffixes = new HashSet<String>(jarStructure.getSuffixes());
-         suffixes.add(".ejb3");
-         jarStructure.setSuffixes(suffixes);
-         return determineStructureWithStructureDeployers(deployment, new FileStructure(), new WARStructure(), jarStructure, new MockEarStructureDeployer());
-      }
-      finally
-      {
-         jarStructure.setSuffixes(defaultSuffixes);
-      }
-   }
-   
-   public void testNotAnEAR() throws Throwable
-   {
-      // TODO JBMICROCONT-185 This gets recognised by the jar deployer assertNotValid("/structure/ear", "notanear");
-   }
-
    /**
     * Validate a basic ear with modules having no subdeployments 
     * @throws Throwable for any problem




More information about the jboss-cvs-commits mailing list