[jboss-cvs] JBossAS SVN: r103821 - in projects/scanning/trunk/testsuite/src/test: java/org/jboss/test/scanning/annotations/test and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 12 07:43:07 EDT 2010


Author: alesj
Date: 2010-04-12 07:43:06 -0400 (Mon, 12 Apr 2010)
New Revision: 103821

Added:
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/HierarchyTestSuite.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/support/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/test/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/test/HierarchyUnitTestCase.java
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hierarchy/
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hierarchy/test/
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hierarchy/test/HierarchyUnitTestCase.xml
Modified:
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/annotations/test/AbstractAnnotationsScanningTest.java
Log:
Add initial hierarchy tests.

Modified: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/annotations/test/AbstractAnnotationsScanningTest.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/annotations/test/AbstractAnnotationsScanningTest.java	2010-04-12 11:36:40 UTC (rev 103820)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/annotations/test/AbstractAnnotationsScanningTest.java	2010-04-12 11:43:06 UTC (rev 103821)
@@ -67,9 +67,10 @@
       enableTrace("org.jboss.deployers");
 
       DeploymentUnit unit = assertDeploy(ear);
-      assertEar(unit);
       try
       {
+         assertEar(unit);
+
          AnnotationRepository env = unit.getAttachment(AnnotationIndex.class);
          assertNotNull(env);
          Set<Element<Annotation, Class<?>>> annotations = env.classIsAnnotatedWith("org.jboss.test.scanning.annotations.support.MarkedAnnotation");

Copied: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/HierarchyTestSuite.java (from rev 103689, 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/hierarchy/HierarchyTestSuite.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/HierarchyTestSuite.java	2010-04-12 11:43:06 UTC (rev 103821)
@@ -0,0 +1,49 @@
+/*
+ * 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.hierarchy;
+
+import org.jboss.test.scanning.hierarchy.test.HierarchyUnitTestCase;
+
+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 HierarchyTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Hierarchy Scanning Tests");
+
+      suite.addTest(HierarchyUnitTestCase.suite());
+
+      return suite;
+   }
+}
\ No newline at end of file

Copied: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/test/HierarchyUnitTestCase.java (from rev 103693, projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/metadata/test/ScanningUnitTestCase.java)
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/test/HierarchyUnitTestCase.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hierarchy/test/HierarchyUnitTestCase.java	2010-04-12 11:43:06 UTC (rev 103821)
@@ -0,0 +1,141 @@
+/*
+ * 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.hierarchy.test;
+
+import java.util.Set;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.scanning.hierarchy.spi.HierarchyIndex;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+import org.jboss.test.scanning.annotations.support.NoExtRecurseFilter;
+import org.jboss.test.scanning.annotations.support.ext.External;
+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.util.Util;
+import org.jboss.test.scanning.annotations.support.war.WebMarkOnClass;
+import org.jboss.test.scanning.annotations.support.war.impl.WebMarkOnClassImpl;
+import org.jboss.test.scanning.annotations.support.warlib.SomeUIClass;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+import junit.framework.Test;
+
+/**
+ * Hierarchy tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class HierarchyUnitTestCase extends BootstrapDeployersTest
+{
+   public HierarchyUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(HierarchyUnitTestCase.class);
+   }
+
+   public void testEar() throws Exception
+   {
+      VirtualFile ear = createTopLevelWithUtil();
+      createAssembledDirectory(ear.getChild("simple.jar"))
+        .addPackage(JarMarkOnClassImpl.class)
+        .addPackage(JarMarkOnClass.class)
+        .addPath("/annotations/base-scan/jar");
+
+      createAssembledDirectory(ear.getChild("simple.war"))
+         .addPackage("WEB-INF/classes", WebMarkOnClassImpl.class)
+         .addPackage("WEB-INF/classes", WebMarkOnClass.class)
+         .addPackage("WEB-INF/lib/ui.jar", SomeUIClass.class)
+         .addPath("/annotations/base-scan/web");
+
+      enableTrace("org.jboss.deployers");
+
+      DeploymentUnit unit = assertDeploy(ear);
+      try
+      {
+         assertEar(unit);
+
+         DeploymentUnit jarUnit = assertChild(unit, "simple.jar");
+         assertJar(jarUnit);
+
+         DeploymentUnit webUnit = assertChild(unit, "simple.war");
+         assertWar(webUnit);
+      }
+      finally
+      {
+         undeploy(unit);
+      }
+   }
+
+   protected void assertEar(DeploymentUnit ear) throws Exception
+   {
+   }
+
+   protected void assertJar(DeploymentUnit jar) throws Exception
+   {
+   }
+
+   protected void assertWar(DeploymentUnit war) throws Exception
+   {
+   }
+
+   protected HierarchyIndex getIndex(DeploymentUnit unit)
+   {
+      HierarchyIndex index = unit.getAttachment(HierarchyIndex.class);
+      assertNotNull(index);
+      return index;
+   }
+
+   protected VirtualFile getRoot(DeploymentUnit unit)
+   {
+      if (unit instanceof VFSDeploymentUnit == false)
+         throw new IllegalArgumentException("Illegal unit type");
+
+      VFSDeploymentUnit vdu = (VFSDeploymentUnit) unit;
+      return vdu.getRoot();
+   }
+
+   protected Set<TypeInfo> getInheritedClasses(DeploymentUnit unit, Class<?> superType)
+   {
+      HierarchyIndex index = getIndex(unit);
+      VirtualFile root = getRoot(unit);
+      return index.getInheritedClasses(root.getPathName(), superType);
+   }
+
+   protected VirtualFile createTopLevelWithUtil() throws Exception
+   {
+      VirtualFile topLevel = VFS.getChild(getName()).getChild("top-level.ear");
+
+      createAssembledDirectory(topLevel)
+         .addPath("/annotations/base-scan")
+         .addPackage("lib/util.jar", Util.class)
+         .addPackage("lib/ext.jar", External.class)
+         .addPackage("lib/ann.jar", NoExtRecurseFilter.class);
+      return topLevel;
+   }
+}

Copied: projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hierarchy/test/HierarchyUnitTestCase.xml (from rev 103689, projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/annotations/test/AnnotationsScanningTestCase.xml)
===================================================================
--- projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hierarchy/test/HierarchyUnitTestCase.xml	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hierarchy/test/HierarchyUnitTestCase.xml	2010-04-12 11:43:06 UTC (rev 103821)
@@ -0,0 +1,13 @@
+<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="AnnEnvDeployer" class="org.jboss.scanning.deployers.ScanningDeployer">
+    <incallback method="addFactory" />
+    <uncallback method="removeFactory" />
+  </bean>
+
+  <bean name="AnnScanningPlugin" class="org.jboss.scanning.hierarchy.plugins.HierarchyIndexScanningPluginFactory" />
+    
+</deployment>




More information about the jboss-cvs-commits mailing list