You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2006/08/30 11:54:08 UTC

svn commit: r438439 - in /incubator/cayenne/main/trunk/integration-test/jpa-unit1/src: main/java/org/apache/cayenne/jpa/itest1/entity/ main/resources/META-INF/ test/java/org/apache/cayenne/jpa/itest/entity/ test/resources/

Author: aadamchik
Date: Wed Aug 30 02:54:07 2006
New Revision: 438439

URL: http://svn.apache.org/viewvc?rev=438439&view=rev
Log:
more integration tests covering "peristent fields and properties" spec chapter

Added:
    incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/CollectionFieldPersistenceEntity.java
    incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity1.java
    incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity2.java
    incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity3.java
    incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity4.java
Modified:
    incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/PropertyPersistenceEntity.java
    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/java/org/apache/cayenne/jpa/itest/entity/EntityClassTest.java
    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/CollectionFieldPersistenceEntity.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/CollectionFieldPersistenceEntity.java?rev=438439&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/CollectionFieldPersistenceEntity.java (added)
+++ incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/CollectionFieldPersistenceEntity.java Wed Aug 30 02:54:07 2006
@@ -0,0 +1,79 @@
+/*****************************************************************
+ *   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.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+@Entity
+public class CollectionFieldPersistenceEntity {
+
+    @Id
+    protected int id;
+
+    @OneToMany
+    protected Collection<HelperEntity1> collection;
+
+    @OneToMany
+    protected Set<HelperEntity2> set;
+
+    @OneToMany
+    protected List<HelperEntity3> list;
+
+    @OneToMany
+    protected Map<Object, HelperEntity4> map;
+
+    public Collection<HelperEntity1> getCollection() {
+        return collection;
+    }
+
+    public void setCollection(Collection<HelperEntity1> collection) {
+        this.collection = collection;
+    }
+
+    public List<HelperEntity3> getList() {
+        return list;
+    }
+
+    public void setList(List<HelperEntity3> list) {
+        this.list = list;
+    }
+
+    public Map<Object, HelperEntity4> getMap() {
+        return map;
+    }
+
+    public void setMap(Map<Object, HelperEntity4> map) {
+        this.map = map;
+    }
+
+    public Set<HelperEntity2> getSet() {
+        return set;
+    }
+
+    public void setSet(Set<HelperEntity2> set) {
+        this.set = set;
+    }
+}

Added: incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity1.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity1.java?rev=438439&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity1.java (added)
+++ incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity1.java Wed Aug 30 02:54:07 2006
@@ -0,0 +1,33 @@
+/*****************************************************************
+ *   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.ManyToOne;
+
+@Entity
+public class HelperEntity1 {
+
+    @Id
+    protected int id;
+
+    @ManyToOne
+    protected CollectionFieldPersistenceEntity entity;
+}

Added: incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity2.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity2.java?rev=438439&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity2.java (added)
+++ incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity2.java Wed Aug 30 02:54:07 2006
@@ -0,0 +1,33 @@
+/*****************************************************************
+ *   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.ManyToOne;
+
+@Entity
+public class HelperEntity2 {
+
+    @Id
+    protected int id;
+
+    @ManyToOne
+    protected CollectionFieldPersistenceEntity entity;
+}

Added: incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity3.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity3.java?rev=438439&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity3.java (added)
+++ incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity3.java Wed Aug 30 02:54:07 2006
@@ -0,0 +1,33 @@
+/*****************************************************************
+ *   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.ManyToOne;
+
+@Entity
+public class HelperEntity3 {
+
+    @Id
+    protected int id;
+
+    @ManyToOne
+    protected CollectionFieldPersistenceEntity entity;
+}
\ No newline at end of file

Added: incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity4.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity4.java?rev=438439&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity4.java (added)
+++ incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/HelperEntity4.java Wed Aug 30 02:54:07 2006
@@ -0,0 +1,33 @@
+/*****************************************************************
+ *   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.ManyToOne;
+
+@Entity
+public class HelperEntity4 {
+
+    @Id
+    protected int id;
+
+    @ManyToOne
+    protected CollectionFieldPersistenceEntity entity;
+}

Modified: incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/PropertyPersistenceEntity.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/PropertyPersistenceEntity.java?rev=438439&r1=438438&r2=438439&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/PropertyPersistenceEntity.java (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/PropertyPersistenceEntity.java Wed Aug 30 02:54:07 2006
@@ -27,6 +27,7 @@
     protected int idx;
 
     protected String property1x;
+    protected boolean property2x;
 
     @Id
     public int getId() {
@@ -43,5 +44,13 @@
 
     public void setProperty1(String property1) {
         this.property1x = property1;
+    }
+
+    public boolean isProperty2() {
+        return property2x;
+    }
+
+    public void setProperty2(boolean property2x) {
+        this.property2x = property2x;
     }
 }

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=438439&r1=438438&r2=438439&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 02:54:07 2006
@@ -24,5 +24,10 @@
 		<class>org.apache.cayenne.jpa.itest1.entity.FieldPersistenceEntity</class>
 		<class>org.apache.cayenne.jpa.itest1.entity.PropertyPersistenceEntity</class>
 		<class>org.apache.cayenne.jpa.itest1.entity.TransientFieldsEntity</class>
+		<class>org.apache.cayenne.jpa.itest1.entity.CollectionFieldPersistenceEntity</class>
+		<class>org.apache.cayenne.jpa.itest1.entity.HelperEntity1</class>
+		<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>
 	</persistence-unit>
 </persistence>

Modified: 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/EntityClassTest.java?rev=438439&r1=438438&r2=438439&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/EntityClassTest.java Wed Aug 30 02:54:07 2006
@@ -18,11 +18,18 @@
  ****************************************************************/
 package org.apache.cayenne.jpa.itest.entity;
 
+import java.util.Collections;
+
 import javax.persistence.EntityManager;
 
 import org.apache.cayenne.jpa.itest.ItestDBUtils;
 import org.apache.cayenne.jpa.itest.ItestSetup;
+import org.apache.cayenne.jpa.itest1.entity.CollectionFieldPersistenceEntity;
 import org.apache.cayenne.jpa.itest1.entity.FieldPersistenceEntity;
+import org.apache.cayenne.jpa.itest1.entity.HelperEntity1;
+import org.apache.cayenne.jpa.itest1.entity.HelperEntity2;
+import org.apache.cayenne.jpa.itest1.entity.HelperEntity3;
+import org.apache.cayenne.jpa.itest1.entity.HelperEntity4;
 import org.apache.cayenne.jpa.itest1.entity.PropertyPersistenceEntity;
 import org.apache.cayenne.jpa.itest1.entity.TransientFieldsEntity;
 
@@ -56,14 +63,28 @@
     }
 
     // TODO: andrus 8/10/2006 - this fails
-    // public void testPropertyBasedPersistence() {
-    // PropertyPersistenceEntity o1 = new PropertyPersistenceEntity();
-    // em.persist(o1);
-    // em.flush();
-    // }
+    public void _testPropertyBasedPersistence() {
+        PropertyPersistenceEntity o1 = new PropertyPersistenceEntity();
+        o1.setProperty1("p1");
+        o1.setProperty2(true);
+        em.persist(o1);
+        em.flush();
+    }
 
     public void testSkipTransientProperties() {
         TransientFieldsEntity o1 = new TransientFieldsEntity();
+        em.persist(o1);
+        em.flush();
+    }
+
+    // TODO: andrus 8/30/2006 - this fails
+    public void _testCollectionTypesProperties() {
+        CollectionFieldPersistenceEntity o1 = new CollectionFieldPersistenceEntity();
+        o1.setCollection(Collections.singleton(new HelperEntity1()));
+        o1.setSet(Collections.singleton(new HelperEntity2()));
+        o1.setList(Collections.singletonList(new HelperEntity3()));
+        o1.setMap(Collections.singletonMap(new Object(), new HelperEntity4()));
+
         em.persist(o1);
         em.flush();
     }

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=438439&r1=438438&r2=438439&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 02:54:07 2006
@@ -2,7 +2,17 @@
 insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('FieldPersistenceEntity', 1);
 insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('PropertyPersistenceEntity', 1);
 insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('TransientFieldsEntity', 1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('CollectionFieldPersistenceEntity', 1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('HelperEntity1', 1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('HelperEntity2', 1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('HelperEntity3', 1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('HelperEntity4', 1);
 
 create table FieldPersistenceEntity (id int not null, property1 VARCHAR(100), primary key(id));
-create table PropertyPersistenceEntity (id int not null, property1 VARCHAR(100), primary key(id));
-create table TransientFieldsEntity (id int not null, property1 VARCHAR(100), primary key(id));
\ No newline at end of file
+create table PropertyPersistenceEntity (id int not null, property1 VARCHAR(100), property2 BOOLEAN, primary key(id));
+create table TransientFieldsEntity (id int not null, property1 VARCHAR(100), primary key(id));
+create table CollectionFieldPersistenceEntity (id int not null, primary key(id));
+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