cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [30/48] Installing Maven Failsafe Plugin
Date Sun, 02 Nov 2014 07:10:18 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshQueryTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshQueryTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshQueryTest.java
deleted file mode 100644
index 7ad23ce..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshQueryTest.java
+++ /dev/null
@@ -1,440 +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.util.List;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.ValueHolder;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.QueryCacheStrategy;
-import org.apache.cayenne.query.RefreshQuery;
-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.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextRefreshQueryTest extends ServerCase {
-
-    @Inject
-    protected DataContext context;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    protected TableHelper tArtist;
-    protected TableHelper tPainting;
-
-    @Override
-    public 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");
-    }
-
-    protected void createRefreshCollectionDataSet() throws Exception {
-        tArtist.insert(33001, "c");
-        tArtist.insert(33002, "b");
-        tPainting.insert(33001, "P1", 33001, 3000);
-        tPainting.insert(33002, "P2", 33001, 4000);
-    }
-
-    protected void createRefreshCollectionToOneUpdateDataSet() throws Exception {
-        tPainting.update().set("ARTIST_ID", 33002).execute();
-    }
-
-    protected void createRefreshObjectToManyDataSet() throws Exception {
-        tArtist.insert(33001, "c");
-        tPainting.insert(33001, "P1", 33001, 3000);
-        tPainting.insert(33002, "P2", 33001, 4000);
-    }
-
-    protected void createRefreshObjectToManyUpdateDataSet() throws Exception {
-        tPainting.delete().where("PAINTING_ID", 33001).execute();
-    }
-
-    public void testRefreshCollection() throws Exception {
-        createRefreshCollectionDataSet();
-
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
-        List<?> artists = context.performQuery(q);
-
-        Artist a1 = (Artist) artists.get(0);
-        Artist a2 = (Artist) artists.get(1);
-
-        assertEquals(2, a1.getPaintingArray().size());
-        assertEquals(0, a2.getPaintingArray().size());
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a1.getObjectId()));
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a2.getObjectId()));
-
-        RefreshQuery refresh = new RefreshQuery(artists);
-        context.performQuery(refresh);
-
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a1.getObjectId()));
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a2.getObjectId()));
-
-        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
-        assertEquals(PersistenceState.HOLLOW, a2.getPersistenceState());
-
-        assertTrue(((ValueHolder) a1.readProperty(Artist.PAINTING_ARRAY_PROPERTY))
-                .isFault());
-        assertTrue(((ValueHolder) a2.readProperty(Artist.PAINTING_ARRAY_PROPERTY))
-                .isFault());
-    }
-
-    public void testRefreshCollectionToOne() throws Exception {
-        createRefreshCollectionDataSet();
-
-        SelectQuery q = new SelectQuery(Painting.class);
-        q.addOrdering("db:PAINTING_ID", SortOrder.ASCENDING);
-        List<?> paints = context.performQuery(q);
-
-        Painting p1 = (Painting) paints.get(0);
-        Painting p2 = (Painting) paints.get(1);
-
-        Artist a1 = p1.getToArtist();
-        assertSame(a1, p2.getToArtist());
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        createRefreshCollectionToOneUpdateDataSet();
-
-        RefreshQuery refresh = new RefreshQuery(paints);
-        context.performQuery(refresh);
-
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        assertEquals(PersistenceState.HOLLOW, p1.getPersistenceState());
-        assertEquals(PersistenceState.HOLLOW, p2.getPersistenceState());
-
-        assertNotSame(a1, p1.getToArtist());
-        assertNotSame(a1, p2.getToArtist());
-        assertEquals("b", p1.getToArtist().getArtistName());
-    }
-
-    public void testRefreshSingleObject() throws Exception {
-        createRefreshCollectionDataSet();
-
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
-        List<?> artists = context.performQuery(q);
-
-        Artist a1 = (Artist) artists.get(0);
-
-        assertEquals(2, a1.getPaintingArray().size());
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a1.getObjectId()));
-
-        RefreshQuery refresh = new RefreshQuery(a1);
-        context.performQuery(refresh);
-
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a1.getObjectId()));
-
-        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
-
-        assertTrue(((ValueHolder) a1.readProperty(Artist.PAINTING_ARRAY_PROPERTY))
-                .isFault());
-    }
-
-    public void testRefreshObjectToMany() throws Exception {
-        createRefreshObjectToManyDataSet();
-
-        Artist a = Cayenne.objectForPK(context, Artist.class, 33001l);
-        assertEquals(2, a.getPaintingArray().size());
-
-        createRefreshObjectToManyUpdateDataSet();
-
-        RefreshQuery refresh = new RefreshQuery(a);
-        context.performQuery(refresh);
-        assertEquals(PersistenceState.HOLLOW, a.getPersistenceState());
-        assertEquals(1, a.getPaintingArray().size());
-    }
-
-    public void testRefreshQueryResultsLocalCache() throws Exception {
-        createRefreshCollectionDataSet();
-
-        Expression qual = ExpressionFactory.matchExp(
-                Painting.PAINTING_TITLE_PROPERTY,
-                "P2");
-        SelectQuery q = new SelectQuery(Painting.class, qual);
-        q.addOrdering("db:PAINTING_ID", SortOrder.ASCENDING);
-        q.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
-        q.setCacheGroups("X");
-        List<?> paints = context.performQuery(q);
-
-        // fetch P1 separately from cached query
-        Painting p1 = Cayenne.objectForPK(context, Painting.class, 33001);
-
-        Painting p2 = (Painting) paints.get(0);
-        Artist a1 = p2.getToArtist();
-        assertSame(a1, p1.getToArtist());
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        createRefreshCollectionToOneUpdateDataSet();
-
-        RefreshQuery refresh = new RefreshQuery(q);
-        context.performQuery(refresh);
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-
-        // probably refreshed eagerly
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
-        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());
-
-        assertSame(a1, p1.getToArtist());
-        assertNotSame(a1, p2.getToArtist());
-        assertEquals("c", p1.getToArtist().getArtistName());
-        assertEquals("b", p2.getToArtist().getArtistName());
-    }
-
-    public void testRefreshQueryResultsSharedCache() throws Exception {
-        createRefreshCollectionDataSet();
-
-        Expression qual = ExpressionFactory.matchExp(
-                Painting.PAINTING_TITLE_PROPERTY,
-                "P2");
-        SelectQuery q = new SelectQuery(Painting.class, qual);
-        q.addOrdering("db:PAINTING_ID", SortOrder.ASCENDING);
-        q.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
-        q.setCacheGroups("X");
-        List<?> paints = context.performQuery(q);
-
-        // fetch P1 separately from cached query
-        Painting p1 = Cayenne.objectForPK(context, Painting.class, 33001);
-
-        Painting p2 = (Painting) paints.get(0);
-        Artist a1 = p2.getToArtist();
-        assertSame(a1, p1.getToArtist());
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        createRefreshCollectionToOneUpdateDataSet();
-
-        RefreshQuery refresh = new RefreshQuery(q);
-        context.performQuery(refresh);
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-
-        // probably refreshed eagerly
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
-        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());
-
-        assertSame(a1, p1.getToArtist());
-        assertNotSame(a1, p2.getToArtist());
-        assertEquals("c", p1.getToArtist().getArtistName());
-        assertEquals("b", p2.getToArtist().getArtistName());
-    }
-
-    public void testRefreshQueryResultGroupLocal() throws Exception {
-        createRefreshCollectionDataSet();
-
-        Expression qual = ExpressionFactory.matchExp(
-                Painting.PAINTING_TITLE_PROPERTY,
-                "P2");
-        SelectQuery q = new SelectQuery(Painting.class, qual);
-        q.addOrdering("db:PAINTING_ID", SortOrder.ASCENDING);
-        q.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
-        q.setCacheGroups("X");
-        List<?> paints = context.performQuery(q);
-
-        // fetch P1 separately from cached query
-        Painting p1 = Cayenne.objectForPK(context, Painting.class, 33001);
-
-        Painting p2 = (Painting) paints.get(0);
-        Artist a1 = p2.getToArtist();
-        assertSame(a1, p1.getToArtist());
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        createRefreshCollectionToOneUpdateDataSet();
-
-        // results are served from cache and therefore are not refreshed
-        context.performQuery(q);
-        assertSame(a1, p1.getToArtist());
-        assertSame(a1, p2.getToArtist());
-        assertEquals("c", p1.getToArtist().getArtistName());
-        assertEquals("c", p2.getToArtist().getArtistName());
-
-        RefreshQuery refresh = new RefreshQuery("X");
-
-        // this should invalidate results for the next query run
-        context.performQuery(refresh);
-
-        // this should force a refresh
-        context.performQuery(q);
-
-        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
-        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());
-
-        assertSame(a1, p1.getToArtist());
-        assertNotSame(a1, p2.getToArtist());
-        assertEquals("c", p1.getToArtist().getArtistName());
-        assertEquals("b", p2.getToArtist().getArtistName());
-    }
-
-    public void testRefreshAll() throws Exception {
-        createRefreshCollectionDataSet();
-
-        SelectQuery q = new SelectQuery(Artist.class);
-        q.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
-        List<?> artists = context.performQuery(q);
-
-        Artist a1 = (Artist) artists.get(0);
-        Artist a2 = (Artist) artists.get(1);
-        Painting p1 = a1.getPaintingArray().get(0);
-        Painting p2 = a1.getPaintingArray().get(0);
-
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a1.getObjectId()));
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a2.getObjectId()));
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-        assertNotNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        RefreshQuery refresh = new RefreshQuery();
-        context.performQuery(refresh);
-
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a1.getObjectId()));
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(a2.getObjectId()));
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p1.getObjectId()));
-        assertNull(context
-                .getParentDataDomain()
-                .getSharedSnapshotCache()
-                .getCachedSnapshot(p2.getObjectId()));
-
-        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
-        assertEquals(PersistenceState.HOLLOW, a2.getPersistenceState());
-        assertEquals(PersistenceState.HOLLOW, p1.getPersistenceState());
-        assertEquals(PersistenceState.HOLLOW, p2.getPersistenceState());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshingIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshingIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshingIT.java
new file mode 100644
index 0000000..91fb0ef
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshingIT.java
@@ -0,0 +1,371 @@
+/*****************************************************************
+ *   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.PersistenceState;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SelectQuery;
+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;
+
+import java.sql.Types;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Test suite covering possible scenarios of refreshing updated objects. This includes
+ * refreshing relationships and attributes changed outside of Cayenne with and without
+ * prefetching.
+ */
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextRefreshingIT extends ServerCase {
+
+    @Inject
+    protected DataContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    @Inject
+    protected DataChannelInterceptor queryInterceptor;
+
+    protected TableHelper tArtist;
+    protected 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);
+    }
+
+    protected void createSingleArtistDataSet() throws Exception {
+        tArtist.insert(5, "artist2");
+    }
+
+    protected void createSingleArtistAndPaintingDataSet() throws Exception {
+        createSingleArtistDataSet();
+        tPainting.insert(4, "p", 5, 1000);
+    }
+
+    protected void createSingleArtistAndUnrelatedPaintingDataSet() throws Exception {
+        createSingleArtistDataSet();
+        tPainting.insert(4, "p", null, 1000);
+    }
+
+    protected void createTwoArtistsAndPaintingDataSet() throws Exception {
+        tArtist.insert(5, "artist2");
+        tArtist.insert(6, "artist3");
+        tPainting.insert(4, "p", 5, 1000);
+    }
+
+    public void testRefetchRootWithUpdatedAttributes() throws Exception {
+
+        createSingleArtistDataSet();
+
+        String nameBefore = "artist2";
+        String nameAfter = "not an artist";
+
+        SelectQuery queryBefore = new SelectQuery(
+                Artist.class,
+                ExpressionFactory.matchExp("artistName", nameBefore));
+
+        Artist artist = (Artist) context.performQuery(queryBefore).get(0);
+        assertEquals(nameBefore, artist.getArtistName());
+
+        assertEquals(1, tArtist.update().set("ARTIST_NAME", nameAfter).execute());
+
+        // fetch into the same context
+        List<Artist> artists = context.performQuery(queryBefore);
+        assertEquals(0, artists.size());
+
+        SelectQuery queryAfter = new SelectQuery(
+                Artist.class,
+                ExpressionFactory.matchExp("artistName", nameAfter));
+
+        artist = (Artist) context.performQuery(queryAfter).get(0);
+        assertNotNull(artist);
+        assertEquals(nameAfter, artist.getArtistName());
+    }
+
+    public void testRefetchRootWithNullifiedToOne() throws Exception {
+        createSingleArtistAndPaintingDataSet();
+
+        Painting painting = (Painting) context.performQuery(
+                new SelectQuery(Painting.class)).get(0);
+
+        assertNotNull(painting.getToArtist());
+        assertEquals("artist2", painting.getToArtist().getArtistName());
+
+        assertEquals(1, tPainting.update().set("ARTIST_ID", null, Types.BIGINT).execute());
+
+        // select without prefetch
+        painting = (Painting) context
+                .performQuery(new SelectQuery(Painting.class))
+                .get(0);
+        assertNotNull(painting);
+        assertNull(painting.getToArtist());
+    }
+
+    public void testRefetchRootWithChangedToOneTarget() throws Exception {
+        createTwoArtistsAndPaintingDataSet();
+
+        Painting painting = (Painting) context.performQuery(
+                new SelectQuery(Painting.class)).get(0);
+
+        Artist artistBefore = painting.getToArtist();
+        assertNotNull(artistBefore);
+        assertEquals("artist2", artistBefore.getArtistName());
+
+        assertEquals(1, tPainting.update().set("ARTIST_ID", 6).execute());
+
+        // select without prefetch
+        painting = (Painting) context
+                .performQuery(new SelectQuery(Painting.class))
+                .get(0);
+        assertNotNull(painting);
+        assertEquals("artist3", painting.getToArtist().getArtistName());
+    }
+
+    public void testRefetchRootWithNullToOneTargetChangedToNotNull() throws Exception {
+        createSingleArtistAndUnrelatedPaintingDataSet();
+
+        Painting painting = (Painting) context.performQuery(
+                new SelectQuery(Painting.class)).get(0);
+
+        assertNull(painting.getToArtist());
+
+        assertEquals(1, tPainting.update().set("ARTIST_ID", 5).execute());
+
+        // select without prefetch
+        painting = (Painting) context
+                .performQuery(new SelectQuery(Painting.class))
+                .get(0);
+        assertNotNull(painting);
+        assertEquals("artist2", painting.getToArtist().getArtistName());
+    }
+
+    public void testRefetchRootWithDeletedToMany() throws Exception {
+        createSingleArtistAndPaintingDataSet();
+
+        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
+                0);
+        assertEquals(artist.getPaintingArray().size(), 1);
+
+        assertEquals(1, tPainting
+                .delete()
+                .where(Painting.PAINTING_ID_PK_COLUMN, 4)
+                .execute());
+
+        // select without prefetch
+        artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(0);
+        assertEquals(artist.getPaintingArray().size(), 1);
+
+        // select using relationship prefetching
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);
+        artist = (Artist) context.performQuery(query).get(0);
+        assertEquals(0, artist.getPaintingArray().size());
+    }
+
+    public void testRefetchRootWithAddedToMany() throws Exception {
+
+        createSingleArtistDataSet();
+
+        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
+                0);
+        assertEquals(artist.getPaintingArray().size(), 0);
+
+        tPainting.insert(5, "p", 5, 1000);
+
+        // select without prefetch
+        SelectQuery query = new SelectQuery(Artist.class);
+        artist = (Artist) context.performQuery(query).get(0);
+        assertEquals(artist.getPaintingArray().size(), 0);
+
+        // select using relationship prefetching
+        query.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);
+        artist = (Artist) context.performQuery(query).get(0);
+        assertEquals(artist.getPaintingArray().size(), 1);
+    }
+
+    public void testInvalidateRootWithUpdatedAttributes() throws Exception {
+        createSingleArtistDataSet();
+
+        String nameBefore = "artist2";
+        String nameAfter = "not an artist";
+
+        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
+                0);
+        assertNotNull(artist);
+        assertEquals(nameBefore, artist.getArtistName());
+
+        // update via DataNode directly
+        assertEquals(1, tArtist.update().set("ARTIST_NAME", nameAfter).execute());
+
+        context.invalidateObjects(artist);
+        assertEquals(nameAfter, artist.getArtistName());
+    }
+
+    public void testInvalidateRootWithNullifiedToOne() throws Exception {
+
+        createSingleArtistAndPaintingDataSet();
+
+        Painting painting = (Painting) context.performQuery(
+                new SelectQuery(Painting.class)).get(0);
+
+        assertNotNull(painting.getToArtist());
+        assertEquals("artist2", painting.getToArtist().getArtistName());
+
+        assertEquals(1, tPainting.update().set("ARTIST_ID", null, Types.BIGINT).execute());
+
+        context.invalidateObjects(painting);
+        assertNull(painting.getToArtist());
+    }
+
+    public void testInvalidateRootWithChangedToOneTarget() throws Exception {
+        createTwoArtistsAndPaintingDataSet();
+
+        Painting painting = (Painting) context.performQuery(
+                new SelectQuery(Painting.class)).get(0);
+        Artist artistBefore = painting.getToArtist();
+        assertNotNull(artistBefore);
+        assertEquals("artist2", artistBefore.getArtistName());
+
+        assertEquals(1, tPainting.update().set("ARTIST_ID", 6).execute());
+
+        context.invalidateObjects(painting);
+        assertNotSame(artistBefore, painting.getToArtist());
+        assertEquals("artist3", painting.getToArtist().getArtistName());
+    }
+
+    public void testInvalidateRootWithNullToOneTargetChangedToNotNull() throws Exception {
+        createSingleArtistAndUnrelatedPaintingDataSet();
+
+        Painting painting = (Painting) context.performQuery(
+                new SelectQuery(Painting.class)).get(0);
+        assertNull(painting.getToArtist());
+
+        assertEquals(1, tPainting.update().set("ARTIST_ID", 5).execute());
+
+        context.invalidateObjects(painting);
+        assertNotNull(painting.getToArtist());
+        assertEquals("artist2", painting.getToArtist().getArtistName());
+    }
+
+    public void testInvalidateRootWithDeletedToMany() throws Exception {
+        createSingleArtistAndPaintingDataSet();
+
+        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
+                0);
+        assertEquals(artist.getPaintingArray().size(), 1);
+
+        assertEquals(1, tPainting.delete().execute());
+
+        context.invalidateObjects(artist);
+        assertEquals(artist.getPaintingArray().size(), 0);
+    }
+
+    public void testInvaliateRootWithAddedToMany() throws Exception {
+
+        createSingleArtistDataSet();
+
+        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
+                0);
+        assertEquals(artist.getPaintingArray().size(), 0);
+
+        tPainting.insert(4, "p", 5, 1000);
+
+        assertEquals(artist.getPaintingArray().size(), 0);
+        context.invalidateObjects(artist);
+        assertEquals(artist.getPaintingArray().size(), 1);
+    }
+
+    public void testInvalidateThenModify() throws Exception {
+
+        createSingleArtistDataSet();
+
+        final Artist artist = (Artist) context
+                .performQuery(new SelectQuery(Artist.class))
+                .get(0);
+        assertNotNull(artist);
+
+        context.invalidateObjects(artist);
+        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
+
+        int queries = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                // this must trigger a fetch
+                artist.setArtistName("new name");
+            }
+        });
+
+        assertEquals(1, queries);
+        assertEquals(PersistenceState.MODIFIED, artist.getPersistenceState());
+    }
+
+    public void testModifyHollow() throws Exception {
+
+        createSingleArtistAndPaintingDataSet();
+
+        Painting painting = (Painting) context.performQuery(
+                new SelectQuery(Painting.class)).get(0);
+        final Artist artist = painting.getToArtist();
+        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
+        assertNull(artist.readPropertyDirectly("artistName"));
+
+        int queries = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                // this must trigger a fetch
+                artist.setDateOfBirth(new Date());
+            }
+        });
+
+        assertEquals(1, queries);
+
+        assertEquals(PersistenceState.MODIFIED, artist.getPersistenceState());
+        assertNotNull(artist.readPropertyDirectly("artistName"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshingTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshingTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshingTest.java
deleted file mode 100644
index 8e83be6..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRefreshingTest.java
+++ /dev/null
@@ -1,371 +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.List;
-
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.SelectQuery;
-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;
-
-/**
- * Test suite covering possible scenarios of refreshing updated objects. This includes
- * refreshing relationships and attributes changed outside of Cayenne with and without
- * prefetching.
- */
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextRefreshingTest extends ServerCase {
-
-    @Inject
-    protected DataContext context;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    @Inject
-    protected DataChannelInterceptor queryInterceptor;
-
-    protected TableHelper tArtist;
-    protected 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);
-    }
-
-    protected void createSingleArtistDataSet() throws Exception {
-        tArtist.insert(5, "artist2");
-    }
-
-    protected void createSingleArtistAndPaintingDataSet() throws Exception {
-        createSingleArtistDataSet();
-        tPainting.insert(4, "p", 5, 1000);
-    }
-
-    protected void createSingleArtistAndUnrelatedPaintingDataSet() throws Exception {
-        createSingleArtistDataSet();
-        tPainting.insert(4, "p", null, 1000);
-    }
-
-    protected void createTwoArtistsAndPaintingDataSet() throws Exception {
-        tArtist.insert(5, "artist2");
-        tArtist.insert(6, "artist3");
-        tPainting.insert(4, "p", 5, 1000);
-    }
-
-    public void testRefetchRootWithUpdatedAttributes() throws Exception {
-
-        createSingleArtistDataSet();
-
-        String nameBefore = "artist2";
-        String nameAfter = "not an artist";
-
-        SelectQuery queryBefore = new SelectQuery(
-                Artist.class,
-                ExpressionFactory.matchExp("artistName", nameBefore));
-
-        Artist artist = (Artist) context.performQuery(queryBefore).get(0);
-        assertEquals(nameBefore, artist.getArtistName());
-
-        assertEquals(1, tArtist.update().set("ARTIST_NAME", nameAfter).execute());
-
-        // fetch into the same context
-        List<Artist> artists = context.performQuery(queryBefore);
-        assertEquals(0, artists.size());
-
-        SelectQuery queryAfter = new SelectQuery(
-                Artist.class,
-                ExpressionFactory.matchExp("artistName", nameAfter));
-
-        artist = (Artist) context.performQuery(queryAfter).get(0);
-        assertNotNull(artist);
-        assertEquals(nameAfter, artist.getArtistName());
-    }
-
-    public void testRefetchRootWithNullifiedToOne() throws Exception {
-        createSingleArtistAndPaintingDataSet();
-
-        Painting painting = (Painting) context.performQuery(
-                new SelectQuery(Painting.class)).get(0);
-
-        assertNotNull(painting.getToArtist());
-        assertEquals("artist2", painting.getToArtist().getArtistName());
-
-        assertEquals(1, tPainting.update().set("ARTIST_ID", null, Types.BIGINT).execute());
-
-        // select without prefetch
-        painting = (Painting) context
-                .performQuery(new SelectQuery(Painting.class))
-                .get(0);
-        assertNotNull(painting);
-        assertNull(painting.getToArtist());
-    }
-
-    public void testRefetchRootWithChangedToOneTarget() throws Exception {
-        createTwoArtistsAndPaintingDataSet();
-
-        Painting painting = (Painting) context.performQuery(
-                new SelectQuery(Painting.class)).get(0);
-
-        Artist artistBefore = painting.getToArtist();
-        assertNotNull(artistBefore);
-        assertEquals("artist2", artistBefore.getArtistName());
-
-        assertEquals(1, tPainting.update().set("ARTIST_ID", 6).execute());
-
-        // select without prefetch
-        painting = (Painting) context
-                .performQuery(new SelectQuery(Painting.class))
-                .get(0);
-        assertNotNull(painting);
-        assertEquals("artist3", painting.getToArtist().getArtistName());
-    }
-
-    public void testRefetchRootWithNullToOneTargetChangedToNotNull() throws Exception {
-        createSingleArtistAndUnrelatedPaintingDataSet();
-
-        Painting painting = (Painting) context.performQuery(
-                new SelectQuery(Painting.class)).get(0);
-
-        assertNull(painting.getToArtist());
-
-        assertEquals(1, tPainting.update().set("ARTIST_ID", 5).execute());
-
-        // select without prefetch
-        painting = (Painting) context
-                .performQuery(new SelectQuery(Painting.class))
-                .get(0);
-        assertNotNull(painting);
-        assertEquals("artist2", painting.getToArtist().getArtistName());
-    }
-
-    public void testRefetchRootWithDeletedToMany() throws Exception {
-        createSingleArtistAndPaintingDataSet();
-
-        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
-                0);
-        assertEquals(artist.getPaintingArray().size(), 1);
-
-        assertEquals(1, tPainting
-                .delete()
-                .where(Painting.PAINTING_ID_PK_COLUMN, 4)
-                .execute());
-
-        // select without prefetch
-        artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(0);
-        assertEquals(artist.getPaintingArray().size(), 1);
-
-        // select using relationship prefetching
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);
-        artist = (Artist) context.performQuery(query).get(0);
-        assertEquals(0, artist.getPaintingArray().size());
-    }
-
-    public void testRefetchRootWithAddedToMany() throws Exception {
-
-        createSingleArtistDataSet();
-
-        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
-                0);
-        assertEquals(artist.getPaintingArray().size(), 0);
-
-        tPainting.insert(5, "p", 5, 1000);
-
-        // select without prefetch
-        SelectQuery query = new SelectQuery(Artist.class);
-        artist = (Artist) context.performQuery(query).get(0);
-        assertEquals(artist.getPaintingArray().size(), 0);
-
-        // select using relationship prefetching
-        query.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);
-        artist = (Artist) context.performQuery(query).get(0);
-        assertEquals(artist.getPaintingArray().size(), 1);
-    }
-
-    public void testInvalidateRootWithUpdatedAttributes() throws Exception {
-        createSingleArtistDataSet();
-
-        String nameBefore = "artist2";
-        String nameAfter = "not an artist";
-
-        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
-                0);
-        assertNotNull(artist);
-        assertEquals(nameBefore, artist.getArtistName());
-
-        // update via DataNode directly
-        assertEquals(1, tArtist.update().set("ARTIST_NAME", nameAfter).execute());
-
-        context.invalidateObjects(artist);
-        assertEquals(nameAfter, artist.getArtistName());
-    }
-
-    public void testInvalidateRootWithNullifiedToOne() throws Exception {
-
-        createSingleArtistAndPaintingDataSet();
-
-        Painting painting = (Painting) context.performQuery(
-                new SelectQuery(Painting.class)).get(0);
-
-        assertNotNull(painting.getToArtist());
-        assertEquals("artist2", painting.getToArtist().getArtistName());
-
-        assertEquals(1, tPainting.update().set("ARTIST_ID", null, Types.BIGINT).execute());
-
-        context.invalidateObjects(painting);
-        assertNull(painting.getToArtist());
-    }
-
-    public void testInvalidateRootWithChangedToOneTarget() throws Exception {
-        createTwoArtistsAndPaintingDataSet();
-
-        Painting painting = (Painting) context.performQuery(
-                new SelectQuery(Painting.class)).get(0);
-        Artist artistBefore = painting.getToArtist();
-        assertNotNull(artistBefore);
-        assertEquals("artist2", artistBefore.getArtistName());
-
-        assertEquals(1, tPainting.update().set("ARTIST_ID", 6).execute());
-
-        context.invalidateObjects(painting);
-        assertNotSame(artistBefore, painting.getToArtist());
-        assertEquals("artist3", painting.getToArtist().getArtistName());
-    }
-
-    public void testInvalidateRootWithNullToOneTargetChangedToNotNull() throws Exception {
-        createSingleArtistAndUnrelatedPaintingDataSet();
-
-        Painting painting = (Painting) context.performQuery(
-                new SelectQuery(Painting.class)).get(0);
-        assertNull(painting.getToArtist());
-
-        assertEquals(1, tPainting.update().set("ARTIST_ID", 5).execute());
-
-        context.invalidateObjects(painting);
-        assertNotNull(painting.getToArtist());
-        assertEquals("artist2", painting.getToArtist().getArtistName());
-    }
-
-    public void testInvalidateRootWithDeletedToMany() throws Exception {
-        createSingleArtistAndPaintingDataSet();
-
-        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
-                0);
-        assertEquals(artist.getPaintingArray().size(), 1);
-
-        assertEquals(1, tPainting.delete().execute());
-
-        context.invalidateObjects(artist);
-        assertEquals(artist.getPaintingArray().size(), 0);
-    }
-
-    public void testInvaliateRootWithAddedToMany() throws Exception {
-
-        createSingleArtistDataSet();
-
-        Artist artist = (Artist) context.performQuery(new SelectQuery(Artist.class)).get(
-                0);
-        assertEquals(artist.getPaintingArray().size(), 0);
-
-        tPainting.insert(4, "p", 5, 1000);
-
-        assertEquals(artist.getPaintingArray().size(), 0);
-        context.invalidateObjects(artist);
-        assertEquals(artist.getPaintingArray().size(), 1);
-    }
-
-    public void testInvalidateThenModify() throws Exception {
-
-        createSingleArtistDataSet();
-
-        final Artist artist = (Artist) context
-                .performQuery(new SelectQuery(Artist.class))
-                .get(0);
-        assertNotNull(artist);
-
-        context.invalidateObjects(artist);
-        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
-
-        int queries = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
-
-            public void execute() {
-                // this must trigger a fetch
-                artist.setArtistName("new name");
-            }
-        });
-
-        assertEquals(1, queries);
-        assertEquals(PersistenceState.MODIFIED, artist.getPersistenceState());
-    }
-
-    public void testModifyHollow() throws Exception {
-
-        createSingleArtistAndPaintingDataSet();
-
-        Painting painting = (Painting) context.performQuery(
-                new SelectQuery(Painting.class)).get(0);
-        final Artist artist = painting.getToArtist();
-        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
-        assertNull(artist.readPropertyDirectly("artistName"));
-
-        int queries = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
-
-            public void execute() {
-                // this must trigger a fetch
-                artist.setDateOfBirth(new Date());
-            }
-        });
-
-        assertEquals(1, queries);
-
-        assertEquals(PersistenceState.MODIFIED, artist.getPersistenceState());
-        assertNotNull(artist.readPropertyDirectly("artistName"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRelationshipQueryIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRelationshipQueryIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRelationshipQueryIT.java
new file mode 100644
index 0000000..bb38882
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRelationshipQueryIT.java
@@ -0,0 +1,137 @@
+/*****************************************************************
+ *   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.Cayenne;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.RelationshipQuery;
+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.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextRelationshipQueryIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @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("PAINTING1");
+        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");
+    }
+
+    private void createOneArtistOnePaintingDataSet() throws Exception {
+
+        tArtist.insert(1, "a1");
+        tPainting.insert(1, "p1", 1);
+    }
+
+    public void testUnrefreshingToOne() throws Exception {
+
+        createOneArtistOnePaintingDataSet();
+
+        Painting p = Cayenne.objectForPK(context, Painting.class, 1);
+
+        // resolve artist once before running non-refreshing query, to check that we do
+        // not refresh the object
+
+        Artist a = Cayenne.objectForPK(context, Artist.class, 1);
+        long v = a.getSnapshotVersion();
+        int writeCalls = a.getPropertyWrittenDirectly();
+        assertEquals("a1", a.getArtistName());
+
+        assertEquals(1, tArtist
+                .update()
+                .set("ARTIST_NAME", "a2")
+                .where("ARTIST_ID", 1)
+                .execute());
+
+        RelationshipQuery toOne = new RelationshipQuery(
+                p.getObjectId(),
+                Painting.TO_ARTIST_PROPERTY,
+                false);
+
+        List<Artist> related = context.performQuery(toOne);
+        assertEquals(1, related.size());
+        assertTrue(related.contains(a));
+        assertEquals("a1", a.getArtistName());
+        assertEquals(v, a.getSnapshotVersion());
+        assertEquals(
+                "Looks like relationship query caused snapshot refresh",
+                writeCalls,
+                a.getPropertyWrittenDirectly());
+    }
+
+    public void testRefreshingToOne() throws Exception {
+
+        createOneArtistOnePaintingDataSet();
+
+        Painting p = Cayenne.objectForPK(context, Painting.class, 1);
+
+        // resolve artist once before running non-refreshing query, to check that we do
+        // not refresh the object
+
+        Artist a = Cayenne.objectForPK(context, Artist.class, 1);
+        long v = a.getSnapshotVersion();
+        int writeCalls = a.getPropertyWrittenDirectly();
+        assertEquals("a1", a.getArtistName());
+
+        assertEquals(1, tArtist
+                .update()
+                .set("ARTIST_NAME", "a2")
+                .where("ARTIST_ID", 1)
+                .execute());
+
+        RelationshipQuery toOne = new RelationshipQuery(
+                p.getObjectId(),
+                Painting.TO_ARTIST_PROPERTY,
+                true);
+
+        List<Artist> related = context.performQuery(toOne);
+        assertEquals(1, related.size());
+        assertTrue(related.contains(a));
+        assertEquals("a2", a.getArtistName());
+        assertTrue("Looks like relationship query didn't cause a snapshot refresh", v < a
+                .getSnapshotVersion());
+        assertTrue(
+                "Looks like relationship query didn't cause a snapshot refresh",
+                writeCalls < a.getPropertyWrittenDirectly());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRelationshipQueryTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRelationshipQueryTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRelationshipQueryTest.java
deleted file mode 100644
index 55309b3..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRelationshipQueryTest.java
+++ /dev/null
@@ -1,137 +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.util.List;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.RelationshipQuery;
-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.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextRelationshipQueryTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @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("PAINTING1");
-        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");
-    }
-
-    private void createOneArtistOnePaintingDataSet() throws Exception {
-
-        tArtist.insert(1, "a1");
-        tPainting.insert(1, "p1", 1);
-    }
-
-    public void testUnrefreshingToOne() throws Exception {
-
-        createOneArtistOnePaintingDataSet();
-
-        Painting p = Cayenne.objectForPK(context, Painting.class, 1);
-
-        // resolve artist once before running non-refreshing query, to check that we do
-        // not refresh the object
-
-        Artist a = Cayenne.objectForPK(context, Artist.class, 1);
-        long v = a.getSnapshotVersion();
-        int writeCalls = a.getPropertyWrittenDirectly();
-        assertEquals("a1", a.getArtistName());
-
-        assertEquals(1, tArtist
-                .update()
-                .set("ARTIST_NAME", "a2")
-                .where("ARTIST_ID", 1)
-                .execute());
-
-        RelationshipQuery toOne = new RelationshipQuery(
-                p.getObjectId(),
-                Painting.TO_ARTIST_PROPERTY,
-                false);
-
-        List<Artist> related = context.performQuery(toOne);
-        assertEquals(1, related.size());
-        assertTrue(related.contains(a));
-        assertEquals("a1", a.getArtistName());
-        assertEquals(v, a.getSnapshotVersion());
-        assertEquals(
-                "Looks like relationship query caused snapshot refresh",
-                writeCalls,
-                a.getPropertyWrittenDirectly());
-    }
-
-    public void testRefreshingToOne() throws Exception {
-
-        createOneArtistOnePaintingDataSet();
-
-        Painting p = Cayenne.objectForPK(context, Painting.class, 1);
-
-        // resolve artist once before running non-refreshing query, to check that we do
-        // not refresh the object
-
-        Artist a = Cayenne.objectForPK(context, Artist.class, 1);
-        long v = a.getSnapshotVersion();
-        int writeCalls = a.getPropertyWrittenDirectly();
-        assertEquals("a1", a.getArtistName());
-
-        assertEquals(1, tArtist
-                .update()
-                .set("ARTIST_NAME", "a2")
-                .where("ARTIST_ID", 1)
-                .execute());
-
-        RelationshipQuery toOne = new RelationshipQuery(
-                p.getObjectId(),
-                Painting.TO_ARTIST_PROPERTY,
-                true);
-
-        List<Artist> related = context.performQuery(toOne);
-        assertEquals(1, related.size());
-        assertTrue(related.contains(a));
-        assertEquals("a2", a.getArtistName());
-        assertTrue("Looks like relationship query didn't cause a snapshot refresh", v < a
-                .getSnapshotVersion());
-        assertTrue(
-                "Looks like relationship query didn't cause a snapshot refresh",
-                writeCalls < a.getPropertyWrittenDirectly());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRollbackIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRollbackIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRollbackIT.java
new file mode 100644
index 0000000..8b512f5
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRollbackIT.java
@@ -0,0 +1,224 @@
+/*****************************************************************
+ *   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.util.List;
+
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.ValueHolder;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+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 DataContextRollbackIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private ServerRuntime serverRuntime;
+
+    @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 testRollbackNew() {
+        Artist artist = (Artist) context.newObject("Artist");
+        artist.setArtistName("a");
+
+        Painting p1 = (Painting) context.newObject("Painting");
+        p1.setPaintingTitle("p1");
+        p1.setToArtist(artist);
+
+        Painting p2 = (Painting) context.newObject("Painting");
+        p2.setPaintingTitle("p2");
+        p2.setToArtist(artist);
+
+        Painting p3 = (Painting) context.newObject("Painting");
+        p3.setPaintingTitle("p3");
+        p3.setToArtist(artist);
+
+        // before:
+        assertEquals(artist, p1.getToArtist());
+        assertEquals(3, artist.getPaintingArray().size());
+
+        context.rollbackChanges();
+
+        // after:
+        assertEquals(PersistenceState.TRANSIENT, artist.getPersistenceState());
+    }
+
+    public void testRollbackNewObject() {
+        String artistName = "revertTestArtist";
+        Artist artist = (Artist) context.newObject("Artist");
+        artist.setArtistName(artistName);
+
+        context.rollbackChanges();
+
+        assertEquals(PersistenceState.TRANSIENT, artist.getPersistenceState());
+        context.commitChanges();
+        // The commit should have made no changes, so
+        // perform a fetch to ensure that this artist hasn't been persisted to the db
+
+        DataContext freshContext = (DataContext) serverRuntime.newContext();
+        assertNotSame(this.context, freshContext);
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.setQualifier(ExpressionFactory.matchExp("artistName", artistName));
+        List<?> queryResults = freshContext.performQuery(query);
+
+        assertEquals(0, queryResults.size());
+    }
+
+    // Catches a bug where new objects were unregistered within an object iterator, thus
+    // modifying the collection the iterator was iterating over
+    // (ConcurrentModificationException)
+    public void testRollbackWithMultipleNewObjects() {
+        String artistName = "rollbackTestArtist";
+        String paintingTitle = "rollbackTestPainting";
+        Artist artist = (Artist) context.newObject("Artist");
+        artist.setArtistName(artistName);
+
+        Painting painting = (Painting) context.newObject("Painting");
+        painting.setPaintingTitle(paintingTitle);
+        painting.setToArtist(artist);
+
+        context.rollbackChanges();
+
+        assertEquals(PersistenceState.TRANSIENT, artist.getPersistenceState());
+        context.commitChanges();
+
+        // The commit should have made no changes, so
+        // perform a fetch to ensure that this artist hasn't been persisted to the db
+
+        DataContext freshContext = (DataContext) serverRuntime.newContext();
+        assertNotSame(this.context, freshContext);
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.setQualifier(ExpressionFactory.matchExp("artistName", artistName));
+        List<?> queryResults = freshContext.performQuery(query);
+
+        assertEquals(0, queryResults.size());
+    }
+
+    public void testRollbackRelationshipModification() {
+        String artistName = "relationshipModArtist";
+        String paintingTitle = "relationshipTestPainting";
+        Artist artist = (Artist) context.newObject("Artist");
+        artist.setArtistName(artistName);
+        Painting painting = (Painting) context.newObject("Painting");
+        painting.setPaintingTitle(paintingTitle);
+        painting.setToArtist(artist);
+        context.commitChanges();
+
+        painting.setToArtist(null);
+        assertEquals(0, artist.getPaintingArray().size());
+        context.rollbackChanges();
+
+        assertTrue(((ValueHolder) artist.getPaintingArray()).isFault());
+        assertEquals(1, artist.getPaintingArray().size());
+        assertEquals(artist, painting.getToArtist());
+
+        // Check that the reverse relationship was handled
+        assertEquals(1, artist.getPaintingArray().size());
+        context.commitChanges();
+
+        DataContext freshContext = (DataContext) serverRuntime.newContext();
+        assertNotSame(this.context, freshContext);
+
+        SelectQuery query = new SelectQuery(Painting.class);
+        query.setQualifier(ExpressionFactory.matchExp("paintingTitle", paintingTitle));
+        List<?> queryResults = freshContext.performQuery(query);
+
+        assertEquals(1, queryResults.size());
+        Painting queriedPainting = (Painting) queryResults.get(0);
+
+        // NB: This is an easier comparison than manually fetching artist
+        assertEquals(artistName, queriedPainting.getToArtist().getArtistName());
+    }
+
+    public void testRollbackDeletedObject() {
+        String artistName = "deleteTestArtist";
+        Artist artist = (Artist) context.newObject("Artist");
+        artist.setArtistName(artistName);
+        context.commitChanges();
+       
+        context.deleteObjects(artist);
+        context.rollbackChanges();
+
+        // Now check everything is as it should be
+        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
+
+        context.commitChanges();
+        // The commit should have made no changes, so
+        // perform a fetch to ensure that this artist hasn't been deleted from the db
+
+        DataContext freshContext = (DataContext) serverRuntime.newContext();
+        assertNotSame(this.context, freshContext);
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.setQualifier(ExpressionFactory.matchExp("artistName", artistName));
+        List<?> queryResults = freshContext.performQuery(query);
+
+        assertEquals(1, queryResults.size());
+    }
+
+    public void testRollbackModifiedObject() {
+        String artistName = "initialTestArtist";
+        Artist artist = (Artist) context.newObject("Artist");
+        artist.setArtistName(artistName);
+        context.commitChanges();
+
+        artist.setArtistName("a new value");
+
+        context.rollbackChanges();
+
+        // Make sure the inmemory changes have been rolled back
+        assertEquals(artistName, artist.getArtistName());
+
+        // Commit what's in memory...
+        context.commitChanges();
+
+        // .. and ensure that the correct data is in the db
+        DataContext freshContext = (DataContext) serverRuntime.newContext();
+        assertNotSame(this.context, freshContext);
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.setQualifier(ExpressionFactory.matchExp("artistName", artistName));
+        List<?> queryResults = freshContext.performQuery(query);
+
+        assertEquals(1, queryResults.size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRollbackTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRollbackTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRollbackTest.java
deleted file mode 100644
index 1c56eec..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextRollbackTest.java
+++ /dev/null
@@ -1,224 +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.util.List;
-
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.ValueHolder;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-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 DataContextRollbackTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private ServerRuntime serverRuntime;
-
-    @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 testRollbackNew() {
-        Artist artist = (Artist) context.newObject("Artist");
-        artist.setArtistName("a");
-
-        Painting p1 = (Painting) context.newObject("Painting");
-        p1.setPaintingTitle("p1");
-        p1.setToArtist(artist);
-
-        Painting p2 = (Painting) context.newObject("Painting");
-        p2.setPaintingTitle("p2");
-        p2.setToArtist(artist);
-
-        Painting p3 = (Painting) context.newObject("Painting");
-        p3.setPaintingTitle("p3");
-        p3.setToArtist(artist);
-
-        // before:
-        assertEquals(artist, p1.getToArtist());
-        assertEquals(3, artist.getPaintingArray().size());
-
-        context.rollbackChanges();
-
-        // after:
-        assertEquals(PersistenceState.TRANSIENT, artist.getPersistenceState());
-    }
-
-    public void testRollbackNewObject() {
-        String artistName = "revertTestArtist";
-        Artist artist = (Artist) context.newObject("Artist");
-        artist.setArtistName(artistName);
-
-        context.rollbackChanges();
-
-        assertEquals(PersistenceState.TRANSIENT, artist.getPersistenceState());
-        context.commitChanges();
-        // The commit should have made no changes, so
-        // perform a fetch to ensure that this artist hasn't been persisted to the db
-
-        DataContext freshContext = (DataContext) serverRuntime.newContext();
-        assertNotSame(this.context, freshContext);
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.setQualifier(ExpressionFactory.matchExp("artistName", artistName));
-        List<?> queryResults = freshContext.performQuery(query);
-
-        assertEquals(0, queryResults.size());
-    }
-
-    // Catches a bug where new objects were unregistered within an object iterator, thus
-    // modifying the collection the iterator was iterating over
-    // (ConcurrentModificationException)
-    public void testRollbackWithMultipleNewObjects() {
-        String artistName = "rollbackTestArtist";
-        String paintingTitle = "rollbackTestPainting";
-        Artist artist = (Artist) context.newObject("Artist");
-        artist.setArtistName(artistName);
-
-        Painting painting = (Painting) context.newObject("Painting");
-        painting.setPaintingTitle(paintingTitle);
-        painting.setToArtist(artist);
-
-        context.rollbackChanges();
-
-        assertEquals(PersistenceState.TRANSIENT, artist.getPersistenceState());
-        context.commitChanges();
-
-        // The commit should have made no changes, so
-        // perform a fetch to ensure that this artist hasn't been persisted to the db
-
-        DataContext freshContext = (DataContext) serverRuntime.newContext();
-        assertNotSame(this.context, freshContext);
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.setQualifier(ExpressionFactory.matchExp("artistName", artistName));
-        List<?> queryResults = freshContext.performQuery(query);
-
-        assertEquals(0, queryResults.size());
-    }
-
-    public void testRollbackRelationshipModification() {
-        String artistName = "relationshipModArtist";
-        String paintingTitle = "relationshipTestPainting";
-        Artist artist = (Artist) context.newObject("Artist");
-        artist.setArtistName(artistName);
-        Painting painting = (Painting) context.newObject("Painting");
-        painting.setPaintingTitle(paintingTitle);
-        painting.setToArtist(artist);
-        context.commitChanges();
-
-        painting.setToArtist(null);
-        assertEquals(0, artist.getPaintingArray().size());
-        context.rollbackChanges();
-
-        assertTrue(((ValueHolder) artist.getPaintingArray()).isFault());
-        assertEquals(1, artist.getPaintingArray().size());
-        assertEquals(artist, painting.getToArtist());
-
-        // Check that the reverse relationship was handled
-        assertEquals(1, artist.getPaintingArray().size());
-        context.commitChanges();
-
-        DataContext freshContext = (DataContext) serverRuntime.newContext();
-        assertNotSame(this.context, freshContext);
-
-        SelectQuery query = new SelectQuery(Painting.class);
-        query.setQualifier(ExpressionFactory.matchExp("paintingTitle", paintingTitle));
-        List<?> queryResults = freshContext.performQuery(query);
-
-        assertEquals(1, queryResults.size());
-        Painting queriedPainting = (Painting) queryResults.get(0);
-
-        // NB: This is an easier comparison than manually fetching artist
-        assertEquals(artistName, queriedPainting.getToArtist().getArtistName());
-    }
-
-    public void testRollbackDeletedObject() {
-        String artistName = "deleteTestArtist";
-        Artist artist = (Artist) context.newObject("Artist");
-        artist.setArtistName(artistName);
-        context.commitChanges();
-       
-        context.deleteObjects(artist);
-        context.rollbackChanges();
-
-        // Now check everything is as it should be
-        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
-
-        context.commitChanges();
-        // The commit should have made no changes, so
-        // perform a fetch to ensure that this artist hasn't been deleted from the db
-
-        DataContext freshContext = (DataContext) serverRuntime.newContext();
-        assertNotSame(this.context, freshContext);
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.setQualifier(ExpressionFactory.matchExp("artistName", artistName));
-        List<?> queryResults = freshContext.performQuery(query);
-
-        assertEquals(1, queryResults.size());
-    }
-
-    public void testRollbackModifiedObject() {
-        String artistName = "initialTestArtist";
-        Artist artist = (Artist) context.newObject("Artist");
-        artist.setArtistName(artistName);
-        context.commitChanges();
-
-        artist.setArtistName("a new value");
-
-        context.rollbackChanges();
-
-        // Make sure the inmemory changes have been rolled back
-        assertEquals(artistName, artist.getArtistName());
-
-        // Commit what's in memory...
-        context.commitChanges();
-
-        // .. and ensure that the correct data is in the db
-        DataContext freshContext = (DataContext) serverRuntime.newContext();
-        assertNotSame(this.context, freshContext);
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.setQualifier(ExpressionFactory.matchExp("artistName", artistName));
-        List<?> queryResults = freshContext.performQuery(query);
-
-        assertEquals(1, queryResults.size());
-    }
-}


Mime
View raw message