From eeb67e9be67323bfe5b951ad2b04de61abe77a11 Mon Sep 17 00:00:00 2001 From: Alexis Hassler Date: Tue, 10 Apr 2012 10:47:29 +0200 Subject: [PATCH 1/2] JPA 2 : upgrade to JBoss AS 7.1.1, Glassfish 3.1.2 and Arquillian 1.0.0.CR8 --- .gitignore | 3 + jpa2/pom.xml | 140 +++++++++--------- .../com/acme/jpa/GamePersistenceTestCase.java | 47 +++--- .../glassfish-resources.xml | 14 ++ .../sun-resources.xml | 26 ---- .../test-persistence.xml | 5 - .../test-persistence.xml | 11 +- .../resources-jbossas-remote/jndi.properties | 3 - .../test-persistence.xml | 2 +- jpa2/src/test/resources/arquillian.xml | 23 +-- 10 files changed, 116 insertions(+), 158 deletions(-) create mode 100644 jpa2/src/test/resources-glassfish-embedded/glassfish-resources.xml delete mode 100644 jpa2/src/test/resources-glassfish-embedded/sun-resources.xml delete mode 100644 jpa2/src/test/resources-jbossas-remote/jndi.properties diff --git a/.gitignore b/.gitignore index 24d3342..153d3d8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ .project .settings/ target/ +.idea/ +*.iml + diff --git a/jpa2/pom.xml b/jpa2/pom.xml index 41d5c48..390bf96 100644 --- a/jpa2/pom.xml +++ b/jpa2/pom.xml @@ -13,9 +13,12 @@ A self-contained Arquillian project for testing JPA 2 - UTF-8 - yyyyMMdd'T'HHmmss - 1.0.0.Alpha5 + UTF-8 + yyyyMMdd'T'HHmmss + 3.1.2 + 7.1.1.Final + 1.0.0.CR8 + 1.0.0.CR3 @@ -47,31 +50,32 @@ - - + org.hibernate hibernate-jpamodelgen 1.0.0.Final provided - - - org.hibernate.javax.persistence - hibernate-jpa-2.0-api - - + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + + junit junit - 4.8.2 + 4.10 + test - - org.jboss.arquillian - arquillian-junit - ${arquillian.version} + + org.jboss.arquillian.junit + arquillian-junit-container + ${arquillian.version} + test @@ -82,7 +86,7 @@ maven-compiler-plugin - 2.3.1 + 2.3.2 1.6 1.6 @@ -113,7 +117,7 @@ org.codehaus.mojo build-helper-maven-plugin - 1.5 + 1.7 process-sources @@ -157,14 +161,15 @@ - org.jboss.arquillian.container - arquillian-glassfish-embedded-3 - ${arquillian.version} + org.jboss.arquillian.container + arquillian-glassfish-embedded-3.1 + ${arquillian_container_glassfish.version} + test - org.glassfish.extras - glassfish-embedded-all - 3.0.1 + org.glassfish.main.extras + glassfish-embedded-web + ${glassfish.version} @@ -180,18 +185,22 @@ + arq-glassfish-remote org.jboss.arquillian.container - arquillian-glassfish-remote-3 - ${arquillian.version} - - - org.glassfish.extras - glassfish-embedded-all - 3.0.1 + arquillian-glassfish-remote-3.1 + ${arquillian_container_glassfish.version} + test + + org.jboss.spec + jboss-javaee-web-6.0 + 3.0.0.Final + pom + provided + @@ -209,30 +218,18 @@ arq-jbossas-managed - org.jboss.arquillian.container - arquillian-jbossas-managed-6 - ${arquillian.version} - - - org.jboss.jbossas - jboss-as-client - 6.0.0.Final - pom - provided - - - org.jboss.spec - jboss-javaee-6.0 - 1.0.0.Beta7 - pom - provided - - - org.jboss.jbossas - jboss-server-manager - 1.0.3.GA - test + org.jboss.as + jboss-as-arquillian-container-managed + ${jbossas.version} + test + + org.jboss.spec + jboss-javaee-web-6.0 + 3.0.0.Final + pom + provided + @@ -247,27 +244,22 @@ - arq-jbossas-remote + + arq-jbossas-remote - - org.jboss.arquillian.container - arquillian-jbossas-remote-6 - ${arquillian.version} - - - org.jboss.spec - jboss-javaee-6.0 - 1.0.0.Beta7 - pom - provided - - - org.jboss.jbossas - jboss-as-client - 6.0.0.20100721-M4 - pom - test - + + org.jboss.as + jboss-as-arquillian-container-remote + ${jbossas.version} + test + + + org.jboss.spec + jboss-javaee-web-6.0 + 3.0.0.Final + pom + provided + diff --git a/jpa2/src/test/java/com/acme/jpa/GamePersistenceTestCase.java b/jpa2/src/test/java/com/acme/jpa/GamePersistenceTestCase.java index f9c700e..4d00f7a 100644 --- a/jpa2/src/test/java/com/acme/jpa/GamePersistenceTestCase.java +++ b/jpa2/src/test/java/com/acme/jpa/GamePersistenceTestCase.java @@ -30,7 +30,7 @@ import javax.persistence.criteria.Root; import javax.transaction.UserTransaction; -import org.jboss.arquillian.api.Deployment; +import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -40,23 +40,19 @@ import org.junit.runner.RunWith; @RunWith(Arquillian.class) -public class GamePersistenceTestCase -{ +public class GamePersistenceTestCase { @Deployment - public static Archive createDeployment() - { + public static Archive createDeployment() { return ShrinkWrap.create(WebArchive.class, "test.war") - .addPackage(Game.class.getPackage()) - .addManifestResource("test-persistence.xml", "persistence.xml") - .addWebResource(EmptyAsset.INSTANCE, "beans.xml"); + .addPackage(Game.class.getPackage()) + .addAsResource("test-persistence.xml", "META-INF/persistence.xml") + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); } - private static final String[] GAME_TITLES = - { - "Super Mario Brothers", - "Mario Kart", - "F-Zero" - }; + private static final String[] GAME_TITLES = {"Super Mario Brothers", + "Mario Kart", + "F-Zero" + }; private static final Object log = System.out; // private static final Object log = null; @@ -68,8 +64,7 @@ public static Archive createDeployment() @Inject UserTransaction utx; - public void insertSampleRecords() throws Exception - { + public void insertSampleRecords() throws Exception { utx.begin(); em.joinTransaction(); @@ -87,17 +82,15 @@ public void insertSampleRecords() throws Exception } @Test - public void should_be_able_to_select_games_using_jpql() throws Exception - { + public void should_be_able_to_select_games_using_jpql() throws Exception { insertSampleRecords(); utx.begin(); em.joinTransaction(); printStatus("Selecting (using JPQL)..."); - List games = - em.createQuery("select g from Game g order by g.id", Game.class) - .getResultList(); + List games = em.createQuery("select g from Game g order by g.id", Game.class) + .getResultList(); printStatus("Found " + games.size() + " games (using JPQL)"); assertEquals(GAME_TITLES.length, games.size()); @@ -110,8 +103,7 @@ public void should_be_able_to_select_games_using_jpql() throws Exception } @Test - public void should_be_able_to_select_games_using_criteria_api() throws Exception - { + public void should_be_able_to_select_games_using_criteria_api() throws Exception { insertSampleRecords(); utx.begin(); @@ -140,14 +132,11 @@ public void should_be_able_to_select_games_using_criteria_api() throws Exception utx.commit(); } - private void printStatus(Object message) - { - if (log instanceof PrintStream) - { + private void printStatus(Object message) { + if (log instanceof PrintStream) { ((PrintStream) log).println(message); } - else if (log instanceof Logger) - { + else if (log instanceof Logger) { ((Logger) log).info(message.toString()); } } diff --git a/jpa2/src/test/resources-glassfish-embedded/glassfish-resources.xml b/jpa2/src/test/resources-glassfish-embedded/glassfish-resources.xml new file mode 100644 index 0000000..ab34307 --- /dev/null +++ b/jpa2/src/test/resources-glassfish-embedded/glassfish-resources.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/jpa2/src/test/resources-glassfish-embedded/sun-resources.xml b/jpa2/src/test/resources-glassfish-embedded/sun-resources.xml deleted file mode 100644 index 5c4117a..0000000 --- a/jpa2/src/test/resources-glassfish-embedded/sun-resources.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - diff --git a/jpa2/src/test/resources-glassfish-embedded/test-persistence.xml b/jpa2/src/test/resources-glassfish-embedded/test-persistence.xml index 62cb3d0..0715a17 100644 --- a/jpa2/src/test/resources-glassfish-embedded/test-persistence.xml +++ b/jpa2/src/test/resources-glassfish-embedded/test-persistence.xml @@ -3,13 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> - jdbc/arquillian - - diff --git a/jpa2/src/test/resources-glassfish-remote/test-persistence.xml b/jpa2/src/test/resources-glassfish-remote/test-persistence.xml index 7993286..25e5eda 100644 --- a/jpa2/src/test/resources-glassfish-remote/test-persistence.xml +++ b/jpa2/src/test/resources-glassfish-remote/test-persistence.xml @@ -1,19 +1,12 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> - - jdbc/__default - - - diff --git a/jpa2/src/test/resources-jbossas-remote/jndi.properties b/jpa2/src/test/resources-jbossas-remote/jndi.properties deleted file mode 100644 index a20ef47..0000000 --- a/jpa2/src/test/resources-jbossas-remote/jndi.properties +++ /dev/null @@ -1,3 +0,0 @@ -java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces -java.naming.provider.url=jnp://localhost:1099 diff --git a/jpa2/src/test/resources-jbossas-remote/test-persistence.xml b/jpa2/src/test/resources-jbossas-remote/test-persistence.xml index b843e35..6cd276a 100644 --- a/jpa2/src/test/resources-jbossas-remote/test-persistence.xml +++ b/jpa2/src/test/resources-jbossas-remote/test-persistence.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> - java:/DefaultDS + java:jboss/datasources/ExampleDS diff --git a/jpa2/src/test/resources/arquillian.xml b/jpa2/src/test/resources/arquillian.xml index 6072f50..04b7f10 100644 --- a/jpa2/src/test/resources/arquillian.xml +++ b/jpa2/src/test/resources/arquillian.xml @@ -1,17 +1,18 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:glassfish-embedded="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3"> - - + + + target + - - src/test/resources-glassfish-embedded/sun-resources.xml - + + + src/test/resources-glassfish-embedded/glassfish-resources.xml + 9999 + + From 603027f9fcbf5e3dd4b8f3025f3aff630ef1a02c Mon Sep 17 00:00:00 2001 From: Alexis Hassler Date: Wed, 11 Apr 2012 21:22:32 +0200 Subject: [PATCH 2/2] JPA 2 : upgrade to Arquillian 1.0.0.Final --- jpa2/pom.xml | 164 +++++++++++++++++++++++++++------------------------ 1 file changed, 88 insertions(+), 76 deletions(-) diff --git a/jpa2/pom.xml b/jpa2/pom.xml index 390bf96..9ed594d 100644 --- a/jpa2/pom.xml +++ b/jpa2/pom.xml @@ -17,7 +17,7 @@ yyyyMMdd'T'HHmmss 3.1.2 7.1.1.Final - 1.0.0.CR8 + 1.0.0.Final 1.0.0.CR3 @@ -54,7 +54,7 @@ org.hibernate hibernate-jpamodelgen - 1.0.0.Final + 1.2.0.Final provided @@ -74,85 +74,11 @@ org.jboss.arquillian.junit arquillian-junit-container - ${arquillian.version} test - - test - - - - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - -proc:none - - - - - - run-annotation-processors-only - generate-sources - - -proc:only - - - - - compile - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - process-sources - - - ${project.build.directory}/generated-sources/annotations - - - - add-source - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - 2.4.3 - - - **/*TestCase.java - - - - derby.stream.error.file - target/derby.log - - - - - - - arq-glassfish-embedded @@ -273,4 +199,90 @@ + + + + + org.jboss.arquillian + arquillian-bom + ${arquillian.version} + import + pom + + + + + + test + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + -proc:none + + + + + + run-annotation-processors-only + generate-sources + + -proc:only + + + + + compile + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + process-sources + + + ${project.build.directory}/generated-sources/annotations + + + + add-source + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + 2.4.3 + + + **/*TestCase.java + + + + derby.stream.error.file + target/derby.log + + + + + + +