[jboss-cvs] JBossAS SVN: r84059 - in projects/jboss-deployers/trunk: deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 10 09:26:27 EST 2009
Author: alesj
Date: 2009-02-10 09:26:27 -0500 (Tue, 10 Feb 2009)
New Revision: 84059
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/support/
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/support/XmlIncludeVirtualFileFilter.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/
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
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/VFSStructureTestSuite.java
Log:
Aviod duplicate context check.
Add initial tests (TODO on actual modification).
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-02-10 14:02:01 UTC (rev 84058)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java 2009-02-10 14:26:27 UTC (rev 84059)
@@ -43,6 +43,7 @@
import org.jboss.test.deployers.vfs.structure.war.test.CombinedWARStructureUnitTestCase;
import org.jboss.test.deployers.vfs.structure.war.test.WARStructureUnitTestCase;
import org.jboss.test.deployers.vfs.structure.war.test.WARUnpackUnitTestCase;
+import org.jboss.test.deployers.vfs.structure.modified.test.MetaDataStructureModificationTestCase;
/**
* VFSStructureTestSuite.
@@ -81,6 +82,7 @@
suite.addTest(InnerModificationUnitTestCase.suite());
suite.addTest(DirStructureUnitTestCase.suite());
suite.addTest(RealDirStructureUnitTestCase.suite());
+ suite.addTest(MetaDataStructureModificationTestCase.suite());
return suite;
}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/support/XmlIncludeVirtualFileFilter.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/support/XmlIncludeVirtualFileFilter.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/support/XmlIncludeVirtualFileFilter.java 2009-02-10 14:26:27 UTC (rev 84059)
@@ -0,0 +1,38 @@
+/*
+ * 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.support;
+
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Include only .xml files.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class XmlIncludeVirtualFileFilter implements VirtualFileFilter
+{
+ public boolean accepts(VirtualFile file)
+ {
+ return file.getName().endsWith(".xml");
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java 2009-02-10 14:26:27 UTC (rev 84059)
@@ -0,0 +1,68 @@
+/*
+ * 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 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.VirtualFileFilter;
+
+/**
+ * Test StructureModificationChecker.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MetaDataStructureModificationTestCase extends StructureModificationTest
+{
+ public MetaDataStructureModificationTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(MetaDataStructureModificationTestCase.class);
+ }
+
+ protected StructureModificationChecker createStructureModificationChecker(MainDeployerStructure mainDeployerStructure, VirtualFileFilter filter)
+ {
+ MetaDataStructureModificationChecker structureModificationChecker = new MetaDataStructureModificationChecker(mainDeployerStructure);
+ structureModificationChecker.setFilter(filter);
+ return structureModificationChecker;
+ }
+
+ protected VirtualFileFilter createFilter()
+ {
+ return new XmlIncludeVirtualFileFilter();
+ }
+
+ protected void testStructureModified(StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception
+ {
+ // initial run
+ assertFalse(checker.hasStructureBeenModified(deploymentUnit.getRoot()));
+ // already cached run
+ assertFalse(checker.hasStructureBeenModified(deploymentUnit.getRoot()));
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/StructureModificationTest.java 2009-02-10 14:26:27 UTC (rev 84059)
@@ -0,0 +1,67 @@
+/*
+ * 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 org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.deployers.vfs.webbeans.test.AbstractWebBeansTest;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * Test StructureModificationChecker.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class StructureModificationTest extends AbstractWebBeansTest
+{
+ protected StructureModificationTest(String name)
+ {
+ super(name);
+ }
+
+ protected abstract StructureModificationChecker createStructureModificationChecker(MainDeployerStructure mainDeployerStructure, VirtualFileFilter filter);
+
+ protected abstract VirtualFileFilter createFilter();
+
+ public void testDoBasicTest() throws Exception
+ {
+ AssembledDirectory ear = createBasicEar();
+
+ MainDeployerStructure mainDeployer = assertBean("MainDeployer", MainDeployerStructure.class);
+ VirtualFileFilter filter = createFilter();
+ StructureModificationChecker checker = createStructureModificationChecker(mainDeployer, filter);
+
+ VFSDeploymentUnit deploymentUnit = assertDeploy(ear);
+ try
+ {
+ testStructureModified(checker, deploymentUnit);
+ }
+ finally
+ {
+ undeploy(deploymentUnit);
+ }
+ }
+
+ protected abstract void testStructureModified(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:02:01 UTC (rev 84058)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java 2009-02-10 14:26:27 UTC (rev 84059)
@@ -22,6 +22,7 @@
package org.jboss.deployers.vfs.spi.structure.modified;
import java.io.IOException;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -39,6 +40,9 @@
*/
public class MetaDataStructureModificationChecker extends AbstractStructureModificationChecker<Long>
{
+ /** The current context path const */
+ private static final Set<String> CURRENT_PATH = Collections.singleton("");
+
/** The metadata filter */
private VirtualFileFilter filter;
@@ -60,7 +64,7 @@
protected boolean hasStructureBeenModifed(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException
{
StructureMetaData structureMetaData = deploymentContext.getTransientManagedObjects().getAttachment(StructureMetaData.class);
- return hasStructureBeenModified(root, structureMetaData);
+ return hasStructureBeenModified(root, structureMetaData, null);
}
/**
@@ -68,10 +72,11 @@
*
* @param root the root
* @param structureMetaData the structure metadata
+ * @param excludedPaths the excluded paths
* @return true if modifed, false otherwise
* @throws IOException for any error
*/
- protected boolean hasStructureBeenModified(VirtualFile root, StructureMetaData structureMetaData) throws IOException
+ protected boolean hasStructureBeenModified(VirtualFile root, StructureMetaData structureMetaData, Set<String> excludedPaths) throws IOException
{
if (structureMetaData == null)
return false;
@@ -81,6 +86,15 @@
{
for (ContextInfo contextInfo : contexts)
{
+ if (excludedPaths != null)
+ {
+ String path = contextInfo.getPath();
+ if (excludedPaths.contains(path))
+ {
+ continue;
+ }
+ }
+
if (hasStructureBeenModifed(root, contextInfo))
return true;
}
@@ -165,7 +179,7 @@
if ("".equals(path) == false)
{
StructureMetaData structureMetaData = contextInfo.getPredeterminedManagedObjects().getAttachment(StructureMetaData.class);
- return hasStructureBeenModified(contextRoot, structureMetaData);
+ return hasStructureBeenModified(contextRoot, structureMetaData, CURRENT_PATH);
}
}
return false;
More information about the jboss-cvs-commits
mailing list