cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r506494 - in /cayenne/main/trunk/itests/jpa-chapter5/src: main/java/org/apache/cayenne/jpa/itest/ch5/entity/ main/resources/META-INF/ test/java/org/apache/cayenne/jpa/itest/ch5/ test/resources/
Date Mon, 12 Feb 2007 15:35:52 GMT
Author: aadamchik
Date: Mon Feb 12 07:35:51 2007
New Revision: 506494

URL: http://svn.apache.org/viewvc?view=rev&rev=506494
Log:
CAY-626: JPA Spec Compatibility Tests
more itests

Added:
    cayenne/main/trunk/itests/jpa-chapter5/src/main/java/org/apache/cayenne/jpa/itest/ch5/entity/RLEntity1.java
    cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_4_EntityMnagerFactoryTest.java
    cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_5_2_ResourceLocalEntityManagerTest.java
Modified:
    cayenne/main/trunk/itests/jpa-chapter5/src/main/resources/META-INF/persistence.xml
    cayenne/main/trunk/itests/jpa-chapter5/src/test/resources/schema-hsqldb.sql

Added: cayenne/main/trunk/itests/jpa-chapter5/src/main/java/org/apache/cayenne/jpa/itest/ch5/entity/RLEntity1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/jpa-chapter5/src/main/java/org/apache/cayenne/jpa/itest/ch5/entity/RLEntity1.java?view=auto&rev=506494
==============================================================================
--- cayenne/main/trunk/itests/jpa-chapter5/src/main/java/org/apache/cayenne/jpa/itest/ch5/entity/RLEntity1.java
(added)
+++ cayenne/main/trunk/itests/jpa-chapter5/src/main/java/org/apache/cayenne/jpa/itest/ch5/entity/RLEntity1.java
Mon Feb 12 07:35:51 2007
@@ -0,0 +1,46 @@
+/*****************************************************************
+ *   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.cayenne.jpa.itest.ch5.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class RLEntity1 {
+
+    @Id
+    protected int id;
+    protected String property1;
+    
+    public int idField() {
+        return id;
+    }
+    
+    public void updateIdField(int id) {
+        this.id = id;
+    }
+
+    public String getProperty1() {
+        return property1;
+    }
+
+    public void setProperty1(String property1) {
+        this.property1 = property1;
+    }
+}

Modified: cayenne/main/trunk/itests/jpa-chapter5/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/jpa-chapter5/src/main/resources/META-INF/persistence.xml?view=diff&rev=506494&r1=506493&r2=506494
==============================================================================
--- cayenne/main/trunk/itests/jpa-chapter5/src/main/resources/META-INF/persistence.xml (original)
+++ cayenne/main/trunk/itests/jpa-chapter5/src/main/resources/META-INF/persistence.xml Mon
Feb 12 07:35:51 2007
@@ -23,4 +23,9 @@
 		<description>Integration test peristence unit #5.</description>
 		<class>org.apache.cayenne.jpa.itest.ch5.entity.SimpleEntity</class>
 	</persistence-unit>
+	
+	<persistence-unit name="itest-non-jta" transaction-type="RESOURCE_LOCAL">
+		<description>Integration test peristence unit #5 - resource local unit.</description>
+		<class>org.apache.cayenne.jpa.itest.ch5.entity.RLEntity1</class>
+	</persistence-unit>
 </persistence>

Added: cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_4_EntityMnagerFactoryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_4_EntityMnagerFactoryTest.java?view=auto&rev=506494
==============================================================================
--- cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_4_EntityMnagerFactoryTest.java
(added)
+++ cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_4_EntityMnagerFactoryTest.java
Mon Feb 12 07:35:51 2007
@@ -0,0 +1,83 @@
+/*****************************************************************
+ *   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.cayenne.jpa.itest.ch5;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.apache.cayenne.itest.jpa.JpaTestCase;
+
+public class _5_4_EntityMnagerFactoryTest extends JpaTestCase {
+
+    public void testCreateEntityManager() {
+        EntityManagerFactory factory = Persistence
+                .createEntityManagerFactory("itest-non-jta");
+        EntityManager em = factory.createEntityManager();
+        assertNotNull(em);
+
+        EntityManager em1 = factory.createEntityManager();
+        assertNotSame(em, em1);
+
+        // per JPA spec, unrecognized properties must be quietly ignored
+        Map properties = new HashMap();
+        properties.put("dummy", "property");
+        EntityManager em2 = factory.createEntityManager(properties);
+        assertNotNull(em2);
+        assertNotSame(em, em2);
+    }
+
+    public void testClose() {
+        EntityManagerFactory factory = Persistence
+                .createEntityManagerFactory("itest-non-jta");
+        EntityManager em = factory.createEntityManager();
+        Map properties = new HashMap();
+        properties.put("dummy", "property");
+        EntityManager em2 = factory.createEntityManager(properties);
+
+        assertTrue(factory.isOpen());
+        assertTrue(em.isOpen());
+        assertTrue(em2.isOpen());
+
+        factory.close();
+
+        assertFalse(factory.isOpen());
+        assertFalse(em.isOpen());
+        assertFalse(em2.isOpen());
+
+        try {
+            factory.createEntityManager();
+            fail("Closed EMF - expected to throw");
+        }
+        catch (IllegalStateException e) {
+
+        }
+
+        try {
+            factory.createEntityManager(properties);
+            fail("Closed EMF - expected to throw");
+        }
+        catch (IllegalStateException e) {
+
+        }
+    }
+}

Added: cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_5_2_ResourceLocalEntityManagerTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_5_2_ResourceLocalEntityManagerTest.java?view=auto&rev=506494
==============================================================================
--- cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_5_2_ResourceLocalEntityManagerTest.java
(added)
+++ cayenne/main/trunk/itests/jpa-chapter5/src/test/java/org/apache/cayenne/jpa/itest/ch5/_5_5_2_ResourceLocalEntityManagerTest.java
Mon Feb 12 07:35:51 2007
@@ -0,0 +1,46 @@
+/*****************************************************************
+ *   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.cayenne.jpa.itest.ch5;
+
+import org.apache.cayenne.itest.jpa.JpaTestCase;
+
+public class _5_5_2_ResourceLocalEntityManagerTest extends JpaTestCase {
+
+    public void testResourceLocalEntityManager() throws Exception {
+        // TODO: andrus 2/11/2007 - this fails due to some classloader issues with peer
+        // tests
+        // getDbHelper().deleteAll("RLEntity1");
+        //
+        // TransactionManager tm = OpenEJBContainer.getContainer().getTxManager();
+        // tm.begin();
+        //
+        // EntityManager entityManager = ItestSetup
+        // .getInstance("itest-non-jta")
+        // .createEntityManager();
+        //
+        // RLEntity1 e = new RLEntity1();
+        // e.setProperty1("XXX");
+        // entityManager.persist(e);
+        //
+        // tm.commit();
+        // assertEquals(0, getDbHelper().getRowCount("RLEntity1"));
+        // entityManager.getTransaction().commit();
+        // assertEquals(1, getDbHelper().getRowCount("RLEntity1"));
+    }
+}

Modified: cayenne/main/trunk/itests/jpa-chapter5/src/test/resources/schema-hsqldb.sql
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/jpa-chapter5/src/test/resources/schema-hsqldb.sql?view=diff&rev=506494&r1=506493&r2=506494
==============================================================================
--- cayenne/main/trunk/itests/jpa-chapter5/src/test/resources/schema-hsqldb.sql (original)
+++ cayenne/main/trunk/itests/jpa-chapter5/src/test/resources/schema-hsqldb.sql Mon Feb 12
07:35:51 2007
@@ -1,4 +1,6 @@
 create table AUTO_PK_SUPPORT (TABLE_NAME CHAR(100) NOT NULL,  NEXT_ID INTEGER NOT NULL, PRIMARY
KEY(TABLE_NAME));
 insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('SimpleEntity', 1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('RLEntity1', 1);
 
 create table SimpleEntity (id int not null, property1 VARCHAR(100), primary key(id));
+create table RLEntity1 (id int not null, property1 VARCHAR(100), primary key(id));



Mime
View raw message