cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [22/48] Installing Maven Failsafe Plugin
Date Sun, 02 Nov 2014 07:10:10 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsIT.java
new file mode 100644
index 0000000..cf2454a
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsIT.java
@@ -0,0 +1,141 @@
+/*****************************************************************
+ *   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.access;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.parallel.ParallelTestContainer;
+import org.apache.cayenne.testdo.relationship.Child;
+import org.apache.cayenne.testdo.relationship.Master;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
+public class NestedDataContextParentPeerEventsIT extends ServerCase {
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DataContext parentContext1;
+
+    @Inject
+    private DataContext parentContext2;
+
+    public void testPeerObjectUpdatedSimpleProperty() throws Exception {
+        Master a = parentContext1.newObject(Master.class);
+        a.setName("X");
+        parentContext1.commitChanges();
+
+        Master a1 = parentContext2.localObject(a);
+
+        final ObjectContext child = runtime.newContext(parentContext1);
+        final Master a2 = child.localObject(a);
+
+        a1.setName("Y");
+        assertEquals("X", a2.getName());
+        parentContext2.commitChangesToParent();
+
+        new ParallelTestContainer() {
+
+            @Override
+            protected void assertResult() throws Exception {
+                assertEquals("Y", a2.getName());
+
+                assertFalse(
+                        "Peer data context became dirty on event processing",
+                        child.hasChanges());
+            }
+        }.runTest(2000);
+    }
+
+    public void testPeerObjectUpdatedToOneRelationship() throws Exception {
+        Master a = parentContext1.newObject(Master.class);
+        Master altA = parentContext1.newObject(Master.class);
+
+        Child p = parentContext1.newObject(Child.class);
+        p.setMaster(a);
+        a.setName("X");
+        altA.setName("Y");
+        parentContext1.commitChanges();
+
+        Child p1 = parentContext2.localObject(p);
+        Master altA1 = parentContext2.localObject(altA);
+
+        final ObjectContext childContext1 = runtime.newContext(parentContext1);
+        final Child p2 = childContext1.localObject(p);
+        final Master altA2 = childContext1.localObject(altA);
+        Master a2 = childContext1.localObject(a);
+
+        p1.setMaster(altA1);
+        assertSame(a2, p2.getMaster());
+        assertNotSame(altA2, p2.getMaster());
+        parentContext2.commitChanges();
+
+        new ParallelTestContainer() {
+
+            @Override
+            protected void assertResult() throws Exception {
+                assertSame(altA2, p2.getMaster());
+                assertFalse(
+                        "Peer data context became dirty on event processing",
+                        childContext1.hasChanges());
+            }
+        }.runTest(2000);
+    }
+
+    public void testPeerObjectUpdatedToManyRelationship() throws Exception {
+        Master a = parentContext1.newObject(Master.class);
+        a.setName("X");
+
+        Child px = parentContext1.newObject(Child.class);
+        px.setMaster(a);
+
+        Child py = parentContext1.newObject(Child.class);
+
+        parentContext1.commitChanges();
+
+        Child py1 = parentContext2.localObject(py);
+        Master a1 = parentContext2.localObject(a);
+
+        final ObjectContext peer2 = runtime.newContext(parentContext1);
+        final Child py2 = peer2.localObject(py);
+        final Master a2 = peer2.localObject(a);
+
+        a1.addToChildren(py1);
+        assertEquals(1, a2.getChildren().size());
+        assertFalse(a2.getChildren().contains(py2));
+        parentContext2.commitChangesToParent();
+
+        new ParallelTestContainer() {
+
+            @Override
+            protected void assertResult() throws Exception {
+                assertEquals(2, a2.getChildren().size());
+                assertTrue(a2.getChildren().contains(py2));
+
+                assertFalse(
+                        "Peer data context became dirty on event processing",
+                        peer2.hasChanges());
+            }
+        }.runTest(2000);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsTest.java
deleted file mode 100644
index d5a295f..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*****************************************************************
- *   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.access;
-
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.test.parallel.ParallelTestContainer;
-import org.apache.cayenne.testdo.relationship.Child;
-import org.apache.cayenne.testdo.relationship.Master;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
-public class NestedDataContextParentPeerEventsTest extends ServerCase {
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private DataContext parentContext1;
-
-    @Inject
-    private DataContext parentContext2;
-
-    public void testPeerObjectUpdatedSimpleProperty() throws Exception {
-        Master a = parentContext1.newObject(Master.class);
-        a.setName("X");
-        parentContext1.commitChanges();
-
-        Master a1 = parentContext2.localObject(a);
-
-        final ObjectContext child = runtime.newContext(parentContext1);
-        final Master a2 = child.localObject(a);
-
-        a1.setName("Y");
-        assertEquals("X", a2.getName());
-        parentContext2.commitChangesToParent();
-
-        new ParallelTestContainer() {
-
-            @Override
-            protected void assertResult() throws Exception {
-                assertEquals("Y", a2.getName());
-
-                assertFalse(
-                        "Peer data context became dirty on event processing",
-                        child.hasChanges());
-            }
-        }.runTest(2000);
-    }
-
-    public void testPeerObjectUpdatedToOneRelationship() throws Exception {
-        Master a = parentContext1.newObject(Master.class);
-        Master altA = parentContext1.newObject(Master.class);
-
-        Child p = parentContext1.newObject(Child.class);
-        p.setMaster(a);
-        a.setName("X");
-        altA.setName("Y");
-        parentContext1.commitChanges();
-
-        Child p1 = parentContext2.localObject(p);
-        Master altA1 = parentContext2.localObject(altA);
-
-        final ObjectContext childContext1 = runtime.newContext(parentContext1);
-        final Child p2 = childContext1.localObject(p);
-        final Master altA2 = childContext1.localObject(altA);
-        Master a2 = childContext1.localObject(a);
-
-        p1.setMaster(altA1);
-        assertSame(a2, p2.getMaster());
-        assertNotSame(altA2, p2.getMaster());
-        parentContext2.commitChanges();
-
-        new ParallelTestContainer() {
-
-            @Override
-            protected void assertResult() throws Exception {
-                assertSame(altA2, p2.getMaster());
-                assertFalse(
-                        "Peer data context became dirty on event processing",
-                        childContext1.hasChanges());
-            }
-        }.runTest(2000);
-    }
-
-    public void testPeerObjectUpdatedToManyRelationship() throws Exception {
-        Master a = parentContext1.newObject(Master.class);
-        a.setName("X");
-
-        Child px = parentContext1.newObject(Child.class);
-        px.setMaster(a);
-
-        Child py = parentContext1.newObject(Child.class);
-
-        parentContext1.commitChanges();
-
-        Child py1 = parentContext2.localObject(py);
-        Master a1 = parentContext2.localObject(a);
-
-        final ObjectContext peer2 = runtime.newContext(parentContext1);
-        final Child py2 = peer2.localObject(py);
-        final Master a2 = peer2.localObject(a);
-
-        a1.addToChildren(py1);
-        assertEquals(1, a2.getChildren().size());
-        assertFalse(a2.getChildren().contains(py2));
-        parentContext2.commitChangesToParent();
-
-        new ParallelTestContainer() {
-
-            @Override
-            protected void assertResult() throws Exception {
-                assertEquals(2, a2.getChildren().size());
-                assertTrue(a2.getChildren().contains(py2));
-
-                assertFalse(
-                        "Peer data context became dirty on event processing",
-                        peer2.hasChanges());
-            }
-        }.runTest(2000);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsIT.java
new file mode 100644
index 0000000..9afd2c7
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsIT.java
@@ -0,0 +1,181 @@
+/*****************************************************************
+ *   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.access;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.parallel.ParallelTestContainer;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class NestedDataContextPeerEventsIT extends ServerCase {
+
+	@Inject
+	private DataContext context;
+
+	@Inject
+	private ServerRuntime runtime;
+
+	public void testPeerObjectUpdatedTempOID() throws Exception {
+
+		ObjectContext peer1 = runtime.newContext(context);
+		final Artist a1 = peer1.newObject(Artist.class);
+		a1.setArtistName("Y");
+
+		ObjectId a1TempId = a1.getObjectId();
+		assertTrue(a1TempId.isTemporary());
+
+		ObjectContext peer2 = runtime.newContext(context);
+		final Artist a2 = peer2.localObject(a1);
+
+		assertEquals(a1TempId, a2.getObjectId());
+
+		peer1.commitChanges();
+
+		// pause to let the context events propagate
+		new ParallelTestContainer() {
+
+			@Override
+			protected void assertResult() throws Exception {
+				assertFalse(a1.getObjectId().isTemporary());
+				assertFalse(a2.getObjectId().isTemporary());
+				assertEquals(a2.getObjectId(), a1.getObjectId());
+			}
+		}.runTest(2000);
+	}
+
+	public void testPeerObjectUpdatedSimpleProperty() throws Exception {
+		Artist a = context.newObject(Artist.class);
+		a.setArtistName("X");
+		context.commitChanges();
+
+		ObjectContext peer1 = runtime.newContext(context);
+		Artist a1 = peer1.localObject(a);
+
+		final ObjectContext peer2 = runtime.newContext(context);
+		final Artist a2 = peer2.localObject(a);
+
+		a1.setArtistName("Y");
+		assertEquals("X", a2.getArtistName());
+		peer1.commitChangesToParent();
+
+		// pause to let the context events propagate
+		new ParallelTestContainer() {
+
+			@Override
+			protected void assertResult() throws Exception {
+				assertEquals("Y", a2.getArtistName());
+				assertFalse(
+						"Peer data context became dirty on event processing",
+						peer2.hasChanges());
+			}
+		}.runTest(2000);
+
+	}
+
+	public void testPeerObjectUpdatedToOneRelationship() throws Exception {
+
+		Artist a = context.newObject(Artist.class);
+		Artist altA = context.newObject(Artist.class);
+
+		Painting p = context.newObject(Painting.class);
+		p.setToArtist(a);
+		p.setPaintingTitle("PPP");
+		a.setArtistName("X");
+		altA.setArtistName("Y");
+		context.commitChanges();
+
+		ObjectContext peer1 = runtime.newContext(context);
+		Painting p1 = peer1.localObject(p);
+		Artist altA1 = peer1.localObject(altA);
+
+		final ObjectContext peer2 = runtime.newContext(context);
+		final Painting p2 = peer2.localObject(p);
+		final Artist altA2 = peer2.localObject(altA);
+		Artist a2 = peer2.localObject(a);
+
+		p1.setToArtist(altA1);
+		assertSame(a2, p2.getToArtist());
+		peer1.commitChangesToParent();
+
+		// pause to let the context events propagate
+		new ParallelTestContainer() {
+
+			@Override
+			protected void assertResult() throws Exception {
+				assertEquals(altA2, p2.getToArtist());
+
+				assertFalse(
+						"Peer data context became dirty on event processing",
+						peer2.hasChanges());
+			}
+		}.runTest(2000);
+
+	}
+
+	public void testPeerObjectUpdatedToManyRelationship() throws Exception {
+
+		Artist a = context.newObject(Artist.class);
+		a.setArtistName("X");
+
+		Painting px = context.newObject(Painting.class);
+		px.setToArtist(a);
+		px.setPaintingTitle("PX");
+
+		Painting py = context.newObject(Painting.class);
+		py.setPaintingTitle("PY");
+
+		context.commitChanges();
+		// pause to let the context events propagate
+		Thread.sleep(500);
+
+		ObjectContext peer1 = runtime.newContext(context);
+		Painting py1 = peer1.localObject(py);
+		Artist a1 = peer1.localObject(a);
+
+		final ObjectContext peer2 = runtime.newContext(context);
+		final Painting py2 = peer2.localObject(py);
+		final Artist a2 = peer2.localObject(a);
+
+		a1.addToPaintingArray(py1);
+		assertEquals(1, a2.getPaintingArray().size());
+		assertFalse(a2.getPaintingArray().contains(py2));
+		peer1.commitChangesToParent();
+		// pause to let the context events propagate
+		new ParallelTestContainer() {
+
+			@Override
+			protected void assertResult() throws Exception {
+				assertEquals(2, a2.getPaintingArray().size());
+				assertTrue(a2.getPaintingArray().contains(py2));
+
+				assertFalse(
+						"Peer data context became dirty on event processing",
+						peer2.hasChanges());
+			}
+		}.runTest(2000);
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsTest.java
deleted file mode 100644
index 7ed001b..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsTest.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*****************************************************************
- *   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.access;
-
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.test.parallel.ParallelTestContainer;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class NestedDataContextPeerEventsTest extends ServerCase {
-
-	@Inject
-	private DataContext context;
-
-	@Inject
-	private ServerRuntime runtime;
-
-	public void testPeerObjectUpdatedTempOID() throws Exception {
-
-		ObjectContext peer1 = runtime.newContext(context);
-		final Artist a1 = peer1.newObject(Artist.class);
-		a1.setArtistName("Y");
-
-		ObjectId a1TempId = a1.getObjectId();
-		assertTrue(a1TempId.isTemporary());
-
-		ObjectContext peer2 = runtime.newContext(context);
-		final Artist a2 = peer2.localObject(a1);
-
-		assertEquals(a1TempId, a2.getObjectId());
-
-		peer1.commitChanges();
-
-		// pause to let the context events propagate
-		new ParallelTestContainer() {
-
-			@Override
-			protected void assertResult() throws Exception {
-				assertFalse(a1.getObjectId().isTemporary());
-				assertFalse(a2.getObjectId().isTemporary());
-				assertEquals(a2.getObjectId(), a1.getObjectId());
-			}
-		}.runTest(2000);
-	}
-
-	public void testPeerObjectUpdatedSimpleProperty() throws Exception {
-		Artist a = context.newObject(Artist.class);
-		a.setArtistName("X");
-		context.commitChanges();
-
-		ObjectContext peer1 = runtime.newContext(context);
-		Artist a1 = peer1.localObject(a);
-
-		final ObjectContext peer2 = runtime.newContext(context);
-		final Artist a2 = peer2.localObject(a);
-
-		a1.setArtistName("Y");
-		assertEquals("X", a2.getArtistName());
-		peer1.commitChangesToParent();
-
-		// pause to let the context events propagate
-		new ParallelTestContainer() {
-
-			@Override
-			protected void assertResult() throws Exception {
-				assertEquals("Y", a2.getArtistName());
-				assertFalse(
-						"Peer data context became dirty on event processing",
-						peer2.hasChanges());
-			}
-		}.runTest(2000);
-
-	}
-
-	public void testPeerObjectUpdatedToOneRelationship() throws Exception {
-
-		Artist a = context.newObject(Artist.class);
-		Artist altA = context.newObject(Artist.class);
-
-		Painting p = context.newObject(Painting.class);
-		p.setToArtist(a);
-		p.setPaintingTitle("PPP");
-		a.setArtistName("X");
-		altA.setArtistName("Y");
-		context.commitChanges();
-
-		ObjectContext peer1 = runtime.newContext(context);
-		Painting p1 = peer1.localObject(p);
-		Artist altA1 = peer1.localObject(altA);
-
-		final ObjectContext peer2 = runtime.newContext(context);
-		final Painting p2 = peer2.localObject(p);
-		final Artist altA2 = peer2.localObject(altA);
-		Artist a2 = peer2.localObject(a);
-
-		p1.setToArtist(altA1);
-		assertSame(a2, p2.getToArtist());
-		peer1.commitChangesToParent();
-
-		// pause to let the context events propagate
-		new ParallelTestContainer() {
-
-			@Override
-			protected void assertResult() throws Exception {
-				assertEquals(altA2, p2.getToArtist());
-
-				assertFalse(
-						"Peer data context became dirty on event processing",
-						peer2.hasChanges());
-			}
-		}.runTest(2000);
-
-	}
-
-	public void testPeerObjectUpdatedToManyRelationship() throws Exception {
-
-		Artist a = context.newObject(Artist.class);
-		a.setArtistName("X");
-
-		Painting px = context.newObject(Painting.class);
-		px.setToArtist(a);
-		px.setPaintingTitle("PX");
-
-		Painting py = context.newObject(Painting.class);
-		py.setPaintingTitle("PY");
-
-		context.commitChanges();
-		// pause to let the context events propagate
-		Thread.sleep(500);
-
-		ObjectContext peer1 = runtime.newContext(context);
-		Painting py1 = peer1.localObject(py);
-		Artist a1 = peer1.localObject(a);
-
-		final ObjectContext peer2 = runtime.newContext(context);
-		final Painting py2 = peer2.localObject(py);
-		final Artist a2 = peer2.localObject(a);
-
-		a1.addToPaintingArray(py1);
-		assertEquals(1, a2.getPaintingArray().size());
-		assertFalse(a2.getPaintingArray().contains(py2));
-		peer1.commitChangesToParent();
-		// pause to let the context events propagate
-		new ParallelTestContainer() {
-
-			@Override
-			protected void assertResult() throws Exception {
-				assertEquals(2, a2.getPaintingArray().size());
-				assertTrue(a2.getPaintingArray().contains(py2));
-
-				assertFalse(
-						"Peer data context became dirty on event processing",
-						peer2.hasChanges());
-			}
-		}.runTest(2000);
-
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextReadIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextReadIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextReadIT.java
new file mode 100644
index 0000000..3e32532
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextReadIT.java
@@ -0,0 +1,376 @@
+/*****************************************************************
+ *   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.access;
+
+import java.sql.Types;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.DataChannel;
+import org.apache.cayenne.DataObject;
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.SortOrder;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.unit.di.DataChannelInterceptor;
+import org.apache.cayenne.unit.di.UnitTestClosure;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class NestedDataContextReadIT extends ServerCase {
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DataChannelInterceptor queryInterceptor;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper tArtist;
+    private TableHelper tPainting;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+
+        tPainting = new TableHelper(dbHelper, "PAINTING");
+        tPainting.setColumns(
+                "PAINTING_ID",
+                "PAINTING_TITLE",
+                "ARTIST_ID",
+                "ESTIMATED_PRICE").setColumnTypes(
+                Types.INTEGER,
+                Types.VARCHAR,
+                Types.BIGINT,
+                Types.DECIMAL);
+    }
+
+    private void createArtistsDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+        tArtist.insert(33003, "artist3");
+        tArtist.insert(33004, "artist4");
+    }
+
+    private void createRelationshipDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+        tArtist.insert(33003, "artist3");
+        tArtist.insert(33004, "artist4");
+        tPainting.insert(33001, "P_artist1", 33001, 3000);
+        tPainting.insert(33002, "P_artist2", 33002, 3000);
+        tPainting.insert(33003, "P_artist3", 33003, 3000);
+        tPainting.insert(33004, "P_artist4", 33004, 3000);
+        tPainting.insert(33005, "P_artist5", null, 3000);
+    }
+
+    private void createPrefetchingDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+        tPainting.insert(33001, "P_artist1", 33001, 3000);
+        tPainting.insert(33006, "P_artist6", 33001, 3000);
+    }
+
+    public void testCreateChildDataContext() {
+        context.setValidatingObjectsOnCommit(true);
+
+        ObjectContext child1 = runtime.newContext(context);
+
+        assertNotNull(child1);
+        assertSame(context, child1.getChannel());
+        assertTrue(((DataContext) child1).isValidatingObjectsOnCommit());
+
+        context.setValidatingObjectsOnCommit(false);
+
+        ObjectContext child2 = runtime.newContext(context);
+
+        assertNotNull(child2);
+        assertSame(context, child2.getChannel());
+        assertFalse(((DataContext) child2).isValidatingObjectsOnCommit());
+
+        // second level of nesting
+        ObjectContext child21 = runtime.newContext((DataChannel) child2);
+
+        assertNotNull(child21);
+        assertSame(child2, child21.getChannel());
+        assertFalse(((DataContext) child2).isValidatingObjectsOnCommit());
+    }
+
+    public void testSelect() throws Exception {
+        createArtistsDataSet();
+
+        ObjectContext child = runtime.newContext(context);
+
+        // test how different object states appear in the child on select
+
+        Persistent _new = context.newObject(Artist.class);
+
+        Persistent hollow = Cayenne.objectForPK(context, Artist.class, 33001);
+        context.invalidateObjects(hollow);
+
+        DataObject committed = Cayenne.objectForPK(context, Artist.class, 33002);
+
+        Artist modified = Cayenne.objectForPK(context, Artist.class, 33003);
+        modified.setArtistName("MODDED");
+
+        DataObject deleted = Cayenne.objectForPK(context, Artist.class, 33004);
+        context.deleteObjects(deleted);
+
+        assertEquals(PersistenceState.HOLLOW, hollow.getPersistenceState());
+        assertEquals(PersistenceState.COMMITTED, committed.getPersistenceState());
+        assertEquals(PersistenceState.MODIFIED, modified.getPersistenceState());
+        assertEquals(PersistenceState.DELETED, deleted.getPersistenceState());
+        assertEquals(PersistenceState.NEW, _new.getPersistenceState());
+
+        List<?> objects = child.performQuery(new SelectQuery(Artist.class));
+        assertEquals("All but NEW object must have been included", 4, objects.size());
+
+        Iterator<?> it = objects.iterator();
+        while (it.hasNext()) {
+            DataObject next = (DataObject) it.next();
+            assertEquals(PersistenceState.COMMITTED, next.getPersistenceState());
+
+            int id = Cayenne.intPKForObject(next);
+            if (id == 33003) {
+                assertEquals("MODDED", next.readProperty(Artist.ARTIST_NAME_PROPERTY));
+            }
+        }
+    }
+
+    public void testReadToOneRelationship() throws Exception {
+        createRelationshipDataSet();
+
+        final ObjectContext child = runtime.newContext(context);
+
+        // test how different object states appear in the child on select
+
+        Painting hollowTargetSrc = Cayenne.objectForPK(context, Painting.class, 33001);
+        Artist hollowTarget = hollowTargetSrc.getToArtist();
+
+        Painting modifiedTargetSrc = Cayenne.objectForPK(context, Painting.class, 33002);
+        Artist modifiedTarget = modifiedTargetSrc.getToArtist();
+        modifiedTarget.setArtistName("M1");
+
+        final Painting deletedTargetSrc = Cayenne.objectForPK(
+                context,
+                Painting.class,
+                33003);
+        Artist deletedTarget = deletedTargetSrc.getToArtist();
+        deletedTargetSrc.setToArtist(null);
+        context.deleteObjects(deletedTarget);
+
+        Painting committedTargetSrc = Cayenne.objectForPK(context, Painting.class, 33004);
+        Artist committedTarget = committedTargetSrc.getToArtist();
+        committedTarget.getArtistName();
+
+        final Painting newTargetSrc = Cayenne.objectForPK(context, Painting.class, 33005);
+        Artist newTarget = context.newObject(Artist.class);
+        newTarget.setArtistName("N1");
+        newTargetSrc.setToArtist(newTarget);
+
+        assertEquals(PersistenceState.COMMITTED, hollowTargetSrc.getPersistenceState());
+        assertEquals(PersistenceState.COMMITTED, modifiedTargetSrc.getPersistenceState());
+        assertEquals(PersistenceState.MODIFIED, deletedTargetSrc.getPersistenceState());
+        assertEquals(PersistenceState.COMMITTED, committedTargetSrc.getPersistenceState());
+        assertEquals(PersistenceState.MODIFIED, newTargetSrc.getPersistenceState());
+
+        assertEquals(PersistenceState.HOLLOW, hollowTarget.getPersistenceState());
+        assertEquals(PersistenceState.MODIFIED, modifiedTarget.getPersistenceState());
+        assertEquals(PersistenceState.DELETED, deletedTarget.getPersistenceState());
+        assertEquals(PersistenceState.COMMITTED, committedTarget.getPersistenceState());
+        assertEquals(PersistenceState.NEW, newTarget.getPersistenceState());
+
+        // run an ordered query, so we can address specific objects directly by index
+        SelectQuery q = new SelectQuery(Painting.class);
+        q.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
+        final List<?> childSources = child.performQuery(q);
+        assertEquals(5, childSources.size());
+
+        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+
+            public void execute() {
+                Painting childHollowTargetSrc = (Painting) childSources.get(0);
+                assertSame(child, childHollowTargetSrc.getObjectContext());
+                Artist childHollowTarget = childHollowTargetSrc.getToArtist();
+                assertNotNull(childHollowTarget);
+                assertEquals(
+                        PersistenceState.HOLLOW,
+                        childHollowTarget.getPersistenceState());
+                assertSame(child, childHollowTarget.getObjectContext());
+
+                Artist childModifiedTarget = ((Painting) childSources.get(1))
+                        .getToArtist();
+
+                assertEquals(
+                        PersistenceState.COMMITTED,
+                        childModifiedTarget.getPersistenceState());
+                assertSame(child, childModifiedTarget.getObjectContext());
+                assertEquals("M1", childModifiedTarget.getArtistName());
+
+                Painting childDeletedTargetSrc = (Painting) childSources.get(2);
+                // make sure we got the right object...
+                assertEquals(
+                        deletedTargetSrc.getObjectId(),
+                        childDeletedTargetSrc.getObjectId());
+                Artist childDeletedTarget = childDeletedTargetSrc.getToArtist();
+                assertNull(childDeletedTarget);
+
+                Artist childCommittedTarget = ((Painting) childSources.get(3))
+                        .getToArtist();
+                assertEquals(
+                        PersistenceState.COMMITTED,
+                        childCommittedTarget.getPersistenceState());
+                assertSame(child, childCommittedTarget.getObjectContext());
+
+                Painting childNewTargetSrc = (Painting) childSources.get(4);
+                // make sure we got the right object...
+                assertEquals(newTargetSrc.getObjectId(), childNewTargetSrc.getObjectId());
+                Artist childNewTarget = childNewTargetSrc.getToArtist();
+                assertNotNull(childNewTarget);
+                assertEquals(
+                        PersistenceState.COMMITTED,
+                        childNewTarget.getPersistenceState());
+                assertSame(child, childNewTarget.getObjectContext());
+                assertEquals("N1", childNewTarget.getArtistName());
+            }
+        });
+    }
+
+    public void testPrefetchingToOne() throws Exception {
+        createPrefetchingDataSet();
+
+        final ObjectContext child = runtime.newContext(context);
+
+        final ObjectId prefetchedId = new ObjectId(
+                "Artist",
+                Artist.ARTIST_ID_PK_COLUMN,
+                new Integer(33001));
+
+        SelectQuery q = new SelectQuery(Painting.class);
+        q.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
+        q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
+
+        final List<?> results = child.performQuery(q);
+
+        // blockQueries();
+
+        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+
+            public void execute() {
+                assertEquals(2, results.size());
+                Iterator<?> it = results.iterator();
+                while (it.hasNext()) {
+                    Painting o = (Painting) it.next();
+                    assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
+                    assertSame(child, o.getObjectContext());
+
+                    Artist o1 = o.getToArtist();
+                    assertNotNull(o1);
+                    assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
+                    assertSame(child, o1.getObjectContext());
+                    assertEquals(prefetchedId, o1.getObjectId());
+                }
+            }
+        });
+    }
+
+    public void testPrefetchingToMany() throws Exception {
+        createPrefetchingDataSet();
+
+        final ObjectContext child = runtime.newContext(context);
+
+        SelectQuery q = new SelectQuery(Artist.class);
+        q.addOrdering(Artist.ARTIST_NAME_PROPERTY, SortOrder.ASCENDING);
+        q.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);
+
+        final List<?> results = child.performQuery(q);
+
+        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+
+            public void execute() {
+                Artist o1 = (Artist) results.get(0);
+                assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
+                assertSame(child, o1.getObjectContext());
+
+                List<?> children1 = o1.getPaintingArray();
+
+                assertEquals(2, children1.size());
+                Iterator<?> it = children1.iterator();
+                while (it.hasNext()) {
+                    Painting o = (Painting) it.next();
+                    assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
+                    assertSame(child, o.getObjectContext());
+
+                    assertEquals(o1, o.getToArtist());
+                }
+
+                Artist o2 = (Artist) results.get(1);
+                assertEquals(PersistenceState.COMMITTED, o2.getPersistenceState());
+                assertSame(child, o2.getObjectContext());
+
+                List<?> children2 = o2.getPaintingArray();
+
+                assertEquals(0, children2.size());
+            }
+        });
+    }
+
+    public void testObjectFromDataRow() throws Exception {
+
+        DataContext childContext = (DataContext) runtime.newContext(context);
+
+        DataRow row = new DataRow(8);
+        row.put("ARTIST_ID", 5l);
+        row.put("ARTIST_NAME", "A");
+        row.put("DATE_OF_BIRTH", new Date());
+
+        Artist artist = childContext.objectFromDataRow(Artist.class, row);
+        assertNotNull(artist);
+        assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
+        assertSame(childContext, artist.getObjectContext());
+        Object parentArtist = context.getObjectStore().getNode(artist.getObjectId());
+        assertNotNull(parentArtist);
+        assertNotSame(artist, parentArtist);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextReadTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextReadTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextReadTest.java
deleted file mode 100644
index c1ecdc7..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextReadTest.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*****************************************************************
- *   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.access;
-
-import java.sql.Types;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.DataChannel;
-import org.apache.cayenne.DataObject;
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.Persistent;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.query.SortOrder;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class NestedDataContextReadTest extends ServerCase {
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DataChannelInterceptor queryInterceptor;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    private TableHelper tArtist;
-    private TableHelper tPainting;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-
-        tPainting = new TableHelper(dbHelper, "PAINTING");
-        tPainting.setColumns(
-                "PAINTING_ID",
-                "PAINTING_TITLE",
-                "ARTIST_ID",
-                "ESTIMATED_PRICE").setColumnTypes(
-                Types.INTEGER,
-                Types.VARCHAR,
-                Types.BIGINT,
-                Types.DECIMAL);
-    }
-
-    private void createArtistsDataSet() throws Exception {
-        tArtist.insert(33001, "artist1");
-        tArtist.insert(33002, "artist2");
-        tArtist.insert(33003, "artist3");
-        tArtist.insert(33004, "artist4");
-    }
-
-    private void createRelationshipDataSet() throws Exception {
-        tArtist.insert(33001, "artist1");
-        tArtist.insert(33002, "artist2");
-        tArtist.insert(33003, "artist3");
-        tArtist.insert(33004, "artist4");
-        tPainting.insert(33001, "P_artist1", 33001, 3000);
-        tPainting.insert(33002, "P_artist2", 33002, 3000);
-        tPainting.insert(33003, "P_artist3", 33003, 3000);
-        tPainting.insert(33004, "P_artist4", 33004, 3000);
-        tPainting.insert(33005, "P_artist5", null, 3000);
-    }
-
-    private void createPrefetchingDataSet() throws Exception {
-        tArtist.insert(33001, "artist1");
-        tArtist.insert(33002, "artist2");
-        tPainting.insert(33001, "P_artist1", 33001, 3000);
-        tPainting.insert(33006, "P_artist6", 33001, 3000);
-    }
-
-    public void testCreateChildDataContext() {
-        context.setValidatingObjectsOnCommit(true);
-
-        ObjectContext child1 = runtime.newContext(context);
-
-        assertNotNull(child1);
-        assertSame(context, child1.getChannel());
-        assertTrue(((DataContext) child1).isValidatingObjectsOnCommit());
-
-        context.setValidatingObjectsOnCommit(false);
-
-        ObjectContext child2 = runtime.newContext(context);
-
-        assertNotNull(child2);
-        assertSame(context, child2.getChannel());
-        assertFalse(((DataContext) child2).isValidatingObjectsOnCommit());
-
-        // second level of nesting
-        ObjectContext child21 = runtime.newContext((DataChannel) child2);
-
-        assertNotNull(child21);
-        assertSame(child2, child21.getChannel());
-        assertFalse(((DataContext) child2).isValidatingObjectsOnCommit());
-    }
-
-    public void testSelect() throws Exception {
-        createArtistsDataSet();
-
-        ObjectContext child = runtime.newContext(context);
-
-        // test how different object states appear in the child on select
-
-        Persistent _new = context.newObject(Artist.class);
-
-        Persistent hollow = Cayenne.objectForPK(context, Artist.class, 33001);
-        context.invalidateObjects(hollow);
-
-        DataObject committed = Cayenne.objectForPK(context, Artist.class, 33002);
-
-        Artist modified = Cayenne.objectForPK(context, Artist.class, 33003);
-        modified.setArtistName("MODDED");
-
-        DataObject deleted = Cayenne.objectForPK(context, Artist.class, 33004);
-        context.deleteObjects(deleted);
-
-        assertEquals(PersistenceState.HOLLOW, hollow.getPersistenceState());
-        assertEquals(PersistenceState.COMMITTED, committed.getPersistenceState());
-        assertEquals(PersistenceState.MODIFIED, modified.getPersistenceState());
-        assertEquals(PersistenceState.DELETED, deleted.getPersistenceState());
-        assertEquals(PersistenceState.NEW, _new.getPersistenceState());
-
-        List<?> objects = child.performQuery(new SelectQuery(Artist.class));
-        assertEquals("All but NEW object must have been included", 4, objects.size());
-
-        Iterator<?> it = objects.iterator();
-        while (it.hasNext()) {
-            DataObject next = (DataObject) it.next();
-            assertEquals(PersistenceState.COMMITTED, next.getPersistenceState());
-
-            int id = Cayenne.intPKForObject(next);
-            if (id == 33003) {
-                assertEquals("MODDED", next.readProperty(Artist.ARTIST_NAME_PROPERTY));
-            }
-        }
-    }
-
-    public void testReadToOneRelationship() throws Exception {
-        createRelationshipDataSet();
-
-        final ObjectContext child = runtime.newContext(context);
-
-        // test how different object states appear in the child on select
-
-        Painting hollowTargetSrc = Cayenne.objectForPK(context, Painting.class, 33001);
-        Artist hollowTarget = hollowTargetSrc.getToArtist();
-
-        Painting modifiedTargetSrc = Cayenne.objectForPK(context, Painting.class, 33002);
-        Artist modifiedTarget = modifiedTargetSrc.getToArtist();
-        modifiedTarget.setArtistName("M1");
-
-        final Painting deletedTargetSrc = Cayenne.objectForPK(
-                context,
-                Painting.class,
-                33003);
-        Artist deletedTarget = deletedTargetSrc.getToArtist();
-        deletedTargetSrc.setToArtist(null);
-        context.deleteObjects(deletedTarget);
-
-        Painting committedTargetSrc = Cayenne.objectForPK(context, Painting.class, 33004);
-        Artist committedTarget = committedTargetSrc.getToArtist();
-        committedTarget.getArtistName();
-
-        final Painting newTargetSrc = Cayenne.objectForPK(context, Painting.class, 33005);
-        Artist newTarget = context.newObject(Artist.class);
-        newTarget.setArtistName("N1");
-        newTargetSrc.setToArtist(newTarget);
-
-        assertEquals(PersistenceState.COMMITTED, hollowTargetSrc.getPersistenceState());
-        assertEquals(PersistenceState.COMMITTED, modifiedTargetSrc.getPersistenceState());
-        assertEquals(PersistenceState.MODIFIED, deletedTargetSrc.getPersistenceState());
-        assertEquals(PersistenceState.COMMITTED, committedTargetSrc.getPersistenceState());
-        assertEquals(PersistenceState.MODIFIED, newTargetSrc.getPersistenceState());
-
-        assertEquals(PersistenceState.HOLLOW, hollowTarget.getPersistenceState());
-        assertEquals(PersistenceState.MODIFIED, modifiedTarget.getPersistenceState());
-        assertEquals(PersistenceState.DELETED, deletedTarget.getPersistenceState());
-        assertEquals(PersistenceState.COMMITTED, committedTarget.getPersistenceState());
-        assertEquals(PersistenceState.NEW, newTarget.getPersistenceState());
-
-        // run an ordered query, so we can address specific objects directly by index
-        SelectQuery q = new SelectQuery(Painting.class);
-        q.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
-        final List<?> childSources = child.performQuery(q);
-        assertEquals(5, childSources.size());
-
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                Painting childHollowTargetSrc = (Painting) childSources.get(0);
-                assertSame(child, childHollowTargetSrc.getObjectContext());
-                Artist childHollowTarget = childHollowTargetSrc.getToArtist();
-                assertNotNull(childHollowTarget);
-                assertEquals(
-                        PersistenceState.HOLLOW,
-                        childHollowTarget.getPersistenceState());
-                assertSame(child, childHollowTarget.getObjectContext());
-
-                Artist childModifiedTarget = ((Painting) childSources.get(1))
-                        .getToArtist();
-
-                assertEquals(
-                        PersistenceState.COMMITTED,
-                        childModifiedTarget.getPersistenceState());
-                assertSame(child, childModifiedTarget.getObjectContext());
-                assertEquals("M1", childModifiedTarget.getArtistName());
-
-                Painting childDeletedTargetSrc = (Painting) childSources.get(2);
-                // make sure we got the right object...
-                assertEquals(
-                        deletedTargetSrc.getObjectId(),
-                        childDeletedTargetSrc.getObjectId());
-                Artist childDeletedTarget = childDeletedTargetSrc.getToArtist();
-                assertNull(childDeletedTarget);
-
-                Artist childCommittedTarget = ((Painting) childSources.get(3))
-                        .getToArtist();
-                assertEquals(
-                        PersistenceState.COMMITTED,
-                        childCommittedTarget.getPersistenceState());
-                assertSame(child, childCommittedTarget.getObjectContext());
-
-                Painting childNewTargetSrc = (Painting) childSources.get(4);
-                // make sure we got the right object...
-                assertEquals(newTargetSrc.getObjectId(), childNewTargetSrc.getObjectId());
-                Artist childNewTarget = childNewTargetSrc.getToArtist();
-                assertNotNull(childNewTarget);
-                assertEquals(
-                        PersistenceState.COMMITTED,
-                        childNewTarget.getPersistenceState());
-                assertSame(child, childNewTarget.getObjectContext());
-                assertEquals("N1", childNewTarget.getArtistName());
-            }
-        });
-    }
-
-    public void testPrefetchingToOne() throws Exception {
-        createPrefetchingDataSet();
-
-        final ObjectContext child = runtime.newContext(context);
-
-        final ObjectId prefetchedId = new ObjectId(
-                "Artist",
-                Artist.ARTIST_ID_PK_COLUMN,
-                new Integer(33001));
-
-        SelectQuery q = new SelectQuery(Painting.class);
-        q.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
-        q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
-
-        final List<?> results = child.performQuery(q);
-
-        // blockQueries();
-
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                assertEquals(2, results.size());
-                Iterator<?> it = results.iterator();
-                while (it.hasNext()) {
-                    Painting o = (Painting) it.next();
-                    assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
-                    assertSame(child, o.getObjectContext());
-
-                    Artist o1 = o.getToArtist();
-                    assertNotNull(o1);
-                    assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
-                    assertSame(child, o1.getObjectContext());
-                    assertEquals(prefetchedId, o1.getObjectId());
-                }
-            }
-        });
-    }
-
-    public void testPrefetchingToMany() throws Exception {
-        createPrefetchingDataSet();
-
-        final ObjectContext child = runtime.newContext(context);
-
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering(Artist.ARTIST_NAME_PROPERTY, SortOrder.ASCENDING);
-        q.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);
-
-        final List<?> results = child.performQuery(q);
-
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                Artist o1 = (Artist) results.get(0);
-                assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
-                assertSame(child, o1.getObjectContext());
-
-                List<?> children1 = o1.getPaintingArray();
-
-                assertEquals(2, children1.size());
-                Iterator<?> it = children1.iterator();
-                while (it.hasNext()) {
-                    Painting o = (Painting) it.next();
-                    assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
-                    assertSame(child, o.getObjectContext());
-
-                    assertEquals(o1, o.getToArtist());
-                }
-
-                Artist o2 = (Artist) results.get(1);
-                assertEquals(PersistenceState.COMMITTED, o2.getPersistenceState());
-                assertSame(child, o2.getObjectContext());
-
-                List<?> children2 = o2.getPaintingArray();
-
-                assertEquals(0, children2.size());
-            }
-        });
-    }
-
-    public void testObjectFromDataRow() throws Exception {
-
-        DataContext childContext = (DataContext) runtime.newContext(context);
-
-        DataRow row = new DataRow(8);
-        row.put("ARTIST_ID", 5l);
-        row.put("ARTIST_NAME", "A");
-        row.put("DATE_OF_BIRTH", new Date());
-
-        Artist artist = childContext.objectFromDataRow(Artist.class, row);
-        assertNotNull(artist);
-        assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
-        assertSame(childContext, artist.getObjectContext());
-        Object parentArtist = context.getObjectStore().getNode(artist.getObjectId());
-        assertNotNull(parentArtist);
-        assertNotSame(artist, parentArtist);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextRollbackIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextRollbackIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextRollbackIT.java
new file mode 100644
index 0000000..86110c2
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextRollbackIT.java
@@ -0,0 +1,70 @@
+/*****************************************************************
+ *   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.access;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class NestedDataContextRollbackIT extends ServerCase {
+
+    @Inject
+    protected ServerRuntime runtime;
+    
+    @Inject
+    private DataContext context;
+
+    public void testRollbackChanges() {
+        ObjectContext child1 = runtime.newContext(context);
+
+        assertFalse(context.hasChanges());
+        assertFalse(child1.hasChanges());
+
+        context.newObject(Artist.class);
+        child1.newObject(Artist.class);
+
+        assertTrue(context.hasChanges());
+        assertTrue(child1.hasChanges());
+
+        child1.rollbackChanges();
+        assertFalse(context.hasChanges());
+        assertFalse(child1.hasChanges());
+    }
+
+    public void testRollbackChangesLocally() {
+        ObjectContext child1 = runtime.newContext(context);
+
+        assertFalse(context.hasChanges());
+        assertFalse(child1.hasChanges());
+
+        context.newObject(Artist.class);
+        child1.newObject(Artist.class);
+
+        assertTrue(context.hasChanges());
+        assertTrue(child1.hasChanges());
+
+        child1.rollbackChangesLocally();
+        assertTrue(context.hasChanges());
+        assertFalse(child1.hasChanges());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextRollbackTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextRollbackTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextRollbackTest.java
deleted file mode 100644
index fa23114..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextRollbackTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*****************************************************************
- *   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.access;
-
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class NestedDataContextRollbackTest extends ServerCase {
-
-    @Inject
-    protected ServerRuntime runtime;
-    
-    @Inject
-    private DataContext context;
-
-    public void testRollbackChanges() {
-        ObjectContext child1 = runtime.newContext(context);
-
-        assertFalse(context.hasChanges());
-        assertFalse(child1.hasChanges());
-
-        context.newObject(Artist.class);
-        child1.newObject(Artist.class);
-
-        assertTrue(context.hasChanges());
-        assertTrue(child1.hasChanges());
-
-        child1.rollbackChanges();
-        assertFalse(context.hasChanges());
-        assertFalse(child1.hasChanges());
-    }
-
-    public void testRollbackChangesLocally() {
-        ObjectContext child1 = runtime.newContext(context);
-
-        assertFalse(context.hasChanges());
-        assertFalse(child1.hasChanges());
-
-        context.newObject(Artist.class);
-        child1.newObject(Artist.class);
-
-        assertTrue(context.hasChanges());
-        assertTrue(child1.hasChanges());
-
-        child1.rollbackChangesLocally();
-        assertTrue(context.hasChanges());
-        assertFalse(child1.hasChanges());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextValidationIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextValidationIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextValidationIT.java
new file mode 100644
index 0000000..fd18428
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextValidationIT.java
@@ -0,0 +1,74 @@
+/*****************************************************************
+ *   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.access;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+import org.apache.cayenne.validation.ValidationException;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class NestedDataContextValidationIT extends ServerCase {
+
+    @Inject
+    protected ServerRuntime runtime;
+    
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+    }
+
+    public void testValidateOnCommitToParent() {
+        context.setValidatingObjectsOnCommit(true);
+
+        ObjectContext childContext = runtime.newContext(context);
+        assertTrue(
+                "Child context must have inherited the validation flag from parent",
+                ((DataContext) childContext).isValidatingObjectsOnCommit());
+
+        Artist a1 = childContext.newObject(Artist.class);
+        try {
+            childContext.commitChangesToParent();
+            fail("No validation was performed");
+        }
+        catch (ValidationException e) {
+            // expected
+        }
+
+        assertFalse(context.hasChanges());
+
+        a1.setArtistName("T");
+        childContext.commitChangesToParent();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextValidationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextValidationTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextValidationTest.java
deleted file mode 100644
index 04bfa8c..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/NestedDataContextValidationTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*****************************************************************
- *   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.access;
-
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.apache.cayenne.validation.ValidationException;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class NestedDataContextValidationTest extends ServerCase {
-
-    @Inject
-    protected ServerRuntime runtime;
-    
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-    }
-
-    public void testValidateOnCommitToParent() {
-        context.setValidatingObjectsOnCommit(true);
-
-        ObjectContext childContext = runtime.newContext(context);
-        assertTrue(
-                "Child context must have inherited the validation flag from parent",
-                ((DataContext) childContext).isValidatingObjectsOnCommit());
-
-        Artist a1 = childContext.newObject(Artist.class);
-        try {
-            childContext.commitChangesToParent();
-            fail("No validation was performed");
-        }
-        catch (ValidationException e) {
-            // expected
-        }
-
-        assertFalse(context.hasChanges());
-
-        a1.setArtistName("T");
-        childContext.commitChangesToParent();
-    }
-}


Mime
View raw message