Author: aadamchik
Date: Sat Nov 25 14:36:17 2006
New Revision: 479219

URL: http://svn.apache.org/viewvc?view=rev&rev=479219
Log:
CAY-682:Generic Cayenne POJO enhancer
(starting to-many tests)

Added:
    
incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java

Added: 
incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java?view=auto&rev=479219
==============================================================================
--- 
incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java
 (added)
+++ 
incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java
 Sat Nov 25 14:36:17 2006
@@ -0,0 +1,58 @@
+/*****************************************************************
+ *   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.itest.pojo;
+
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.cayenne.query.SelectQuery;
+
+public class OneToManyObjectTest extends PojoContextCase {
+
+    public void testSelectToMany() throws Exception {
+        getDbHelper().deleteAll("many_to_one_entity1");
+        getDbHelper().deleteAll("one_to_many_entity1");
+        getDbHelper().insert("one_to_many_entity1", new String[] {
+            "id"
+        }, new Object[] {
+            5
+        });
+
+        getDbHelper().insert("many_to_one_entity1", new String[] {
+                "id", "one_to_many_entity1_id"
+        }, new Object[] {
+                16, 5
+        });
+
+        SelectQuery q = new SelectQuery(OneToManyEntity1.class);
+        List results = context.performQuery(q);
+        assertEquals(1, results.size());
+
+        OneToManyEntity1 o1 = (OneToManyEntity1) results.get(0);
+
+        Field f = 
OneToManyEntity1.class.getDeclaredField("$cay_faultResolved_toMany");
+        assertEquals(Boolean.FALSE, f.get(o1));
+
+        Collection<ManyToOneEntity1> or = o1.getToMany();
+        assertNotNull(or);
+        
+        assertEquals(Boolean.TRUE, f.get(o1));
+    }
+}


Reply via email to