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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 6 10:53:15 EDT 2010


Author: alesj
Date: 2010-04-06 10:53:15 -0400 (Tue, 06 Apr 2010)
New Revision: 103579

Added:
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/HibernateTestSuite.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/MockJPADeployer.java
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/test/
   projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.java
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/
   projects/scanning/trunk/testsuite/src/test/resources/hibernate/defaultpar.jar
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/test/
   projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.xml
Modified:
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java
Log:
Initial Hibernate tests.

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-04-06 14:49:25 UTC (rev 103578)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java	2010-04-06 14:53:15 UTC (rev 103579)
@@ -110,7 +110,7 @@
 
    Package loadPackage(String pckg)
    {
-      return loadClass(pckg + "/package-info").getPackage();
+      return loadClass(pckg + ".package-info").getPackage();
    }
 
    void addPackage(URL url, String pckg)

Copied: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/HibernateTestSuite.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/hibernate/HibernateTestSuite.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/HibernateTestSuite.java	2010-04-06 14:53:15 UTC (rev 103579)
@@ -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.hibernate;
+
+import org.jboss.test.scanning.hibernate.test.HibernateUnitTestCase;
+
+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 HibernateTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Hibernate Scanning Tests");
+
+      suite.addTest(HibernateUnitTestCase.suite());
+
+      return suite;
+   }
+}
\ No newline at end of file

Added: projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/MockJPADeployer.java
===================================================================
--- projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/MockJPADeployer.java	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/support/MockJPADeployer.java	2010-04-06 14:53:15 UTC (rev 103579)
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockJPADeployer extends AbstractVFSParsingDeployer<Object>
+{
+   public MockJPADeployer()
+   {
+      super(Object.class);
+      setAttachmentKey("org.jboss.metadata.jpa.spec.PersistenceMetaData");
+      setName("persistence.xml");
+   }
+
+   @Override
+   protected Object parse(VFSDeploymentUnit unit, VirtualFile file, Object root) throws Exception
+   {
+      return file.getPathName();
+   }
+}

Added: 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	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/java/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.java	2010-04-06 14:53:15 UTC (rev 103579)
@@ -0,0 +1,88 @@
+/*
+ * 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.test;
+
+import javax.persistence.Entity;
+
+import java.net.URL;
+
+import org.jboss.classloader.plugins.filter.CombiningClassFilter;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.classloader.spi.filter.ClassFilterUtils;
+import org.jboss.classloader.spi.filter.PackageClassFilter;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+import junit.framework.Test;
+import org.hibernate.ejb.packaging.Scanner;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class HibernateUnitTestCase extends BootstrapDeployersTest
+{
+   public HibernateUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(HibernateUnitTestCase.class);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+   }
+
+   public void testBasicUsage() throws Exception
+   {
+      ClassLoaderSystem system = (ClassLoaderSystem) getBean("ClassLoaderSystem", ControllerState.INSTALLED);
+      // we need to see hibernate/jpa
+      ClassFilter hibernateFilter = new PackageClassFilter(new String[]{Scanner.class.getPackage().getName(), Entity.class.getPackage().getName()});
+      ClassFilter before = new CombiningClassFilter(false, new ClassFilter[]{ClassFilterUtils.JAVA_ONLY, hibernateFilter});
+      ParentPolicy parentPolicy = new ParentPolicy(before, ClassFilterUtils.NOTHING);
+      system.getDefaultDomain().setParentPolicy(parentPolicy);
+
+      URL url = getResource("/hibernate/defaultpar.jar");
+      VirtualFile file = VFS.getChild(url);
+      DeploymentUnit unit = assertDeploy(file);
+      try
+      {
+         Scanner scanner = unit.getAttachment(Scanner.class);
+         assertNotNull(scanner);
+         // TODO
+      }
+      finally
+      {
+         undeploy(unit);
+      }
+   }
+}

Added: projects/scanning/trunk/testsuite/src/test/resources/hibernate/defaultpar.jar
===================================================================
(Binary files differ)


Property changes on: projects/scanning/trunk/testsuite/src/test/resources/hibernate/defaultpar.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Copied: projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.xml (from rev 103405, 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/hibernate/test/HibernateUnitTestCase.xml	                        (rev 0)
+++ projects/scanning/trunk/testsuite/src/test/resources/org/jboss/test/scanning/hibernate/test/HibernateUnitTestCase.xml	2010-04-06 14:53:15 UTC (rev 103579)
@@ -0,0 +1,25 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="jpa-deployer" class="org.jboss.test.scanning.hibernate.support.MockJPADeployer"/>  
+
+  <bean name="AnnEnvDeployer" class="org.jboss.scanning.deployers.ScanningDeployer">
+    <incallback method="addFactory" />
+    <uncallback method="removeFactory" />
+  </bean>
+
+  <bean name="HibScanningPlugin" class="org.jboss.scanning.hibernate.HibernateScanningPluginFactory">
+      <property name="annotations">
+          <set elementClass="java.lang.Class">
+              javax.persistence.Entity
+              javax.persistence.MappedSuperclass
+              javax.persistence.Embeddable
+          </set>
+      </property>
+      <property name="patterns">
+          <set>
+              **/*.hbm.xml
+          </set>
+      </property>
+  </bean>
+    
+</deployment>




More information about the jboss-cvs-commits mailing list