Author: aadamchik
Date: Wed Aug 30 03:37:38 2006
New Revision: 438450

URL: http://svn.apache.org/viewvc?rev=438450&view=rev
Log:
more integration tests

Added:
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/EmbeddedIdEntity.java
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClass1.java
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClassEntity.java
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/NoPkEntity.java
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PeristentFieldsAndProperties_2_1_1_Test.java
      - copied, changed from r438439, 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/EntityClassTest.java
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PrimaryKeyAndIdentity_2_1_4_Test.java
Removed:
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/EntityClassTest.java
Modified:
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml
    
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql

Added: 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/EmbeddedIdEntity.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/EmbeddedIdEntity.java?rev=438450&view=auto
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/EmbeddedIdEntity.java
 (added)
+++ 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/EmbeddedIdEntity.java
 Wed Aug 30 03:37:38 2006
@@ -0,0 +1,39 @@
+/*****************************************************************
+ *   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.itest1.entity;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+
[EMAIL PROTECTED]
+public class EmbeddedIdEntity {
+
+    @EmbeddedId
+    protected IdClass1 id;
+
+    protected String property1;
+
+    public String getProperty1() {
+        return property1;
+    }
+
+    public void setProperty1(String property1) {
+        this.property1 = property1;
+    }
+}

Added: 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClass1.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClass1.java?rev=438450&view=auto
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClass1.java
 (added)
+++ 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClass1.java
 Wed Aug 30 03:37:38 2006
@@ -0,0 +1,32 @@
+/*****************************************************************
+ *   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.itest1.entity;
+
+import java.io.Serializable;
+
+import javax.persistence.Id;
+
+public class IdClass1 implements Serializable {
+
+    @Id
+    protected int id1;
+
+    @Id
+    protected int id2;
+}

Added: 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClassEntity.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClassEntity.java?rev=438450&view=auto
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClassEntity.java
 (added)
+++ 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/IdClassEntity.java
 Wed Aug 30 03:37:38 2006
@@ -0,0 +1,44 @@
+/*****************************************************************
+ *   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.itest1.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+
[EMAIL PROTECTED]
[EMAIL PROTECTED](value = IdClass1.class)
+public class IdClassEntity {
+
+    @Id
+    protected int id1;
+
+    @Id
+    protected int id2;
+
+    protected String property1;
+
+    public String getProperty1() {
+        return property1;
+    }
+
+    public void setProperty1(String property1) {
+        this.property1 = property1;
+    }
+}

Added: 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/NoPkEntity.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/NoPkEntity.java?rev=438450&view=auto
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/NoPkEntity.java
 (added)
+++ 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/NoPkEntity.java
 Wed Aug 30 03:37:38 2006
@@ -0,0 +1,29 @@
+/*****************************************************************
+ *   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.itest1.entity;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+
[EMAIL PROTECTED]
+public class NoPkEntity {
+
+    @Basic
+    protected int property1;
+}

Modified: 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml?rev=438450&r1=438449&r2=438450&view=diff
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml
 (original)
+++ 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml
 Wed Aug 30 03:37:38 2006
@@ -29,5 +29,8 @@
                
<class>org.apache.cayenne.jpa.itest1.entity.HelperEntity2</class>
                
<class>org.apache.cayenne.jpa.itest1.entity.HelperEntity3</class>
                
<class>org.apache.cayenne.jpa.itest1.entity.HelperEntity4</class>
+               <class>org.apache.cayenne.jpa.itest1.entity.NoPkEntity</class>
+               
<class>org.apache.cayenne.jpa.itest1.entity.IdClassEntity</class>
+               
<class>org.apache.cayenne.jpa.itest1.entity.EmbeddedIdEntity</class>
        </persistence-unit>
 </persistence>

Copied: 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PeristentFieldsAndProperties_2_1_1_Test.java
 (from r438439, 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/EntityClassTest.java)
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PeristentFieldsAndProperties_2_1_1_Test.java?p2=incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PeristentFieldsAndProperties_2_1_1_Test.java&p1=incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/EntityClassTest.java&r1=438439&r2=438450&rev=438450&view=diff
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/EntityClassTest.java
 (original)
+++ 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PeristentFieldsAndProperties_2_1_1_Test.java
 Wed Aug 30 03:37:38 2006
@@ -33,7 +33,7 @@
 import org.apache.cayenne.jpa.itest1.entity.PropertyPersistenceEntity;
 import org.apache.cayenne.jpa.itest1.entity.TransientFieldsEntity;
 
-public class EntityClassTest extends Unit1Case {
+public class PeristentFieldsAndProperties_2_1_1_Test extends Unit1Case {
 
     protected EntityManager em;
 
@@ -45,7 +45,9 @@
 
     @Override
     protected void tearDown() throws Exception {
-        em.getTransaction().rollback();
+        if (em.getTransaction().isActive()) {
+            em.getTransaction().rollback();
+        }
         em.close();
     }
 
@@ -55,29 +57,29 @@
 
         FieldPersistenceEntity o1 = new FieldPersistenceEntity();
         em.persist(o1);
-        em.flush();
+        em.getTransaction().commit();
 
         assertEquals(FieldPersistenceEntity.INITIAL_VALUE, 
ItestDBUtils.getSingleValue(
                 "FieldPersistenceEntity",
                 "property1"));
     }
 
-    // TODO: andrus 8/10/2006 - this fails
+    // TODO: andrus 8/10/2006 - fails
     public void _testPropertyBasedPersistence() {
         PropertyPersistenceEntity o1 = new PropertyPersistenceEntity();
         o1.setProperty1("p1");
         o1.setProperty2(true);
         em.persist(o1);
-        em.flush();
+        em.getTransaction().commit();
     }
 
     public void testSkipTransientProperties() {
         TransientFieldsEntity o1 = new TransientFieldsEntity();
         em.persist(o1);
-        em.flush();
+        em.getTransaction().commit();
     }
 
-    // TODO: andrus 8/30/2006 - this fails
+    // TODO: andrus 8/30/2006 - fails
     public void _testCollectionTypesProperties() {
         CollectionFieldPersistenceEntity o1 = new 
CollectionFieldPersistenceEntity();
         o1.setCollection(Collections.singleton(new HelperEntity1()));
@@ -86,6 +88,16 @@
         o1.setMap(Collections.singletonMap(new Object(), new HelperEntity4()));
 
         em.persist(o1);
-        em.flush();
+        em.getTransaction().commit();
+    }
+
+    // TODO: andrus 8/30/2006 - implement me
+    public void testExceptionInPropertyAccessors() {
+        // Runtime exceptions thrown by property accessor methods cause the 
current
+        // transaction to be rolled back.
+        // Exceptions thrown by such methods when used by the persistence 
runtime to load
+        // or store persistent state cause the persistence runtime to rollback 
the current
+        // transaction and to throw a PersistenceException that wraps the 
application
+        // exception.
     }
 }

Added: 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PrimaryKeyAndIdentity_2_1_4_Test.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PrimaryKeyAndIdentity_2_1_4_Test.java?rev=438450&view=auto
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PrimaryKeyAndIdentity_2_1_4_Test.java
 (added)
+++ 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PrimaryKeyAndIdentity_2_1_4_Test.java
 Wed Aug 30 03:37:38 2006
@@ -0,0 +1,95 @@
+/*****************************************************************
+ *   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.entity;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
+
+import org.apache.cayenne.jpa.itest.ItestDBUtils;
+import org.apache.cayenne.jpa.itest.ItestSetup;
+import org.apache.cayenne.jpa.itest1.entity.EmbeddedIdEntity;
+import org.apache.cayenne.jpa.itest1.entity.FieldPersistenceEntity;
+import org.apache.cayenne.jpa.itest1.entity.IdClassEntity;
+import org.apache.cayenne.jpa.itest1.entity.NoPkEntity;
+
+public class PrimaryKeyAndIdentity_2_1_4_Test extends Unit1Case {
+
+    protected EntityManager em;
+
+    @Override
+    protected void setUp() throws Exception {
+        em = ItestSetup.getInstance().createEntityManager();
+        em.getTransaction().begin();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (em.getTransaction().isActive()) {
+            em.getTransaction().rollback();
+        }
+        em.close();
+    }
+
+    public void testNoPkEntity() {
+        NoPkEntity o1 = new NoPkEntity();
+
+        try {
+            em.persist(o1);
+
+        }
+        catch (IllegalArgumentException e) {
+            return;
+        }
+
+        try {
+            em.getTransaction().commit();
+        }
+        catch (PersistenceException e) {
+            return;
+        }
+
+        fail("Must have thrown on an attempt to persist or flush "
+                + "an entity without defined id");
+    }
+
+    public void testSimplePk() throws Exception {
+        FieldPersistenceEntity o1 = new FieldPersistenceEntity();
+        em.persist(o1);
+    }
+
+    // TODO: andrus 8/10/2006 - fails
+    public void _testIdClassPk() throws Exception {
+        IdClassEntity o1 = new IdClassEntity();
+        o1.setProperty1("p1");
+        em.persist(o1);
+        em.getTransaction().commit();
+
+        assertEquals("p1", ItestDBUtils.getSingleValue("IdClassEntity", 
"property1"));
+    }
+
+    // TODO: andrus 8/10/2006 - fails
+    public void _testEmbeddedIdPk() throws Exception {
+        EmbeddedIdEntity o1 = new EmbeddedIdEntity();
+        o1.setProperty1("p1");
+        em.persist(o1);
+        em.getTransaction().commit();
+
+        assertEquals("p1", ItestDBUtils.getSingleValue("EmbeddedIdEntity", 
"property1"));
+    }
+}

Modified: 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql?rev=438450&r1=438449&r2=438450&view=diff
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql
 (original)
+++ 
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql
 Wed Aug 30 03:37:38 2006
@@ -15,4 +15,7 @@
 create table HelperEntity1 (id int not null, entity_id int, primary key(id));
 create table HelperEntity2 (id int not null, entity_id int, primary key(id));
 create table HelperEntity3 (id int not null, entity_id int, primary key(id));
-create table HelperEntity4 (id int not null, entity_id int, primary key(id));
\ No newline at end of file
+create table HelperEntity4 (id int not null, entity_id int, primary key(id));
+create table NoPkEntity (property1 VARCHAR(100));
+create table IdClassEntity (id1 int not null, id2 int not null, property1 
VARCHAR(100), primary key(id1, id2));
+create table EmbeddedIdEntity (id1 int not null, id2 int not null, property1 
VARCHAR(100), primary key(id1, id2));
\ No newline at end of file


Reply via email to