[jboss-cvs] JBossAS SVN: r91963 - in projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure: dir/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 4 10:41:26 EDT 2009


Author: alesj
Date: 2009-08-04 10:41:26 -0400 (Tue, 04 Aug 2009)
New Revision: 91963

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/EsbStructureUnitTestCase.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/GroupingStructureUnitTestCase.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/SubDirectoryStructureTest.java
Modified:
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/DirStructureUnitTestCase.java
Log:
[JBDEPLOY-208]; test new grouping structure.

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java	2009-08-04 14:19:07 UTC (rev 91962)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java	2009-08-04 14:41:26 UTC (rev 91963)
@@ -69,13 +69,28 @@
 
    protected void assertChildContexts(VFSDeploymentContext context, String... paths)
    {
+      assertChildContexts(context, false, paths);
+   }
+
+   protected void assertChildContexts(VFSDeploymentContext context, boolean flatten, String... paths)
+   {
       List<String> expected = new ArrayList<String>();
       if (paths != null)
       {
          for (String path : paths)
             expected.add(path);
       }
-      List<DeploymentContext> children = context.getChildren();
+
+      List<DeploymentContext> children;
+      if (flatten)
+      {
+         children = new ArrayList<DeploymentContext>();
+         flattenContexts(children, context);
+      }
+      else
+      {
+         children = context.getChildren();
+      }
       assertNotNull(children);
       assertEquals("Expected " + expected + " got " + simplePrint(children), expected.size(), children.size());
       
@@ -84,14 +99,47 @@
          boolean found = false;
          for (DeploymentContext child : children)
          {
-            if (path.equals(child.getRelativePath()))
+            String childPath = child.getRelativePath();
+            if (path.equals(childPath))
+            {
                found = true;
+               break;
+            }
+            if (flatten)
+            {
+               DeploymentContext parent = child.getParent();
+               if (parent != null)
+               {
+                  String parentPath = parent.getRelativePath();
+                  if (parentPath.endsWith("/") == false && childPath.startsWith("/") == false)
+                     parentPath += "/";
+
+                  if (path.equals(parentPath + childPath))
+                  {
+                     found = true;
+                     break;
+                  }
+               }
+            }
          }
          if (found == false)
             fail("Expected " + path + " in " + children);
       }
    }
-   
+
+   protected void flattenContexts(List<DeploymentContext> contexts, DeploymentContext context)
+   {
+      List<DeploymentContext> children = context.getChildren();
+      if (children != null)
+      {
+         for (DeploymentContext dc : children)
+         {
+            contexts.add(dc);
+            flattenContexts(contexts, dc);
+         }
+      }
+   }
+
    protected String simplePrint(List<DeploymentContext> children)
    {
       StringBuilder builder = new StringBuilder();

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java	2009-08-04 14:19:07 UTC (rev 91962)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java	2009-08-04 14:41:26 UTC (rev 91963)
@@ -25,6 +25,8 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 import org.jboss.test.deployers.vfs.structure.dir.test.DirStructureUnitTestCase;
+import org.jboss.test.deployers.vfs.structure.dir.test.EsbStructureUnitTestCase;
+import org.jboss.test.deployers.vfs.structure.dir.test.GroupingStructureUnitTestCase;
 import org.jboss.test.deployers.vfs.structure.dir.test.RealDirStructureUnitTestCase;
 import org.jboss.test.deployers.vfs.structure.ear.test.EARStructureRecognizeTestCase;
 import org.jboss.test.deployers.vfs.structure.ear.test.EARStructureUnitTestCase;
@@ -84,6 +86,8 @@
       suite.addTest(InnerModificationUnitTestCase.suite());
       suite.addTest(DirStructureUnitTestCase.suite());
       suite.addTest(RealDirStructureUnitTestCase.suite());
+      suite.addTest(GroupingStructureUnitTestCase.suite());
+      suite.addTest(EsbStructureUnitTestCase.suite());
       suite.addTest(MetaDataStructureModificationTestCase.suite());
       suite.addTest(MetaDataStructureModificationTreeCacheTestCase.suite());
       suite.addTest(SynchModificationTestCase.suite());

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/DirStructureUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/DirStructureUnitTestCase.java	2009-08-04 14:19:07 UTC (rev 91962)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/DirStructureUnitTestCase.java	2009-08-04 14:41:26 UTC (rev 91963)
@@ -22,11 +22,10 @@
 package org.jboss.test.deployers.vfs.structure.dir.test;
 
 import junit.framework.Test;
+import org.jboss.deployers.vfs.plugins.structure.dir.DirectoryStructure;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
 import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
-import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
-import org.jboss.deployers.vfs.plugins.structure.dir.DirectoryStructure;
-import org.jboss.test.deployers.vfs.structure.AbstractStructureTest;
 import org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer;
 
 /**
@@ -35,7 +34,7 @@
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class DirStructureUnitTestCase extends AbstractStructureTest
+public class DirStructureUnitTestCase extends SubDirectoryStructureTest
 {
    public DirStructureUnitTestCase(String name)
    {
@@ -47,33 +46,14 @@
       return suite(DirStructureUnitTestCase.class);
    }
 
+   protected boolean shouldFlattenContext()
+   {
+      return false;  // this one already produces flat view
+   }
+
    @SuppressWarnings("deprecation")
    protected VFSDeploymentContext determineStructure(VFSDeployment deployment) throws Exception
    {
       return determineStructureWithStructureDeployers(deployment, new MockEarStructureDeployer(), new JARStructure(), new DirectoryStructure());
    }
-
-   public void testSarWithLib() throws Throwable
-   {
-      VFSDeploymentContext context = assertDeploy("/structure/dir", "test-in-lib.sar");
-      assertChildContexts(context, "lib/test.jar");
-   }
-
-   public void testSarWithNestedLib() throws Throwable
-   {
-      VFSDeploymentContext context = assertDeploy("/structure/dir", "test-in-lib-nested.sar");
-      assertChildContexts(context, "lib/nested/test.jar");
-   }
-
-   public void testEarSarWithLib() throws Throwable
-   {
-      VFSDeploymentContext context = assertDeploy("/structure/dir", "simple.ear");
-      assertChildContexts(context, "test-in-lib.sar", "test-in-lib.sar/lib/test.jar");
-   }
-
-   public void testEarSarWithNestedLib() throws Throwable
-   {
-      VFSDeploymentContext context = assertDeploy("/structure/dir", "nested.ear");
-      assertChildContexts(context, "test-in-lib-nested.sar", "test-in-lib-nested.sar/lib/nested/test.jar");
-   }
 }

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/EsbStructureUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/EsbStructureUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/EsbStructureUnitTestCase.java	2009-08-04 14:41:26 UTC (rev 91963)
@@ -0,0 +1,72 @@
+/*
+* 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.dir.test;
+
+import junit.framework.Test;
+import org.jboss.deployers.vfs.plugins.structure.dir.GroupingStructure;
+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.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * Esb example test.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class EsbStructureUnitTestCase extends AbstractStructureTest
+{
+   public EsbStructureUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(EsbStructureUnitTestCase.class);
+   }
+   
+   protected VFSDeploymentContext determineStructure(VFSDeployment deployment) throws Exception
+   {
+      GroupingStructure gs = new GroupingStructure();
+      VirtualFileFilter top = new VirtualFileFilter()
+      {
+         public boolean accepts(VirtualFile file)
+         {
+            return file.getName().endsWith(".esb");
+         }
+      };
+      gs.setShortCircuitFilter(top);
+      gs.addGroup("jars");
+      gs.addGroup("wars");
+      return determineStructureWithStructureDeployers(deployment, new JARStructure(), new WARStructure(), gs);
+   }
+
+   public void testEsbStructure() throws Throwable
+   {
+      VFSDeploymentContext context = assertDeploy("/structure/dir", "beve.esb");
+      assertChildContexts(context, "jars/j1.jar", "wars/w1.war");
+   }
+}
\ No newline at end of file

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/GroupingStructureUnitTestCase.java (from rev 91150, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/DirStructureUnitTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/GroupingStructureUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/GroupingStructureUnitTestCase.java	2009-08-04 14:41:26 UTC (rev 91963)
@@ -0,0 +1,71 @@
+/*
+* 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.dir.test;
+
+import junit.framework.Test;
+import org.jboss.deployers.vfs.plugins.structure.dir.GroupingStructure;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Test grouping examples.
+ * Substitute for legacy DirectoryStrucutre.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class GroupingStructureUnitTestCase extends SubDirectoryStructureTest
+{
+   public GroupingStructureUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(GroupingStructureUnitTestCase.class);
+   }
+
+   protected boolean shouldFlattenContext()
+   {
+      return true;
+   }
+
+   protected VFSDeploymentContext determineStructure(VFSDeployment deployment) throws Exception
+   {
+      GroupingStructure gs = new GroupingStructure();
+      VirtualFileFilter top = new VirtualFileFilter()
+      {
+         public boolean accepts(VirtualFile file)
+         {
+            return file.getName().endsWith(".sar");
+         }
+      };
+      gs.setShortCircuitFilter(top);
+      gs.addGroup("lib");
+      gs.addGroup("lib/nested");
+      return determineStructureWithStructureDeployers(deployment, new MockEarStructureDeployer(), new JARStructure(), gs);
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/SubDirectoryStructureTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/SubDirectoryStructureTest.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/dir/test/SubDirectoryStructureTest.java	2009-08-04 14:41:26 UTC (rev 91963)
@@ -0,0 +1,64 @@
+/*
+* 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.dir.test;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.test.deployers.vfs.structure.AbstractStructureTest;
+
+/**
+ * Test sub dir handling.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class SubDirectoryStructureTest extends AbstractStructureTest
+{
+   protected SubDirectoryStructureTest(String name)
+   {
+      super(name);
+   }
+
+   protected abstract boolean shouldFlattenContext();
+
+   public void testSarWithLib() throws Throwable
+   {
+      VFSDeploymentContext context = assertDeploy("/structure/dir", "test-in-lib.sar");
+      assertChildContexts(context, "lib/test.jar");
+   }
+
+   public void testSarWithNestedLib() throws Throwable
+   {
+      VFSDeploymentContext context = assertDeploy("/structure/dir", "test-in-lib-nested.sar");
+      assertChildContexts(context, "lib/nested/test.jar");
+   }
+
+   public void testEarSarWithLib() throws Throwable
+   {
+      VFSDeploymentContext context = assertDeploy("/structure/dir", "simple.ear");
+      assertChildContexts(context, shouldFlattenContext(), "test-in-lib.sar", "test-in-lib.sar/lib/test.jar");
+   }
+
+   public void testEarSarWithNestedLib() throws Throwable
+   {
+      VFSDeploymentContext context = assertDeploy("/structure/dir", "nested.ear");
+      assertChildContexts(context, shouldFlattenContext(), "test-in-lib-nested.sar", "test-in-lib-nested.sar/lib/nested/test.jar");
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list