You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2014/11/02 08:09:50 UTC
[02/48] Installing Maven Failsafe Plugin
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/reflect/generic/DataObjectDescriptorFactory_InheritanceMapsIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/reflect/generic/DataObjectDescriptorFactory_InheritanceMapsIT.java b/cayenne-server/src/test/java/org/apache/cayenne/reflect/generic/DataObjectDescriptorFactory_InheritanceMapsIT.java
new file mode 100644
index 0000000..aba4a61
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/reflect/generic/DataObjectDescriptorFactory_InheritanceMapsIT.java
@@ -0,0 +1,78 @@
+/*****************************************************************
+ * 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.reflect.generic;
+
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.reflect.AttributeProperty;
+import org.apache.cayenne.reflect.ClassDescriptor;
+import org.apache.cayenne.reflect.PropertyDescriptor;
+import org.apache.cayenne.reflect.PropertyVisitor;
+import org.apache.cayenne.reflect.SingletonFaultFactory;
+import org.apache.cayenne.reflect.ToManyProperty;
+import org.apache.cayenne.reflect.ToOneProperty;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.INHERTITANCE_SINGLE_TABLE1_PROJECT)
+public class DataObjectDescriptorFactory_InheritanceMapsIT extends ServerCase {
+
+ @Inject
+ private EntityResolver resolver;
+
+ public void testVisitProperties_IterationOrder() {
+
+ DataObjectDescriptorFactory factory = new DataObjectDescriptorFactory(
+ resolver.getClassDescriptorMap(), new SingletonFaultFactory());
+
+ for (ObjEntity e : resolver.getObjEntities()) {
+ ClassDescriptor descriptor = factory.getDescriptor(e.getName());
+
+ final PropertyDescriptor[] lastProcessed = new PropertyDescriptor[1];
+
+ PropertyVisitor visitor = new PropertyVisitor() {
+
+ public boolean visitToOne(ToOneProperty property) {
+ DataObjectDescriptorFactoryIT.assertPropertiesAreInOrder(
+ lastProcessed[0], property);
+ lastProcessed[0] = property;
+ return true;
+ }
+
+ public boolean visitToMany(ToManyProperty property) {
+ DataObjectDescriptorFactoryIT.assertPropertiesAreInOrder(
+ lastProcessed[0], property);
+ lastProcessed[0] = property;
+ return true;
+ }
+
+ public boolean visitAttribute(AttributeProperty property) {
+ DataObjectDescriptorFactoryIT.assertPropertiesAreInOrder(
+ lastProcessed[0], property);
+ lastProcessed[0] = property;
+ return true;
+ }
+ };
+
+ descriptor.visitProperties(visitor);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/reflect/generic/DataObjectDescriptorFactory_InheritanceMapsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/reflect/generic/DataObjectDescriptorFactory_InheritanceMapsTest.java b/cayenne-server/src/test/java/org/apache/cayenne/reflect/generic/DataObjectDescriptorFactory_InheritanceMapsTest.java
deleted file mode 100644
index cadcdc9..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/reflect/generic/DataObjectDescriptorFactory_InheritanceMapsTest.java
+++ /dev/null
@@ -1,78 +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.reflect.generic;
-
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.reflect.AttributeProperty;
-import org.apache.cayenne.reflect.ClassDescriptor;
-import org.apache.cayenne.reflect.PropertyDescriptor;
-import org.apache.cayenne.reflect.PropertyVisitor;
-import org.apache.cayenne.reflect.SingletonFaultFactory;
-import org.apache.cayenne.reflect.ToManyProperty;
-import org.apache.cayenne.reflect.ToOneProperty;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.INHERTITANCE_SINGLE_TABLE1_PROJECT)
-public class DataObjectDescriptorFactory_InheritanceMapsTest extends ServerCase {
-
- @Inject
- private EntityResolver resolver;
-
- public void testVisitProperties_IterationOrder() {
-
- DataObjectDescriptorFactory factory = new DataObjectDescriptorFactory(
- resolver.getClassDescriptorMap(), new SingletonFaultFactory());
-
- for (ObjEntity e : resolver.getObjEntities()) {
- ClassDescriptor descriptor = factory.getDescriptor(e.getName());
-
- final PropertyDescriptor[] lastProcessed = new PropertyDescriptor[1];
-
- PropertyVisitor visitor = new PropertyVisitor() {
-
- public boolean visitToOne(ToOneProperty property) {
- DataObjectDescriptorFactoryTest.assertPropertiesAreInOrder(
- lastProcessed[0], property);
- lastProcessed[0] = property;
- return true;
- }
-
- public boolean visitToMany(ToManyProperty property) {
- DataObjectDescriptorFactoryTest.assertPropertiesAreInOrder(
- lastProcessed[0], property);
- lastProcessed[0] = property;
- return true;
- }
-
- public boolean visitAttribute(AttributeProperty property) {
- DataObjectDescriptorFactoryTest.assertPropertiesAreInOrder(
- lastProcessed[0], property);
- lastProcessed[0] = property;
- return true;
- }
- };
-
- descriptor.visitProperties(visitor);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/tx/DefaultTransactionManagerIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/tx/DefaultTransactionManagerIT.java b/cayenne-server/src/test/java/org/apache/cayenne/tx/DefaultTransactionManagerIT.java
new file mode 100644
index 0000000..126a498
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/tx/DefaultTransactionManagerIT.java
@@ -0,0 +1,75 @@
+/*****************************************************************
+ * 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.tx;
+
+import org.apache.cayenne.log.JdbcEventLogger;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DefaultTransactionManagerIT extends ServerCase {
+
+ public void testPerformInTransaction_NoTx() {
+
+ final BaseTransaction tx = mock(BaseTransaction.class);
+ TransactionFactory txFactory = mock(TransactionFactory.class);
+ when(txFactory.createTransaction()).thenReturn(tx);
+
+ DefaultTransactionManager txManager = new DefaultTransactionManager(txFactory, mock(JdbcEventLogger.class));
+
+ final Object expectedResult = new Object();
+ Object result = txManager.performInTransaction(new TransactionalOperation<Object>() {
+ public Object perform() {
+ assertNotNull(BaseTransaction.getThreadTransaction());
+ return expectedResult;
+ }
+ });
+
+ assertSame(expectedResult, result);
+ }
+
+ public void testPerformInTransaction_ExistingTx() {
+
+ final BaseTransaction tx1 = mock(BaseTransaction.class);
+ TransactionFactory txFactory = mock(TransactionFactory.class);
+ when(txFactory.createTransaction()).thenReturn(tx1);
+
+ DefaultTransactionManager txManager = new DefaultTransactionManager(txFactory, mock(JdbcEventLogger.class));
+
+ final BaseTransaction tx2 = mock(BaseTransaction.class);
+ BaseTransaction.bindThreadTransaction(tx2);
+ try {
+
+ final Object expectedResult = new Object();
+ Object result = txManager.performInTransaction(new TransactionalOperation<Object>() {
+ public Object perform() {
+ assertSame(tx2, BaseTransaction.getThreadTransaction());
+ return expectedResult;
+ }
+ });
+
+ assertSame(expectedResult, result);
+ } finally {
+ BaseTransaction.bindThreadTransaction(null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/tx/DefaultTransactionManagerTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/tx/DefaultTransactionManagerTest.java b/cayenne-server/src/test/java/org/apache/cayenne/tx/DefaultTransactionManagerTest.java
deleted file mode 100644
index 495286b..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/tx/DefaultTransactionManagerTest.java
+++ /dev/null
@@ -1,75 +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.tx;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DefaultTransactionManagerTest extends ServerCase {
-
- public void testPerformInTransaction_NoTx() {
-
- final BaseTransaction tx = mock(BaseTransaction.class);
- TransactionFactory txFactory = mock(TransactionFactory.class);
- when(txFactory.createTransaction()).thenReturn(tx);
-
- DefaultTransactionManager txManager = new DefaultTransactionManager(txFactory, mock(JdbcEventLogger.class));
-
- final Object expectedResult = new Object();
- Object result = txManager.performInTransaction(new TransactionalOperation<Object>() {
- public Object perform() {
- assertNotNull(BaseTransaction.getThreadTransaction());
- return expectedResult;
- }
- });
-
- assertSame(expectedResult, result);
- }
-
- public void testPerformInTransaction_ExistingTx() {
-
- final BaseTransaction tx1 = mock(BaseTransaction.class);
- TransactionFactory txFactory = mock(TransactionFactory.class);
- when(txFactory.createTransaction()).thenReturn(tx1);
-
- DefaultTransactionManager txManager = new DefaultTransactionManager(txFactory, mock(JdbcEventLogger.class));
-
- final BaseTransaction tx2 = mock(BaseTransaction.class);
- BaseTransaction.bindThreadTransaction(tx2);
- try {
-
- final Object expectedResult = new Object();
- Object result = txManager.performInTransaction(new TransactionalOperation<Object>() {
- public Object perform() {
- assertSame(tx2, BaseTransaction.getThreadTransaction());
- return expectedResult;
- }
- });
-
- assertSame(expectedResult, result);
- } finally {
- BaseTransaction.bindThreadTransaction(null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
index 37e520d..f0ebb94 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
@@ -19,14 +19,7 @@
package org.apache.cayenne.unit;
-import java.sql.Connection;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.cayenne.access.DataContextProcedureQueryTest;
+import org.apache.cayenne.access.DataContextProcedureQueryIT;
import org.apache.cayenne.dba.DbAdapter;
import org.apache.cayenne.dba.oracle.OracleAdapter;
import org.apache.cayenne.map.DataMap;
@@ -35,6 +28,13 @@ import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.Procedure;
import org.apache.cayenne.map.ProcedureParameter;
+import java.sql.Connection;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
/**
*/
public class OracleUnitDbAdapter extends UnitDbAdapter {
@@ -104,7 +104,7 @@ public class OracleUnitDbAdapter extends UnitDbAdapter {
@Override
public void tweakProcedure(Procedure proc) {
- if (DataContextProcedureQueryTest.SELECT_STORED_PROCEDURE.equals(proc.getName())
+ if (DataContextProcedureQueryIT.SELECT_STORED_PROCEDURE.equals(proc.getName())
&& proc.getCallParameters().size() == 2) {
List params = new ArrayList(proc.getCallParameters());
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/di/DICaseSelfIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/DICaseSelfIT.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/DICaseSelfIT.java
new file mode 100644
index 0000000..605ba17
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/DICaseSelfIT.java
@@ -0,0 +1,81 @@
+/*****************************************************************
+ * 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.unit.di;
+
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.di.Key;
+import org.apache.cayenne.di.Module;
+import org.apache.cayenne.di.spi.DefaultScope;
+
+public class DICaseSelfIT extends DICase {
+
+ private static final Injector injector;
+
+ static {
+ Module selfTestModule = new Module() {
+
+ public void configure(Binder binder) {
+ DefaultScope testScope = new DefaultScope();
+
+ binder.bind(UnitTestLifecycleManager.class).toInstance(
+ new DefaultUnitTestLifecycleManager(testScope));
+
+ binder.bind(Key.get(Object.class, "test-scope")).to(Object.class).in(
+ testScope);
+ binder
+ .bind(Key.get(Object.class, "singleton-scope"))
+ .to(Object.class)
+ .inSingletonScope();
+ }
+ };
+
+ injector = DIBootstrap.createInjector(selfTestModule);
+ }
+
+ @Inject("test-scope")
+ protected Object testScoped;
+
+ @Inject("singleton-scope")
+ protected Object singletonScoped;
+
+ @Override
+ protected Injector getUnitTestInjector() {
+ return injector;
+ }
+
+ public void testInjection() throws Exception {
+
+ Object testScoped = this.testScoped;
+ assertNotNull(testScoped);
+
+ Object singletonScoped = this.singletonScoped;
+ assertNotNull(singletonScoped);
+
+ tearDown();
+ setUp();
+
+ assertNotSame(testScoped, this.testScoped);
+ assertNotNull(this.testScoped);
+ assertSame(singletonScoped, this.singletonScoped);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/di/DICaseSelfTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/DICaseSelfTest.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/DICaseSelfTest.java
deleted file mode 100644
index 871dd29..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/DICaseSelfTest.java
+++ /dev/null
@@ -1,81 +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.unit.di;
-
-import org.apache.cayenne.di.Binder;
-import org.apache.cayenne.di.DIBootstrap;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.di.Key;
-import org.apache.cayenne.di.Module;
-import org.apache.cayenne.di.spi.DefaultScope;
-
-public class DICaseSelfTest extends DICase {
-
- private static final Injector injector;
-
- static {
- Module selfTestModule = new Module() {
-
- public void configure(Binder binder) {
- DefaultScope testScope = new DefaultScope();
-
- binder.bind(UnitTestLifecycleManager.class).toInstance(
- new DefaultUnitTestLifecycleManager(testScope));
-
- binder.bind(Key.get(Object.class, "test-scope")).to(Object.class).in(
- testScope);
- binder
- .bind(Key.get(Object.class, "singleton-scope"))
- .to(Object.class)
- .inSingletonScope();
- }
- };
-
- injector = DIBootstrap.createInjector(selfTestModule);
- }
-
- @Inject("test-scope")
- protected Object testScoped;
-
- @Inject("singleton-scope")
- protected Object singletonScoped;
-
- @Override
- protected Injector getUnitTestInjector() {
- return injector;
- }
-
- public void testInjection() throws Exception {
-
- Object testScoped = this.testScoped;
- assertNotNull(testScoped);
-
- Object singletonScoped = this.singletonScoped;
- assertNotNull(singletonScoped);
-
- tearDown();
- setUp();
-
- assertNotSame(testScoped, this.testScoped);
- assertNotNull(this.testScoped);
- assertSame(singletonScoped, this.singletonScoped);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfIT.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfIT.java
new file mode 100644
index 0000000..bd72025
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfIT.java
@@ -0,0 +1,52 @@
+/*****************************************************************
+ * 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.unit.di.server;
+
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.di.Provider;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class ServerCaseSelfIT extends ServerCase {
+
+ @Inject
+ protected ServerRuntime runtime;
+
+ @Inject
+ protected Provider<ServerRuntime> runtimeProvider;
+
+ @Inject
+ protected ServerCaseProperties properties;
+
+ public void testSetup_TearDown_Runtime() throws Exception {
+
+ assertNotNull(properties);
+ assertEquals(ServerCase.TESTMAP_PROJECT, properties.getConfigurationLocation());
+
+ ServerRuntime local = this.runtime;
+ assertNotNull(local);
+ assertSame(local, runtimeProvider.get());
+
+ tearDown();
+
+ setUp();
+ assertNotSame(local, this.runtime);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java
deleted file mode 100644
index ee59635..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java
+++ /dev/null
@@ -1,52 +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.unit.di.server;
-
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.di.Provider;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class ServerCaseSelfTest extends ServerCase {
-
- @Inject
- protected ServerRuntime runtime;
-
- @Inject
- protected Provider<ServerRuntime> runtimeProvider;
-
- @Inject
- protected ServerCaseProperties properties;
-
- public void testSetup_TearDown_Runtime() throws Exception {
-
- assertNotNull(properties);
- assertEquals(ServerCase.TESTMAP_PROJECT, properties.getConfigurationLocation());
-
- ServerRuntime local = this.runtime;
- assertNotNull(local);
- assertSame(local, runtimeProvider.get());
-
- tearDown();
-
- setUp();
- assertNotSame(local, this.runtime);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java
new file mode 100644
index 0000000..024f5e9
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115IT.java
@@ -0,0 +1,115 @@
+/*****************************************************************
+ * 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.unit.jira;
+
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.Expression;
+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.relationship.ClobMaster;
+import org.apache.cayenne.unit.UnitDbAdapter;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.List;
+
+/**
+ */
+@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
+public class CAY_115IT extends ServerCase {
+
+ @Inject
+ protected DataContext context;
+
+ @Inject
+ protected UnitDbAdapter accessStackAdapter;
+
+ @Inject
+ protected DBHelper dbHelper;
+
+ protected TableHelper tClobMaster;
+ protected TableHelper tClobDetail;
+
+ @Override
+ protected void setUpAfterInjection() throws Exception {
+ dbHelper.deleteAll("CLOB_DETAIL");
+ dbHelper.deleteAll("CLOB_MASTER");
+
+ tClobMaster = new TableHelper(dbHelper, "CLOB_MASTER");
+ tClobMaster.setColumns("CLOB_MASTER_ID", "CLOB_COLUMN", "NAME");
+
+ tClobDetail = new TableHelper(dbHelper, "CLOB_DETAIL");
+ tClobDetail.setColumns("CLOB_DETAIL_ID", "CLOB_MASTER_ID", "NAME");
+ }
+
+ protected void createDistinctClobFetchDataSet() throws Exception {
+ tClobMaster.insert(1, "cm1 clob", "cm1");
+ tClobMaster.insert(2, "cm2 clob", "cm2");
+ tClobMaster.insert(3, "cm3 clob", "cm3");
+ }
+
+ protected void createDistinctClobFetchWithToManyJoin() throws Exception {
+ tClobMaster.insert(1, "cm1 clob", "cm1");
+ tClobMaster.insert(2, "cm2 clob", "cm2");
+ tClobMaster.insert(3, "cm3 clob", "cm3");
+ tClobDetail.insert(1, 1, "cd11");
+ tClobDetail.insert(2, 2, "cd21");
+ tClobDetail.insert(3, 2, "cd22");
+ tClobDetail.insert(4, 3, "cd31");
+ }
+
+ public void testDistinctClobFetch() throws Exception {
+ if (!accessStackAdapter.supportsLobInsertsAsStrings()) {
+ return;
+ }
+
+ createDistinctClobFetchDataSet();
+
+ SelectQuery noDistinct = new SelectQuery(ClobMaster.class);
+ noDistinct.addOrdering(ClobMaster.NAME_PROPERTY, SortOrder.ASCENDING);
+
+ SelectQuery distinct = new SelectQuery(ClobMaster.class);
+ distinct.setDistinct(true);
+ distinct.addOrdering(ClobMaster.NAME_PROPERTY, SortOrder.ASCENDING);
+
+ List<?> noDistinctResult = context.performQuery(noDistinct);
+ List<?> distinctResult = context.performQuery(distinct);
+
+ assertEquals(3, noDistinctResult.size());
+ assertEquals(noDistinctResult, distinctResult);
+ }
+
+ public void testDistinctClobFetchWithToManyJoin() throws Exception {
+ if (!accessStackAdapter.supportsLobInsertsAsStrings()) {
+ return;
+ }
+
+ createDistinctClobFetchWithToManyJoin();
+
+ Expression qual = Expression.fromString("details.name like 'cd%'");
+ SelectQuery query = new SelectQuery(ClobMaster.class, qual);
+ List<?> result = context.performQuery(query);
+
+ assertEquals(3, result.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115Test.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115Test.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115Test.java
deleted file mode 100644
index 48c7031..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_115Test.java
+++ /dev/null
@@ -1,115 +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.unit.jira;
-
-import java.util.List;
-
-import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-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.relationship.ClobMaster;
-import org.apache.cayenne.unit.UnitDbAdapter;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-/**
- */
-@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
-public class CAY_115Test extends ServerCase {
-
- @Inject
- protected DataContext context;
-
- @Inject
- protected UnitDbAdapter accessStackAdapter;
-
- @Inject
- protected DBHelper dbHelper;
-
- protected TableHelper tClobMaster;
- protected TableHelper tClobDetail;
-
- @Override
- protected void setUpAfterInjection() throws Exception {
- dbHelper.deleteAll("CLOB_DETAIL");
- dbHelper.deleteAll("CLOB_MASTER");
-
- tClobMaster = new TableHelper(dbHelper, "CLOB_MASTER");
- tClobMaster.setColumns("CLOB_MASTER_ID", "CLOB_COLUMN", "NAME");
-
- tClobDetail = new TableHelper(dbHelper, "CLOB_DETAIL");
- tClobDetail.setColumns("CLOB_DETAIL_ID", "CLOB_MASTER_ID", "NAME");
- }
-
- protected void createDistinctClobFetchDataSet() throws Exception {
- tClobMaster.insert(1, "cm1 clob", "cm1");
- tClobMaster.insert(2, "cm2 clob", "cm2");
- tClobMaster.insert(3, "cm3 clob", "cm3");
- }
-
- protected void createDistinctClobFetchWithToManyJoin() throws Exception {
- tClobMaster.insert(1, "cm1 clob", "cm1");
- tClobMaster.insert(2, "cm2 clob", "cm2");
- tClobMaster.insert(3, "cm3 clob", "cm3");
- tClobDetail.insert(1, 1, "cd11");
- tClobDetail.insert(2, 2, "cd21");
- tClobDetail.insert(3, 2, "cd22");
- tClobDetail.insert(4, 3, "cd31");
- }
-
- public void testDistinctClobFetch() throws Exception {
- if (!accessStackAdapter.supportsLobInsertsAsStrings()) {
- return;
- }
-
- createDistinctClobFetchDataSet();
-
- SelectQuery noDistinct = new SelectQuery(ClobMaster.class);
- noDistinct.addOrdering(ClobMaster.NAME_PROPERTY, SortOrder.ASCENDING);
-
- SelectQuery distinct = new SelectQuery(ClobMaster.class);
- distinct.setDistinct(true);
- distinct.addOrdering(ClobMaster.NAME_PROPERTY, SortOrder.ASCENDING);
-
- List<?> noDistinctResult = context.performQuery(noDistinct);
- List<?> distinctResult = context.performQuery(distinct);
-
- assertEquals(3, noDistinctResult.size());
- assertEquals(noDistinctResult, distinctResult);
- }
-
- public void testDistinctClobFetchWithToManyJoin() throws Exception {
- if (!accessStackAdapter.supportsLobInsertsAsStrings()) {
- return;
- }
-
- createDistinctClobFetchWithToManyJoin();
-
- Expression qual = Expression.fromString("details.name like 'cd%'");
- SelectQuery query = new SelectQuery(ClobMaster.class, qual);
- List<?> result = context.performQuery(query);
-
- assertEquals(3, result.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java
new file mode 100644
index 0000000..eaf446e
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191IT.java
@@ -0,0 +1,79 @@
+/*****************************************************************
+ * 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.unit.jira;
+
+import java.sql.Types;
+
+import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.relationship.FkOfDifferentType;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
+public class CAY_191IT extends ServerCase {
+
+ @Inject
+ protected DataContext context;
+
+ @Inject
+ protected DBHelper dbHelper;
+
+ protected TableHelper tRelationshipHelper;
+ protected TableHelper tFkOfDifferentType;
+
+ @Override
+ protected void setUpAfterInjection() throws Exception {
+ dbHelper.deleteAll("FK_OF_DIFFERENT_TYPE");
+ dbHelper.update("REFLEXIVE_AND_TO_ONE").set("PARENT_ID", null, Types.INTEGER).execute();
+ dbHelper.deleteAll("REFLEXIVE_AND_TO_ONE");
+ dbHelper.deleteAll("RELATIONSHIP_HELPER");
+
+ tRelationshipHelper = new TableHelper(dbHelper, "RELATIONSHIP_HELPER");
+ tRelationshipHelper.setColumns("NAME", "RELATIONSHIP_HELPER_ID");
+
+ tFkOfDifferentType = new TableHelper(dbHelper, "FK_OF_DIFFERENT_TYPE");
+ tFkOfDifferentType.setColumns("ID", "RELATIONSHIP_HELPER_FK");
+ }
+
+ protected void createTestDataSet() throws Exception {
+ tRelationshipHelper.insert("RH1", 1);
+ tFkOfDifferentType.insert(1, 1);
+ }
+
+ public void testResolveToOneOverFKOfDifferentNumType() throws Exception {
+ // this is mostly for legacy schemas, as on many dbs you won;t be able to even
+ // create the FK constraint...
+
+ createTestDataSet();
+
+ FkOfDifferentType root = Cayenne.objectForPK(
+ context,
+ FkOfDifferentType.class,
+ 1);
+
+ assertNotNull(root);
+ assertNotNull(root.getRelationshipHelper());
+ assertEquals("RH1", root.getRelationshipHelper().getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191Test.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191Test.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191Test.java
deleted file mode 100644
index fd0303c..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_191Test.java
+++ /dev/null
@@ -1,79 +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.unit.jira;
-
-import java.sql.Types;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.relationship.FkOfDifferentType;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
-public class CAY_191Test extends ServerCase {
-
- @Inject
- protected DataContext context;
-
- @Inject
- protected DBHelper dbHelper;
-
- protected TableHelper tRelationshipHelper;
- protected TableHelper tFkOfDifferentType;
-
- @Override
- protected void setUpAfterInjection() throws Exception {
- dbHelper.deleteAll("FK_OF_DIFFERENT_TYPE");
- dbHelper.update("REFLEXIVE_AND_TO_ONE").set("PARENT_ID", null, Types.INTEGER).execute();
- dbHelper.deleteAll("REFLEXIVE_AND_TO_ONE");
- dbHelper.deleteAll("RELATIONSHIP_HELPER");
-
- tRelationshipHelper = new TableHelper(dbHelper, "RELATIONSHIP_HELPER");
- tRelationshipHelper.setColumns("NAME", "RELATIONSHIP_HELPER_ID");
-
- tFkOfDifferentType = new TableHelper(dbHelper, "FK_OF_DIFFERENT_TYPE");
- tFkOfDifferentType.setColumns("ID", "RELATIONSHIP_HELPER_FK");
- }
-
- protected void createTestDataSet() throws Exception {
- tRelationshipHelper.insert("RH1", 1);
- tFkOfDifferentType.insert(1, 1);
- }
-
- public void testResolveToOneOverFKOfDifferentNumType() throws Exception {
- // this is mostly for legacy schemas, as on many dbs you won;t be able to even
- // create the FK constraint...
-
- createTestDataSet();
-
- FkOfDifferentType root = Cayenne.objectForPK(
- context,
- FkOfDifferentType.class,
- 1);
-
- assertNotNull(root);
- assertNotNull(root.getRelationshipHelper());
- assertEquals("RH1", root.getRelationshipHelper().getName());
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java
new file mode 100644
index 0000000..5ebfd81
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194IT.java
@@ -0,0 +1,107 @@
+/*****************************************************************
+ * 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.unit.jira;
+
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.relationship.ReflexiveAndToOne;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.sql.Types;
+import java.util.List;
+
+/**
+ * Testing qualifier translator correctness on reflexive relationships.
+ */
+// TODO: this is really a qualifier translator general test... need to
+// find an appropriate place in unit tests..
+@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
+public class CAY_194IT extends ServerCase {
+
+ @Inject
+ protected DataContext context;
+
+ @Inject
+ private DBHelper dbHelper;
+
+ @Override
+ protected void setUpAfterInjection() throws Exception {
+ TableHelper tReflexive = new TableHelper(dbHelper, "REFLEXIVE_AND_TO_ONE");
+ tReflexive.setColumns("REFLEXIVE_AND_TO_ONE_ID", "PARENT_ID");
+
+ tReflexive.update().set("PARENT_ID", null, Types.INTEGER).execute();
+
+ dbHelper.deleteAll("REFLEXIVE_AND_TO_ONE");
+ dbHelper.deleteAll("TO_ONEFK1");
+ }
+
+ public void testQualifyOnToMany() {
+
+ ReflexiveAndToOne ox = context.newObject(ReflexiveAndToOne.class);
+ ox.setName("ox");
+ ReflexiveAndToOne o1 = context.newObject(ReflexiveAndToOne.class);
+ o1.setName("o1");
+
+ ReflexiveAndToOne o2 = context.newObject(ReflexiveAndToOne.class);
+ o2.setName("o2");
+ o2.setToParent(o1);
+
+ context.commitChanges();
+
+ Expression qualifier = ExpressionFactory.matchExp("children", o2);
+ List<?> parents = context.performQuery(new SelectQuery(
+ ReflexiveAndToOne.class,
+ qualifier));
+ assertEquals(1, parents.size());
+ assertSame(o1, parents.get(0));
+
+ qualifier = ExpressionFactory.matchExp("children", o1);
+ parents = context
+ .performQuery(new SelectQuery(ReflexiveAndToOne.class, qualifier));
+ assertEquals(0, parents.size());
+ }
+
+ public void testQualifyOnToOne() {
+
+ ReflexiveAndToOne ox = context.newObject(ReflexiveAndToOne.class);
+ ox.setName("ox");
+ ReflexiveAndToOne o1 = context.newObject(ReflexiveAndToOne.class);
+ o1.setName("o1");
+
+ ReflexiveAndToOne o2 = context.newObject(ReflexiveAndToOne.class);
+ o2.setName("o2");
+ o2.setToParent(o1);
+
+ context.commitChanges();
+
+ Expression qualifier = ExpressionFactory.matchExp("toParent", o1);
+ List<?> children = context.performQuery(new SelectQuery(
+ ReflexiveAndToOne.class,
+ qualifier));
+ assertEquals(1, children.size());
+ assertSame(o2, children.get(0));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194Test.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194Test.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194Test.java
deleted file mode 100644
index a56bc38..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/jira/CAY_194Test.java
+++ /dev/null
@@ -1,107 +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.unit.jira;
-
-import java.sql.Types;
-import java.util.List;
-
-import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.relationship.ReflexiveAndToOne;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-/**
- * Testing qualifier translator correctness on reflexive relationships.
- */
-// TODO: this is really a qualifier translator general test... need to
-// find an appropriate place in unit tests..
-@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
-public class CAY_194Test extends ServerCase {
-
- @Inject
- protected DataContext context;
-
- @Inject
- private DBHelper dbHelper;
-
- @Override
- protected void setUpAfterInjection() throws Exception {
- TableHelper tReflexive = new TableHelper(dbHelper, "REFLEXIVE_AND_TO_ONE");
- tReflexive.setColumns("REFLEXIVE_AND_TO_ONE_ID", "PARENT_ID");
-
- tReflexive.update().set("PARENT_ID", null, Types.INTEGER).execute();
-
- dbHelper.deleteAll("REFLEXIVE_AND_TO_ONE");
- dbHelper.deleteAll("TO_ONEFK1");
- }
-
- public void testQualifyOnToMany() {
-
- ReflexiveAndToOne ox = context.newObject(ReflexiveAndToOne.class);
- ox.setName("ox");
- ReflexiveAndToOne o1 = context.newObject(ReflexiveAndToOne.class);
- o1.setName("o1");
-
- ReflexiveAndToOne o2 = context.newObject(ReflexiveAndToOne.class);
- o2.setName("o2");
- o2.setToParent(o1);
-
- context.commitChanges();
-
- Expression qualifier = ExpressionFactory.matchExp("children", o2);
- List<?> parents = context.performQuery(new SelectQuery(
- ReflexiveAndToOne.class,
- qualifier));
- assertEquals(1, parents.size());
- assertSame(o1, parents.get(0));
-
- qualifier = ExpressionFactory.matchExp("children", o1);
- parents = context
- .performQuery(new SelectQuery(ReflexiveAndToOne.class, qualifier));
- assertEquals(0, parents.size());
- }
-
- public void testQualifyOnToOne() {
-
- ReflexiveAndToOne ox = context.newObject(ReflexiveAndToOne.class);
- ox.setName("ox");
- ReflexiveAndToOne o1 = context.newObject(ReflexiveAndToOne.class);
- o1.setName("o1");
-
- ReflexiveAndToOne o2 = context.newObject(ReflexiveAndToOne.class);
- o2.setName("o2");
- o2.setToParent(o1);
-
- context.commitChanges();
-
- Expression qualifier = ExpressionFactory.matchExp("toParent", o1);
- List<?> children = context.performQuery(new SelectQuery(
- ReflexiveAndToOne.class,
- qualifier));
- assertEquals(1, children.size());
- assertSame(o2, children.get(0));
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationIT.java b/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationIT.java
new file mode 100644
index 0000000..f106204
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationIT.java
@@ -0,0 +1,85 @@
+/*****************************************************************
+ * 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.util;
+
+import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.di.DataChannelInterceptor;
+import org.apache.cayenne.unit.di.UnitTestClosure;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DeepMergeOperationIT extends ServerCase {
+
+ @Inject
+ private DataChannelInterceptor queryInterceptor;
+
+ @Inject
+ private DataContext context;
+
+ @Inject
+ private DataContext context1;
+
+ public void testDeepMergeNonExistent() {
+
+ final Artist a = context.newObject(Artist.class);
+ a.setArtistName("AAA");
+ context.commitChanges();
+
+ final DeepMergeOperation op = new DeepMergeOperation(context1);
+
+ queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+
+ public void execute() {
+ Artist a2 = (Artist) op.merge(a);
+ assertNotNull(a2);
+ assertEquals(PersistenceState.COMMITTED, a2.getPersistenceState());
+ assertEquals(a.getArtistName(), a2.getArtistName());
+ }
+ });
+ }
+
+ public void testDeepMergeModified() {
+
+ final Artist a = context.newObject(Artist.class);
+ a.setArtistName("AAA");
+ context.commitChanges();
+
+ final Artist a1 = (Artist) Cayenne.objectForPK(context1, a.getObjectId());
+ a1.setArtistName("BBB");
+ final DeepMergeOperation op = new DeepMergeOperation(context1);
+
+ queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+
+ public void execute() {
+ Artist a2 = (Artist) op.merge(a);
+ assertNotNull(a2);
+ assertEquals(PersistenceState.MODIFIED, a2.getPersistenceState());
+ assertSame(a1, a2);
+ assertEquals("BBB", a2.getArtistName());
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationInheritanceIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationInheritanceIT.java b/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationInheritanceIT.java
new file mode 100644
index 0000000..ba64dec
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationInheritanceIT.java
@@ -0,0 +1,140 @@
+/*****************************************************************
+ * 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.util;
+
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.testdo.inherit.Department;
+import org.apache.cayenne.testdo.inherit.Employee;
+import org.apache.cayenne.testdo.inherit.Manager;
+import org.apache.cayenne.unit.di.DataChannelInterceptor;
+import org.apache.cayenne.unit.di.UnitTestClosure;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.PEOPLE_PROJECT)
+public class DeepMergeOperationInheritanceIT extends ServerCase {
+
+ @Inject
+ private DataContext context;
+
+ @Inject
+ private DataContext context1;
+
+ @Inject
+ protected DataChannelInterceptor queryInterceptor;
+
+ public void testDeepMergeExistingSubclass() {
+
+ final Department d1 = context.newObject(Department.class);
+ d1.setName("D1");
+
+ // need to do double commit as Ashwood sorter blows on Employees/Departments
+ // ordering...
+ context.commitChanges();
+
+ Employee e1 = context.newObject(Employee.class);
+ e1.setName("E1");
+ e1.setPersonType("EE");
+ d1.addToEmployees(e1);
+
+ Manager e2 = context.newObject(Manager.class);
+ e2.setName("E2");
+ e2.setPersonType("EM");
+ d1.addToEmployees(e2);
+
+ context.commitChanges();
+
+ // need to make sure source relationship is resolved as a result of some Ashwood
+ // strangeness...
+ d1.getEmployees().size();
+
+ // resolve Employees
+ context1.performQuery(new SelectQuery(Employee.class));
+
+ final DeepMergeOperation op = new DeepMergeOperation(context1);
+
+ queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+
+ public void execute() {
+ Department d2 = (Department) op.merge(d1);
+ assertNotNull(d2);
+ assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());
+
+ for (Employee ex : d2.getEmployees()) {
+ if ("E2".equals(ex.getName())) {
+ assertTrue(ex instanceof Manager);
+ }
+ else {
+ assertFalse(ex instanceof Manager);
+ }
+ }
+ }
+ });
+
+ }
+
+ public void testDeepMergeNonExistentSubclass() {
+
+ final Department d1 = context.newObject(Department.class);
+ d1.setName("D1");
+
+ // need to do double commit as Ashwood sorter blows on Employees/Departments
+ // ordering...
+ context.commitChanges();
+
+ Employee e1 = context.newObject(Employee.class);
+ e1.setName("E1");
+ e1.setPersonType("EE");
+ d1.addToEmployees(e1);
+
+ Manager e2 = context.newObject(Manager.class);
+ e2.setName("E2");
+ e2.setPersonType("EM");
+ d1.addToEmployees(e2);
+
+ context.commitChanges();
+
+ // need to make sure source relationship is resolved as a result of some Ashwood
+ // strangeness...
+ d1.getEmployees().size();
+ final DeepMergeOperation op = new DeepMergeOperation(context1);
+
+ queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+
+ public void execute() {
+ Department d2 = (Department) op.merge(d1);
+ assertNotNull(d2);
+ assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());
+
+ for (Employee ex : d2.getEmployees()) {
+ if ("E2".equals(ex.getName())) {
+ assertTrue(ex instanceof Manager);
+ }
+ else {
+ assertFalse(ex instanceof Manager);
+ }
+ }
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationInheritanceTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationInheritanceTest.java b/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationInheritanceTest.java
deleted file mode 100644
index 4289440..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationInheritanceTest.java
+++ /dev/null
@@ -1,140 +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.util;
-
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.testdo.inherit.Department;
-import org.apache.cayenne.testdo.inherit.Employee;
-import org.apache.cayenne.testdo.inherit.Manager;
-import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.PEOPLE_PROJECT)
-public class DeepMergeOperationInheritanceTest extends ServerCase {
-
- @Inject
- private DataContext context;
-
- @Inject
- private DataContext context1;
-
- @Inject
- protected DataChannelInterceptor queryInterceptor;
-
- public void testDeepMergeExistingSubclass() {
-
- final Department d1 = context.newObject(Department.class);
- d1.setName("D1");
-
- // need to do double commit as Ashwood sorter blows on Employees/Departments
- // ordering...
- context.commitChanges();
-
- Employee e1 = context.newObject(Employee.class);
- e1.setName("E1");
- e1.setPersonType("EE");
- d1.addToEmployees(e1);
-
- Manager e2 = context.newObject(Manager.class);
- e2.setName("E2");
- e2.setPersonType("EM");
- d1.addToEmployees(e2);
-
- context.commitChanges();
-
- // need to make sure source relationship is resolved as a result of some Ashwood
- // strangeness...
- d1.getEmployees().size();
-
- // resolve Employees
- context1.performQuery(new SelectQuery(Employee.class));
-
- final DeepMergeOperation op = new DeepMergeOperation(context1);
-
- queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
- public void execute() {
- Department d2 = (Department) op.merge(d1);
- assertNotNull(d2);
- assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());
-
- for (Employee ex : d2.getEmployees()) {
- if ("E2".equals(ex.getName())) {
- assertTrue(ex instanceof Manager);
- }
- else {
- assertFalse(ex instanceof Manager);
- }
- }
- }
- });
-
- }
-
- public void testDeepMergeNonExistentSubclass() {
-
- final Department d1 = context.newObject(Department.class);
- d1.setName("D1");
-
- // need to do double commit as Ashwood sorter blows on Employees/Departments
- // ordering...
- context.commitChanges();
-
- Employee e1 = context.newObject(Employee.class);
- e1.setName("E1");
- e1.setPersonType("EE");
- d1.addToEmployees(e1);
-
- Manager e2 = context.newObject(Manager.class);
- e2.setName("E2");
- e2.setPersonType("EM");
- d1.addToEmployees(e2);
-
- context.commitChanges();
-
- // need to make sure source relationship is resolved as a result of some Ashwood
- // strangeness...
- d1.getEmployees().size();
- final DeepMergeOperation op = new DeepMergeOperation(context1);
-
- queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
- public void execute() {
- Department d2 = (Department) op.merge(d1);
- assertNotNull(d2);
- assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());
-
- for (Employee ex : d2.getEmployees()) {
- if ("E2".equals(ex.getName())) {
- assertTrue(ex instanceof Manager);
- }
- else {
- assertFalse(ex instanceof Manager);
- }
- }
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationTest.java b/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationTest.java
deleted file mode 100644
index a488dc0..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/util/DeepMergeOperationTest.java
+++ /dev/null
@@ -1,85 +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.util;
-
-import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class DeepMergeOperationTest extends ServerCase {
-
- @Inject
- private DataChannelInterceptor queryInterceptor;
-
- @Inject
- private DataContext context;
-
- @Inject
- private DataContext context1;
-
- public void testDeepMergeNonExistent() {
-
- final Artist a = context.newObject(Artist.class);
- a.setArtistName("AAA");
- context.commitChanges();
-
- final DeepMergeOperation op = new DeepMergeOperation(context1);
-
- queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
- public void execute() {
- Artist a2 = (Artist) op.merge(a);
- assertNotNull(a2);
- assertEquals(PersistenceState.COMMITTED, a2.getPersistenceState());
- assertEquals(a.getArtistName(), a2.getArtistName());
- }
- });
- }
-
- public void testDeepMergeModified() {
-
- final Artist a = context.newObject(Artist.class);
- a.setArtistName("AAA");
- context.commitChanges();
-
- final Artist a1 = (Artist) Cayenne.objectForPK(context1, a.getObjectId());
- a1.setArtistName("BBB");
- final DeepMergeOperation op = new DeepMergeOperation(context1);
-
- queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
- public void execute() {
- Artist a2 = (Artist) op.merge(a);
- assertNotNull(a2);
- assertEquals(PersistenceState.MODIFIED, a2.getPersistenceState());
- assertSame(a1, a2);
- assertEquals("BBB", a2.getArtistName());
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/util/EntityMergeSupportIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/util/EntityMergeSupportIT.java b/cayenne-server/src/test/java/org/apache/cayenne/util/EntityMergeSupportIT.java
new file mode 100644
index 0000000..d5239fd
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/util/EntityMergeSupportIT.java
@@ -0,0 +1,99 @@
+/*****************************************************************
+ * 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.util;
+
+import java.sql.Types;
+import java.util.Arrays;
+
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbJoin;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.DeleteRule;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.merge.MergeCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class EntityMergeSupportIT extends MergeCase {
+
+ public void testMerging() {
+ DbEntity dbEntity1 = new DbEntity("NEW_TABLE");
+
+ DbAttribute e1col1 = new DbAttribute("ID", Types.INTEGER, dbEntity1);
+ e1col1.setMandatory(true);
+ e1col1.setPrimaryKey(true);
+ dbEntity1.addAttribute(e1col1);
+
+ DbAttribute e1col2 = new DbAttribute("NAME", Types.VARCHAR, dbEntity1);
+ e1col2.setMaxLength(10);
+ e1col2.setMandatory(false);
+ dbEntity1.addAttribute(e1col2);
+
+ map.addDbEntity(dbEntity1);
+
+ DbEntity dbEntity2 = new DbEntity("NEW_TABLE2");
+ DbAttribute e2col1 = new DbAttribute("ID", Types.INTEGER, dbEntity2);
+ e2col1.setMandatory(true);
+ e2col1.setPrimaryKey(true);
+ dbEntity2.addAttribute(e2col1);
+ DbAttribute e2col2 = new DbAttribute("FK", Types.INTEGER, dbEntity2);
+ dbEntity2.addAttribute(e2col2);
+
+ map.addDbEntity(dbEntity2);
+
+ // create db relationships
+ DbRelationship rel1To2 = new DbRelationship("rel1To2");
+ rel1To2.setSourceEntity(dbEntity1);
+ rel1To2.setTargetEntity(dbEntity2);
+ rel1To2.setToMany(true);
+ rel1To2.addJoin(new DbJoin(rel1To2, e1col1.getName(), e2col2.getName()));
+ dbEntity1.addRelationship(rel1To2);
+ DbRelationship rel2To1 = new DbRelationship("rel2To1");
+ rel2To1.setSourceEntity(dbEntity2);
+ rel2To1.setTargetEntity(dbEntity1);
+ rel2To1.setToMany(false);
+ rel2To1.addJoin(new DbJoin(rel2To1, e2col2.getName(), e1col1.getName()));
+ dbEntity2.addRelationship(rel2To1);
+ assertSame(rel1To2, rel2To1.getReverseRelationship());
+ assertSame(rel2To1, rel1To2.getReverseRelationship());
+
+ ObjEntity objEntity1 = new ObjEntity("NewTable");
+ objEntity1.setDbEntity(dbEntity1);
+ map.addObjEntity(objEntity1);
+
+ ObjEntity objEntity2 = new ObjEntity("NewTable2");
+ objEntity2.setDbEntity(dbEntity2);
+ map.addObjEntity(objEntity2);
+
+ assertTrue(new EntityMergeSupport(map).synchronizeWithDbEntities(Arrays.asList(objEntity1, objEntity2)));
+ assertNotNull(objEntity1.getAttribute("name"));
+ assertNotNull(objEntity1.getRelationship("rel1To2"));
+ assertNotNull(objEntity2.getRelationship("rel2To1"));
+
+ assertEquals(objEntity1.getRelationship("rel1To2").getDeleteRule(), DeleteRule.DEFAULT_DELETE_RULE_TO_MANY);
+ assertEquals(objEntity2.getRelationship("rel2To1").getDeleteRule(), DeleteRule.DEFAULT_DELETE_RULE_TO_ONE);
+
+ map.removeObjEntity(objEntity2.getName());
+ map.removeObjEntity(objEntity1.getName());
+ map.removeDbEntity(dbEntity2.getName());
+ map.removeDbEntity(dbEntity1.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java b/cayenne-server/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java
deleted file mode 100644
index fac1c32..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/util/EntityMergeSupportTest.java
+++ /dev/null
@@ -1,99 +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.util;
-
-import java.sql.Types;
-import java.util.Arrays;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.DeleteRule;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.merge.MergeCase;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class EntityMergeSupportTest extends MergeCase {
-
- public void testMerging() {
- DbEntity dbEntity1 = new DbEntity("NEW_TABLE");
-
- DbAttribute e1col1 = new DbAttribute("ID", Types.INTEGER, dbEntity1);
- e1col1.setMandatory(true);
- e1col1.setPrimaryKey(true);
- dbEntity1.addAttribute(e1col1);
-
- DbAttribute e1col2 = new DbAttribute("NAME", Types.VARCHAR, dbEntity1);
- e1col2.setMaxLength(10);
- e1col2.setMandatory(false);
- dbEntity1.addAttribute(e1col2);
-
- map.addDbEntity(dbEntity1);
-
- DbEntity dbEntity2 = new DbEntity("NEW_TABLE2");
- DbAttribute e2col1 = new DbAttribute("ID", Types.INTEGER, dbEntity2);
- e2col1.setMandatory(true);
- e2col1.setPrimaryKey(true);
- dbEntity2.addAttribute(e2col1);
- DbAttribute e2col2 = new DbAttribute("FK", Types.INTEGER, dbEntity2);
- dbEntity2.addAttribute(e2col2);
-
- map.addDbEntity(dbEntity2);
-
- // create db relationships
- DbRelationship rel1To2 = new DbRelationship("rel1To2");
- rel1To2.setSourceEntity(dbEntity1);
- rel1To2.setTargetEntity(dbEntity2);
- rel1To2.setToMany(true);
- rel1To2.addJoin(new DbJoin(rel1To2, e1col1.getName(), e2col2.getName()));
- dbEntity1.addRelationship(rel1To2);
- DbRelationship rel2To1 = new DbRelationship("rel2To1");
- rel2To1.setSourceEntity(dbEntity2);
- rel2To1.setTargetEntity(dbEntity1);
- rel2To1.setToMany(false);
- rel2To1.addJoin(new DbJoin(rel2To1, e2col2.getName(), e1col1.getName()));
- dbEntity2.addRelationship(rel2To1);
- assertSame(rel1To2, rel2To1.getReverseRelationship());
- assertSame(rel2To1, rel1To2.getReverseRelationship());
-
- ObjEntity objEntity1 = new ObjEntity("NewTable");
- objEntity1.setDbEntity(dbEntity1);
- map.addObjEntity(objEntity1);
-
- ObjEntity objEntity2 = new ObjEntity("NewTable2");
- objEntity2.setDbEntity(dbEntity2);
- map.addObjEntity(objEntity2);
-
- assertTrue(new EntityMergeSupport(map).synchronizeWithDbEntities(Arrays.asList(objEntity1, objEntity2)));
- assertNotNull(objEntity1.getAttribute("name"));
- assertNotNull(objEntity1.getRelationship("rel1To2"));
- assertNotNull(objEntity2.getRelationship("rel2To1"));
-
- assertEquals(objEntity1.getRelationship("rel1To2").getDeleteRule(), DeleteRule.DEFAULT_DELETE_RULE_TO_MANY);
- assertEquals(objEntity2.getRelationship("rel2To1").getDeleteRule(), DeleteRule.DEFAULT_DELETE_RULE_TO_ONE);
-
- map.removeObjEntity(objEntity2.getName());
- map.removeObjEntity(objEntity1.getName());
- map.removeDbEntity(dbEntity2.getName());
- map.removeDbEntity(dbEntity1.getName());
- }
-}