[jboss-cvs] JBossAS SVN: r93807 - in projects/jboss-deployers/trunk: deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 21 09:27:48 EDT 2009


Author: alesj
Date: 2009-09-21 09:27:47 -0400 (Mon, 21 Sep 2009)
New Revision: 93807

Added:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DirModificationCheckerFilter.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/DirRemovalModificationTestCase.java
Modified:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.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/modified/test/MetaDataStructureModificationTestCase.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/StructureModificationTest.java
Log:
Test for JBDEPLOY-207.

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-09-21 13:14:29 UTC (rev 93806)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java	2009-09-21 13:27:47 UTC (rev 93807)
@@ -40,6 +40,7 @@
 import org.jboss.test.deployers.vfs.structure.jar.test.CombinedJARStructureUnitTestCase;
 import org.jboss.test.deployers.vfs.structure.jar.test.ConfiguredSuffixJARStructureUnitTestCase;
 import org.jboss.test.deployers.vfs.structure.jar.test.JARStructureUnitTestCase;
+import org.jboss.test.deployers.vfs.structure.modified.test.DirRemovalModificationTestCase;
 import org.jboss.test.deployers.vfs.structure.modified.test.MetaDataStructureModificationTestCase;
 import org.jboss.test.deployers.vfs.structure.modified.test.MetaDataStructureModificationTreeCacheTestCase;
 import org.jboss.test.deployers.vfs.structure.modified.test.SynchModificationTestCase;
@@ -91,6 +92,7 @@
       suite.addTest(MetaDataStructureModificationTestCase.suite());
       suite.addTest(MetaDataStructureModificationTreeCacheTestCase.suite());
       suite.addTest(SynchModificationTestCase.suite());
+      suite.addTest(DirRemovalModificationTestCase.suite());
 
       return suite;
    }

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/DirRemovalModificationTestCase.java (from rev 91502, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/DirRemovalModificationTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/DirRemovalModificationTestCase.java	2009-09-21 13:27:47 UTC (rev 93807)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.modified.test;
+
+import java.io.File;
+
+import junit.framework.Test;
+import org.jboss.deployers.structure.spi.main.MainDeployerInternals;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.modified.DirModificationCheckerFilter;
+import org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker;
+import org.jboss.deployers.vfs.spi.structure.modified.StructureCache;
+import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * Test JBDEPLOY-207, Rob's dir removal.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DirRemovalModificationTestCase extends StructureModificationTest
+{
+   private File tmpDir;
+
+   public DirRemovalModificationTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(DirRemovalModificationTestCase.class);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      try
+      {
+         if (tmpDir != null)
+            assertTrue(tmpDir.delete());
+      }
+      finally
+      {
+         super.tearDown();
+      }
+   }
+
+   protected StructureModificationChecker createStructureModificationChecker(MainDeployerInternals mainDeployerInternals, VirtualFileFilter filter)
+   {
+      MetaDataStructureModificationChecker structureModificationChecker = new MetaDataStructureModificationChecker(mainDeployerInternals);
+      structureModificationChecker.setCache(createStructureCache());
+      structureModificationChecker.setFilter(filter);
+      structureModificationChecker.setRootFilter(new DirModificationCheckerFilter());
+      return structureModificationChecker;
+   }
+
+   protected StructureCache<Long> createStructureCache()
+   {
+      return null; // use default
+   }
+
+   protected VirtualFileFilter createFilter()
+   {
+      return null;
+   }
+
+   @Override
+   protected VirtualFile makeRoot() throws Exception
+   {
+      File tmpFile = File.createTempFile("jbdeploy207", ".tmp");
+      tmpFile.deleteOnExit();
+      File tmpParent = tmpFile.getParentFile();
+      tmpDir = new File(tmpParent, "tmp-dir");
+      assertTrue(tmpDir.mkdir());
+      return VFS.createNewRoot(tmpDir.toURI());
+   }
+
+   protected void testStructureModified(VirtualFile root, StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception
+   {
+      assertFalse("Structure should not be modified.", checker.hasStructureBeenModified(root));
+
+      Thread.sleep(1500); // wait more than 1000ms, which is OS offset
+
+      File parentDir = tmpDir.getParentFile();
+      assertTrue(tmpDir.delete());
+      tmpDir = new File(parentDir, "tmp-dir");
+      assertTrue(tmpDir.mkdir());
+      root = VFS.createNewRoot(tmpDir.toURI());
+
+      assertTrue("We created new directory, expecting modified root.", checker.hasStructureBeenModified(root));
+   }
+}
\ No newline at end of file

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java	2009-09-21 13:14:29 UTC (rev 93806)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java	2009-09-21 13:27:47 UTC (rev 93807)
@@ -71,7 +71,7 @@
       return new XmlIncludeVirtualFileFilter();
    }
 
-   protected void testStructureModified(AssembledDirectory ear, StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception
+   protected void testStructureModified(VirtualFile ear, StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception
    {
       VirtualFile root = deploymentUnit.getRoot();
       // initial run

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/StructureModificationTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/StructureModificationTest.java	2009-09-21 13:14:29 UTC (rev 93806)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/StructureModificationTest.java	2009-09-21 13:27:47 UTC (rev 93807)
@@ -25,7 +25,7 @@
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
 import org.jboss.test.deployers.vfs.webbeans.test.AbstractWebBeansTest;
-import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.VirtualFileFilter;
 
 /**
@@ -51,9 +51,14 @@
 
    protected abstract VirtualFileFilter createFilter();
 
+   protected VirtualFile makeRoot() throws Exception
+   {
+      return createBasicEar();
+   }
+
    public void testDoBasicTest() throws Exception
    {
-      AssembledDirectory ear = createBasicEar();
+      VirtualFile ear = makeRoot();
       StructureModificationChecker checker = createStructureModificationChecker();
 
       VFSDeploymentUnit deploymentUnit = assertDeploy(ear);
@@ -67,5 +72,5 @@
       }
    }
 
-   protected abstract void testStructureModified(AssembledDirectory ear, StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception;
+   protected abstract void testStructureModified(VirtualFile ear, StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception;
 }

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java	2009-09-21 13:14:29 UTC (rev 93806)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java	2009-09-21 13:27:47 UTC (rev 93807)
@@ -157,7 +157,9 @@
          boolean result = hasRootBeenModified(root);
          if (result || getRootFilter().checkRootOnly(root))
          {
-            getCache().invalidateCache(root);
+            if (result)
+               getCache().invalidateCache(root);
+            
             return result;
          }
       }

Copied: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DirModificationCheckerFilter.java (from rev 92382, projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/ModificationCheckerFilter.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DirModificationCheckerFilter.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DirModificationCheckerFilter.java	2009-09-21 13:27:47 UTC (rev 93807)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployers.vfs.spi.structure.modified;
+
+import java.io.IOException;
+
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Directory ModificationCheckerFilter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DirModificationCheckerFilter implements ModificationCheckerFilter
+{
+   /**
+    * Accept all; dirs, files, archives, ...
+    */
+   public boolean accepts(VirtualFile file)
+   {
+      return true;
+   }
+
+   public boolean checkRootOnly(VirtualFile root)
+   {
+      try
+      {
+         // if file or archive, no point in checking fwd
+         return root.isArchive() || root.isLeaf();
+      }
+      catch (IOException e)
+      {
+         return true; // true, as we don't wanna go fwd with broken check
+      }
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list