[jboss-cvs] JBossAS SVN: r106055 - in projects/scanning/trunk: testsuite/src/test/java/org/jboss/test/scanning/hibernate/support and 13 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 15 11:45:02 EDT 2010


Author: alesj
Date: 2010-06-15 11:45:01 -0400 (Tue, 15 Jun 2010)
New Revision: 106055

Added:
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/Account.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/package-info.java
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/META-INF/
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/META-INF/application.properties
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/ext.jar/
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/ext.jar/META-INF/
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/ext.jar/META-INF/empty.txt
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/par.jar/
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/par.jar/META-INF/
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/par.jar/META-INF/persistence.xml
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/support/
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/support/model/
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/support/model/Account.hbm.xml
Modified:
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.java
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.xml
Log:
Allow for external lazy scanning -- e.g. <jar-file> in persistence.xml.

Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java	2010-06-15 13:38:00 UTC (rev 106054)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java	2010-06-15 15:45:01 UTC (rev 106055)
@@ -93,7 +93,8 @@
       this.finder = DeploymentUtilsFactory.getFinder(unit);
       this.handler = DeploymentUtilsFactory.getHandler(unit);
 
-      allowQueryInvocationSearch = DeploymentUtilsFactory.getAttachment(unit, "org.jboss.scanning.hibernate.allowQueryInvocationSearch", Boolean.class, Boolean.FALSE);      
+      // allow runtime scanning, but don't cache
+      allowQueryInvocationSearch = DeploymentUtilsFactory.getAttachment(unit, "org.jboss.scanning.hibernate.allowQueryInvocationSearch", Boolean.class, Boolean.TRUE);      
       cacheNewResults = DeploymentUtilsFactory.getAttachment(unit, "org.jboss.scanning.hibernate.cacheNewResults", Boolean.class, Boolean.FALSE);
    }
 

Added: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/Account.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/Account.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/Account.java	2010-06-15 15:45:01 UTC (rev 106055)
@@ -0,0 +1,33 @@
+/*
+ * 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.hibernate.support.model;
+
+import javax.persistence.Entity;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+ at Entity
+public class Account
+{
+}

Added: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/package-info.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/package-info.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/model/package-info.java	2010-06-15 15:45:01 UTC (rev 106055)
@@ -0,0 +1,27 @@
+/*
+* 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.
+*/
+ at JBossXmlSchema(namespace="urn:jboss:myother:1.0", elementFormDefault= XmlNsForm.QUALIFIED)
+package org.jboss.test.scanning.hibernate.support.model;
+
+import javax.xml.bind.annotation.XmlNsForm;
+
+import org.jboss.xb.annotations.JBossXmlSchema;

Modified: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.java	2010-06-15 13:38:00 UTC (rev 106054)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.java	2010-06-15 15:45:01 UTC (rev 106055)
@@ -34,7 +34,9 @@
 import java.util.Set;
 
 import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.support.AssembledDirectory;
 import org.jboss.test.scanning.ScanningDeployersTest;
+import org.jboss.test.scanning.hibernate.support.model.Account;
 import org.jboss.vfs.VFS;
 import org.jboss.vfs.VirtualFile;
 
@@ -73,6 +75,11 @@
       {
          Scanner scanner = unit.getAttachment(Scanner.class);
          assertNotNull(scanner);
+         // annotations
+         final HashSet<Class<? extends Annotation>> annotationsToLookFor = new HashSet<Class<? extends Annotation>>(Arrays.asList(Entity.class, Embeddable.class, MappedSuperclass.class));
+         Set<Class<?>> annotatedClasses = scanner.getClassesInJar(url, annotationsToLookFor);
+         assertNotNull(annotatedClasses);
+         assertEquals(3, annotatedClasses.size());
          // files
          Set<NamedInputStream> files = scanner.getFilesInJar(url, Collections.singleton("**/*.hbm.xml"));
          assertNotNull(files);
@@ -81,15 +88,47 @@
          Set<Package> pckgs = scanner.getPackagesInJar(url, Collections.<Class<? extends Annotation>>emptySet());
          assertNotNull(pckgs);
          assertEquals(1, pckgs.size()); // only packages with some Hibernate/JPA related classes
-         // annotations
-         final HashSet<Class<? extends Annotation>> annotationsToLookFor = new HashSet<Class<? extends Annotation>>(Arrays.asList(Entity.class, Embeddable.class, MappedSuperclass.class));
-         Set<Class<?>> annotatedClasses = scanner.getClassesInJar(url, annotationsToLookFor);
-         assertNotNull(annotatedClasses);
-         assertEquals(3, annotatedClasses.size());
       }
       finally
       {
          undeploy(unit);
       }
    }
+
+   public void testExternalJarUsage() throws Exception
+   {
+      VirtualFile virtual = VFS.getChild("/virtual/ext.ear");
+      AssembledDirectory top = createAssembledDirectory(virtual);
+      top.addPath("META-INF", "/hibernate/ext.ear/META-INF");
+      top.addPath("par.jar", "/hibernate/ext.ear/par.jar");
+      top.addPath("ext.jar", "/hibernate/ext.ear/ext.jar");
+      top.addPackage("ext.jar", Account.class);
+      top.addResources("ext.jar", Account.class, new String[]{"**/*.hbm.xml"}, new String[]{});
+
+      DeploymentUnit topDU = assertDeploy(virtual);
+      try
+      {
+         DeploymentUnit parDU = assertChild(topDU, "par.jar");
+         Scanner scanner = parDU.getAttachment(Scanner.class);
+         assertNotNull(scanner);
+         VirtualFile extVirtual = virtual.getChild("ext.jar");
+         URL url = extVirtual.asDirectoryURL();
+         // annotations
+         Set<Class<?>> classes = scanner.getClassesInJar(url, Collections.<Class<? extends Annotation>>singleton(Entity.class));
+         assertNotNull(classes);
+         assertEquals(1, classes.size());
+         // files
+         Set<NamedInputStream> files = scanner.getFilesInJar(url, Collections.singleton("**/*.hbm.xml"));
+         assertNotNull(files);
+         assertEquals(1, files.size());
+         // packages
+         Set<Package> pckgs = scanner.getPackagesInJar(url, Collections.<Class<? extends Annotation>>emptySet());
+         assertNotNull(pckgs);
+         assertEquals(1, pckgs.size());
+      }
+      finally
+      {
+         undeploy(topDU);   
+      }
+   }
 }

Added: projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/META-INF/application.properties
===================================================================
--- projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/META-INF/application.properties	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/META-INF/application.properties	2010-06-15 15:45:01 UTC (rev 106055)
@@ -0,0 +1,2 @@
+config-module=par.jar
+mappings-module=ext.jar

Added: projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/ext.jar/META-INF/empty.txt
===================================================================
--- projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/ext.jar/META-INF/empty.txt	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/ext.jar/META-INF/empty.txt	2010-06-15 15:45:01 UTC (rev 106055)
@@ -0,0 +1 @@
+Empty.

Added: projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/par.jar/META-INF/persistence.xml
===================================================================
--- projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/par.jar/META-INF/persistence.xml	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/resources/hibernate/ext.ear/par.jar/META-INF/persistence.xml	2010-06-15 15:45:01 UTC (rev 106055)
@@ -0,0 +1 @@
+<persistence/>

Added: projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/support/model/Account.hbm.xml
===================================================================
--- projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/support/model/Account.hbm.xml	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/support/model/Account.hbm.xml	2010-06-15 15:45:01 UTC (rev 106055)
@@ -0,0 +1 @@
+<hbm/>

Modified: projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.xml
===================================================================
--- projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.xml	2010-06-15 13:38:00 UTC (rev 106054)
+++ projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.xml	2010-06-15 15:45:01 UTC (rev 106055)
@@ -1,5 +1,8 @@
 <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.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>  
+
   <bean name="jpa-deployer" class="org.jboss.test.scanning.hibernate.support.MockJPADeployer"/>  
 
   <bean name="AnnEnvDeployer" class="org.jboss.scanning.deployers.ScanningDeployer">



More information about the jboss-cvs-commits mailing list