[jboss-cvs] JBossAS SVN: r92064 - in projects/jboss-deployers/trunk: deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 6 09:09:14 EDT 2009
Author: alesj
Date: 2009-08-06 09:09:13 -0400 (Thu, 06 Aug 2009)
New Revision: 92064
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/ExposedPMRFilter.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/PathMatchersTestCase.java
Modified:
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/PathMatchersResourceFilter.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/VFSMatchersTestSuite.java
Log:
Test path matchers.
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/VFSMatchersTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/VFSMatchersTestSuite.java 2009-08-06 11:54:35 UTC (rev 92063)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/VFSMatchersTestSuite.java 2009-08-06 13:09:13 UTC (rev 92064)
@@ -26,6 +26,7 @@
import junit.textui.TestRunner;
import org.jboss.test.deployers.vfs.matchers.test.FileMatchersTestCase;
import org.jboss.test.deployers.vfs.matchers.test.JarExtensionsTestCase;
+import org.jboss.test.deployers.vfs.matchers.test.PathMatchersTestCase;
/**
* Matchers test suite.
@@ -44,6 +45,7 @@
TestSuite suite = new TestSuite("VFS Matchers Tests");
suite.addTest(FileMatchersTestCase.suite());
+ suite.addTest(PathMatchersTestCase.suite());
suite.addTest(JarExtensionsTestCase.suite());
return suite;
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/ExposedPMRFilter.java (from rev 91150, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/ExposedFileStructure.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/ExposedPMRFilter.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/ExposedPMRFilter.java 2009-08-06 13:09:13 UTC (rev 92064)
@@ -0,0 +1,65 @@
+/*
+* 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.matchers.support;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.beans.metadata.api.annotations.Install;
+import org.jboss.beans.metadata.api.annotations.Uninstall;
+import org.jboss.deployers.vfs.spi.deployer.PathMatcher;
+import org.jboss.deployers.vfs.spi.structure.modified.PathMatchersResourceFilter;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * Exposes matchers.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ExposedPMRFilter extends PathMatchersResourceFilter
+{
+ protected Set<PathMatcher> matchers = new HashSet<PathMatcher>();
+
+ public ExposedPMRFilter(VirtualFileFilter delegate)
+ {
+ super(delegate);
+ }
+
+ public Set<PathMatcher> getMatchers()
+ {
+ return matchers;
+ }
+
+ @Install
+ public boolean addPathMatcher(PathMatcher pm)
+ {
+ super.addPathMatcher(pm);
+ return matchers.add(pm);
+ }
+
+ @Uninstall
+ public boolean removePathMatcher(PathMatcher pm)
+ {
+ matchers.remove(pm);
+ return super.removePathMatcher(pm);
+ }
+}
\ No newline at end of file
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/PathMatchersTestCase.java (from rev 91150, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/FileMatchersTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/PathMatchersTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/PathMatchersTestCase.java 2009-08-06 13:09:13 UTC (rev 92064)
@@ -0,0 +1,146 @@
+/*
+* 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.matchers.test;
+
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.deployers.spi.deployer.Deployers;
+import org.jboss.deployers.vfs.spi.deployer.FileMatcher;
+import org.jboss.deployers.vfs.spi.deployer.PathMatcher;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.test.deployers.vfs.matchers.support.ExposedFileStructure;
+import org.jboss.test.deployers.vfs.matchers.support.ExposedPMRFilter;
+import org.jboss.test.deployers.vfs.matchers.support.FeedbackDeployer;
+import org.jboss.test.deployers.vfs.matchers.support.TestBeanDeployer;
+import org.jboss.test.deployers.vfs.matchers.support.TestNameDeployer;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * Path matchers tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PathMatchersTestCase extends KernelHolderDeployersTest
+{
+ public PathMatchersTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(PathMatchersTestCase.class);
+ }
+
+ public void testMatchers() throws Throwable
+ {
+ KernelController controller = getController();
+
+ MainDeployerImpl main = new MainDeployerImpl();
+ main.setStructuralDeployers(createStructuralDeployers());
+
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("JARStructure", JARStructure.class.getName());
+ controller.install(builder.getBeanMetaData());
+ builder = BeanMetaDataBuilder.createBuilder("FileStructure", ExposedFileStructure.class.getName());
+ controller.install(builder.getBeanMetaData());
+
+ ControllerContext jarContext = controller.getInstalledContext("JARStructure");
+ assertNotNull(jarContext);
+ JARStructure jarStructure = (JARStructure)jarContext.getTarget();
+ assertNotNull(jarStructure);
+ addStructureDeployer(main, jarStructure);
+
+ builder = BeanMetaDataBuilder.createBuilder("PMRF", ExposedPMRFilter.class.getName());
+ builder.addConstructorParameter(VirtualFileFilter.class.getName(), builder.createInject("FileStructure"));
+ controller.install(builder.getBeanMetaData());
+
+ ControllerContext fileContext = controller.getInstalledContext("FileStructure");
+ assertNotNull(fileContext);
+ ExposedFileStructure fileStructure = (ExposedFileStructure)fileContext.getTarget();
+ assertNotNull(fileStructure);
+ addStructureDeployer(main, fileStructure);
+
+ ControllerContext filterContext = controller.getInstalledContext("PMRF");
+ assertNotNull(filterContext);
+ ExposedPMRFilter filter = (ExposedPMRFilter) filterContext.getTarget();
+ assertNotNull(filter);
+
+ Set<FileMatcher> matchers = fileStructure.getMatchers();
+ assertNotNull(matchers);
+ assertEmpty(matchers);
+
+ Set<PathMatcher> pms = filter.getMatchers();
+ assertNotNull(pms);
+ assertEmpty(pms);
+
+ builder = BeanMetaDataBuilder.createBuilder("BeanDeployer", TestBeanDeployer.class.getName());
+ controller.install(builder.getBeanMetaData());
+ assertEquals(1, matchers.size());
+ assertEquals(1, pms.size());
+
+ builder = BeanMetaDataBuilder.createBuilder("ExactNameDeployer", TestNameDeployer.class.getName());
+ builder.addConstructorParameter(String.class.getName(), "some.bsh");
+ controller.install(builder.getBeanMetaData());
+ assertEquals(2, matchers.size());
+ assertEquals(2, pms.size());
+
+ Deployers deployers = createDeployers();
+ main.setDeployers(deployers);
+
+ FeedbackDeployer beanDeployer = addDeployer(main, "BeanDeployer");
+ FeedbackDeployer nameDeployer = addDeployer(main, "ExactNameDeployer");
+
+ Deployment deploymentBeans = createDeployment("/matchers", "qwert.beans");
+ assertDeploy(main, deploymentBeans);
+ Deployment deploymentShells = createDeployment("/matchers", "beanshell.jar");
+ assertDeploy(main, deploymentShells);
+
+ assertNotNull(beanDeployer.getFiles());
+ assertEquals(new String[]{"some-beans.xml"}, beanDeployer.getFiles().toArray());
+
+ assertNotNull(nameDeployer.getFiles());
+ assertEquals(new String[]{"some.bsh"}, nameDeployer.getFiles().toArray());
+
+ // test path matching
+
+ assertTrue(filter.accepts("foobar-beans.xml"));
+ assertTrue(filter.accepts("/foobar-beans.xml"));
+ assertTrue(filter.accepts("/org/jboss/foobar-beans.xml"));
+ assertTrue(filter.accepts("some.bsh"));
+ assertTrue(filter.accepts("/some.bsh"));
+ assertTrue(filter.accepts("/org/jboss/some.bsh"));
+
+ assertFalse(filter.accepts("jboss-service.xml"));
+ assertFalse(filter.accepts("foobar.txt"));
+ assertFalse(filter.accepts("/foobar.txt"));
+ assertFalse(filter.accepts("/com/foo/foobar.txt"));
+ assertFalse(filter.accepts("/justpath"));
+ assertFalse(filter.accepts("/justpath/"));
+ assertFalse(filter.accepts("/qwert/justpath/"));
+ }
+}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java 2009-08-06 11:54:35 UTC (rev 92063)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java 2009-08-06 13:09:13 UTC (rev 92064)
@@ -74,7 +74,7 @@
int p = path.lastIndexOf("/");
String fileName;
- if (p > 0)
+ if (p >= 0)
fileName = path.substring(p + 1);
else
fileName = path;
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/PathMatchersResourceFilter.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/PathMatchersResourceFilter.java 2009-08-06 11:54:35 UTC (rev 92063)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/PathMatchersResourceFilter.java 2009-08-06 13:09:13 UTC (rev 92064)
@@ -79,7 +79,7 @@
* @param pm the path matcher
* @return Set#add
*/
- public boolean addFileMatcher(PathMatcher pm)
+ public boolean addPathMatcher(PathMatcher pm)
{
return pathMatchers.add(pm);
}
@@ -90,7 +90,7 @@
* @param pm the path matcher
* @return Set#remove
*/
- public boolean removeFileMatcher(PathMatcher pm)
+ public boolean removePathMatcher(PathMatcher pm)
{
return pathMatchers.remove(pm);
}
More information about the jboss-cvs-commits
mailing list