Author: rmannibucau
Date: Wed Jun 27 08:26:10 2012
New Revision: 1354366
URL: http://svn.apache.org/viewvc?rev=1354366&view=rev
Log:
OPENEJB-1850 groovy jpa test
Added:
openejb/trunk/openejb/examples/groovy-jpa/
openejb/trunk/openejb/examples/groovy-jpa/pom.xml
openejb/trunk/openejb/examples/groovy-jpa/src/
openejb/trunk/openejb/examples/groovy-jpa/src/main/
openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/
openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/org/
openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/org/superbiz/
openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/
openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/Person.groovy
openejb/trunk/openejb/examples/groovy-jpa/src/main/resources/
openejb/trunk/openejb/examples/groovy-jpa/src/main/resources/META-INF/
openejb/trunk/openejb/examples/groovy-jpa/src/main/resources/META-INF/persistence.xml
openejb/trunk/openejb/examples/groovy-jpa/src/test/
openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/
openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/org/
openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/org/superbiz/
openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/
openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/GroovyJPATest.groovy
Modified:
openejb/trunk/openejb/examples/groovy-cdi/pom.xml
openejb/trunk/openejb/examples/groovy-cdi/src/main/java/org/superbiz/groovy/Hello.groovy
openejb/trunk/openejb/examples/groovy-cdi/src/test/java/org/superbiz/groovy/HelloTest.groovy
openejb/trunk/openejb/examples/pom.xml
Modified: openejb/trunk/openejb/examples/groovy-cdi/pom.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/groovy-cdi/pom.xml?rev=1354366&r1=1354365&r2=1354366&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/groovy-cdi/pom.xml (original)
+++ openejb/trunk/openejb/examples/groovy-cdi/pom.xml Wed Jun 27 08:26:10 2012
@@ -24,7 +24,7 @@
<artifactId>groovy-cdi</artifactId>
<packaging>jar</packaging>
<version>1.1-SNAPSHOT</version>
- <name>OpenEJB :: Examples :: Groovy</name>
+ <name>OpenEJB :: Examples :: Groovy CDI</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Modified:
openejb/trunk/openejb/examples/groovy-cdi/src/main/java/org/superbiz/groovy/Hello.groovy
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/groovy-cdi/src/main/java/org/superbiz/groovy/Hello.groovy?rev=1354366&r1=1354365&r2=1354366&view=diff
==============================================================================
---
openejb/trunk/openejb/examples/groovy-cdi/src/main/java/org/superbiz/groovy/Hello.groovy
(original)
+++
openejb/trunk/openejb/examples/groovy-cdi/src/main/java/org/superbiz/groovy/Hello.groovy
Wed Jun 27 08:26:10 2012
@@ -1,3 +1,19 @@
+/*
+ * 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.superbiz.groovy
class Hello {
Modified:
openejb/trunk/openejb/examples/groovy-cdi/src/test/java/org/superbiz/groovy/HelloTest.groovy
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/groovy-cdi/src/test/java/org/superbiz/groovy/HelloTest.groovy?rev=1354366&r1=1354365&r2=1354366&view=diff
==============================================================================
---
openejb/trunk/openejb/examples/groovy-cdi/src/test/java/org/superbiz/groovy/HelloTest.groovy
(original)
+++
openejb/trunk/openejb/examples/groovy-cdi/src/test/java/org/superbiz/groovy/HelloTest.groovy
Wed Jun 27 08:26:10 2012
@@ -1,3 +1,19 @@
+/*
+ * 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.superbiz.groovy
import org.junit.runner.RunWith
Added: openejb/trunk/openejb/examples/groovy-jpa/pom.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/groovy-jpa/pom.xml?rev=1354366&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/groovy-jpa/pom.xml (added)
+++ openejb/trunk/openejb/examples/groovy-jpa/pom.xml Wed Jun 27 08:26:10 2012
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>groovy-jpa</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Groovy JPA</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <sourceDirectory>src/main/groovy</sourceDirectory>
+ <testSourceDirectory>src/test/groovy</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <compilerId>groovy-eclipse-compiler</compilerId>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-compiler</artifactId>
+ <version>2.6.0-01</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>2.0.0-rc-4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
Added:
openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/Person.groovy
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/Person.groovy?rev=1354366&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/Person.groovy
(added)
+++
openejb/trunk/openejb/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/Person.groovy
Wed Jun 27 08:26:10 2012
@@ -0,0 +1,27 @@
+/*
+ * 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.superbiz.groovy
+
+import javax.persistence.Entity
+import javax.persistence.Id
+import javax.persistence.GeneratedValue
+
+@Entity
+class Person {
+ @Id @GeneratedValue long id
+ String name
+}
Added:
openejb/trunk/openejb/examples/groovy-jpa/src/main/resources/META-INF/persistence.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/groovy-jpa/src/main/resources/META-INF/persistence.xml?rev=1354366&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/groovy-jpa/src/main/resources/META-INF/persistence.xml
(added)
+++
openejb/trunk/openejb/examples/groovy-jpa/src/main/resources/META-INF/persistence.xml
Wed Jun 27 08:26:10 2012
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ 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">
+ <persistence-unit name="groovy" transaction-type="RESOURCE_LOCAL">
+ <jta-data-source>jdbc/groovy</jta-data-source>
+ <class>org.superbiz.groovy.Person</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
+ <property name="javax.persistence.jdbc.password" value="" />
+ <property name="javax.persistence.jdbc.user" value="sa" />
+ <property name="javax.persistence.jdbc.driver"
value="org.hsqldb.jdbcDriver" />
+ <property name="javax.persistence.jdbc.url"
value="jdbc:hsqldb:mem:groovy" />
+ </properties>
+ </persistence-unit>
+</persistence>
Added:
openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/GroovyJPATest.groovy
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/GroovyJPATest.groovy?rev=1354366&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/GroovyJPATest.groovy
(added)
+++
openejb/trunk/openejb/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/GroovyJPATest.groovy
Wed Jun 27 08:26:10 2012
@@ -0,0 +1,67 @@
+/*
+ * 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.superbiz.groovy
+
+import org.apache.ziplock.JarLocation
+import org.jboss.arquillian.container.test.api.Deployment
+import org.jboss.arquillian.junit.Arquillian
+import org.jboss.shrinkwrap.api.ArchivePaths
+import org.jboss.shrinkwrap.api.ShrinkWrap
+import org.jboss.shrinkwrap.api.spec.WebArchive
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+
+import static org.junit.Assert.assertThat
+import static org.hamcrest.CoreMatchers.is
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset
+import javax.persistence.PersistenceUnit
+import javax.persistence.EntityManagerFactory
+
+import static org.junit.Assert.assertNotNull
+import javax.persistence.EntityManager
+
+@RunWith(Arquillian.class)
+class GroovyJPATest {
+ @PersistenceUnit
+ private EntityManagerFactory emf
+
+ @Deployment
+ static WebArchive war() {
+ ShrinkWrap.create(WebArchive.class)
+ .addAsLibraries(JarLocation.jarLocation(GroovyObject.class))
+ .addAsWebInfResource(new
ClassLoaderAsset("META-INF/persistence.xml"),
ArchivePaths.create("persistence.xml"))
+ .addClasses(Person.class)
+ }
+
+ @Test
+ void persist() {
+ assertNotNull emf
+ final EntityManager em = emf.createEntityManager()
+
+ em.transaction.begin()
+ em.persist(new Person(name: 'openejb'))
+ em.transaction.commit()
+
+ def list = em.createQuery("select p from Person p").resultList
+ assertNotNull list
+ assertEquals 1, list.size()
+ assertEquals 'openejb', list.first().name
+ }
+}
Modified: openejb/trunk/openejb/examples/pom.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/pom.xml?rev=1354366&r1=1354365&r2=1354366&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/pom.xml (original)
+++ openejb/trunk/openejb/examples/pom.xml Wed Jun 27 08:26:10 2012
@@ -60,6 +60,7 @@
<module>dynamic-proxy-to-access-mbean</module>
<module>ear-testing</module>
<module>groovy-cdi</module>
+ <module>groovy-jpa</module>
<module>helloworld-weblogic</module>
<module>injection-of-connectionfactory</module>
<module>injection-of-datasource</module>