cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [27/48] Installing Maven Failsafe Plugin
Date Sun, 02 Nov 2014 07:10:15 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextTest.java
deleted file mode 100644
index b325a6f..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextTest.java
+++ /dev/null
@@ -1,804 +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 static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.DataObject;
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.Fault;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.ResultIterator;
-import org.apache.cayenne.ResultIteratorCallback;
-import org.apache.cayenne.conn.PoolManager;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.query.EJBQLQuery;
-import org.apache.cayenne.query.ObjectIdQuery;
-import org.apache.cayenne.query.Ordering;
-import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.QueryMetadata;
-import org.apache.cayenne.query.QueryRouter;
-import org.apache.cayenne.query.SQLTemplate;
-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.Exhibit;
-import org.apache.cayenne.testdo.testmap.NullTestEntity;
-import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.testdo.testmap.ROArtist;
-import org.apache.cayenne.unit.UnitDbAdapter;
-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.ServerCaseDataSourceFactory;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextTest extends ServerCase {
-
-    @Inject
-    protected DataContext context;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    @Inject
-    protected UnitDbAdapter accessStackAdapter;
-
-    @Inject
-    protected DataChannelInterceptor queryInterceptor;
-
-    @Inject
-    protected ServerCaseDataSourceFactory dataSourceFactory;
-
-    protected TableHelper tArtist;
-    protected TableHelper tExhibit;
-    protected TableHelper tGallery;
-    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");
-        dbHelper.deleteAll("EXHIBIT");
-        dbHelper.deleteAll("GALLERY");
-
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-
-        tExhibit = new TableHelper(dbHelper, "EXHIBIT");
-        tExhibit.setColumns("EXHIBIT_ID", "GALLERY_ID", "OPENING_DATE", "CLOSING_DATE");
-
-        tGallery = new TableHelper(dbHelper, "GALLERY");
-        tGallery.setColumns("GALLERY_ID", "GALLERY_NAME");
-
-        tPainting = new TableHelper(dbHelper, "PAINTING");
-        tPainting.setColumns("PAINTING_ID", "PAINTING_TITLE", "ARTIST_ID", "ESTIMATED_PRICE");
-    }
-
-    protected void createSingleArtistDataSet() throws Exception {
-        tArtist.insert(33001, "artist1");
-    }
-
-    protected void createFiveArtistDataSet_MixedCaseName() throws Exception {
-        tArtist.insert(33001, "artist1");
-        tArtist.insert(33002, "Artist3");
-        tArtist.insert(33003, "aRtist5");
-        tArtist.insert(33004, "arTist2");
-        tArtist.insert(33005, "artISt4");
-    }
-
-    protected void createGalleriesAndExhibitsDataSet() throws Exception {
-
-        tGallery.insert(33001, "gallery1");
-        tGallery.insert(33002, "gallery2");
-        tGallery.insert(33003, "gallery3");
-        tGallery.insert(33004, "gallery4");
-
-        Timestamp now = new Timestamp(System.currentTimeMillis());
-
-        tExhibit.insert(1, 33001, now, now);
-        tExhibit.insert(2, 33002, now, now);
-    }
-
-    protected void createArtistsDataSet() throws Exception {
-        tArtist.insert(33001, "artist1");
-        tArtist.insert(33002, "artist2");
-        tArtist.insert(33003, "artist3");
-        tArtist.insert(33004, "artist4");
-        tArtist.insert(33005, "artist5");
-        tArtist.insert(33006, "artist11");
-        tArtist.insert(33007, "artist21");
-    }
-
-    protected void createArtistsAndPaintingsDataSet() throws Exception {
-        createArtistsDataSet();
-
-        tPainting.insert(33001, "P_artist1", 33001, 1000);
-        tPainting.insert(33002, "P_artist2", 33002, 2000);
-        tPainting.insert(33003, "P_artist3", 33003, 3000);
-        tPainting.insert(33004, "P_artist4", 33004, 4000);
-        tPainting.insert(33005, "P_artist5", 33005, 5000);
-        tPainting.insert(33006, "P_artist11", 33006, 11000);
-        tPainting.insert(33007, "P_artist21", 33007, 21000);
-    }
-
-    public void testCurrentSnapshot1() throws Exception {
-        createSingleArtistDataSet();
-
-        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(Artist.ARTIST_NAME_PROPERTY,
-                "artist1"));
-        Artist artist = (Artist) context.performQuery(query).get(0);
-
-        DataRow snapshot = context.currentSnapshot(artist);
-        assertEquals(artist.getArtistName(), snapshot.get("ARTIST_NAME"));
-        assertEquals(artist.getDateOfBirth(), snapshot.get("DATE_OF_BIRTH"));
-    }
-
-    public void testCurrentSnapshot2() throws Exception {
-        createSingleArtistDataSet();
-
-        // test null values
-        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(Artist.ARTIST_NAME_PROPERTY,
-                "artist1"));
-        Artist artist = (Artist) context.performQuery(query).get(0);
-
-        artist.setArtistName(null);
-        artist.setDateOfBirth(null);
-
-        DataRow snapshot = context.currentSnapshot(artist);
-        assertTrue(snapshot.containsKey("ARTIST_NAME"));
-        assertNull(snapshot.get("ARTIST_NAME"));
-
-        assertTrue(snapshot.containsKey("DATE_OF_BIRTH"));
-        assertNull(snapshot.get("DATE_OF_BIRTH"));
-    }
-
-    public void testCurrentSnapshot3() throws Exception {
-        createSingleArtistDataSet();
-
-        // test null values
-        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(Artist.ARTIST_NAME_PROPERTY,
-                "artist1"));
-        Artist artist = (Artist) context.performQuery(query).get(0);
-
-        // test FK relationship snapshotting
-        Painting p1 = new Painting();
-        context.registerNewObject(p1);
-        p1.setToArtist(artist);
-
-        DataRow s1 = context.currentSnapshot(p1);
-        Map<String, Object> idMap = artist.getObjectId().getIdSnapshot();
-        assertEquals(idMap.get("ARTIST_ID"), s1.get("ARTIST_ID"));
-    }
-
-    /**
-     * Testing snapshot with to-one fault. This was a bug CAY-96.
-     */
-    public void testCurrentSnapshotWithToOneFault() throws Exception {
-
-        createGalleriesAndExhibitsDataSet();
-
-        // Exhibit with Gallery as Fault must still include Gallery
-        // Artist and Exhibit (Exhibit has unresolved to-one to gallery as in
-        // the
-        // CAY-96 bug report)
-
-        ObjectId eId = new ObjectId("Exhibit", Exhibit.EXHIBIT_ID_PK_COLUMN, 2);
-        Exhibit e = (Exhibit) context.performQuery(new ObjectIdQuery(eId)).get(0);
-
-        assertTrue(e.readPropertyDirectly(Exhibit.TO_GALLERY_PROPERTY) instanceof Fault);
-
-        DataRow snapshot = context.currentSnapshot(e);
-
-        // assert that after taking a snapshot, we have FK in, but the
-        // relationship
-        // is still a Fault
-        assertTrue(e.readPropertyDirectly(Exhibit.TO_GALLERY_PROPERTY) instanceof Fault);
-        assertEquals(new Integer(33002), snapshot.get("GALLERY_ID"));
-    }
-
-    /**
-     * Tests how CHAR field is handled during fetch. Some databases (Oracle...)
-     * would pad a CHAR column with extra spaces, returned to the client.
-     * Cayenne should trim it.
-     */
-    public void testCharFetch() throws Exception {
-        createSingleArtistDataSet();
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        Artist a = (Artist) context.performQuery(query).get(0);
-        assertEquals(a.getArtistName().trim(), a.getArtistName());
-    }
-
-    /**
-     * Tests how CHAR field is handled during fetch in the WHERE clause. Some
-     * databases (Oracle...) would pad a CHAR column with extra spaces, returned
-     * to the client. Cayenne should trim it.
-     */
-    public void testCharInQualifier() throws Exception {
-        createArtistsDataSet();
-
-        Expression e = ExpressionFactory.matchExp("artistName", "artist1");
-        SelectQuery q = new SelectQuery(Artist.class, e);
-        List<Artist> artists = context.performQuery(q);
-        assertEquals(1, artists.size());
-    }
-
-    /**
-     * Test fetching query with multiple relationship paths between the same 2
-     * entities used in qualifier.
-     */
-    public void testMultiObjRelFetch() throws Exception {
-        createArtistsAndPaintingsDataSet();
-
-        SelectQuery q = new SelectQuery(Painting.class);
-        q.andQualifier(ExpressionFactory.matchExp("toArtist.artistName", "artist2"));
-        q.orQualifier(ExpressionFactory.matchExp("toArtist.artistName", "artist4"));
-        List<Painting> results = context.performQuery(q);
-
-        assertEquals(2, results.size());
-    }
-
-    /**
-     * Test fetching query with multiple relationship paths between the same 2
-     * entities used in qualifier.
-     */
-    public void testMultiDbRelFetch() throws Exception {
-        createArtistsAndPaintingsDataSet();
-
-        SelectQuery q = new SelectQuery("Painting");
-        q.andQualifier(ExpressionFactory.matchDbExp("toArtist.ARTIST_NAME", "artist2"));
-        q.orQualifier(ExpressionFactory.matchDbExp("toArtist.ARTIST_NAME", "artist4"));
-        List<?> results = context.performQuery(q);
-
-        assertEquals(2, results.size());
-    }
-
-    public void testSelectDate() throws Exception {
-        createGalleriesAndExhibitsDataSet();
-
-        List<Exhibit> objects = context.performQuery(new SelectQuery(Exhibit.class));
-        assertFalse(objects.isEmpty());
-
-        Exhibit e1 = objects.get(0);
-        assertEquals(java.util.Date.class, e1.getClosingDate().getClass());
-    }
-
-    public void testCaseInsensitiveOrdering() throws Exception {
-        if (!accessStackAdapter.supportsCaseInsensitiveOrder()) {
-            return;
-        }
-
-        createFiveArtistDataSet_MixedCaseName();
-
-        // case insensitive ordering appends extra columns
-        // to the query when query is using DISTINCT...
-        // verify that the result is not messed up
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        Ordering ordering = new Ordering(Artist.ARTIST_NAME_PROPERTY, SortOrder.ASCENDING_INSENSITIVE);
-        query.addOrdering(ordering);
-        query.setDistinct(true);
-
-        List<Artist> objects = context.performQuery(query);
-        assertEquals(5, objects.size());
-
-        Artist artist = objects.get(0);
-        DataRow snapshot = context.getObjectStore().getSnapshot(artist.getObjectId());
-        assertEquals(3, snapshot.size());
-
-        // assert the ordering
-        assertEquals("artist1", objects.get(0).getArtistName());
-        assertEquals("arTist2", objects.get(1).getArtistName());
-        assertEquals("Artist3", objects.get(2).getArtistName());
-        assertEquals("artISt4", objects.get(3).getArtistName());
-        assertEquals("aRtist5", objects.get(4).getArtistName());
-    }
-
-    public void testSelect_DataRows() throws Exception {
-        createArtistsAndPaintingsDataSet();
-
-        SelectQuery<DataRow> query = SelectQuery.dataRowQuery(Artist.class, null);
-        List<DataRow> objects = context.select(query);
-
-        assertNotNull(objects);
-        assertEquals(7, objects.size());
-        assertTrue("DataRow expected, got " + objects.get(0).getClass(), objects.get(0) instanceof DataRow);
-    }
-
-    public void testPerformSelectQuery1() throws Exception {
-        createArtistsAndPaintingsDataSet();
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        List<?> objects = context.performQuery(query);
-
-        assertNotNull(objects);
-        assertEquals(7, objects.size());
-        assertTrue("Artist expected, got " + objects.get(0).getClass(), objects.get(0) instanceof Artist);
-    }
-
-    public void testPerformSelectQuery2() throws Exception {
-        createArtistsAndPaintingsDataSet();
-
-        // do a query with complex qualifier
-        List<Expression> expressions = new ArrayList<Expression>();
-        expressions.add(ExpressionFactory.matchExp("artistName", "artist3"));
-        expressions.add(ExpressionFactory.matchExp("artistName", "artist5"));
-        expressions.add(ExpressionFactory.matchExp("artistName", "artist21"));
-
-        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.joinExp(Expression.OR, expressions));
-
-        List<?> objects = context.performQuery(query);
-
-        assertNotNull(objects);
-        assertEquals(3, objects.size());
-        assertTrue("Artist expected, got " + objects.get(0).getClass(), objects.get(0) instanceof Artist);
-    }
-
-    public void testPerformQuery_Routing() {
-        Query query = mock(Query.class);
-        QueryMetadata md = mock(QueryMetadata.class);
-        when(query.getMetaData(any(EntityResolver.class))).thenReturn(md);
-        context.performGenericQuery(query);
-        verify(query).route(any(QueryRouter.class), eq(context.getEntityResolver()), (Query) isNull());
-    }
-
-    public void testPerformNonSelectingQuery() throws Exception {
-
-        createSingleArtistDataSet();
-
-        SelectQuery select = new SelectQuery(Painting.class, Expression.fromString("db:PAINTING_ID = 1"));
-
-        assertEquals(0, context.performQuery(select).size());
-
-        SQLTemplate query = new SQLTemplate(Painting.class,
-                "INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ARTIST_ID, ESTIMATED_PRICE) "
-                        + "VALUES (1, 'PX', 33001, 1)");
-        context.performNonSelectingQuery(query);
-        assertEquals(1, context.performQuery(select).size());
-    }
-
-    public void testPerformNonSelectingQueryCounts1() throws Exception {
-        createArtistsDataSet();
-
-        SQLTemplate query = new SQLTemplate(Painting.class,
-                "INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ARTIST_ID, ESTIMATED_PRICE) "
-                        + "VALUES ($pid, '$pt', $aid, $price)");
-
-        Map<String, Object> map = new HashMap<String, Object>();
-        map.put("pid", new Integer(1));
-        map.put("pt", "P1");
-        map.put("aid", new Integer(33002));
-        map.put("price", new Double(1.1));
-
-        // single batch of parameters
-        query.setParameters(map);
-
-        int[] counts = context.performNonSelectingQuery(query);
-        assertNotNull(counts);
-        assertEquals(1, counts.length);
-        assertEquals(1, counts[0]);
-    }
-
-    public void testPerformNonSelectingQueryCounts2() throws Exception {
-
-        createArtistsDataSet();
-
-        SQLTemplate query = new SQLTemplate(Painting.class,
-                "INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ARTIST_ID, ESTIMATED_PRICE) "
-                        + "VALUES ($pid, '$pt', $aid, #bind($price 'DECIMAL' 2))");
-
-        Map<String, Object>[] maps = new Map[3];
-        for (int i = 0; i < maps.length; i++) {
-            maps[i] = new HashMap<String, Object>();
-            maps[i].put("pid", new Integer(1 + i));
-            maps[i].put("pt", "P-" + i);
-            maps[i].put("aid", new Integer(33002));
-            maps[i].put("price", new BigDecimal("1." + i));
-        }
-
-        // single batch of parameters
-        query.setParameters(maps);
-
-        int[] counts = context.performNonSelectingQuery(query);
-        assertNotNull(counts);
-        assertEquals(maps.length, counts.length);
-        for (int i = 0; i < maps.length; i++) {
-            assertEquals(1, counts[i]);
-        }
-
-        SQLTemplate delete = new SQLTemplate(Painting.class, "delete from PAINTING");
-        counts = context.performNonSelectingQuery(delete);
-        assertNotNull(counts);
-        assertEquals(1, counts.length);
-        assertEquals(3, counts[0]);
-    }
-
-    public void testPerformPaginatedQuery() throws Exception {
-        createArtistsDataSet();
-
-        SelectQuery<Artist> query = SelectQuery.query(Artist.class);
-        query.setPageSize(5);
-        List<Artist> objects = context.select(query);
-        assertNotNull(objects);
-        assertTrue(objects instanceof IncrementalFaultList<?>);
-        assertTrue(((IncrementalFaultList<Artist>) objects).elements.get(0) instanceof Long);
-        assertTrue(((IncrementalFaultList<Artist>) objects).elements.get(6) instanceof Long);
-
-        assertTrue(objects.get(0) instanceof Artist);
-    }
-
-    public void testPerformPaginatedQuery1() throws Exception {
-        createArtistsDataSet();
-
-        EJBQLQuery query = new EJBQLQuery("select a FROM Artist a");
-        query.setPageSize(5);
-        List<?> objects = context.performQuery(query);
-        assertNotNull(objects);
-        assertTrue(objects instanceof IncrementalFaultList<?>);
-        assertTrue(((IncrementalFaultList<?>) objects).elements.get(0) instanceof Long);
-        assertTrue(((IncrementalFaultList<?>) objects).elements.get(6) instanceof Long);
-
-        assertTrue(objects.get(0) instanceof Artist);
-    }
-
-    public void testPerformPaginatedQueryBigPage() throws Exception {
-        createArtistsDataSet();
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.setPageSize(5);
-        final List<?> objects = context.performQuery(query);
-        assertNotNull(objects);
-        assertTrue(objects instanceof IncrementalFaultList<?>);
-
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                assertEquals(7, objects.size());
-            }
-        });
-    }
-
-    public void testPerformDataRowQuery() throws Exception {
-
-        createArtistsDataSet();
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.setFetchingDataRows(true);
-        List<?> objects = context.performQuery(query);
-
-        assertNotNull(objects);
-        assertEquals(7, objects.size());
-        assertTrue("Map expected, got " + objects.get(0).getClass(), objects.get(0) instanceof Map<?, ?>);
-    }
-
-    public void testCommitChangesRO1() throws Exception {
-
-        ROArtist a1 = (ROArtist) context.newObject("ROArtist");
-        a1.writePropertyDirectly("artistName", "abc");
-        a1.setPersistenceState(PersistenceState.MODIFIED);
-
-        try {
-            context.commitChanges();
-            fail("Inserting a 'read-only' object must fail.");
-        } catch (Exception ex) {
-            // exception is expected,
-            // must blow on saving new "read-only" object.
-        }
-    }
-
-    public void testCommitChangesRO2() throws Exception {
-        createArtistsDataSet();
-
-        SelectQuery query = new SelectQuery(ROArtist.class, ExpressionFactory.matchExp(Artist.ARTIST_NAME_PROPERTY,
-                "artist1"));
-        ROArtist a1 = (ROArtist) context.performQuery(query).get(0);
-        a1.writeProperty(ROArtist.ARTIST_NAME_PROPERTY, "abc");
-
-        try {
-            context.commitChanges();
-            fail("Updating a 'read-only' object must fail.");
-        } catch (Exception ex) {
-            // exception is expected,
-            // must blow on saving new "read-only" object.
-        }
-    }
-
-    public void testCommitChangesRO3() throws Exception {
-
-        createArtistsDataSet();
-
-        SelectQuery query = new SelectQuery(ROArtist.class, ExpressionFactory.matchExp(Artist.ARTIST_NAME_PROPERTY,
-                "artist1"));
-        ROArtist a1 = (ROArtist) context.performQuery(query).get(0);
-        context.deleteObjects(a1);
-
-        try {
-            context.commitChanges();
-            fail("Deleting a 'read-only' object must fail.");
-        } catch (Exception ex) {
-            // exception is expected,
-            // must blow on saving new "read-only" object.
-        }
-    }
-
-    public void testCommitChangesRO4() throws Exception {
-        createArtistsDataSet();
-
-        SelectQuery query = new SelectQuery(ROArtist.class, ExpressionFactory.matchExp(Artist.ARTIST_NAME_PROPERTY,
-                "artist1"));
-        ROArtist a1 = (ROArtist) context.performQuery(query).get(0);
-
-        Painting painting = context.newObject(Painting.class);
-        painting.setPaintingTitle("paint");
-        a1.addToPaintingArray(painting);
-
-        assertEquals(PersistenceState.MODIFIED, a1.getPersistenceState());
-        try {
-            context.commitChanges();
-        } catch (Exception ex) {
-            fail("Updating 'read-only' object's to-many must succeed, instead an exception was thrown: " + ex);
-        }
-
-        assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
-    }
-
-	public void testIterate() throws Exception {
-
-		createArtistsDataSet();
-
-		SelectQuery<Artist> q1 = new SelectQuery<Artist>(Artist.class);
-		
-		final int[] count = new int[1];
-		
-		context.iterate(q1, new ResultIteratorCallback<Artist>() {
-
-			@Override
-			public void next(Artist object) {
-				assertNotNull(object.getArtistName());
-				count[0]++;
-			}
-		});
-		
-		 assertEquals(7, count[0]);
-	}
-
-    public void testIterateDataRows() throws Exception {
-
-        createArtistsDataSet();
-
-        SelectQuery<DataRow> q1 = SelectQuery.dataRowQuery(Artist.class, null);
-        final int[] count = new int[1];
-        
-        context.iterate(q1, new ResultIteratorCallback<DataRow>() {
-        	
-        	@Override
-        	public void next(DataRow object) {
-        		 assertNotNull(object.get("ARTIST_ID"));
-                 count[0]++;
-        	}
-        });
-        
-        assertEquals(7, count[0]);
-    }
-
-    public void testIterator() throws Exception {
-
-        createArtistsDataSet();
-
-        SelectQuery<Artist> q1 = new SelectQuery<Artist>(Artist.class);
-
-        ResultIterator<Artist> it = context.iterator(q1);
-        try {
-            int count = 0;
-
-            for (Artist a : it) {
-                count++;
-            }
-
-            assertEquals(7, count);
-        } finally {
-            it.close();
-        }
-    }
-
-    public void testPerformIteratedQuery1() throws Exception {
-
-        createArtistsDataSet();
-
-        SelectQuery<Artist> q1 = new SelectQuery<Artist>(Artist.class);
-        ResultIterator<?> it = context.performIteratedQuery(q1);
-
-        try {
-            int count = 0;
-            while (it.hasNextRow()) {
-                it.nextRow();
-                count++;
-            }
-
-            assertEquals(7, count);
-        } finally {
-            it.close();
-        }
-    }
-
-    public void testPerformIteratedQuery2() throws Exception {
-        createArtistsAndPaintingsDataSet();
-
-        ResultIterator it = context.performIteratedQuery(new SelectQuery(Artist.class));
-
-        // just for this test increase pool size
-        changeMaxConnections(1);
-
-        try {
-            while (it.hasNextRow()) {
-                DataRow row = (DataRow) it.nextRow();
-
-                // try instantiating an object and fetching its relationships
-                Artist artist = context.objectFromDataRow(Artist.class, row);
-                List<?> paintings = artist.getPaintingArray();
-                assertNotNull(paintings);
-                assertEquals("Expected one painting for artist: " + artist, 1, paintings.size());
-            }
-        } finally {
-            // change allowed connections back
-            changeMaxConnections(-1);
-            it.close();
-        }
-    }
-
-    /**
-     * Tests that hasChanges performs correctly when an object is "modified" and
-     * the property is simply set to the same value (an unreal modification)
-     */
-    public void testHasChangesPhantom() {
-
-        String artistName = "ArtistName";
-        Artist artist = (Artist) context.newObject("Artist");
-        artist.setArtistName(artistName);
-        context.commitChanges();
-
-        // Set again to *exactly* the same value
-        artist.setArtistName(artistName);
-
-        // note that since 1.2 the polciy is for hasChanges to return true for
-        // phantom
-        // modifications, as there is no way to detect some more subtle
-        // modifications like
-        // a change of the master related object, until we actually create the
-        // PKs
-        assertTrue(context.hasChanges());
-    }
-
-    /**
-     * Tests that hasChanges performs correctly when an object is "modified" and
-     * the property is simply set to the same value (an unreal modification)
-     */
-    public void testHasChangesRealModify() {
-        Artist artist = (Artist) context.newObject("Artist");
-        artist.setArtistName("ArtistName");
-        context.commitChanges();
-
-        artist.setArtistName("Something different");
-        assertTrue(context.hasChanges());
-    }
-
-    public void testInvalidateObjects_Vararg() throws Exception {
-
-        DataRow row = new DataRow(10);
-        row.put("ARTIST_ID", new Integer(1));
-        row.put("ARTIST_NAME", "ArtistXYZ");
-        row.put("DATE_OF_BIRTH", new Date());
-        DataObject object = context.objectFromDataRow(Artist.class, row);
-        ObjectId oid = object.getObjectId();
-
-        // insert object into the ObjectStore
-        context.getObjectStore().registerNode(oid, object);
-
-        assertSame(object, context.getObjectStore().getNode(oid));
-        assertNotNull(context.getObjectStore().getCachedSnapshot(oid));
-
-        context.invalidateObjects(object);
-
-        assertSame(oid, object.getObjectId());
-        assertNull(context.getObjectStore().getCachedSnapshot(oid));
-        assertSame(object, context.getObjectStore().getNode(oid));
-    }
-
-    public void testInvalidateObjects() throws Exception {
-
-        DataRow row = new DataRow(10);
-        row.put("ARTIST_ID", new Integer(1));
-        row.put("ARTIST_NAME", "ArtistXYZ");
-        row.put("DATE_OF_BIRTH", new Date());
-        DataObject object = context.objectFromDataRow(Artist.class, row);
-        ObjectId oid = object.getObjectId();
-
-        // insert object into the ObjectStore
-        context.getObjectStore().registerNode(oid, object);
-
-        assertSame(object, context.getObjectStore().getNode(oid));
-        assertNotNull(context.getObjectStore().getCachedSnapshot(oid));
-
-        context.invalidateObjects(Collections.singleton(object));
-
-        assertSame(oid, object.getObjectId());
-        assertNull(context.getObjectStore().getCachedSnapshot(oid));
-        assertSame(object, context.getObjectStore().getNode(oid));
-    }
-
-    public void testBeforeHollowDeleteShouldChangeStateToCommited() throws Exception {
-        createSingleArtistDataSet();
-
-        Artist hollow = Cayenne.objectForPK(context, Artist.class, 33001);
-        context.invalidateObjects(hollow);
-        assertEquals(PersistenceState.HOLLOW, hollow.getPersistenceState());
-
-        // testing this...
-        context.deleteObjects(hollow);
-        assertSame(hollow, context.getGraphManager().getNode(new ObjectId("Artist", "ARTIST_ID", 33001)));
-        assertEquals("artist1", hollow.getArtistName());
-
-        assertEquals(PersistenceState.DELETED, hollow.getPersistenceState());
-    }
-
-    public void testCommitUnchangedInsert() throws Exception {
-
-        // see CAY-1444 - reproducible on DB's that support auto incremented PK
-
-        NullTestEntity newObject = context.newObject(NullTestEntity.class);
-
-        assertTrue(context.hasChanges());
-        context.commitChanges();
-        assertFalse(context.hasChanges());
-
-        assertEquals(PersistenceState.COMMITTED, newObject.getPersistenceState());
-    }
-
-    private void changeMaxConnections(int delta) {
-        PoolManager manager = (PoolManager) dataSourceFactory.getSharedDataSource();
-        manager.setMaxConnections(manager.getMaxConnections() + delta);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextValidationIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextValidationIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextValidationIT.java
new file mode 100644
index 0000000..b22daf9
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextValidationIT.java
@@ -0,0 +1,104 @@
+/*****************************************************************
+ *   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.di.Inject;
+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;
+import org.apache.cayenne.unit.util.ValidationDelegate;
+import org.apache.cayenne.validation.ValidationResult;
+
+/**
+ */
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextValidationIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @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");
+    }
+
+    public void testValidatingObjectsOnCommitProperty() throws Exception {
+        context.setValidatingObjectsOnCommit(true);
+        assertTrue(context.isValidatingObjectsOnCommit());
+
+        context.setValidatingObjectsOnCommit(false);
+        assertFalse(context.isValidatingObjectsOnCommit());
+    }
+
+    public void testValidatingObjectsOnCommit() throws Exception {
+        // test that validation is called properly
+
+        context.setValidatingObjectsOnCommit(true);
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("a1");
+        context.commitChanges();
+        assertTrue(a1.isValidateForSaveCalled());
+
+        context.setValidatingObjectsOnCommit(false);
+        Artist a2 = context.newObject(Artist.class);
+        a2.setArtistName("a2");
+        context.commitChanges();
+        assertFalse(a2.isValidateForSaveCalled());
+    }
+
+    public void testValidationModifyingContext() throws Exception {
+
+        ValidationDelegate delegate = new ValidationDelegate() {
+
+            public void validateForSave(Object object, ValidationResult validationResult) {
+
+                Artist a = (Artist) object;
+                Painting p = a.getObjectContext().newObject(Painting.class);
+                p.setPaintingTitle("XXX");
+                p.setToArtist(a);
+            }
+        };
+
+        context.setValidatingObjectsOnCommit(true);
+        Artist a1 = context.newObject(Artist.class);
+        a1.setValidationDelegate(delegate);
+        a1.setArtistName("a1");
+
+        // add another artist to ensure that modifying context works when more than one
+        // object is committed
+        Artist a2 = context.newObject(Artist.class);
+        a2.setValidationDelegate(delegate);
+        a2.setArtistName("a2");
+        context.commitChanges();
+
+        assertEquals(2, context.performQuery(new SelectQuery(Painting.class)).size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextValidationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextValidationTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextValidationTest.java
deleted file mode 100644
index a774327..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextValidationTest.java
+++ /dev/null
@@ -1,104 +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.di.Inject;
-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;
-import org.apache.cayenne.unit.util.ValidationDelegate;
-import org.apache.cayenne.validation.ValidationResult;
-
-/**
- */
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataContextValidationTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @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");
-    }
-
-    public void testValidatingObjectsOnCommitProperty() throws Exception {
-        context.setValidatingObjectsOnCommit(true);
-        assertTrue(context.isValidatingObjectsOnCommit());
-
-        context.setValidatingObjectsOnCommit(false);
-        assertFalse(context.isValidatingObjectsOnCommit());
-    }
-
-    public void testValidatingObjectsOnCommit() throws Exception {
-        // test that validation is called properly
-
-        context.setValidatingObjectsOnCommit(true);
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("a1");
-        context.commitChanges();
-        assertTrue(a1.isValidateForSaveCalled());
-
-        context.setValidatingObjectsOnCommit(false);
-        Artist a2 = context.newObject(Artist.class);
-        a2.setArtistName("a2");
-        context.commitChanges();
-        assertFalse(a2.isValidateForSaveCalled());
-    }
-
-    public void testValidationModifyingContext() throws Exception {
-
-        ValidationDelegate delegate = new ValidationDelegate() {
-
-            public void validateForSave(Object object, ValidationResult validationResult) {
-
-                Artist a = (Artist) object;
-                Painting p = a.getObjectContext().newObject(Painting.class);
-                p.setPaintingTitle("XXX");
-                p.setToArtist(a);
-            }
-        };
-
-        context.setValidatingObjectsOnCommit(true);
-        Artist a1 = context.newObject(Artist.class);
-        a1.setValidationDelegate(delegate);
-        a1.setArtistName("a1");
-
-        // add another artist to ensure that modifying context works when more than one
-        // object is committed
-        Artist a2 = context.newObject(Artist.class);
-        a2.setValidationDelegate(delegate);
-        a2.setArtistName("a2");
-        context.commitChanges();
-
-        assertEquals(2, context.performQuery(new SelectQuery(Painting.class)).size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainCallbacksIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainCallbacksIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainCallbacksIT.java
new file mode 100644
index 0000000..de4fce3
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainCallbacksIT.java
@@ -0,0 +1,471 @@
+/*****************************************************************
+ *   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.PersistenceState;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.LifecycleEvent;
+import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.query.RefreshQuery;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
+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 DataDomainCallbacksIT extends ServerCase {
+
+    @Inject
+    private EntityResolver resolver;
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private ObjectContext context1;
+    
+    @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");
+        dbHelper.deleteAll("EXHIBIT");
+        dbHelper.deleteAll("GALLERY");
+    }
+
+    public void testPostLoad() throws Exception {
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
+        MockCallingBackListener listener = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_LOAD,
+                Artist.class,
+                listener,
+                "publicCallback");
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+        assertEquals(0, a1.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        SelectQuery q = new SelectQuery(Artist.class);
+        context.performQuery(q);
+        assertEquals(1, a1.getPostLoaded());
+        assertSame(a1, listener.getPublicCalledbackEntity());
+
+        a1.resetCallbackFlags();
+        listener.reset();
+
+        // post load must be called on rollback...
+        a1.resetCallbackFlags();
+        listener.reset();
+
+        context.rollbackChanges();
+        assertEquals(0, a1.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        // now change and rollback the artist - postLoad must be called
+        a1.setArtistName("YY");
+        context.rollbackChanges();
+        assertEquals(1, a1.getPostLoaded());
+        assertSame(a1, listener.getPublicCalledbackEntity());
+
+        // test invalidated
+        a1.resetCallbackFlags();
+        listener.reset();
+        assertEquals(0, a1.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        context.performQuery(new RefreshQuery(a1));
+        assertEquals(0, a1.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        a1.getArtistName();
+        assertEquals(1, a1.getPostLoaded());
+        assertSame(a1, listener.getPublicCalledbackEntity());
+    }
+
+    public void testPostLoad_MixedResult() throws Exception {
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
+        MockCallingBackListener listener = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_LOAD,
+                Artist.class,
+                listener,
+                "publicCallback");
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+        assertEquals(0, a1.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        EJBQLQuery q = new EJBQLQuery("select a, a.artistName from Artist a");
+        context.performQuery(q);
+        assertEquals(1, a1.getPostLoaded());
+        assertSame(a1, listener.getPublicCalledbackEntity());
+    }
+
+    public void testPostLoad_Relationship() throws Exception {
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
+        MockCallingBackListener listener = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_LOAD,
+                Artist.class,
+                listener,
+                "publicCallback");
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        Painting p1 = context.newObject(Painting.class);
+        p1.setToArtist(a1);
+        p1.setPaintingTitle("XXX");
+        context.commitChanges();
+
+        context.invalidateObjects(a1, p1);
+
+        SelectQuery q = new SelectQuery(Painting.class);
+        p1 = (Painting) context1.performQuery(q).get(0);
+
+        // this should be a hollow object, so no callback just yet
+        a1 = p1.getToArtist();
+        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
+        assertEquals(0, a1.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        a1.getArtistName();
+        assertEquals(1, a1.getPostLoaded());
+        assertSame(a1, listener.getPublicCalledbackEntity());
+    }
+
+    public void testPostLoad_Prefetch() throws Exception {
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
+        MockCallingBackListener listener = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_LOAD,
+                Artist.class,
+                listener,
+                "publicCallback");
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        Painting p1 = context.newObject(Painting.class);
+        p1.setToArtist(a1);
+        p1.setPaintingTitle("XXX");
+        context.commitChanges();
+
+        SelectQuery q = new SelectQuery(Painting.class);
+        q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
+        p1 = (Painting) context1.performQuery(q).get(0);
+
+        // artist is prefetched here, and a callback must have been invoked
+        a1 = p1.getToArtist();
+        assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
+        assertEquals(1, a1.getPostLoaded());
+        assertSame(a1, listener.getPublicCalledbackEntity());
+    }
+
+    public void testPostLoad_LocalObject() throws Exception {
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+
+        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
+        MockCallingBackListener listener = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_LOAD,
+                Artist.class,
+                listener,
+                "publicCallback");
+
+        Artist a2 = context1.localObject(a1);
+
+        assertEquals(PersistenceState.HOLLOW, a2.getPersistenceState());
+        assertEquals(0, a2.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        a2.getArtistName();
+        assertEquals(1, a2.getPostLoaded());
+        assertSame(a2, listener.getPublicCalledbackEntity());
+    }
+
+    public void testPostLoad_ThatModifiesObject() {
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
+        MockCallingBackListener listener = new MockCallingBackListener() {
+        	@Override
+        	public void publicCallback(Object entity) {
+        		super.publicCallback(entity);
+        		Artist a = (Artist)entity;
+        		a.setArtistName("Changed"); // modify object during postLoad callback
+        	}
+        };
+        registry.addListener(
+                LifecycleEvent.POST_LOAD,
+                Artist.class,
+                listener,
+                "publicCallback");
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        Painting p1 = context.newObject(Painting.class);
+        p1.setToArtist(a1);
+        p1.setPaintingTitle("XXX");
+        context.commitChanges();
+
+        context.invalidateObjects(a1, p1);
+
+        SelectQuery q = new SelectQuery(Painting.class);
+        p1 = (Painting) context1.performQuery(q).get(0);
+
+        // this should be a hollow object, so no callback just yet
+        a1 = p1.getToArtist();
+        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
+        assertEquals(0, a1.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        a1.getArtistName();
+        assertEquals(1, a1.getPostLoaded());
+        assertSame(a1, listener.getPublicCalledbackEntity());
+    }
+    
+    public void testPreUpdate() {
+
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+        assertFalse(a1.isPreUpdated());
+
+        a1.setArtistName("YY");
+        context.commitChanges();
+        assertFalse(a1.isPreUpdated());
+
+        registry
+                .addCallback(LifecycleEvent.PRE_UPDATE, Artist.class, "preUpdateCallback");
+        a1.setArtistName("ZZ");
+        context.commitChanges();
+        assertTrue(a1.isPreUpdated());
+
+        a1.resetCallbackFlags();
+        assertFalse(a1.isPreUpdated());
+
+        MockCallingBackListener listener2 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.PRE_UPDATE,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        a1.setArtistName("AA");
+        context.commitChanges();
+
+        assertTrue(a1.isPreUpdated());
+        assertSame(a1, listener2.getPublicCalledbackEntity());
+    }
+
+    public void testPostUpdate() {
+
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+        assertFalse(a1.isPostUpdated());
+
+        a1.setArtistName("YY");
+        context.commitChanges();
+        assertFalse(a1.isPostUpdated());
+
+        registry.addCallback(
+                LifecycleEvent.POST_UPDATE,
+                Artist.class,
+                "postUpdateCallback");
+        a1.setArtistName("ZZ");
+        context.commitChanges();
+        assertTrue(a1.isPostUpdated());
+
+        a1.resetCallbackFlags();
+        assertFalse(a1.isPostUpdated());
+
+        MockCallingBackListener listener2 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_UPDATE,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        a1.setArtistName("AA");
+        context.commitChanges();
+
+        assertTrue(a1.isPostUpdated());
+        assertSame(a1, listener2.getPublicCalledbackEntity());
+    }
+
+    public void testPostRemove() {
+
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+
+        registry.addCallback(
+                LifecycleEvent.POST_REMOVE,
+                Artist.class,
+                "postRemoveCallback");
+        MockCallingBackListener listener2 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_REMOVE,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        context.deleteObjects(a1);
+        context.commitChanges();
+
+        assertTrue(a1.isPostRemoved());
+        assertSame(a1, listener2.getPublicCalledbackEntity());
+    }
+
+    public void testPostRemove_UpdatedDeleted() {
+
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+
+        MockCallingBackListener listener1 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_REMOVE,
+                Artist.class,
+                listener1,
+                "publicCallback");
+
+        MockCallingBackListener listener2 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_UPDATE,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        // change before removing
+        a1.setArtistName("YY");
+        context.deleteObjects(a1);
+        context.commitChanges();
+
+        assertNull(listener2.getPublicCalledbackEntity());
+        assertSame(a1, listener1.getPublicCalledbackEntity());
+    }
+
+    public void testPostRemove_InsertedUpdatedDeleted() {
+
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        MockCallingBackListener listener0 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_PERSIST,
+                Artist.class,
+                listener0,
+                "publicCallback");
+
+        MockCallingBackListener listener1 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_REMOVE,
+                Artist.class,
+                listener1,
+                "publicCallback");
+
+        MockCallingBackListener listener2 = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_UPDATE,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.deleteObjects(a1);
+        context.commitChanges();
+
+        assertNull(listener0.getPublicCalledbackEntity());
+        assertNull(listener1.getPublicCalledbackEntity());
+        assertNull(listener2.getPublicCalledbackEntity());
+    }
+
+    public void testPostPersist() {
+
+        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+        assertFalse(a1.isPostPersisted());
+
+        registry.addCallback(
+                LifecycleEvent.POST_PERSIST,
+                Artist.class,
+                "postPersistCallback");
+        MockCallingBackListener listener2 = new MockCallingBackListener() {
+
+            @Override
+            public void publicCallback(Object entity) {
+                super.publicCallback(entity);
+                assertFalse(((Persistent) entity).getObjectId().isTemporary());
+            }
+        };
+        registry.addListener(
+                LifecycleEvent.POST_PERSIST,
+                Artist.class,
+                listener2,
+                "publicCallback");
+
+        Artist a2 = context.newObject(Artist.class);
+        a2.setArtistName("XX");
+        context.commitChanges();
+
+        assertFalse(a1.isPostPersisted());
+        assertTrue(a2.isPostPersisted());
+        assertSame(a2, listener2.getPublicCalledbackEntity());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java
deleted file mode 100644
index e0855eb..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java
+++ /dev/null
@@ -1,473 +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.ObjectContext;
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.Persistent;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEvent;
-import org.apache.cayenne.query.EJBQLQuery;
-import org.apache.cayenne.query.RefreshQuery;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
-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 DataDomainCallbacksTest extends ServerCase {
-
-    @Inject
-    private EntityResolver resolver;
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private ObjectContext context1;
-    
-    @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");
-        dbHelper.deleteAll("EXHIBIT");
-        dbHelper.deleteAll("GALLERY");
-    }
-
-    public void testPostLoad() throws Exception {
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
-        MockCallingBackListener listener = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_LOAD,
-                Artist.class,
-                listener,
-                "publicCallback");
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-        assertEquals(0, a1.getPostLoaded());
-        assertNull(listener.getPublicCalledbackEntity());
-
-        SelectQuery q = new SelectQuery(Artist.class);
-        context.performQuery(q);
-        assertEquals(1, a1.getPostLoaded());
-        assertSame(a1, listener.getPublicCalledbackEntity());
-
-        a1.resetCallbackFlags();
-        listener.reset();
-
-        // post load must be called on rollback...
-        a1.resetCallbackFlags();
-        listener.reset();
-
-        context.rollbackChanges();
-        assertEquals(0, a1.getPostLoaded());
-        assertNull(listener.getPublicCalledbackEntity());
-
-        // now change and rollback the artist - postLoad must be called
-        a1.setArtistName("YY");
-        context.rollbackChanges();
-        assertEquals(1, a1.getPostLoaded());
-        assertSame(a1, listener.getPublicCalledbackEntity());
-
-        // test invalidated
-        a1.resetCallbackFlags();
-        listener.reset();
-        assertEquals(0, a1.getPostLoaded());
-        assertNull(listener.getPublicCalledbackEntity());
-
-        context.performQuery(new RefreshQuery(a1));
-        assertEquals(0, a1.getPostLoaded());
-        assertNull(listener.getPublicCalledbackEntity());
-
-        a1.getArtistName();
-        assertEquals(1, a1.getPostLoaded());
-        assertSame(a1, listener.getPublicCalledbackEntity());
-    }
-
-    public void testPostLoad_MixedResult() throws Exception {
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
-        MockCallingBackListener listener = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_LOAD,
-                Artist.class,
-                listener,
-                "publicCallback");
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-        assertEquals(0, a1.getPostLoaded());
-        assertNull(listener.getPublicCalledbackEntity());
-
-        EJBQLQuery q = new EJBQLQuery("select a, a.artistName from Artist a");
-        context.performQuery(q);
-        assertEquals(1, a1.getPostLoaded());
-        assertSame(a1, listener.getPublicCalledbackEntity());
-    }
-
-    public void testPostLoad_Relationship() throws Exception {
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
-        MockCallingBackListener listener = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_LOAD,
-                Artist.class,
-                listener,
-                "publicCallback");
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        Painting p1 = context.newObject(Painting.class);
-        p1.setToArtist(a1);
-        p1.setPaintingTitle("XXX");
-        context.commitChanges();
-
-        context.invalidateObjects(a1, p1);
-
-        SelectQuery q = new SelectQuery(Painting.class);
-        p1 = (Painting) context1.performQuery(q).get(0);
-
-        // this should be a hollow object, so no callback just yet
-        a1 = p1.getToArtist();
-        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
-        assertEquals(0, a1.getPostLoaded());
-        assertNull(listener.getPublicCalledbackEntity());
-
-        a1.getArtistName();
-        assertEquals(1, a1.getPostLoaded());
-        assertSame(a1, listener.getPublicCalledbackEntity());
-    }
-
-    public void testPostLoad_Prefetch() throws Exception {
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
-        MockCallingBackListener listener = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_LOAD,
-                Artist.class,
-                listener,
-                "publicCallback");
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        Painting p1 = context.newObject(Painting.class);
-        p1.setToArtist(a1);
-        p1.setPaintingTitle("XXX");
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(Painting.class);
-        q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
-        p1 = (Painting) context1.performQuery(q).get(0);
-
-        // artist is prefetched here, and a callback must have been invoked
-        a1 = p1.getToArtist();
-        assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
-        assertEquals(1, a1.getPostLoaded());
-        assertSame(a1, listener.getPublicCalledbackEntity());
-    }
-
-    public void testPostLoad_LocalObject() throws Exception {
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-
-        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
-        MockCallingBackListener listener = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_LOAD,
-                Artist.class,
-                listener,
-                "publicCallback");
-
-        Artist a2 = context1.localObject(a1);
-
-        assertEquals(PersistenceState.HOLLOW, a2.getPersistenceState());
-        assertEquals(0, a2.getPostLoaded());
-        assertNull(listener.getPublicCalledbackEntity());
-
-        a2.getArtistName();
-        assertEquals(1, a2.getPostLoaded());
-        assertSame(a2, listener.getPublicCalledbackEntity());
-    }
-
-    public void testPostLoad_ThatModifiesObject() {
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
-        MockCallingBackListener listener = new MockCallingBackListener() {
-        	@Override
-        	public void publicCallback(Object entity) {
-        		super.publicCallback(entity);
-        		Artist a = (Artist)entity;
-        		a.setArtistName("Changed"); // modify object during postLoad callback
-        	}
-        };
-        registry.addListener(
-                LifecycleEvent.POST_LOAD,
-                Artist.class,
-                listener,
-                "publicCallback");
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        Painting p1 = context.newObject(Painting.class);
-        p1.setToArtist(a1);
-        p1.setPaintingTitle("XXX");
-        context.commitChanges();
-
-        context.invalidateObjects(a1, p1);
-
-        SelectQuery q = new SelectQuery(Painting.class);
-        p1 = (Painting) context1.performQuery(q).get(0);
-
-        // this should be a hollow object, so no callback just yet
-        a1 = p1.getToArtist();
-        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
-        assertEquals(0, a1.getPostLoaded());
-        assertNull(listener.getPublicCalledbackEntity());
-
-        a1.getArtistName();
-        assertEquals(1, a1.getPostLoaded());
-        assertSame(a1, listener.getPublicCalledbackEntity());
-    }
-    
-    public void testPreUpdate() {
-
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-        assertFalse(a1.isPreUpdated());
-
-        a1.setArtistName("YY");
-        context.commitChanges();
-        assertFalse(a1.isPreUpdated());
-
-        registry
-                .addCallback(LifecycleEvent.PRE_UPDATE, Artist.class, "preUpdateCallback");
-        a1.setArtistName("ZZ");
-        context.commitChanges();
-        assertTrue(a1.isPreUpdated());
-
-        a1.resetCallbackFlags();
-        assertFalse(a1.isPreUpdated());
-
-        MockCallingBackListener listener2 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.PRE_UPDATE,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        a1.setArtistName("AA");
-        context.commitChanges();
-
-        assertTrue(a1.isPreUpdated());
-        assertSame(a1, listener2.getPublicCalledbackEntity());
-    }
-
-    public void testPostUpdate() {
-
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-        assertFalse(a1.isPostUpdated());
-
-        a1.setArtistName("YY");
-        context.commitChanges();
-        assertFalse(a1.isPostUpdated());
-
-        registry.addCallback(
-                LifecycleEvent.POST_UPDATE,
-                Artist.class,
-                "postUpdateCallback");
-        a1.setArtistName("ZZ");
-        context.commitChanges();
-        assertTrue(a1.isPostUpdated());
-
-        a1.resetCallbackFlags();
-        assertFalse(a1.isPostUpdated());
-
-        MockCallingBackListener listener2 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_UPDATE,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        a1.setArtistName("AA");
-        context.commitChanges();
-
-        assertTrue(a1.isPostUpdated());
-        assertSame(a1, listener2.getPublicCalledbackEntity());
-    }
-
-    public void testPostRemove() {
-
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-
-        registry.addCallback(
-                LifecycleEvent.POST_REMOVE,
-                Artist.class,
-                "postRemoveCallback");
-        MockCallingBackListener listener2 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_REMOVE,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        context.deleteObjects(a1);
-        context.commitChanges();
-
-        assertTrue(a1.isPostRemoved());
-        assertSame(a1, listener2.getPublicCalledbackEntity());
-    }
-
-    public void testPostRemove_UpdatedDeleted() {
-
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-
-        MockCallingBackListener listener1 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_REMOVE,
-                Artist.class,
-                listener1,
-                "publicCallback");
-
-        MockCallingBackListener listener2 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_UPDATE,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        // change before removing
-        a1.setArtistName("YY");
-        context.deleteObjects(a1);
-        context.commitChanges();
-
-        assertNull(listener2.getPublicCalledbackEntity());
-        assertSame(a1, listener1.getPublicCalledbackEntity());
-    }
-
-    public void testPostRemove_InsertedUpdatedDeleted() {
-
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        MockCallingBackListener listener0 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_PERSIST,
-                Artist.class,
-                listener0,
-                "publicCallback");
-
-        MockCallingBackListener listener1 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_REMOVE,
-                Artist.class,
-                listener1,
-                "publicCallback");
-
-        MockCallingBackListener listener2 = new MockCallingBackListener();
-        registry.addListener(
-                LifecycleEvent.POST_UPDATE,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.deleteObjects(a1);
-        context.commitChanges();
-
-        assertNull(listener0.getPublicCalledbackEntity());
-        assertNull(listener1.getPublicCalledbackEntity());
-        assertNull(listener2.getPublicCalledbackEntity());
-    }
-
-    public void testPostPersist() {
-
-        LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("XX");
-        context.commitChanges();
-        assertFalse(a1.isPostPersisted());
-
-        registry.addCallback(
-                LifecycleEvent.POST_PERSIST,
-                Artist.class,
-                "postPersistCallback");
-        MockCallingBackListener listener2 = new MockCallingBackListener() {
-
-            @Override
-            public void publicCallback(Object entity) {
-                super.publicCallback(entity);
-                assertFalse(((Persistent) entity).getObjectId().isTemporary());
-            }
-        };
-        registry.addListener(
-                LifecycleEvent.POST_PERSIST,
-                Artist.class,
-                listener2,
-                "publicCallback");
-
-        Artist a2 = context.newObject(Artist.class);
-        a2.setArtistName("XX");
-        context.commitChanges();
-
-        assertFalse(a1.isPostPersisted());
-        assertTrue(a2.isPostPersisted());
-        assertSame(a2, listener2.getPublicCalledbackEntity());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainFiltersIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainFiltersIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainFiltersIT.java
new file mode 100644
index 0000000..c8fa69c
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainFiltersIT.java
@@ -0,0 +1,200 @@
+/*****************************************************************
+ *   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.DataChannelFilter;
+import org.apache.cayenne.DataChannelFilterChain;
+import org.apache.cayenne.MockDataChannelFilter;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.QueryResponse;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.graph.GraphDiff;
+import org.apache.cayenne.query.Query;
+import org.apache.cayenne.query.SelectQuery;
+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.util.ListResponse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataDomainFiltersIT extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private ServerRuntime runtime;
+
+    public void testDefaultNoFilters() {
+
+        DataDomain domain = runtime.getDataDomain();
+        assertEquals(0, domain.filters.size());
+    }
+
+    public void testOnQuery_FilterOrdering() {
+
+        DataDomain domain = runtime.getDataDomain();
+
+        final List<String> results = new ArrayList<String>();
+
+        DataChannelFilter f1 = new MockDataChannelFilter() {
+
+            @Override
+            public QueryResponse onQuery(
+                    ObjectContext originatingContext,
+                    Query query,
+                    DataChannelFilterChain filterChain) {
+
+                results.add("f1start");
+                QueryResponse response = filterChain.onQuery(originatingContext, query);
+                results.add("f1end");
+                return response;
+            }
+        };
+
+        DataChannelFilter f2 = new MockDataChannelFilter() {
+
+            @Override
+            public QueryResponse onQuery(
+                    ObjectContext originatingContext,
+                    Query query,
+                    DataChannelFilterChain filterChain) {
+
+                results.add("f2start");
+                QueryResponse response = filterChain.onQuery(originatingContext, query);
+                results.add("f2end");
+                return response;
+            }
+        };
+
+        domain.filters.add(f1);
+        domain.filters.add(f2);
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        QueryResponse response = domain.onQuery(context, query);
+        assertNotNull(response);
+        assertEquals(4, results.size());
+        assertEquals("f2start", results.get(0));
+        assertEquals("f1start", results.get(1));
+        assertEquals("f1end", results.get(2));
+        assertEquals("f2end", results.get(3));
+    }
+
+    public void testOnSync_FilterOrdering() {
+
+        DataDomain domain = runtime.getDataDomain();
+
+        final List<String> results = new ArrayList<String>();
+
+        DataChannelFilter f1 = new MockDataChannelFilter() {
+
+            @Override
+            public GraphDiff onSync(
+                    ObjectContext originatingContext,
+                    GraphDiff changes,
+                    int syncType,
+                    DataChannelFilterChain filterChain) {
+
+                results.add("f1start");
+                GraphDiff response = filterChain.onSync(
+                        originatingContext,
+                        changes,
+                        syncType);
+                results.add("f1end");
+                return response;
+            }
+        };
+
+        DataChannelFilter f2 = new MockDataChannelFilter() {
+
+            @Override
+            public GraphDiff onSync(
+                    ObjectContext originatingContext,
+                    GraphDiff changes,
+                    int syncType,
+                    DataChannelFilterChain filterChain) {
+
+                results.add("f2start");
+                GraphDiff response = filterChain.onSync(
+                        originatingContext,
+                        changes,
+                        syncType);
+                results.add("f2end");
+                return response;
+            }
+        };
+
+        domain.filters.add(f1);
+        domain.filters.add(f2);
+
+        Artist a = context.newObject(Artist.class);
+        a.setArtistName("AAA");
+
+        // testing domain.onSync indirectly
+        context.commitChanges();
+        assertEquals(4, results.size());
+        assertEquals("f2start", results.get(0));
+        assertEquals("f1start", results.get(1));
+        assertEquals("f1end", results.get(2));
+        assertEquals("f2end", results.get(3));
+    }
+
+    public void testOnQuery_Blocking() {
+
+        DataDomain domain = runtime.getDataDomain();
+
+        final QueryResponse r1 = new ListResponse();
+        final QueryResponse r2 = new ListResponse();
+
+        DataChannelFilter f1 = new MockDataChannelFilter() {
+
+            @Override
+            public QueryResponse onQuery(
+                    ObjectContext originatingContext,
+                    Query query,
+                    DataChannelFilterChain filterChain) {
+
+                return r1;
+            }
+        };
+
+        DataChannelFilter f2 = new MockDataChannelFilter() {
+
+            @Override
+            public QueryResponse onQuery(
+                    ObjectContext originatingContext,
+                    Query query,
+                    DataChannelFilterChain filterChain) {
+
+                return r2;
+            }
+        };
+
+        domain.filters.add(f1);
+        domain.filters.add(f2);
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        QueryResponse response = domain.onQuery(context, query);
+        assertSame(r2, response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainFiltersTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainFiltersTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainFiltersTest.java
deleted file mode 100644
index b36e98a..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainFiltersTest.java
+++ /dev/null
@@ -1,200 +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.ArrayList;
-import java.util.List;
-
-import org.apache.cayenne.DataChannelFilter;
-import org.apache.cayenne.DataChannelFilterChain;
-import org.apache.cayenne.MockDataChannelFilter;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.QueryResponse;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.graph.GraphDiff;
-import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.SelectQuery;
-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.util.ListResponse;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataDomainFiltersTest extends ServerCase {
-
-    @Inject
-    private ObjectContext context;
-
-    @Inject
-    private ServerRuntime runtime;
-
-    public void testDefaultNoFilters() {
-
-        DataDomain domain = runtime.getDataDomain();
-        assertEquals(0, domain.filters.size());
-    }
-
-    public void testOnQuery_FilterOrdering() {
-
-        DataDomain domain = runtime.getDataDomain();
-
-        final List<String> results = new ArrayList<String>();
-
-        DataChannelFilter f1 = new MockDataChannelFilter() {
-
-            @Override
-            public QueryResponse onQuery(
-                    ObjectContext originatingContext,
-                    Query query,
-                    DataChannelFilterChain filterChain) {
-
-                results.add("f1start");
-                QueryResponse response = filterChain.onQuery(originatingContext, query);
-                results.add("f1end");
-                return response;
-            }
-        };
-
-        DataChannelFilter f2 = new MockDataChannelFilter() {
-
-            @Override
-            public QueryResponse onQuery(
-                    ObjectContext originatingContext,
-                    Query query,
-                    DataChannelFilterChain filterChain) {
-
-                results.add("f2start");
-                QueryResponse response = filterChain.onQuery(originatingContext, query);
-                results.add("f2end");
-                return response;
-            }
-        };
-
-        domain.filters.add(f1);
-        domain.filters.add(f2);
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        QueryResponse response = domain.onQuery(context, query);
-        assertNotNull(response);
-        assertEquals(4, results.size());
-        assertEquals("f2start", results.get(0));
-        assertEquals("f1start", results.get(1));
-        assertEquals("f1end", results.get(2));
-        assertEquals("f2end", results.get(3));
-    }
-
-    public void testOnSync_FilterOrdering() {
-
-        DataDomain domain = runtime.getDataDomain();
-
-        final List<String> results = new ArrayList<String>();
-
-        DataChannelFilter f1 = new MockDataChannelFilter() {
-
-            @Override
-            public GraphDiff onSync(
-                    ObjectContext originatingContext,
-                    GraphDiff changes,
-                    int syncType,
-                    DataChannelFilterChain filterChain) {
-
-                results.add("f1start");
-                GraphDiff response = filterChain.onSync(
-                        originatingContext,
-                        changes,
-                        syncType);
-                results.add("f1end");
-                return response;
-            }
-        };
-
-        DataChannelFilter f2 = new MockDataChannelFilter() {
-
-            @Override
-            public GraphDiff onSync(
-                    ObjectContext originatingContext,
-                    GraphDiff changes,
-                    int syncType,
-                    DataChannelFilterChain filterChain) {
-
-                results.add("f2start");
-                GraphDiff response = filterChain.onSync(
-                        originatingContext,
-                        changes,
-                        syncType);
-                results.add("f2end");
-                return response;
-            }
-        };
-
-        domain.filters.add(f1);
-        domain.filters.add(f2);
-
-        Artist a = context.newObject(Artist.class);
-        a.setArtistName("AAA");
-
-        // testing domain.onSync indirectly
-        context.commitChanges();
-        assertEquals(4, results.size());
-        assertEquals("f2start", results.get(0));
-        assertEquals("f1start", results.get(1));
-        assertEquals("f1end", results.get(2));
-        assertEquals("f2end", results.get(3));
-    }
-
-    public void testOnQuery_Blocking() {
-
-        DataDomain domain = runtime.getDataDomain();
-
-        final QueryResponse r1 = new ListResponse();
-        final QueryResponse r2 = new ListResponse();
-
-        DataChannelFilter f1 = new MockDataChannelFilter() {
-
-            @Override
-            public QueryResponse onQuery(
-                    ObjectContext originatingContext,
-                    Query query,
-                    DataChannelFilterChain filterChain) {
-
-                return r1;
-            }
-        };
-
-        DataChannelFilter f2 = new MockDataChannelFilter() {
-
-            @Override
-            public QueryResponse onQuery(
-                    ObjectContext originatingContext,
-                    Query query,
-                    DataChannelFilterChain filterChain) {
-
-                return r2;
-            }
-        };
-
-        domain.filters.add(f1);
-        domain.filters.add(f2);
-
-        SelectQuery query = new SelectQuery(Artist.class);
-        QueryResponse response = domain.onQuery(context, query);
-        assertSame(r2, response);
-    }
-}


Mime
View raw message