cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [26/48] Installing Maven Failsafe Plugin
Date Sun, 02 Nov 2014 07:10:14 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainIT.java
new file mode 100644
index 0000000..8bba81e
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainIT.java
@@ -0,0 +1,256 @@
+/*****************************************************************
+ *   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.CayenneRuntimeException;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.annotation.PostAdd;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.event.DefaultEventManager;
+import org.apache.cayenne.log.JdbcEventLogger;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Exhibit;
+import org.apache.cayenne.testdo.testmap.Gallery;
+import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.testdo.testmap.annotations.Tag1;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataDomainIT extends ServerCase {
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private JdbcEventLogger logger;
+
+    public void testName() throws Exception {
+        DataDomain domain = new DataDomain("some name");
+        assertEquals("some name", domain.getName());
+        domain.setName("tst_name");
+        assertEquals("tst_name", domain.getName());
+    }
+
+    public void testLookupDataNode() {
+
+        DataDomain domain = new DataDomain("test");
+
+        DataMap m1 = new DataMap("m1");
+        DataNode n1 = new DataNode("n1");
+        n1.addDataMap(m1);
+        domain.addNode(n1);
+
+        DataMap m2 = new DataMap("m2");
+        DataNode n2 = new DataNode("n2");
+        n2.addDataMap(m2);
+        domain.addNode(n2);
+
+        assertSame(n1, domain.lookupDataNode(m1));
+        assertSame(n2, domain.lookupDataNode(m2));
+
+        try {
+
+            domain.lookupDataNode(new DataMap("m3"));
+            fail("must have thrown on missing Map to Node maping");
+        } catch (CayenneRuntimeException e) {
+            // expected
+        }
+    }
+
+    public void testLookupDataNode_Default() {
+
+        DataDomain domain = new DataDomain("test");
+
+        DataMap m1 = new DataMap("m1");
+        DataNode n1 = new DataNode("n1");
+        n1.addDataMap(m1);
+        domain.setDefaultNode(n1);
+
+        DataMap m2 = new DataMap("m2");
+        DataNode n2 = new DataNode("n2");
+        n2.addDataMap(m2);
+        domain.addNode(n2);
+
+        assertSame(n1, domain.lookupDataNode(m1));
+        assertSame(n2, domain.lookupDataNode(m2));
+
+        // must map to default
+        assertSame(n1, domain.lookupDataNode(new DataMap("m3")));
+    }
+
+    public void testNodes() throws Exception {
+        DataDomain domain = new DataDomain("dom1");
+        assertEquals(0, domain.getDataNodes().size());
+        DataNode node = new DataNode("1");
+        node.setJdbcEventLogger(logger);
+        domain.addNode(node);
+        assertEquals(1, domain.getDataNodes().size());
+        node = new DataNode("2");
+        node.setJdbcEventLogger(logger);
+        domain.addNode(node);
+        assertEquals(2, domain.getDataNodes().size());
+    }
+
+    public void testNodeMaps() throws Exception {
+        DataDomain domain = new DataDomain("dom1");
+        assertNull(domain.getDataMap("map"));
+
+        DataNode node = new DataNode("1");
+        node.setJdbcEventLogger(logger);
+        node.addDataMap(new DataMap("map"));
+
+        domain.addNode(node);
+        assertNotNull(domain.getDataMap("map"));
+    }
+
+    public void testMaps() throws Exception {
+        DataDomain d1 = new DataDomain("dom1");
+
+        DataMap m1 = new DataMap("m1");
+        d1.addDataMap(m1);
+        assertSame(m1, d1.getDataMap(m1.getName()));
+
+        d1.removeDataMap(m1.getName());
+        assertNull(d1.getDataMap(m1.getName()));
+    }
+
+    public void testEntityResolverRefresh() throws Exception {
+        DataDomain domain = new DataDomain("dom1");
+        org.apache.cayenne.map.EntityResolver resolver = domain.getEntityResolver();
+        assertNotNull(resolver);
+
+        DataMap map = new DataMap("map");
+        ObjEntity entity = new ObjEntity("TestEntity");
+        map.addObjEntity(entity);
+
+        domain.addDataMap(map);
+
+        assertSame(entity, resolver.getObjEntity("TestEntity"));
+    }
+
+    public void testEntityResolver() {
+        assertNotNull(runtime.getDataDomain().getEntityResolver());
+
+        DataDomain domain = new DataDomain("dom1");
+        assertNotNull(domain.getEntityResolver());
+    }
+
+    public void testInitDataDomainWithSharedCache() throws Exception {
+        Map<Object, Object> properties = new HashMap<Object, Object>();
+        properties.put(DataDomain.SHARED_CACHE_ENABLED_PROPERTY, Boolean.TRUE.toString());
+
+        DataDomain domain = new DataDomain("d1", properties);
+        assertTrue(domain.isSharedCacheEnabled());
+    }
+
+    public void testInitDataDomainWithDedicatedCache() throws Exception {
+        Map<Object, Object> properties = new HashMap<Object, Object>();
+        properties.put(DataDomain.SHARED_CACHE_ENABLED_PROPERTY, Boolean.FALSE.toString());
+
+        DataDomain domain = new DataDomain("d1", properties);
+        assertFalse(domain.isSharedCacheEnabled());
+    }
+
+    public void testInitDataDomainValidation() throws Exception {
+        Map<Object, Object> properties = new HashMap<Object, Object>();
+        properties.put(DataDomain.VALIDATING_OBJECTS_ON_COMMIT_PROPERTY, Boolean.TRUE.toString());
+
+        DataDomain domain = new DataDomain("d1", properties);
+        assertTrue(domain.isValidatingObjectsOnCommit());
+    }
+
+    public void testInitDataDomainNoValidation() throws Exception {
+        Map<Object, Object> properties = new HashMap<Object, Object>();
+        properties.put(DataDomain.VALIDATING_OBJECTS_ON_COMMIT_PROPERTY, Boolean.FALSE.toString());
+
+        DataDomain domain = new DataDomain("d1", properties);
+        assertFalse(domain.isValidatingObjectsOnCommit());
+    }
+
+    public void testShutdownCache() {
+        DataDomain domain = new DataDomain("X");
+
+        final boolean[] cacheShutdown = new boolean[1];
+
+        DataRowStore cache = new DataRowStore("Y", Collections.EMPTY_MAP, new DefaultEventManager()) {
+
+            @Override
+            public void shutdown() {
+                cacheShutdown[0] = true;
+            }
+        };
+
+        domain.setSharedSnapshotCache(cache);
+        domain.shutdown();
+
+        assertTrue(cacheShutdown[0]);
+    }
+
+    public void testAddListener() {
+
+        DataDomain domain = runtime.getDataDomain();
+        PostAddListener listener = new PostAddListener();
+        domain.addListener(listener);
+
+        ObjectContext context = runtime.newContext();
+
+        context.newObject(Gallery.class);
+        assertEquals("e:Gallery;", listener.getAndReset());
+
+        context.newObject(Artist.class);
+        assertEquals("a:Artist;", listener.getAndReset());
+
+        context.newObject(Exhibit.class);
+        assertEquals("", listener.getAndReset());
+
+        context.newObject(Painting.class);
+        assertEquals("e:Painting;", listener.getAndReset());
+    }
+
+    class PostAddListener {
+
+        StringBuilder callbackBuffer = new StringBuilder();
+
+        @PostAdd({ Gallery.class, Painting.class })
+        void postAddEntities(Persistent object) {
+            callbackBuffer.append("e:" + object.getObjectId().getEntityName() + ";");
+        }
+
+        @PostAdd(entityAnnotations = Tag1.class)
+        void postAddAnnotated(Persistent object) {
+            callbackBuffer.append("a:" + object.getObjectId().getEntityName() + ";");
+        }
+
+        String getAndReset() {
+            String v = callbackBuffer.toString();
+            callbackBuffer = new StringBuilder();
+            return v;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainQueryActionIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainQueryActionIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainQueryActionIT.java
new file mode 100644
index 0000000..5e053a1
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainQueryActionIT.java
@@ -0,0 +1,109 @@
+/*****************************************************************
+ *   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.cache.MockQueryCache;
+import org.apache.cayenne.cache.QueryCache;
+import org.apache.cayenne.cache.QueryCacheEntryFactory;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.QueryCacheStrategy;
+import org.apache.cayenne.query.QueryMetadata;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.SortOrder;
+import org.apache.cayenne.test.jdbc.DBHelper;
+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.io.Serializable;
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataDomainQueryActionIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    public 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");
+    }
+
+    @Override
+    public void tearDownBeforeInjection() {
+        runtime.getDataDomain().resetProperties();
+    }
+
+    public void testCachedQuery() {
+
+        DataDomain domain = runtime.getDataDomain();
+
+        Painting p = context.newObject(Painting.class);
+        p.setPaintingTitle("sample");
+
+        SelectQuery query = new SelectQuery(Painting.class);
+
+        query.addPrefetch(Painting.TO_GALLERY_PROPERTY);
+        query.addPrefetch(Painting.TO_ARTIST_PROPERTY);
+        query.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
+        query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+        query.setPageSize(5);
+
+        QueryCache cache = domain.queryCache;
+
+        domain.queryCache = new MockQueryCache() {
+
+            @Override
+            public List<?> get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
+                Object results = factory.createObject();
+                assertTrue(
+                        "Query cache is not serializable.",
+                        results instanceof Serializable);
+
+                return null;
+            }
+
+            @SuppressWarnings("all")
+            @Override
+            public void put(QueryMetadata metadata, List results) {
+                assertTrue(
+                        "Query cache is not serializable.",
+                        results instanceof Serializable);
+            }
+        };
+
+        DataDomainQueryAction action = new DataDomainQueryAction(context, domain, query);
+        action.execute();
+
+        domain.queryCache = cache;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java
deleted file mode 100644
index 6303af0..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java
+++ /dev/null
@@ -1,109 +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.io.Serializable;
-import java.util.List;
-
-import org.apache.cayenne.cache.MockQueryCache;
-import org.apache.cayenne.cache.QueryCache;
-import org.apache.cayenne.cache.QueryCacheEntryFactory;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.QueryCacheStrategy;
-import org.apache.cayenne.query.QueryMetadata;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.query.SortOrder;
-import org.apache.cayenne.test.jdbc.DBHelper;
-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 DataDomainQueryActionTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    @Override
-    public 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");
-    }
-
-    @Override
-    public void tearDownBeforeInjection() {
-        runtime.getDataDomain().resetProperties();
-    }
-
-    public void testCachedQuery() {
-
-        DataDomain domain = runtime.getDataDomain();
-
-        Painting p = context.newObject(Painting.class);
-        p.setPaintingTitle("sample");
-
-        SelectQuery query = new SelectQuery(Painting.class);
-
-        query.addPrefetch(Painting.TO_GALLERY_PROPERTY);
-        query.addPrefetch(Painting.TO_ARTIST_PROPERTY);
-        query.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
-        query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
-        query.setPageSize(5);
-
-        QueryCache cache = domain.queryCache;
-
-        domain.queryCache = new MockQueryCache() {
-
-            @Override
-            public List<?> get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
-                Object results = factory.createObject();
-                assertTrue(
-                        "Query cache is not serializable.",
-                        results instanceof Serializable);
-
-                return null;
-            }
-
-            @SuppressWarnings("all")
-            @Override
-            public void put(QueryMetadata metadata, List results) {
-                assertTrue(
-                        "Query cache is not serializable.",
-                        results instanceof Serializable);
-            }
-        };
-
-        DataDomainQueryAction action = new DataDomainQueryAction(context, domain, query);
-        action.execute();
-
-        domain.queryCache = cache;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainTest.java
deleted file mode 100644
index 666931f..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataDomainTest.java
+++ /dev/null
@@ -1,256 +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.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.Persistent;
-import org.apache.cayenne.annotation.PostAdd;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.event.DefaultEventManager;
-import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.testdo.testmap.Exhibit;
-import org.apache.cayenne.testdo.testmap.Gallery;
-import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.testdo.testmap.annotations.Tag1;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataDomainTest extends ServerCase {
-
-    @Inject
-    private ServerRuntime runtime;
-
-    @Inject
-    private JdbcEventLogger logger;
-
-    public void testName() throws Exception {
-        DataDomain domain = new DataDomain("some name");
-        assertEquals("some name", domain.getName());
-        domain.setName("tst_name");
-        assertEquals("tst_name", domain.getName());
-    }
-
-    public void testLookupDataNode() {
-
-        DataDomain domain = new DataDomain("test");
-
-        DataMap m1 = new DataMap("m1");
-        DataNode n1 = new DataNode("n1");
-        n1.addDataMap(m1);
-        domain.addNode(n1);
-
-        DataMap m2 = new DataMap("m2");
-        DataNode n2 = new DataNode("n2");
-        n2.addDataMap(m2);
-        domain.addNode(n2);
-
-        assertSame(n1, domain.lookupDataNode(m1));
-        assertSame(n2, domain.lookupDataNode(m2));
-
-        try {
-
-            domain.lookupDataNode(new DataMap("m3"));
-            fail("must have thrown on missing Map to Node maping");
-        } catch (CayenneRuntimeException e) {
-            // expected
-        }
-    }
-
-    public void testLookupDataNode_Default() {
-
-        DataDomain domain = new DataDomain("test");
-
-        DataMap m1 = new DataMap("m1");
-        DataNode n1 = new DataNode("n1");
-        n1.addDataMap(m1);
-        domain.setDefaultNode(n1);
-
-        DataMap m2 = new DataMap("m2");
-        DataNode n2 = new DataNode("n2");
-        n2.addDataMap(m2);
-        domain.addNode(n2);
-
-        assertSame(n1, domain.lookupDataNode(m1));
-        assertSame(n2, domain.lookupDataNode(m2));
-
-        // must map to default
-        assertSame(n1, domain.lookupDataNode(new DataMap("m3")));
-    }
-
-    public void testNodes() throws Exception {
-        DataDomain domain = new DataDomain("dom1");
-        assertEquals(0, domain.getDataNodes().size());
-        DataNode node = new DataNode("1");
-        node.setJdbcEventLogger(logger);
-        domain.addNode(node);
-        assertEquals(1, domain.getDataNodes().size());
-        node = new DataNode("2");
-        node.setJdbcEventLogger(logger);
-        domain.addNode(node);
-        assertEquals(2, domain.getDataNodes().size());
-    }
-
-    public void testNodeMaps() throws Exception {
-        DataDomain domain = new DataDomain("dom1");
-        assertNull(domain.getDataMap("map"));
-
-        DataNode node = new DataNode("1");
-        node.setJdbcEventLogger(logger);
-        node.addDataMap(new DataMap("map"));
-
-        domain.addNode(node);
-        assertNotNull(domain.getDataMap("map"));
-    }
-
-    public void testMaps() throws Exception {
-        DataDomain d1 = new DataDomain("dom1");
-
-        DataMap m1 = new DataMap("m1");
-        d1.addDataMap(m1);
-        assertSame(m1, d1.getDataMap(m1.getName()));
-
-        d1.removeDataMap(m1.getName());
-        assertNull(d1.getDataMap(m1.getName()));
-    }
-
-    public void testEntityResolverRefresh() throws Exception {
-        DataDomain domain = new DataDomain("dom1");
-        org.apache.cayenne.map.EntityResolver resolver = domain.getEntityResolver();
-        assertNotNull(resolver);
-
-        DataMap map = new DataMap("map");
-        ObjEntity entity = new ObjEntity("TestEntity");
-        map.addObjEntity(entity);
-
-        domain.addDataMap(map);
-
-        assertSame(entity, resolver.getObjEntity("TestEntity"));
-    }
-
-    public void testEntityResolver() {
-        assertNotNull(runtime.getDataDomain().getEntityResolver());
-
-        DataDomain domain = new DataDomain("dom1");
-        assertNotNull(domain.getEntityResolver());
-    }
-
-    public void testInitDataDomainWithSharedCache() throws Exception {
-        Map<Object, Object> properties = new HashMap<Object, Object>();
-        properties.put(DataDomain.SHARED_CACHE_ENABLED_PROPERTY, Boolean.TRUE.toString());
-
-        DataDomain domain = new DataDomain("d1", properties);
-        assertTrue(domain.isSharedCacheEnabled());
-    }
-
-    public void testInitDataDomainWithDedicatedCache() throws Exception {
-        Map<Object, Object> properties = new HashMap<Object, Object>();
-        properties.put(DataDomain.SHARED_CACHE_ENABLED_PROPERTY, Boolean.FALSE.toString());
-
-        DataDomain domain = new DataDomain("d1", properties);
-        assertFalse(domain.isSharedCacheEnabled());
-    }
-
-    public void testInitDataDomainValidation() throws Exception {
-        Map<Object, Object> properties = new HashMap<Object, Object>();
-        properties.put(DataDomain.VALIDATING_OBJECTS_ON_COMMIT_PROPERTY, Boolean.TRUE.toString());
-
-        DataDomain domain = new DataDomain("d1", properties);
-        assertTrue(domain.isValidatingObjectsOnCommit());
-    }
-
-    public void testInitDataDomainNoValidation() throws Exception {
-        Map<Object, Object> properties = new HashMap<Object, Object>();
-        properties.put(DataDomain.VALIDATING_OBJECTS_ON_COMMIT_PROPERTY, Boolean.FALSE.toString());
-
-        DataDomain domain = new DataDomain("d1", properties);
-        assertFalse(domain.isValidatingObjectsOnCommit());
-    }
-
-    public void testShutdownCache() {
-        DataDomain domain = new DataDomain("X");
-
-        final boolean[] cacheShutdown = new boolean[1];
-
-        DataRowStore cache = new DataRowStore("Y", Collections.EMPTY_MAP, new DefaultEventManager()) {
-
-            @Override
-            public void shutdown() {
-                cacheShutdown[0] = true;
-            }
-        };
-
-        domain.setSharedSnapshotCache(cache);
-        domain.shutdown();
-
-        assertTrue(cacheShutdown[0]);
-    }
-
-    public void testAddListener() {
-
-        DataDomain domain = runtime.getDataDomain();
-        PostAddListener listener = new PostAddListener();
-        domain.addListener(listener);
-
-        ObjectContext context = runtime.newContext();
-
-        context.newObject(Gallery.class);
-        assertEquals("e:Gallery;", listener.getAndReset());
-
-        context.newObject(Artist.class);
-        assertEquals("a:Artist;", listener.getAndReset());
-
-        context.newObject(Exhibit.class);
-        assertEquals("", listener.getAndReset());
-
-        context.newObject(Painting.class);
-        assertEquals("e:Painting;", listener.getAndReset());
-    }
-
-    class PostAddListener {
-
-        StringBuilder callbackBuffer = new StringBuilder();
-
-        @PostAdd({ Gallery.class, Painting.class })
-        void postAddEntities(Persistent object) {
-            callbackBuffer.append("e:" + object.getObjectId().getEntityName() + ";");
-        }
-
-        @PostAdd(entityAnnotations = Tag1.class)
-        void postAddAnnotated(Persistent object) {
-            callbackBuffer.append("a:" + object.getObjectId().getEntityName() + ";");
-        }
-
-        String getAndReset() {
-            String v = callbackBuffer.toString();
-            callbackBuffer = new StringBuilder();
-            return v;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeIT.java
new file mode 100644
index 0000000..86b4005
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeIT.java
@@ -0,0 +1,86 @@
+/*****************************************************************
+ *   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.dba.JdbcAdapter;
+import org.apache.cayenne.di.AdhocObjectFactory;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataNodeIT extends ServerCase {
+    
+    @Inject
+    private AdhocObjectFactory objectFactory;
+
+    public void testName() throws Exception {
+        String tstName = "tst_name";
+        DataNode node = new DataNode();
+        assertNull(node.getName());
+        node.setName(tstName);
+        assertEquals(tstName, node.getName());
+    }
+
+    public void testDataSourceLocation() throws Exception {
+        String tstName = "tst_name";
+        DataNode node = new DataNode();
+        assertNull(node.getDataSourceLocation());
+        node.setDataSourceLocation(tstName);
+        assertEquals(tstName, node.getDataSourceLocation());
+    }
+
+    public void testDataSourceFactory() throws Exception {
+        String tstName = "tst_name";
+        DataNode node = new DataNode();
+        assertNull(node.getDataSourceFactory());
+        node.setDataSourceFactory(tstName);
+        assertEquals(tstName, node.getDataSourceFactory());
+    }
+
+    public void testNodeEntityResolver() {
+        DataNode node = new DataNode();
+        assertNull(node.getEntityResolver());
+
+        org.apache.cayenne.map.EntityResolver resolver = new org.apache.cayenne.map.EntityResolver();
+        node.setEntityResolver(resolver);
+        assertSame(resolver, node.getEntityResolver());
+    }
+
+    public void testAdapter() throws Exception {
+        DataNode node = new DataNode();
+
+        assertNull(node.getAdapter());
+
+        JdbcAdapter a1 = objectFactory.newInstance(
+                JdbcAdapter.class, 
+                JdbcAdapter.class.getName());
+        node.setAdapter(a1);
+
+        assertSame(a1, node.getAdapter());
+
+        JdbcAdapter a2 = objectFactory.newInstance(
+                JdbcAdapter.class, 
+                JdbcAdapter.class.getName());
+        node.setAdapter(a2);
+
+        assertSame(a2, node.getAdapter());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeQueriesIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeQueriesIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeQueriesIT.java
new file mode 100644
index 0000000..bfe476a
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeQueriesIT.java
@@ -0,0 +1,189 @@
+/*****************************************************************
+ *   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.DataRow;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.query.Query;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+import org.apache.cayenne.unit.util.SQLTemplateCustomizer;
+
+import java.sql.Date;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataNodeQueriesIT extends ServerCase {
+
+    @Inject
+    protected DataNode node;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    @Inject
+    protected SQLTemplateCustomizer sqlTemplateCustomizer;
+
+    protected TableHelper tArtist;
+
+    @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");
+    }
+
+    protected void createFourArtists() throws Exception {
+        tArtist.insert(11, "artist2");
+        tArtist.insert(101, "artist3");
+        tArtist.insert(201, "artist4");
+        tArtist.insert(3001, "artist5");
+    }
+
+    public void testCreatePkSupportForMapEntities() throws Exception {
+
+        DbEntity artistEnt = node.getEntityResolver().getDbEntity("ARTIST");
+        assertNotNull(node.getAdapter().getPkGenerator().generatePk(
+                node,
+                artistEnt.getPrimaryKeys().iterator().next()));
+
+        DbEntity exhibitEnt = node.getEntityResolver().getDbEntity("EXHIBIT");
+        assertNotNull(node.getAdapter().getPkGenerator().generatePk(
+                node,
+                exhibitEnt.getPrimaryKeys().iterator().next()));
+    }
+
+    public void testPerfomQueriesSQLTemplate() throws Exception {
+        String template = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
+                + "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+
+        Map<String, Object> bindings = new HashMap<String, Object>();
+        bindings.put("id", 1l);
+        bindings.put("name", "a1");
+        bindings.put("dob", new Date(System.currentTimeMillis()));
+        query.setParameters(bindings);
+
+        MockOperationObserver observer = new MockOperationObserver();
+        node.performQueries(Collections.singletonList((Query) query), observer);
+        assertNotNull(observer.countsForQuery(query));
+        assertEquals(1, observer.countsForQuery(query)[0]);
+
+        // check the data
+
+        assertEquals(1, tArtist.getRowCount());
+        assertEquals(1l, tArtist.getLong("ARTIST_ID"));
+        assertEquals("a1", tArtist.getString("ARTIST_NAME").trim());
+    }
+
+    public void testPerfomQueriesSelectingSQLTemplate1() throws Exception {
+        createFourArtists();
+
+        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+
+        MockOperationObserver observer = new MockOperationObserver();
+        node.performQueries(Collections.singletonList((Query) query), observer);
+
+        List<DataRow> data = observer.rowsForQuery(query);
+        assertEquals(4, data.size());
+        DataRow row = data.get(2);
+        assertEquals(1, row.size());
+        assertEquals(201, row.get("ARTIST_ID"));
+    }
+
+    public void testPerfomQueriesSelectingSQLTemplate2() throws Exception {
+        createFourArtists();
+
+        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+        SQLTemplate query = new SQLTemplate(Object.class, template);
+        sqlTemplateCustomizer.updateSQLTemplate(query);
+
+        MockOperationObserver observer = new MockOperationObserver();
+        node.performQueries(Collections.singletonList((Query) query), observer);
+
+        List<DataRow> data = observer.rowsForQuery(query);
+        assertEquals(4, data.size());
+        DataRow row = data.get(2);
+        assertEquals(3, row.size());
+
+        Number id = (Number) row.get("ARTIST_ID");
+        assertNotNull(id);
+        assertEquals(201, id.intValue());
+    }
+
+    public void testPerfomQueriesSelectingSQLTemplateAlias() throws Exception {
+        createFourArtists();
+
+        String template = "SELECT #result('ARTIST_ID' 'int' 'A') FROM ARTIST ORDER BY ARTIST_ID";
+        Query query = new SQLTemplate(Object.class, template);
+
+        MockOperationObserver observer = new MockOperationObserver();
+        node.performQueries(Collections.singletonList(query), observer);
+
+        List<DataRow> data = observer.rowsForQuery(query);
+        assertEquals(4, data.size());
+        DataRow row = data.get(2);
+        assertEquals(1, row.size());
+        assertEquals(201, row.get("A"));
+    }
+
+    public void testRunMultiLineSQLTemplateUNIX() throws Exception {
+        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME)"
+                + "\n"
+                + "VALUES (1, 'A')";
+        Query template = new SQLTemplate(Object.class, templateString);
+        node.performQueries(
+                Collections.singletonList(template),
+                new MockOperationObserver());
+    }
+
+    public void testRunMultiLineSQLTemplateWindows() throws Exception {
+        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME)"
+                + "\r\n"
+                + "VALUES (1, 'A')";
+        Query template = new SQLTemplate(Object.class, templateString);
+        node.performQueries(
+                Collections.singletonList(template),
+                new MockOperationObserver());
+    }
+
+    public void testRunMultiLineSQLTemplateMac() throws Exception {
+        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME)"
+                + "\r"
+                + "VALUES (1, 'A')";
+        Query template = new SQLTemplate(Object.class, templateString);
+        node.performQueries(
+                Collections.singletonList(template),
+                new MockOperationObserver());
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeQueriesTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeQueriesTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeQueriesTest.java
deleted file mode 100644
index ba5edd2..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeQueriesTest.java
+++ /dev/null
@@ -1,189 +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.Date;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.apache.cayenne.unit.util.SQLTemplateCustomizer;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataNodeQueriesTest extends ServerCase {
-
-    @Inject
-    protected DataNode node;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    @Inject
-    protected SQLTemplateCustomizer sqlTemplateCustomizer;
-
-    protected TableHelper tArtist;
-
-    @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");
-    }
-
-    protected void createFourArtists() throws Exception {
-        tArtist.insert(11, "artist2");
-        tArtist.insert(101, "artist3");
-        tArtist.insert(201, "artist4");
-        tArtist.insert(3001, "artist5");
-    }
-
-    public void testCreatePkSupportForMapEntities() throws Exception {
-
-        DbEntity artistEnt = node.getEntityResolver().getDbEntity("ARTIST");
-        assertNotNull(node.getAdapter().getPkGenerator().generatePk(
-                node,
-                artistEnt.getPrimaryKeys().iterator().next()));
-
-        DbEntity exhibitEnt = node.getEntityResolver().getDbEntity("EXHIBIT");
-        assertNotNull(node.getAdapter().getPkGenerator().generatePk(
-                node,
-                exhibitEnt.getPrimaryKeys().iterator().next()));
-    }
-
-    public void testPerfomQueriesSQLTemplate() throws Exception {
-        String template = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
-                + "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-
-        Map<String, Object> bindings = new HashMap<String, Object>();
-        bindings.put("id", 1l);
-        bindings.put("name", "a1");
-        bindings.put("dob", new Date(System.currentTimeMillis()));
-        query.setParameters(bindings);
-
-        MockOperationObserver observer = new MockOperationObserver();
-        node.performQueries(Collections.singletonList((Query) query), observer);
-        assertNotNull(observer.countsForQuery(query));
-        assertEquals(1, observer.countsForQuery(query)[0]);
-
-        // check the data
-
-        assertEquals(1, tArtist.getRowCount());
-        assertEquals(1l, tArtist.getLong("ARTIST_ID"));
-        assertEquals("a1", tArtist.getString("ARTIST_NAME").trim());
-    }
-
-    public void testPerfomQueriesSelectingSQLTemplate1() throws Exception {
-        createFourArtists();
-
-        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-
-        MockOperationObserver observer = new MockOperationObserver();
-        node.performQueries(Collections.singletonList((Query) query), observer);
-
-        List<DataRow> data = observer.rowsForQuery(query);
-        assertEquals(4, data.size());
-        DataRow row = data.get(2);
-        assertEquals(1, row.size());
-        assertEquals(201, row.get("ARTIST_ID"));
-    }
-
-    public void testPerfomQueriesSelectingSQLTemplate2() throws Exception {
-        createFourArtists();
-
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = new SQLTemplate(Object.class, template);
-        sqlTemplateCustomizer.updateSQLTemplate(query);
-
-        MockOperationObserver observer = new MockOperationObserver();
-        node.performQueries(Collections.singletonList((Query) query), observer);
-
-        List<DataRow> data = observer.rowsForQuery(query);
-        assertEquals(4, data.size());
-        DataRow row = data.get(2);
-        assertEquals(3, row.size());
-
-        Number id = (Number) row.get("ARTIST_ID");
-        assertNotNull(id);
-        assertEquals(201, id.intValue());
-    }
-
-    public void testPerfomQueriesSelectingSQLTemplateAlias() throws Exception {
-        createFourArtists();
-
-        String template = "SELECT #result('ARTIST_ID' 'int' 'A') FROM ARTIST ORDER BY ARTIST_ID";
-        Query query = new SQLTemplate(Object.class, template);
-
-        MockOperationObserver observer = new MockOperationObserver();
-        node.performQueries(Collections.singletonList(query), observer);
-
-        List<DataRow> data = observer.rowsForQuery(query);
-        assertEquals(4, data.size());
-        DataRow row = data.get(2);
-        assertEquals(1, row.size());
-        assertEquals(201, row.get("A"));
-    }
-
-    public void testRunMultiLineSQLTemplateUNIX() throws Exception {
-        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME)"
-                + "\n"
-                + "VALUES (1, 'A')";
-        Query template = new SQLTemplate(Object.class, templateString);
-        node.performQueries(
-                Collections.singletonList(template),
-                new MockOperationObserver());
-    }
-
-    public void testRunMultiLineSQLTemplateWindows() throws Exception {
-        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME)"
-                + "\r\n"
-                + "VALUES (1, 'A')";
-        Query template = new SQLTemplate(Object.class, templateString);
-        node.performQueries(
-                Collections.singletonList(template),
-                new MockOperationObserver());
-    }
-
-    public void testRunMultiLineSQLTemplateMac() throws Exception {
-        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME)"
-                + "\r"
-                + "VALUES (1, 'A')";
-        Query template = new SQLTemplate(Object.class, templateString);
-        node.performQueries(
-                Collections.singletonList(template),
-                new MockOperationObserver());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeTest.java
deleted file mode 100644
index 315ccf3..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataNodeTest.java
+++ /dev/null
@@ -1,88 +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 junit.framework.TestCase;
-
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.di.AdhocObjectFactory;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataNodeTest extends ServerCase {
-    
-    @Inject
-    private AdhocObjectFactory objectFactory;
-
-    public void testName() throws Exception {
-        String tstName = "tst_name";
-        DataNode node = new DataNode();
-        assertNull(node.getName());
-        node.setName(tstName);
-        assertEquals(tstName, node.getName());
-    }
-
-    public void testDataSourceLocation() throws Exception {
-        String tstName = "tst_name";
-        DataNode node = new DataNode();
-        assertNull(node.getDataSourceLocation());
-        node.setDataSourceLocation(tstName);
-        assertEquals(tstName, node.getDataSourceLocation());
-    }
-
-    public void testDataSourceFactory() throws Exception {
-        String tstName = "tst_name";
-        DataNode node = new DataNode();
-        assertNull(node.getDataSourceFactory());
-        node.setDataSourceFactory(tstName);
-        assertEquals(tstName, node.getDataSourceFactory());
-    }
-
-    public void testNodeEntityResolver() {
-        DataNode node = new DataNode();
-        assertNull(node.getEntityResolver());
-
-        org.apache.cayenne.map.EntityResolver resolver = new org.apache.cayenne.map.EntityResolver();
-        node.setEntityResolver(resolver);
-        assertSame(resolver, node.getEntityResolver());
-    }
-
-    public void testAdapter() throws Exception {
-        DataNode node = new DataNode();
-
-        assertNull(node.getAdapter());
-
-        JdbcAdapter a1 = objectFactory.newInstance(
-                JdbcAdapter.class, 
-                JdbcAdapter.class.getName());
-        node.setAdapter(a1);
-
-        assertSame(a1, node.getAdapter());
-
-        JdbcAdapter a2 = objectFactory.newInstance(
-                JdbcAdapter.class, 
-                JdbcAdapter.class.getName());
-        node.setAdapter(a2);
-
-        assertSame(a2, node.getAdapter());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowStoreIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowStoreIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowStoreIT.java
new file mode 100644
index 0000000..306b678
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowStoreIT.java
@@ -0,0 +1,131 @@
+/*****************************************************************
+ *   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.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.event.DefaultEventManager;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataRowStoreIT extends ServerCase {
+
+    public void testDefaultConstructor() {
+        DataRowStore cache = new DataRowStore(
+                "cacheXYZ",
+                Collections.EMPTY_MAP,
+                new DefaultEventManager());
+        assertEquals("cacheXYZ", cache.getName());
+        assertNotNull(cache.getSnapshotEventSubject());
+        assertTrue(cache.getSnapshotEventSubject().getSubjectName().contains("cacheXYZ"));
+
+        assertEquals(DataRowStore.REMOTE_NOTIFICATION_DEFAULT, cache
+                .isNotifyingRemoteListeners());
+    }
+
+    public void testConstructorWithProperties() {
+        Map<Object, Object> props = new HashMap<Object, Object>();
+        props.put(DataRowStore.REMOTE_NOTIFICATION_PROPERTY, String
+                .valueOf(!DataRowStore.REMOTE_NOTIFICATION_DEFAULT));
+
+        DataRowStore cache = new DataRowStore(
+                "cacheXYZ",
+                props,
+                new DefaultEventManager());
+        assertEquals("cacheXYZ", cache.getName());
+        assertEquals(!DataRowStore.REMOTE_NOTIFICATION_DEFAULT, cache
+                .isNotifyingRemoteListeners());
+    }
+
+    public void testNotifyingRemoteListeners() {
+        DataRowStore cache = new DataRowStore(
+                "cacheXYZ",
+                Collections.EMPTY_MAP,
+                new DefaultEventManager());
+
+        assertEquals(DataRowStore.REMOTE_NOTIFICATION_DEFAULT, cache
+                .isNotifyingRemoteListeners());
+
+        cache.setNotifyingRemoteListeners(!DataRowStore.REMOTE_NOTIFICATION_DEFAULT);
+        assertEquals(!DataRowStore.REMOTE_NOTIFICATION_DEFAULT, cache
+                .isNotifyingRemoteListeners());
+    }
+
+    /**
+     * Tests LRU cache behavior.
+     */
+    public void testMaxSize() throws Exception {
+        Map<Object, Object> props = new HashMap<Object, Object>();
+        props.put(DataRowStore.SNAPSHOT_CACHE_SIZE_PROPERTY, String.valueOf(2));
+
+        DataRowStore cache = new DataRowStore(
+                "cacheXYZ",
+                props,
+                new DefaultEventManager());
+        assertEquals(2, cache.maximumSize());
+        assertEquals(0, cache.size());
+
+        ObjectId key1 = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 1);
+        Map<Object, Object> diff1 = new HashMap<Object, Object>();
+        diff1.put(key1, new DataRow(1));
+
+        ObjectId key2 = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 2);
+        Map<Object, Object> diff2 = new HashMap<Object, Object>();
+        diff2.put(key2, new DataRow(1));
+
+        ObjectId key3 = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 3);
+        Map<Object, Object> diff3 = new HashMap<Object, Object>();
+        diff3.put(key3, new DataRow(1));
+
+        cache.processSnapshotChanges(
+                this,
+                diff1,
+                Collections.EMPTY_LIST,
+                Collections.EMPTY_LIST,
+                Collections.EMPTY_LIST);
+        assertEquals(1, cache.size());
+
+        cache.processSnapshotChanges(
+                this,
+                diff2,
+                Collections.EMPTY_LIST,
+                Collections.EMPTY_LIST,
+                Collections.EMPTY_LIST);
+        assertEquals(2, cache.size());
+
+        // this addition must overflow the cache, and throw out the first item
+        cache.processSnapshotChanges(
+                this,
+                diff3,
+                Collections.EMPTY_LIST,
+                Collections.EMPTY_LIST,
+                Collections.EMPTY_LIST);
+        assertEquals(2, cache.size());
+        assertNotNull(cache.getCachedSnapshot(key2));
+        assertNotNull(cache.getCachedSnapshot(key3));
+        assertNull(cache.getCachedSnapshot(key1));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowStoreTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowStoreTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowStoreTest.java
deleted file mode 100644
index 7a51657..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowStoreTest.java
+++ /dev/null
@@ -1,131 +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.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.event.DefaultEventManager;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DataRowStoreTest extends ServerCase {
-
-    public void testDefaultConstructor() {
-        DataRowStore cache = new DataRowStore(
-                "cacheXYZ",
-                Collections.EMPTY_MAP,
-                new DefaultEventManager());
-        assertEquals("cacheXYZ", cache.getName());
-        assertNotNull(cache.getSnapshotEventSubject());
-        assertTrue(cache.getSnapshotEventSubject().getSubjectName().contains("cacheXYZ"));
-
-        assertEquals(DataRowStore.REMOTE_NOTIFICATION_DEFAULT, cache
-                .isNotifyingRemoteListeners());
-    }
-
-    public void testConstructorWithProperties() {
-        Map<Object, Object> props = new HashMap<Object, Object>();
-        props.put(DataRowStore.REMOTE_NOTIFICATION_PROPERTY, String
-                .valueOf(!DataRowStore.REMOTE_NOTIFICATION_DEFAULT));
-
-        DataRowStore cache = new DataRowStore(
-                "cacheXYZ",
-                props,
-                new DefaultEventManager());
-        assertEquals("cacheXYZ", cache.getName());
-        assertEquals(!DataRowStore.REMOTE_NOTIFICATION_DEFAULT, cache
-                .isNotifyingRemoteListeners());
-    }
-
-    public void testNotifyingRemoteListeners() {
-        DataRowStore cache = new DataRowStore(
-                "cacheXYZ",
-                Collections.EMPTY_MAP,
-                new DefaultEventManager());
-
-        assertEquals(DataRowStore.REMOTE_NOTIFICATION_DEFAULT, cache
-                .isNotifyingRemoteListeners());
-
-        cache.setNotifyingRemoteListeners(!DataRowStore.REMOTE_NOTIFICATION_DEFAULT);
-        assertEquals(!DataRowStore.REMOTE_NOTIFICATION_DEFAULT, cache
-                .isNotifyingRemoteListeners());
-    }
-
-    /**
-     * Tests LRU cache behavior.
-     */
-    public void testMaxSize() throws Exception {
-        Map<Object, Object> props = new HashMap<Object, Object>();
-        props.put(DataRowStore.SNAPSHOT_CACHE_SIZE_PROPERTY, String.valueOf(2));
-
-        DataRowStore cache = new DataRowStore(
-                "cacheXYZ",
-                props,
-                new DefaultEventManager());
-        assertEquals(2, cache.maximumSize());
-        assertEquals(0, cache.size());
-
-        ObjectId key1 = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 1);
-        Map<Object, Object> diff1 = new HashMap<Object, Object>();
-        diff1.put(key1, new DataRow(1));
-
-        ObjectId key2 = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 2);
-        Map<Object, Object> diff2 = new HashMap<Object, Object>();
-        diff2.put(key2, new DataRow(1));
-
-        ObjectId key3 = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 3);
-        Map<Object, Object> diff3 = new HashMap<Object, Object>();
-        diff3.put(key3, new DataRow(1));
-
-        cache.processSnapshotChanges(
-                this,
-                diff1,
-                Collections.EMPTY_LIST,
-                Collections.EMPTY_LIST,
-                Collections.EMPTY_LIST);
-        assertEquals(1, cache.size());
-
-        cache.processSnapshotChanges(
-                this,
-                diff2,
-                Collections.EMPTY_LIST,
-                Collections.EMPTY_LIST,
-                Collections.EMPTY_LIST);
-        assertEquals(2, cache.size());
-
-        // this addition must overflow the cache, and throw out the first item
-        cache.processSnapshotChanges(
-                this,
-                diff3,
-                Collections.EMPTY_LIST,
-                Collections.EMPTY_LIST,
-                Collections.EMPTY_LIST);
-        assertEquals(2, cache.size());
-        assertNotNull(cache.getCachedSnapshot(key2));
-        assertNotNull(cache.getCachedSnapshot(key3));
-        assertNull(cache.getCachedSnapshot(key1));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowUtilsIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowUtilsIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowUtilsIT.java
new file mode 100644
index 0000000..7d9c18d
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowUtilsIT.java
@@ -0,0 +1,152 @@
+/*****************************************************************
+ *   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.DataRow;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.reflect.ArcProperty;
+import org.apache.cayenne.reflect.ClassDescriptor;
+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.Gallery;
+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 DataRowUtilsIT extends ServerCase {
+
+    @Inject
+    protected DataContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    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");
+    }
+
+    protected void createOneArtist() throws Exception {
+        tArtist.insert(11, "artist2");
+    }
+
+    protected void createOneArtistAndOnePainting() throws Exception {
+        tArtist.insert(11, "artist2");
+        tPainting.insert(6, "p_artist2", 11, 1000);
+    }
+
+    public void testMerge() throws Exception {
+        createOneArtist();
+
+        String n1 = "changed";
+        String n2 = "changed again";
+
+        SelectQuery artistQ = new SelectQuery(Artist.class);
+        Artist a1 = (Artist) context.performQuery(artistQ).get(0);
+        a1.setArtistName(n1);
+
+        DataRow s2 = new DataRow(2);
+        s2.put("ARTIST_NAME", n2);
+        s2.put("DATE_OF_BIRTH", new java.util.Date());
+
+        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Artist");
+        DataRowUtils.mergeObjectWithSnapshot(context, d, a1, s2);
+
+        // name was modified, so it should not change during merge
+        assertEquals(n1, a1.getArtistName());
+
+        // date of birth came from database, it should be updated during merge
+        assertEquals(s2.get("DATE_OF_BIRTH"), a1.getDateOfBirth());
+    }
+
+    public void testIsToOneTargetModified() throws Exception {
+        createOneArtist();
+
+        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Painting");
+        ArcProperty toArtist = (ArcProperty) d.getProperty("toArtist");
+
+        Artist artist2 = (Artist) context
+                .performQuery(new SelectQuery(Artist.class))
+                .get(0);
+        Painting painting = context.newObject(Painting.class);
+        painting.setPaintingTitle("PX");
+        painting.setToArtist(artist2);
+
+        context.commitChanges();
+
+        tArtist.insert(119, "artist3");
+        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(
+                Artist.ARTIST_NAME_PROPERTY,
+                "artist3"));
+        Artist artist3 = (Artist) context.performQuery(query).get(0);
+        assertNotSame(artist3, painting.getToArtist());
+
+        ObjectDiff diff = context.getObjectStore().registerDiff(
+                painting.getObjectId(),
+                null);
+
+        assertFalse(DataRowUtils.isToOneTargetModified(toArtist, painting, diff));
+
+        painting.setToArtist(artist3);
+        assertTrue(DataRowUtils.isToOneTargetModified(toArtist, painting, diff));
+    }
+
+    public void testIsToOneTargetModifiedWithNewTarget() throws Exception {
+        createOneArtistAndOnePainting();
+
+        // add NEW gallery to painting
+        List<Painting> paintings = context.performQuery(new SelectQuery(Painting.class));
+        assertEquals(1, paintings.size());
+        Painting p1 = paintings.get(0);
+
+        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Painting");
+        ArcProperty toGallery = (ArcProperty) d.getProperty("toGallery");
+
+        ObjectDiff diff = context.getObjectStore().registerDiff(p1.getObjectId(), null);
+        assertFalse(DataRowUtils.isToOneTargetModified(toGallery, p1, diff));
+
+        Gallery g1 = (Gallery) context.newObject("Gallery");
+        g1.addToPaintingArray(p1);
+        assertTrue(DataRowUtils.isToOneTargetModified(toGallery, p1, diff));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowUtilsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowUtilsTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowUtilsTest.java
deleted file mode 100644
index 1cc2d8a..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataRowUtilsTest.java
+++ /dev/null
@@ -1,152 +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.DataRow;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.reflect.ArcProperty;
-import org.apache.cayenne.reflect.ClassDescriptor;
-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.Gallery;
-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 DataRowUtilsTest extends ServerCase {
-
-    @Inject
-    protected DataContext context;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    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");
-    }
-
-    protected void createOneArtist() throws Exception {
-        tArtist.insert(11, "artist2");
-    }
-
-    protected void createOneArtistAndOnePainting() throws Exception {
-        tArtist.insert(11, "artist2");
-        tPainting.insert(6, "p_artist2", 11, 1000);
-    }
-
-    public void testMerge() throws Exception {
-        createOneArtist();
-
-        String n1 = "changed";
-        String n2 = "changed again";
-
-        SelectQuery artistQ = new SelectQuery(Artist.class);
-        Artist a1 = (Artist) context.performQuery(artistQ).get(0);
-        a1.setArtistName(n1);
-
-        DataRow s2 = new DataRow(2);
-        s2.put("ARTIST_NAME", n2);
-        s2.put("DATE_OF_BIRTH", new java.util.Date());
-
-        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Artist");
-        DataRowUtils.mergeObjectWithSnapshot(context, d, a1, s2);
-
-        // name was modified, so it should not change during merge
-        assertEquals(n1, a1.getArtistName());
-
-        // date of birth came from database, it should be updated during merge
-        assertEquals(s2.get("DATE_OF_BIRTH"), a1.getDateOfBirth());
-    }
-
-    public void testIsToOneTargetModified() throws Exception {
-        createOneArtist();
-
-        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Painting");
-        ArcProperty toArtist = (ArcProperty) d.getProperty("toArtist");
-
-        Artist artist2 = (Artist) context
-                .performQuery(new SelectQuery(Artist.class))
-                .get(0);
-        Painting painting = context.newObject(Painting.class);
-        painting.setPaintingTitle("PX");
-        painting.setToArtist(artist2);
-
-        context.commitChanges();
-
-        tArtist.insert(119, "artist3");
-        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(
-                Artist.ARTIST_NAME_PROPERTY,
-                "artist3"));
-        Artist artist3 = (Artist) context.performQuery(query).get(0);
-        assertNotSame(artist3, painting.getToArtist());
-
-        ObjectDiff diff = context.getObjectStore().registerDiff(
-                painting.getObjectId(),
-                null);
-
-        assertFalse(DataRowUtils.isToOneTargetModified(toArtist, painting, diff));
-
-        painting.setToArtist(artist3);
-        assertTrue(DataRowUtils.isToOneTargetModified(toArtist, painting, diff));
-    }
-
-    public void testIsToOneTargetModifiedWithNewTarget() throws Exception {
-        createOneArtistAndOnePainting();
-
-        // add NEW gallery to painting
-        List<Painting> paintings = context.performQuery(new SelectQuery(Painting.class));
-        assertEquals(1, paintings.size());
-        Painting p1 = paintings.get(0);
-
-        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Painting");
-        ArcProperty toGallery = (ArcProperty) d.getProperty("toGallery");
-
-        ObjectDiff diff = context.getObjectStore().registerDiff(p1.getObjectId(), null);
-        assertFalse(DataRowUtils.isToOneTargetModified(toGallery, p1, diff));
-
-        Gallery g1 = (Gallery) context.newObject("Gallery");
-        g1.addToPaintingArray(p1);
-        assertTrue(DataRowUtils.isToOneTargetModified(toGallery, p1, diff));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/DateTimeTypesIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DateTimeTypesIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DateTimeTypesIT.java
new file mode 100644
index 0000000..2e01bd1
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DateTimeTypesIT.java
@@ -0,0 +1,197 @@
+/*****************************************************************
+ *   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.DataRow;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.NamedQuery;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.testdo.testmap.CalendarEntity;
+import org.apache.cayenne.testdo.testmap.DateTestEntity;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Time;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * Tests Date handling in Cayenne.
+ */
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DateTimeTypesIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("CALENDAR_TEST");
+        dbHelper.deleteAll("DATE_TEST");
+    }
+
+    public void testCalendar() throws Exception {
+
+        CalendarEntity test = context.newObject(CalendarEntity.class);
+
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2002, 1, 1);
+
+        test.setCalendarField(cal);
+        context.commitChanges();
+
+        SelectQuery q = new SelectQuery(CalendarEntity.class);
+        CalendarEntity testRead = (CalendarEntity) context.performQuery(q).get(0);
+        assertNotNull(testRead.getCalendarField());
+        assertEquals(cal, testRead.getCalendarField());
+
+        test.setCalendarField(null);
+        context.commitChanges();
+    }
+
+    public void testDate() throws Exception {
+        DateTestEntity test = context.newObject(DateTestEntity.class);
+
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2002, 1, 1);
+        Date nowDate = cal.getTime();
+        test.setDateColumn(nowDate);
+        context.commitChanges();
+
+        SelectQuery q = new SelectQuery(DateTestEntity.class);
+        DateTestEntity testRead = (DateTestEntity) context.performQuery(q).get(0);
+        assertNotNull(testRead.getDateColumn());
+        assertEquals(nowDate, testRead.getDateColumn());
+        assertEquals(Date.class, testRead.getDateColumn().getClass());
+    }
+
+    public void testTime() throws Exception {
+        DateTestEntity test = context.newObject(DateTestEntity.class);
+
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(1970, 0, 1, 1, 20, 30);
+        Date nowTime = cal.getTime();
+        test.setTimeColumn(nowTime);
+        context.commitChanges();
+
+        SelectQuery q = new SelectQuery(DateTestEntity.class);
+        DateTestEntity testRead = (DateTestEntity) context.performQuery(q).get(0);
+        assertNotNull(testRead.getTimeColumn());
+        assertEquals(Date.class, testRead.getTimeColumn().getClass());
+
+        // OpenBase fails to store seconds for the time
+        // FrontBase returns time with 1 hour offset (I guess "TIME WITH TIMEZONE" may
+        // need to be used as a default FB type?)
+        // so this test is approximate...
+
+        long delta = nowTime.getTime() - testRead.getTimeColumn().getTime();
+        assertTrue("" + delta, Math.abs(delta) <= 1000 * 60 * 60);
+    }
+
+    public void testTimestamp() throws Exception {
+        DateTestEntity test = context.newObject(DateTestEntity.class);
+
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2003, 1, 1, 1, 20, 30);
+
+        // most databases fail millisecond accuracy
+        // cal.set(Calendar.MILLISECOND, 55);
+
+        Date now = cal.getTime();
+        test.setTimestampColumn(now);
+        context.commitChanges();
+
+        SelectQuery q = new SelectQuery(DateTestEntity.class);
+        DateTestEntity testRead = (DateTestEntity) context.performQuery(q).get(0);
+        assertNotNull(testRead.getTimestampColumn());
+        assertEquals(now, testRead.getTimestampColumn());
+    }
+
+    public void testSQLTemplateTimestamp() throws Exception {
+        DateTestEntity test = context.newObject(DateTestEntity.class);
+
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2003, 1, 1, 1, 20, 30);
+
+        // most databases fail millisecond accuracy
+        // cal.set(Calendar.MILLISECOND, 55);
+
+        Date now = cal.getTime();
+        test.setTimestampColumn(now);
+        context.commitChanges();
+
+        NamedQuery q = new NamedQuery("SelectDateTest");
+        DataRow testRead = (DataRow) context.performQuery(q).get(0);
+        Date columnValue = (Date) testRead.get("TIMESTAMP_COLUMN");
+        assertNotNull(columnValue);
+        assertEquals(now, columnValue);
+    }
+
+    public void testSQLTemplateDate() throws Exception {
+        DateTestEntity test = (DateTestEntity) context.newObject("DateTestEntity");
+
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2003, 1, 1, 1, 20, 30);
+
+        // most databases fail millisecond accuracy
+        // cal.set(Calendar.MILLISECOND, 55);
+
+        java.sql.Date now = new java.sql.Date(cal.getTime().getTime());
+        test.setDateColumn(now);
+        context.commitChanges();
+
+        NamedQuery q = new NamedQuery("SelectDateTest");
+        DataRow testRead = (DataRow) context.performQuery(q).get(0);
+        Date columnValue = (Date) testRead.get("DATE_COLUMN");
+        assertNotNull(columnValue);
+        assertEquals(now.toString(), new java.sql.Date(columnValue.getTime()).toString());
+    }
+
+    public void testSQLTemplateTime() throws Exception {
+        DateTestEntity test = (DateTestEntity) context.newObject("DateTestEntity");
+
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2003, 1, 1, 1, 20, 30);
+
+        // most databases fail millisecond accuracy
+        // cal.set(Calendar.MILLISECOND, 55);
+
+        Time now = new Time(cal.getTime().getTime());
+        test.setTimeColumn(now);
+        context.commitChanges();
+
+        NamedQuery q = new NamedQuery("SelectDateTest");
+        DataRow testRead = (DataRow) context.performQuery(q).get(0);
+        Date columnValue = (Date) testRead.get("TIME_COLUMN");
+        assertNotNull(columnValue);
+        assertEquals(now.toString(), new Time(columnValue.getTime()).toString());
+    }
+}


Mime
View raw message