[jboss-cvs] JBossAS SVN: r83411 - in projects/jboss-deployers/trunk: deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify and 16 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 26 09:34:58 EST 2009


Author: alesj
Date: 2009-01-26 09:34:58 -0500 (Mon, 26 Jan 2009)
New Revision: 83411

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/VFSStructureProcessorTestSuite.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/support/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/StructureProcessorUnitTest.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/META-INF/emtpy.txt
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/tempchild/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/tempchild/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/tempchild/META-INF/sub.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/directtop/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/directtop/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/directtop/META-INF/top.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/META-INF/emtpy.txt
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/somechild/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/somechild/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/somechild/META-INF/child.xml
Modified:
   projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/AbstractModificationTypeMatcher.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/DeployersVFSTestSuite.java
Log:
Add test for modifcation structure processor.

Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java	2009-01-26 14:27:56 UTC (rev 83410)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java	2009-01-26 14:34:58 UTC (rev 83411)
@@ -290,11 +290,11 @@
    }
 
    /**
-    * Set context info processor.
+    * Set structure processor.
     *
     * @param structureProcessor the context info processor
     */
-   public void setContextInfoProcessor(StructureProcessor structureProcessor)
+   public void setStructureProcessor(StructureProcessor structureProcessor)
    {
       this.structureProcessor = structureProcessor;
    }
@@ -302,9 +302,9 @@
    /**
     * Get the context info processor.
     *
-    * @return the context info processor
+    * @return the structure processor
     */
-   protected StructureProcessor getContextInfoProcessor()
+   protected StructureProcessor getStructureProcessor()
    {
       return structureProcessor;
    }

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/AbstractModificationTypeMatcher.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/AbstractModificationTypeMatcher.java	2009-01-26 14:27:56 UTC (rev 83410)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/AbstractModificationTypeMatcher.java	2009-01-26 14:34:58 UTC (rev 83411)
@@ -39,16 +39,22 @@
    protected Logger log = Logger.getLogger(getClass());
 
    private boolean checkChildren;
+   private boolean topLevelOnly;
+   private boolean childrenOnly;
+
    private ModificationType modificationType;
 
    public boolean determineModification(VirtualFile root, StructureMetaData structureMetaData)
    {
       ContextInfo contextInfo = structureMetaData.getContext("");
-      boolean result = isModificationDetermined(root, contextInfo);
-      if (result)
+      if (childrenOnly == false)
       {
-         contextInfo.setModificationType(modificationType);
-         return true;
+         boolean result = isModificationDetermined(root, contextInfo);
+         if (result)
+         {
+            contextInfo.setModificationType(modificationType);
+            return true;
+         }
       }
 
       if (checkChildren)
@@ -84,10 +90,14 @@
 
    public boolean determineModification(VirtualFile root, ContextInfo contextInfo)
    {
-      boolean result = isModificationDetermined(root, contextInfo);
-      if (result)
+      boolean result = false;
+      if (topLevelOnly == false)
       {
-         contextInfo.setModificationType(modificationType);         
+         result = isModificationDetermined(root, contextInfo);
+         if (result)
+         {
+            contextInfo.setModificationType(modificationType);
+         }
       }
       return result;
    }
@@ -112,6 +122,26 @@
    }
 
    /**
+    * Is this matcher top level only.
+    *
+    * @param topLevelOnly the top level only flag
+    */
+   public void setTopLevelOnly(boolean topLevelOnly)
+   {
+      this.topLevelOnly = topLevelOnly;
+   }
+
+   /**
+    * Is this matcher children only.
+    *
+    * @param childrenOnly the children only flag
+    */
+   public void setChildrenOnly(boolean childrenOnly)
+   {
+      this.childrenOnly = childrenOnly;
+   }
+
+   /**
     * Set the modification type.
     *
     * @param modificationType the modification type

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/DeployersVFSTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/DeployersVFSTestSuite.java	2009-01-26 14:27:56 UTC (rev 83410)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/DeployersVFSTestSuite.java	2009-01-26 14:34:58 UTC (rev 83411)
@@ -40,6 +40,7 @@
 import org.jboss.test.deployers.vfs.parsing.test.ParsingTestSuite;
 import org.jboss.test.deployers.vfs.structure.VFSStructureTestSuite;
 import org.jboss.test.deployers.vfs.structurebuilder.VFSStructureBuilderTestSuite;
+import org.jboss.test.deployers.vfs.structureprocessor.VFSStructureProcessorTestSuite;
 import org.jboss.test.deployers.vfs.xb.JBossXBDeployersTestSuite;
 
 /**
@@ -62,6 +63,7 @@
 
       suite.addTest(VFSDeploymentFactoryTestSuite.suite());
       suite.addTest(VFSStructureBuilderTestSuite.suite());
+      suite.addTest(VFSStructureProcessorTestSuite.suite());
       suite.addTest(VFSStructureTestSuite.suite());
       suite.addTest(VFSMetaDataTestSuite.suite());
       suite.addTest(ParsingTestSuite.suite());

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/VFSStructureProcessorTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/VFSStructureProcessorTestSuite.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/VFSStructureProcessorTestSuite.java	2009-01-26 14:34:58 UTC (rev 83411)
@@ -0,0 +1,49 @@
+/*
+* 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.structureprocessor;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.deployers.vfs.structureprocessor.test.VFSStructureProcessorUnitTestCase;
+
+/**
+ * VFSStructureProcessorTestSuite.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public class VFSStructureProcessorTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("VFS Structure Processor Tests");
+
+      suite.addTest(VFSStructureProcessorUnitTestCase.suite());
+
+      return suite;
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/StructureProcessorUnitTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/StructureProcessorUnitTest.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/StructureProcessorUnitTest.java	2009-01-26 14:34:58 UTC (rev 83411)
@@ -0,0 +1,61 @@
+/*
+* 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.structureprocessor.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.deployers.structure.spi.StructureBuilder;
+import org.jboss.deployers.structure.spi.StructureProcessor;
+import org.jboss.deployers.structure.spi.helpers.AbstractStructureBuilder;
+import org.jboss.test.deployers.BaseDeployersVFSTest;
+
+/**
+ * StructureProcessorUnitTest.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class StructureProcessorUnitTest extends BaseDeployersVFSTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(StructureProcessorUnitTest.class);
+   }
+
+   public StructureProcessorUnitTest(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected StructureBuilder createStructureBuilder()
+   {
+      StructureBuilder structureBuilder = super.createStructureBuilder();
+      if (structureBuilder instanceof AbstractStructureBuilder)
+      {
+         AbstractStructureBuilder asb = AbstractStructureBuilder.class.cast(structureBuilder);
+         asb.setStructureProcessor(createStructureProcessor());
+      }
+      return structureBuilder;
+   }
+
+   protected abstract StructureProcessor createStructureProcessor();
+}
\ No newline at end of file

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java (from rev 83352, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java	2009-01-26 14:34:58 UTC (rev 83411)
@@ -0,0 +1,153 @@
+/*
+* 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.structureprocessor.test;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.StructureProcessor;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.deployers.vfs.plugins.structure.modify.ModificationTypeMatcher;
+import org.jboss.deployers.vfs.plugins.structure.modify.ModificationTypeStructureProcessor;
+import org.jboss.deployers.vfs.plugins.structure.modify.TempTopModificationTypeMatcher;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFSStructureProcessorUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public class VFSStructureProcessorUnitTestCase extends StructureProcessorUnitTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(VFSStructureProcessorUnitTestCase.class);
+   }
+
+   public VFSStructureProcessorUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected StructureProcessor createStructureProcessor()
+   {
+      ModificationTypeStructureProcessor mtsp = new ModificationTypeStructureProcessor();
+
+      ModificationTypeMatcher topAndChildren = createTempMatcher(true, true, false, true, "child.xml");
+      ModificationTypeMatcher directTop = createTempMatcher(true, false, true, false, "top.xml");
+      ModificationTypeMatcher justChildren = createTempMatcher(true, false, false, true, "sub.xml");
+
+      mtsp.setMatchers(Arrays.asList(directTop, topAndChildren, justChildren));
+      return mtsp;
+   }
+
+   protected ModificationTypeMatcher createTempMatcher(
+         boolean metadataOnly,
+         boolean checkChildren,
+         boolean topLevelOnly,
+         boolean childrenOnly,
+         String... paths)
+   {
+      TempTopModificationTypeMatcher matcher = new TempTopModificationTypeMatcher(paths);
+      matcher.setMetadataOnly(metadataOnly);
+      matcher.setCheckChildren(checkChildren);
+      matcher.setTopLevelOnly(topLevelOnly);
+      matcher.setChildrenOnly(childrenOnly);
+      return matcher;
+   }
+
+   protected VFSDeploymentContext getTopDeploymentContext(DeployerClient main, String name)
+   {
+      MainDeployerImpl mdi = (MainDeployerImpl)main;
+      Collection<DeploymentContext> all = mdi.getAll();
+      for (DeploymentContext dc : all)
+      {
+         if (dc.getSimpleName().equals(name))
+            return VFSDeploymentContext.class.cast(dc);
+      }
+      throw new IllegalArgumentException("No such deployment context: " + name + ", all: " + all);
+   }
+
+   protected void testTopModification(String path) throws Exception
+   {
+      DeployerClient main = createMainDeployer();
+      addStructureDeployer(main, new JARStructure());
+
+      VFSDeployment deployment = createDeployment("/structureprocessor", path);
+      main.deploy(deployment);
+      try
+      {
+         VFSDeploymentContext vdc = getTopDeploymentContext(main, path);
+         VirtualFile root = vdc.getRoot();
+         assertTrue("Should be temp", VFSUtils.isTemporaryFile(root));
+      }
+      finally
+      {
+         main.undeploy(deployment);
+      }
+   }
+
+   public void testDirectTopLevelModification() throws Exception
+   {
+      testTopModification("directtop");
+   }
+
+   public void testTopFromChildModification() throws Exception
+   {
+      testTopModification("topfromchild");
+   }
+
+   public void testChildModification() throws Exception
+   {
+      DeployerClient main = createMainDeployer();
+      addStructureDeployer(main, new JARStructure());
+
+      VFSDeployment deployment = createDeployment("/structureprocessor", "childmod");
+      main.deploy(deployment);
+      try
+      {
+         VFSDeploymentContext vdc = getTopDeploymentContext(main, "childmod");
+         VirtualFile root = vdc.getRoot();
+         VirtualFile file = root.getChild("tempchild");
+         try
+         {
+            assertTrue("Should be temp", VFSUtils.isTemporaryFile(file));
+         }
+         finally
+         {
+            file.cleanup();
+         }
+      }
+      finally
+      {
+         main.undeploy(deployment);
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/META-INF/emtpy.txt
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/META-INF/emtpy.txt	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/META-INF/emtpy.txt	2009-01-26 14:34:58 UTC (rev 83411)
@@ -0,0 +1 @@
+empty

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/tempchild/META-INF/sub.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/tempchild/META-INF/sub.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/childmod/tempchild/META-INF/sub.xml	2009-01-26 14:34:58 UTC (rev 83411)
@@ -0,0 +1 @@
+<sub/>

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/directtop/META-INF/top.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/directtop/META-INF/top.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/directtop/META-INF/top.xml	2009-01-26 14:34:58 UTC (rev 83411)
@@ -0,0 +1 @@
+<top/>

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/META-INF/emtpy.txt
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/META-INF/emtpy.txt	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/META-INF/emtpy.txt	2009-01-26 14:34:58 UTC (rev 83411)
@@ -0,0 +1 @@
+empty

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/structureprocessor/topfromchild/somechild/META-INF/child.xml
===================================================================




More information about the jboss-cvs-commits mailing list