[jboss-cvs] JBossAS SVN: r84061 - in projects/jboss-deployers/trunk: deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 10 10:52:25 EST 2009


Author: alesj
Date: 2009-02-10 10:52:24 -0500 (Tue, 10 Feb 2009)
New Revision: 84061

Modified:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.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:
Add logs when modified.
Test update, add, remove.

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-02-10 14:57:10 UTC (rev 84060)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java	2009-02-10 15:52:24 UTC (rev 84061)
@@ -21,12 +21,18 @@
  */
 package org.jboss.test.deployers.vfs.structure.modified.test;
 
+import java.io.File;
+import java.net.URL;
+
 import junit.framework.Test;
 import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker;
 import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
 import org.jboss.test.deployers.vfs.structure.modified.support.XmlIncludeVirtualFileFilter;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.VirtualFileFilter;
 
 /**
@@ -58,11 +64,44 @@
       return new XmlIncludeVirtualFileFilter();
    }
 
-   protected void testStructureModified(StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception
+   protected void testStructureModified(AssembledDirectory ear, StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception
    {
+      VirtualFile root = deploymentUnit.getRoot();
       // initial run
-      assertFalse(checker.hasStructureBeenModified(deploymentUnit.getRoot()));
+      assertFalse(checker.hasStructureBeenModified(root));
       // already cached run 
-      assertFalse(checker.hasStructureBeenModified(deploymentUnit.getRoot()));
+      assertFalse(checker.hasStructureBeenModified(root));
+
+      AssembledDirectory jar = (AssembledDirectory)ear.getChild("simple.jar");
+      AssembledDirectory jarMD = (AssembledDirectory)jar.getChild("META-INF");
+
+      // 'update' web-beans.xml
+      URL url = getResource("/webbeans/simple/jar/META-INF/web-beans.xml");
+      assertNotNull(url);
+      File file = new File(url.toURI());
+      assertTrue(file.setLastModified(System.currentTimeMillis()));
+      assertTrue(checker.hasStructureBeenModified(root));
+      // should be the same
+      assertFalse(checker.hasStructureBeenModified(root));
+
+      // add new xml
+      url = getResource("/scanning/smoke/META-INF/jboss-scanning.xml");
+      assertNotNull(url);
+      jarMD.addChild(VFS.createNewRoot(url));
+      assertTrue(checker.hasStructureBeenModified(root));
+      // should be the same
+      assertFalse(checker.hasStructureBeenModified(root));
+
+      // 'remove' new xml
+      jarMD = jar.mkdir("META-INF");
+      url = getResource("/dependency/module/META-INF/jboss-dependency.xml");
+      assertNotNull(url);
+      jarMD.addChild(VFS.createNewRoot(url));
+      url = getResource("/webbeans/simple/ejb/META-INF/web-beans.xml");
+      assertNotNull(url);
+      jarMD.addChild(VFS.createNewRoot(url));
+      assertTrue(checker.hasStructureBeenModified(root));
+      // should be the same
+      assertFalse(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/StructureModificationTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/StructureModificationTest.java	2009-02-10 14:57:10 UTC (rev 84060)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/StructureModificationTest.java	2009-02-10 15:52:24 UTC (rev 84061)
@@ -55,7 +55,7 @@
       VFSDeploymentUnit deploymentUnit = assertDeploy(ear);
       try
       {
-         testStructureModified(checker, deploymentUnit);
+         testStructureModified(ear, checker, deploymentUnit);
       }
       finally
       {
@@ -63,5 +63,5 @@
       }
    }
 
-   protected abstract void testStructureModified(StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception;
+   protected abstract void testStructureModified(AssembledDirectory 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/MetaDataStructureModificationChecker.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java	2009-02-10 14:57:10 UTC (rev 84060)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java	2009-02-10 15:52:24 UTC (rev 84061)
@@ -130,6 +130,8 @@
                   // do we have some new files or some were deleted
                   if (leaves != null && children != null && leaves.size() != children.size())
                   {
+                     if (log.isTraceEnabled())
+                        log.trace("Metadata files number changed, old: " + leaves + ", now: " + children);
                      return true;
                   }
 
@@ -171,6 +173,8 @@
                   // not all previous leaves were removed - we're missing some == modified
                   if (leaves != null && leaves.isEmpty() == false)
                   {
+                     if (log.isTraceEnabled())
+                        log.trace("Missing old files: " + leaves);
                      return true;
                   }
                }




More information about the jboss-cvs-commits mailing list