[jboss-cvs] JBossAS SVN: r103660 - in projects/scanning/trunk/testsuite/src/test: java/org/jboss/test/scanning/metadata/support and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 7 16:58:58 EDT 2010


Author: alesj
Date: 2010-04-07 16:58:57 -0400 (Wed, 07 Apr 2010)
New Revision: 103660

Added:
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/MetaDataTestSuite.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/DummyScanningHandle.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/SingletonVisitor.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/TestScanningPlugin.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/TestScanningPluginFactory.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.java
   projects/scanning/trunk/testsuite/src/test/resources/metadata/recurse/
   projects/scanning/trunk/testsuite/src/test/resources/metadata/recurse/META-INF/
   projects/scanning/trunk/testsuite/src/test/resources/metadata/recurse/META-INF/jboss-scanning.xml
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/metadata/
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/metadata/test/
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.xml
Log:
Add scanning visiting tests.

Copied: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/MetaDataTestSuite.java (from rev 103416, projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/annotations/AnnotationsTestSuite.java)
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/MetaDataTestSuite.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/MetaDataTestSuite.java	2010-04-07 20:58:57 UTC (rev 103660)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.metadata;
+
+import org.jboss.test.scanning.metadata.test.ScanningMetaDataTestCase;
+import org.jboss.test.scanning.metadata.test.ScanningUnitTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MetaDataTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("MetaData Scanning Tests");
+
+      suite.addTest(ScanningMetaDataTestCase.suite());
+      suite.addTest(ScanningUnitTestCase.suite());
+
+      return suite;
+   }
+}
\ No newline at end of file

Added: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/DummyScanningHandle.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/DummyScanningHandle.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/DummyScanningHandle.java	2010-04-07 20:58:57 UTC (rev 103660)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.metadata.support;
+
+import org.jboss.scanning.spi.ScanningHandle;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DummyScanningHandle implements ScanningHandle
+{
+   public void merge(ScanningHandle subHandle)
+   {
+   }
+}
\ No newline at end of file

Added: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/SingletonVisitor.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/SingletonVisitor.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/SingletonVisitor.java	2010-04-07 20:58:57 UTC (rev 103660)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.metadata.support;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.classloading.spi.visitor.ResourceVisitor;
+import org.jboss.scanning.spi.helpers.AllRecurseFilter;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class SingletonVisitor implements ResourceVisitor
+{
+   public static final SingletonVisitor INSTANCE = new SingletonVisitor();
+
+   private Set<String> visited = new HashSet<String>();
+
+   private SingletonVisitor()
+   {
+   }
+
+   public ResourceFilter getFilter()
+   {
+      return AllRecurseFilter.INSTANCE;
+   }
+
+   public void visit(ResourceContext resource)
+   {
+      visited.add(resource.getResourceName());
+   }
+
+   public Set<String> getVisited()
+   {
+      return visited;
+   }
+
+   public void clear()
+   {
+      visited.clear();
+   }
+}
\ No newline at end of file

Added: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/TestScanningPlugin.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/TestScanningPlugin.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/TestScanningPlugin.java	2010-04-07 20:58:57 UTC (rev 103660)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.metadata.support;
+
+import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.scanning.spi.helpers.AbstractScanningPlugin;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TestScanningPlugin extends AbstractScanningPlugin<DummyScanningHandle, DummyScanningHandle>
+{
+   @Override
+   protected DummyScanningHandle doCreateHandle()
+   {
+      return new DummyScanningHandle();
+   }
+
+   public Class<DummyScanningHandle> getHandleInterface()
+   {
+      return DummyScanningHandle.class;
+   }
+
+   public ResourceFilter getFilter()
+   {
+      return SingletonVisitor.INSTANCE.getFilter();
+   }
+
+   public void visit(ResourceContext resource)
+   {
+      SingletonVisitor.INSTANCE.visit(resource);
+   }
+}

Added: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/TestScanningPluginFactory.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/TestScanningPluginFactory.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/support/TestScanningPluginFactory.java	2010-04-07 20:58:57 UTC (rev 103660)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.metadata.support;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.scanning.plugins.DeploymentScanningPluginFactory;
+import org.jboss.scanning.spi.ScanningPlugin;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TestScanningPluginFactory implements DeploymentScanningPluginFactory<DummyScanningHandle, DummyScanningHandle>
+{
+   public boolean isRelevant(DeploymentUnit unit)
+   {
+      return true;
+   }
+
+   public ScanningPlugin<DummyScanningHandle, DummyScanningHandle> create(DeploymentUnit unit)
+   {
+      return new TestScanningPlugin();
+   }
+}
\ No newline at end of file

Copied: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.java (from rev 103652, projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/test/ScanningMetaDataTestCase.java)
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.java	2010-04-07 20:58:57 UTC (rev 103660)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.scanning.metadata.test;
+
+import java.util.Set;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+import org.jboss.test.scanning.annotations.support.jar.JarMarkOnClass;
+import org.jboss.test.scanning.annotations.support.jar.impl.JarMarkOnClassImpl;
+import org.jboss.test.scanning.annotations.support.war.WebMarkOnClass;
+import org.jboss.test.scanning.annotations.support.war.impl.WebMarkOnClassImpl;
+import org.jboss.test.scanning.metadata.support.SingletonVisitor;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+import junit.framework.Test;
+
+/**
+ * Test if scanning recurse filter work.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ScanningUnitTestCase extends BootstrapDeployersTest
+{
+   public ScanningUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ScanningUnitTestCase.class);
+   }
+
+   public void testRecurseFilter() throws Exception
+   {
+      VirtualFile jar = VFS.getChild(getName()).getChild("simple.jar");
+      createAssembledDirectory(jar)
+            .addPackage(JarMarkOnClassImpl.class)
+            .addPackage(JarMarkOnClass.class)
+            .addPackage(WebMarkOnClass.class)
+            .addPackage(WebMarkOnClassImpl.class)
+            .addPath("/metadata/recurse");
+
+      DeploymentUnit unit = assertDeploy(jar);
+      try
+      {
+         SingletonVisitor visitor = SingletonVisitor.INSTANCE;
+         Set<String> visited = visitor.getVisited();
+         System.out.println("visited = " + visited); // TODO -- proper test
+      }
+      finally
+      {
+         undeploy(unit);
+      }
+   }
+}
\ No newline at end of file

Copied: projects/scanning/trunk/testsuite/src/test/resources/metadata/recurse/META-INF/jboss-scanning.xml (from rev 103411, projects/scanning/trunk/testsuite/src/test/resources/annotations/base-scan/jar/META-INF/jboss-scanning.xml)
===================================================================
--- projects/scanning/trunk/testsuite/src/test/resources/metadata/recurse/META-INF/jboss-scanning.xml	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/resources/metadata/recurse/META-INF/jboss-scanning.xml	2010-04-07 20:58:57 UTC (rev 103660)
@@ -0,0 +1,6 @@
+<scanning xmlns="urn:jboss:scanning:1.0">
+  <path name="simple.jar">
+    <include name="org.jboss.test.scanning.annotations.support.jar"/>
+    <include name="org.jboss.test.scanning.annotations.support.war"/>
+  </path>
+</scanning>

Added: projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.xml
===================================================================
--- projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.xml	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.xml	2010-04-07 20:58:57 UTC (rev 103660)
@@ -0,0 +1,18 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+  <bean name="WarStructure" class="org.jboss.deployers.vfs.plugins.structure.war.WARStructure"/>
+
+  <bean name="ScanningMDDeployer" class="org.jboss.scanning.deployers.metadata.ScanningMetaDataDeployer"/>
+
+  <bean name="AnnEnvDeployer" class="org.jboss.scanning.deployers.ScanningDeployer">
+    <property name="filter">
+      <bean class="org.jboss.scanning.deployers.filter.ScanningDeploymentUnitFilter"/>
+    </property>
+    <incallback method="addFactory" />
+    <uncallback method="removeFactory" />
+  </bean>
+
+  <bean name="AnnScanningPlugin" class="org.jboss.test.scanning.metadata.support.TestScanningPluginFactory"/>
+
+</deployment>




More information about the jboss-cvs-commits mailing list