cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r667510 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/ java/org/apache/cayenne/testdo/relationship/ java/org/apache/cayenne/testdo/relationship/auto/ resources/ resources/dml/
Date Fri, 13 Jun 2008 12:49:03 GMT
Author: aadamchik
Date: Fri Jun 13 05:49:03 2008
New Revision: 667510

URL: http://svn.apache.org/viewvc?rev=667510&view=rev
Log:
unit test for circular flattened relationships (works; so that's just a sanity check)

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/FlattenedCircular.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/auto/_FlattenedCircular.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/FlattenedRelationshipsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/FlattenedRelationshipsTest.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/relationships.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/FlattenedRelationshipsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/FlattenedRelationshipsTest.java?rev=667510&r1=667509&r2=667510&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/FlattenedRelationshipsTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/FlattenedRelationshipsTest.java
Fri Jun 13 05:49:03 2008
@@ -27,6 +27,7 @@
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.testdo.relationship.FlattenedCircular;
 import org.apache.cayenne.testdo.relationship.FlattenedTest1;
 import org.apache.cayenne.testdo.relationship.FlattenedTest2;
 import org.apache.cayenne.testdo.relationship.FlattenedTest3;
@@ -48,12 +49,9 @@
     }
 
     public void testInsertJoinWithPK() throws Exception {
-        FlattenedTest1 obj01 = context
-                .newObject(FlattenedTest1.class);
-        FlattenedTest3 obj11 = context
-                .newObject(FlattenedTest3.class);
-        FlattenedTest3 obj12 = context
-                .newObject(FlattenedTest3.class);
+        FlattenedTest1 obj01 = context.newObject(FlattenedTest1.class);
+        FlattenedTest3 obj11 = context.newObject(FlattenedTest3.class);
+        FlattenedTest3 obj12 = context.newObject(FlattenedTest3.class);
 
         obj01.setName("t01");
         obj11.setName("t11");
@@ -88,10 +86,8 @@
         joinSelect.setFetchingDataRows(true);
         assertEquals(3, context.performQuery(joinSelect).size());
 
-        FlattenedTest1 ft1 = DataObjectUtils.objectForPK(
-                context,
-                FlattenedTest1.class,
-                2);
+        FlattenedTest1 ft1 = DataObjectUtils
+                .objectForPK(context, FlattenedTest1.class, 2);
 
         assertEquals("ft12", ft1.getName());
         List related = ft1.getFt3OverComplex();
@@ -99,10 +95,8 @@
 
         assertEquals(2, related.size());
 
-        FlattenedTest3 ft3 = DataObjectUtils.objectForPK(
-                context,
-                FlattenedTest3.class,
-                3);
+        FlattenedTest3 ft3 = DataObjectUtils
+                .objectForPK(context, FlattenedTest3.class, 3);
         assertTrue(related.contains(ft3));
 
         ft1.removeFromFt3OverComplex(ft3);
@@ -116,21 +110,14 @@
     }
 
     public void testQualifyOnToManyFlattened() throws Exception {
-        FlattenedTest1 obj01 = context
-                .newObject(FlattenedTest1.class);
-        FlattenedTest2 obj02 = context
-                .newObject(FlattenedTest2.class);
-        FlattenedTest3 obj031 = context
-                .newObject(FlattenedTest3.class);
-        FlattenedTest3 obj032 = context
-                .newObject(FlattenedTest3.class);
-
-        FlattenedTest1 obj11 = context
-                .newObject(FlattenedTest1.class);
-        FlattenedTest2 obj12 = context
-                .newObject(FlattenedTest2.class);
-        FlattenedTest3 obj131 = context
-                .newObject(FlattenedTest3.class);
+        FlattenedTest1 obj01 = context.newObject(FlattenedTest1.class);
+        FlattenedTest2 obj02 = context.newObject(FlattenedTest2.class);
+        FlattenedTest3 obj031 = context.newObject(FlattenedTest3.class);
+        FlattenedTest3 obj032 = context.newObject(FlattenedTest3.class);
+
+        FlattenedTest1 obj11 = context.newObject(FlattenedTest1.class);
+        FlattenedTest2 obj12 = context.newObject(FlattenedTest2.class);
+        FlattenedTest3 obj131 = context.newObject(FlattenedTest3.class);
 
         obj01.setName("t01");
         obj02.setName("t02");
@@ -166,14 +153,11 @@
     }
 
     public void testToOneSeriesFlattenedRel() {
-        FlattenedTest1 ft1 = (FlattenedTest1) context
-                .newObject("FlattenedTest1");
+        FlattenedTest1 ft1 = (FlattenedTest1) context.newObject("FlattenedTest1");
         ft1.setName("FT1Name");
-        FlattenedTest2 ft2 = (FlattenedTest2) context
-                .newObject("FlattenedTest2");
+        FlattenedTest2 ft2 = (FlattenedTest2) context.newObject("FlattenedTest2");
         ft2.setName("FT2Name");
-        FlattenedTest3 ft3 = (FlattenedTest3) context
-                .newObject("FlattenedTest3");
+        FlattenedTest3 ft3 = (FlattenedTest3) context.newObject("FlattenedTest3");
         ft3.setName("FT3Name");
 
         ft2.setToFT1(ft1);
@@ -224,4 +208,20 @@
         context.performQuery(new SelectQuery(FlattenedTest3.class));
         assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);
     }
+
+    public void testFlattenedCircular() throws Exception {
+        createTestData("testFlattenedCircular");
+        context = createDataContext();
+        FlattenedCircular fc1 = DataObjectUtils.objectForPK(
+                context,
+                FlattenedCircular.class,
+                1);
+
+        List<FlattenedCircular> side2s = fc1.getSide2s();
+        assertEquals(2, side2s.size());
+
+        List<FlattenedCircular> side1s = fc1.getSide1s();
+        assertTrue(side1s.isEmpty());
+    }
+
 }

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/FlattenedCircular.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/FlattenedCircular.java?rev=667510&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/FlattenedCircular.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/FlattenedCircular.java
Fri Jun 13 05:49:03 2008
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.relationship;
+
+import org.apache.cayenne.testdo.relationship.auto._FlattenedCircular;
+
+public class FlattenedCircular extends _FlattenedCircular {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/auto/_FlattenedCircular.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/auto/_FlattenedCircular.java?rev=667510&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/auto/_FlattenedCircular.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/relationship/auto/_FlattenedCircular.java
Fri Jun 13 05:49:03 2008
@@ -0,0 +1,45 @@
+package org.apache.cayenne.testdo.relationship.auto;
+
+import java.util.List;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.testdo.relationship.FlattenedCircular;
+
+/**
+ * Class _FlattenedCircular was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _FlattenedCircular extends CayenneDataObject {
+
+    public static final String SIDE2S_PROPERTY = "side2s";
+    public static final String SIDE1S_PROPERTY = "side1s";
+
+    public static final String ID_PK_COLUMN = "ID";
+
+    public void addToSide2s(FlattenedCircular obj) {
+        addToManyTarget("side2s", obj, true);
+    }
+    public void removeFromSide2s(FlattenedCircular obj) {
+        removeToManyTarget("side2s", obj, true);
+    }
+    @SuppressWarnings("unchecked")
+    public List<FlattenedCircular> getSide2s() {
+        return (List<FlattenedCircular>)readProperty("side2s");
+    }
+
+
+    public void addToSide1s(FlattenedCircular obj) {
+        addToManyTarget("side1s", obj, true);
+    }
+    public void removeFromSide1s(FlattenedCircular obj) {
+        removeToManyTarget("side1s", obj, true);
+    }
+    @SuppressWarnings("unchecked")
+    public List<FlattenedCircular> getSide1s() {
+        return (List<FlattenedCircular>)readProperty("side1s");
+    }
+
+
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/FlattenedRelationshipsTest.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/FlattenedRelationshipsTest.xml?rev=667510&r1=667509&r2=667510&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/FlattenedRelationshipsTest.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/FlattenedRelationshipsTest.xml
Fri Jun 13 05:49:03 2008
@@ -59,10 +59,37 @@
 		insert into COMPLEX_JOIN (PK, FT1_FK, FT3_FK, EXTRA_COLUMN) values (2002, 2, 3, 'C')
 		</value></constructor-arg>
 	</bean>
-
-	<!-- ======================================= -->
-	<!-- Data Sets -->
-	<!-- ======================================= -->	
+	<bean id="FC1" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.relationship.FlattenedCircular</value></constructor-arg>
+		<constructor-arg><value>
+		insert into FLATTENED_CIRCULAR (ID) values (1)
+		</value></constructor-arg>
+	</bean>
+	<bean id="FC2" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.relationship.FlattenedCircular</value></constructor-arg>
+		<constructor-arg><value>
+		insert into FLATTENED_CIRCULAR (ID) values (2)
+		</value></constructor-arg>
+	</bean>
+	<bean id="FC3" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.relationship.FlattenedCircular</value></constructor-arg>
+		<constructor-arg><value>
+		insert into FLATTENED_CIRCULAR (ID) values (3)
+		</value></constructor-arg>
+	</bean>
+	<bean id="FCJ1" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.relationship.FlattenedCircular</value></constructor-arg>
+		<constructor-arg><value>
+		insert into FLATTENED_CIRCULAR_JOIN (SIDE1_ID, SIDE2_ID) values (1, 2)
+		</value></constructor-arg>
+	</bean>
+	<bean id="FCJ2" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.relationship.FlattenedCircular</value></constructor-arg>
+		<constructor-arg><value>
+		insert into FLATTENED_CIRCULAR_JOIN (SIDE1_ID, SIDE2_ID) values (1, 3)
+		</value></constructor-arg>
+	</bean>
+	
 	<bean id="test" class="java.util.ArrayList">
 		<constructor-arg>
 			<list>
@@ -73,6 +100,17 @@
 			</list>
 		</constructor-arg>
 	</bean>
+	<bean id="testFlattenedCircular" class="java.util.ArrayList">
+		<constructor-arg>
+			<list>
+				<ref bean="FC1"/>
+				<ref bean="FC2"/>
+				<ref bean="FC3"/>
+				<ref bean="FCJ1"/>
+				<ref bean="FCJ2"/>
+			</list>
+		</constructor-arg>
+	</bean>
 	<bean id="testUnsetJoinWithPK" class="java.util.ArrayList">
 		<constructor-arg>
 			<list>

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/relationships.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/relationships.map.xml?rev=667510&r1=667509&r2=667510&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/relationships.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/relationships.map.xml
Fri Jun 13 05:49:03 2008
@@ -49,6 +49,13 @@
 		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
 		<db-attribute name="RELATIONSHIP_HELPER_FK" type="SMALLINT"/>
 	</db-entity>
+	<db-entity name="FLATTENED_CIRCULAR">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="FLATTENED_CIRCULAR_JOIN">
+		<db-attribute name="SIDE1_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="SIDE2_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
 	<db-entity name="FLATTENED_TEST_1">
 		<db-attribute name="FT1_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
 		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
@@ -143,6 +150,8 @@
 	</obj-entity>
 	<obj-entity name="FkOfDifferentType" className="org.apache.cayenne.testdo.relationship.FkOfDifferentType"
dbEntityName="FK_OF_DIFFERENT_TYPE">
 	</obj-entity>
+	<obj-entity name="FlattenedCircular" className="org.apache.cayenne.testdo.relationship.FlattenedCircular"
dbEntityName="FLATTENED_CIRCULAR">
+	</obj-entity>
 	<obj-entity name="FlattenedTest1" className="org.apache.cayenne.testdo.relationship.FlattenedTest1"
dbEntityName="FLATTENED_TEST_1">
 		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
 	</obj-entity>
@@ -237,6 +246,18 @@
 	<db-relationship name="relationshipHelper" source="FK_OF_DIFFERENT_TYPE" target="RELATIONSHIP_HELPER"
toMany="false">
 		<db-attribute-pair source="RELATIONSHIP_HELPER_FK" target="RELATIONSHIP_HELPER_ID"/>
 	</db-relationship>
+	<db-relationship name="side1s" source="FLATTENED_CIRCULAR" target="FLATTENED_CIRCULAR_JOIN"
toDependentPK="true" toMany="true">
+		<db-attribute-pair source="ID" target="SIDE2_ID"/>
+	</db-relationship>
+	<db-relationship name="side2s" source="FLATTENED_CIRCULAR" target="FLATTENED_CIRCULAR_JOIN"
toDependentPK="true" toMany="true">
+		<db-attribute-pair source="ID" target="SIDE1_ID"/>
+	</db-relationship>
+	<db-relationship name="side1" source="FLATTENED_CIRCULAR_JOIN" target="FLATTENED_CIRCULAR"
toMany="false">
+		<db-attribute-pair source="SIDE1_ID" target="ID"/>
+	</db-relationship>
+	<db-relationship name="side2" source="FLATTENED_CIRCULAR_JOIN" target="FLATTENED_CIRCULAR"
toMany="false">
+		<db-attribute-pair source="SIDE2_ID" target="ID"/>
+	</db-relationship>
 	<db-relationship name="complexJoins" source="FLATTENED_TEST_1" target="COMPLEX_JOIN"
toMany="true">
 		<db-attribute-pair source="FT1_ID" target="FT1_FK"/>
 	</db-relationship>
@@ -323,6 +344,8 @@
 	<obj-relationship name="test1Array" source="DeleteRuleTest2" target="DeleteRuleTest1"
deleteRule="Nullify" db-relationship-path="test1Array"/>
 	<obj-relationship name="toDeleteRuleTest2" source="DeleteRuleTest3" target="DeleteRuleTest2"
db-relationship-path="toDeleteRuleTest2"/>
 	<obj-relationship name="relationshipHelper" source="FkOfDifferentType" target="RelationshipHelper"
db-relationship-path="relationshipHelper"/>
+	<obj-relationship name="side2s" source="FlattenedCircular" target="FlattenedCircular"
db-relationship-path="side2s.side2"/>
+	<obj-relationship name="side1s" source="FlattenedCircular" target="FlattenedCircular"
db-relationship-path="side1s.side1"/>
 	<obj-relationship name="ft2Array" source="FlattenedTest1" target="FlattenedTest2" db-relationship-path="ft2Array"/>
 	<obj-relationship name="ft3Array" source="FlattenedTest1" target="FlattenedTest3" db-relationship-path="ft2Array.ft3Array"/>
 	<obj-relationship name="ft3OverComplex" source="FlattenedTest1" target="FlattenedTest3"
db-relationship-path="complexJoins.toFT3"/>



Mime
View raw message