This is an automated email from the ASF dual-hosted git repository. jgallimore pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomee.git
commit a68f21d1aafeab53ebe3c55415e4739476045409 Author: Jonathan Gallimore <j...@jrg.me.uk> AuthorDate: Tue Jun 25 17:23:55 2019 +0100 TOMEE-2548 Adding (currently failing) test for Hibernate --- .../cmp/sample/CustomOrmXmlHibernateEarTest.java | 106 +++++++++++++++++++++ .../src/test/resources/arquillian.xml | 22 +++++ .../arquillian/tests/cmp/sample/custom-orm.xml | 4 +- .../{persistence.xml => persistence-hibernate.xml} | 8 +- .../arquillian/tests/cmp/sample/persistence.xml | 2 +- arquillian/arquillian-tomee-tests/pom.xml | 58 +++++++++++ 6 files changed, 193 insertions(+), 7 deletions(-) diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlHibernateEarTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlHibernateEarTest.java new file mode 100644 index 0000000..2eb9302 --- /dev/null +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlHibernateEarTest.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.arquillian.tests.cmp.sample; + +import org.apache.ziplock.IO; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.resolver.api.maven.Maven; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.File; +import java.net.URL; + +/** + * @version $Rev$ $Date$ + */ +@RunWith(Arquillian.class) +public class CustomOrmXmlHibernateEarTest { + + @ArquillianResource + private URL url; + + @Deployment(testable = false) + public static EnterpriseArchive createDeployment() { + + final JavaArchive clientJar = ShrinkWrap.create(JavaArchive.class, "client.jar") + .addClasses(ActorDetails.class, LocalActor.class, LocalActorHome.class, + LocalMovie.class, LocalMovieHome.class, MovieDetails.class, + MoviesBusiness.class, MoviesBusinessHome.class); + + final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejb-jar.jar") + .addClasses(ActorBean.class, MovieBean.class, MovieDetails.class, MoviesBusinessBean.class) + .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml"), "META-INF/openejb-cmp-generated-orm.xml") + .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/persistence-hibernate.xml"), "META-INF/persistence.xml") + .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "META-INF/openejb-jar.xml") + .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml"), "META-INF/ejb-jar.xml"); + + final WebArchive testWar = ShrinkWrap.create(WebArchive.class, "test.war") + .addClass(MoviesServlet.class) + .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/web.xml"), "web.xml"); + + final File[] hibernateDependencies = Maven.resolver().resolve( + "org.hibernate:hibernate-entitymanager:4.3.9.Final", + "org.hibernate:hibernate-core:4.3.9.Final", + "org.hibernate.common:hibernate-commons-annotations:4.0.5.Final", + "antlr:antlr:2.7.7", + "org.jboss:jandex:1.1.0.Final", + "org.jboss.logging:jboss-logging:3.1.3.GA", + "org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1", + "dom4j:dom4j:1.6.1", + "org.javassist:javassist:3.18.1-GA", + "mysql:mysql-connector-java:5.1.13" + ).withoutTransitivity().asFile(); + + final EnterpriseArchive archive = ShrinkWrap.create(EnterpriseArchive.class, "test.ear") + .addAsLibrary(clientJar) + .addAsLibraries(hibernateDependencies) + .addAsModule(ejbJar) + .addAsModule(testWar); + + System.out.println(archive.toString(true)); + return archive; + } + + + @Test + @RunAsClient + public void checkCmpJpaEntityORMMappings() throws Exception { + final String output = IO.slurp(new URL(url.toExternalForm() + "/test/test/")); + System.out.println(output); + + Assert.assertTrue(output.contains("TABLE_NAME: ACTOR, COLUMN_NAME: ACTORID, DATA_TYPE: INTEGER, CHARACTER_MAXIMUM_LENGTH: null")); + Assert.assertTrue(output.contains("TABLE_NAME: ACTOR, COLUMN_NAME: ACTOR_NAME, DATA_TYPE: CHARACTER VARYING, CHARACTER_MAXIMUM_LENGTH: 250")); + Assert.assertTrue(output.contains("TABLE_NAME: ACTOR_MOVIE, COLUMN_NAME: ACTORS_ACTORID, DATA_TYPE: INTEGER, CHARACTER_MAXIMUM_LENGTH: null")); + Assert.assertTrue(output.contains("TABLE_NAME: ACTOR_MOVIE, COLUMN_NAME: MOVIES_MOVIEID, DATA_TYPE: INTEGER, CHARACTER_MAXIMUM_LENGTH: null")); + Assert.assertTrue(output.contains("TABLE_NAME: MOVIE, COLUMN_NAME: MOVIEID, DATA_TYPE: INTEGER, CHARACTER_MAXIMUM_LENGTH: null")); + Assert.assertTrue(output.contains("TABLE_NAME: MOVIE, COLUMN_NAME: GENRE, DATA_TYPE: CHARACTER VARYING, CHARACTER_MAXIMUM_LENGTH: 255")); + Assert.assertTrue(output.contains("TABLE_NAME: MOVIE, COLUMN_NAME: MOVIE_NAME, DATA_TYPE: CHARACTER VARYING, CHARACTER_MAXIMUM_LENGTH: 250")); + + final String[] split = output.split("\r?\n"); + Assert.assertEquals(7, split.length); + } +} \ No newline at end of file diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml index 8640e8e..eb1807a 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/arquillian.xml @@ -113,6 +113,28 @@ </property> </configuration> </container> + <container qualifier="tomee-remote-hibernate"> + <configuration> + <property name="httpPort">-1</property> + <property name="ajpPort">-1</property> + <property name="stopPort">-1</property> + <property name="dir">target/tomee-remote</property> + <property name="appWorkingDir">target/arquillian-remote-working-dir</property> + <property name="portRange">33001-36000</property> + <property name="cleanOnStartUp">true</property> + <property name="properties"> + My\ DataSource.JdbcUrl = jdbc:hsqldb:mem:hsqldb + My\ Unmanaged\ DataSource.JdbcUrl = jdbc:hsqldb:mem:hsqldb + openejb.classloader.forced-load=org.apache.openejb.arquillian.tests + openejb.ear.use-as-webcontext-base=true + embedded = false + + # try to save some permgen mem + openejb.cdi.activated-on-ejb = false + openejb.descriptors.output = true + </property> + </configuration> + </container> <container qualifier="tomee-remote-secpol"> <configuration> <property name="httpPort">-1</property> diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml index 22dbae5..b6414e4 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. --> -<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0"> +<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="2.0"> <entity class="openejb.org.apache.openejb.arquillian.tests.cmp.sample.Movie" name="Movie"> <description>CustomOrmXmlTest#MovieBean</description> <table/> @@ -31,7 +31,7 @@ <column name="movie_name" length="250"/> </basic> <basic name="genre"/> - <many-to-many mapped-by="movies" name="actors"/> + <many-to-many mapped-by="movies" name="actors" /> </attributes> </entity> <entity class="openejb.org.apache.openejb.arquillian.tests.cmp.sample.Actor" name="Actor"> diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence-hibernate.xml similarity index 82% copy from arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml copy to arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence-hibernate.xml index 05667e4..e7a437a 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence-hibernate.xml @@ -18,15 +18,15 @@ --> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="cmp" transaction-type="JTA"> + <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <jta-data-source>My DataSource</jta-data-source> <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source> <mapping-file>META-INF/openejb-cmp-generated-orm.xml</mapping-file> <class>openejb.org.apache.openejb.arquillian.tests.cmp.sample.Movie</class> <class>openejb.org.apache.openejb.arquillian.tests.cmp.sample.Actor</class> <properties> - <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true, Indexes=false, IgnoreErrors=true)"/> - <property name="openjpa.Log" value="DefaultLevel=INFO"/> - <property name="eclipselink.ddl-generation" value="create-tables"/> + <property name="hibernate.hbm2ddl.auto" value="update"/> + <property name="hibernate.show_sql" value="true" /> </properties> </persistence-unit> -</persistence> +</persistence> \ No newline at end of file diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml index 05667e4..ce03420 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml @@ -29,4 +29,4 @@ <property name="eclipselink.ddl-generation" value="create-tables"/> </properties> </persistence-unit> -</persistence> +</persistence> \ No newline at end of file diff --git a/arquillian/arquillian-tomee-tests/pom.xml b/arquillian/arquillian-tomee-tests/pom.xml index c665903..bab84f3 100644 --- a/arquillian/arquillian-tomee-tests/pom.xml +++ b/arquillian/arquillian-tomee-tests/pom.xml @@ -121,6 +121,64 @@ <version>${project.version}</version> </dependency> + + <!-- for tests with Hibernate --> + + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + <version>4.3.9.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>4.3.9.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.hibernate.common</groupId> + <artifactId>hibernate-commons-annotations</artifactId> + <version>4.0.5.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>antlr</groupId> + <artifactId>antlr</artifactId> + <version>2.7.7</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss</groupId> + <artifactId>jandex</artifactId> + <version>1.1.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging</artifactId> + <version>3.1.3.GA</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging-annotations</artifactId> + <version>1.2.0.Beta1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>dom4j</groupId> + <artifactId>dom4j</artifactId> + <version>1.6.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.javassist</groupId> + <artifactId>javassist</artifactId> + <version>3.18.1-GA</version> + <scope>provided</scope> + </dependency> + <!-- just to get it in the correct order --> <dependency> <groupId>${project.groupId}</groupId>