http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java deleted file mode 100644 index 6481114..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java +++ /dev/null @@ -1,263 +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.remote; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.cayenne.CayenneContext; -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.ObjectId; -import org.apache.cayenne.access.ClientServerChannel; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.event.MockEventManager; -import org.apache.cayenne.graph.GraphChangeHandler; -import org.apache.cayenne.graph.GraphDiff; -import org.apache.cayenne.map.LifecycleEvent; -import org.apache.cayenne.reflect.LifecycleCallbackRegistry; -import org.apache.cayenne.testdo.mt.ClientMtTable1; -import org.apache.cayenne.testdo.mt.ClientMtTable2; -import org.apache.cayenne.testdo.mt.MtTable1; -import org.apache.cayenne.unit.di.client.ClientCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) -public class ClientChannelServerDiffsTest extends ClientCase { - - @Inject - private ClientServerChannel clientServerChannel; - - @Inject - private ClientConnection connection; - - public void testReturnIdDiff() { - - final Object[] ids = new Object[2]; - - final GraphChangeHandler diffReader = new NoopGraphChangeHandler() { - - @Override - public void nodeIdChanged(Object oldId, Object newId) { - ids[0] = oldId; - ids[1] = newId; - } - }; - - ClientChannel channel = new ClientChannel( - connection, - false, - new MockEventManager(), - false) { - - @Override - public GraphDiff onSync( - ObjectContext originatingContext, - GraphDiff changes, - int syncType) { - - GraphDiff serverDiff = super - .onSync(originatingContext, changes, syncType); - - assertNotNull(serverDiff); - serverDiff.apply(diffReader); - return serverDiff; - } - }; - - CayenneContext context = new CayenneContext(channel); - context.newObject(ClientMtTable1.class); - context.commitChanges(); - - assertTrue(ids[0] instanceof ObjectId); - assertTrue(((ObjectId) ids[0]).isTemporary()); - - assertTrue(ids[1] instanceof ObjectId); - assertFalse(((ObjectId) ids[1]).isTemporary()); - } - - public void testReturnDiffInPrePersist() { - - final List<GenericDiff> diffs = new ArrayList<GenericDiff>(); - final NoopGraphChangeHandler diffReader = new NoopGraphChangeHandler() { - - @Override - public void nodePropertyChanged( - Object nodeId, - String property, - Object oldValue, - Object newValue) { - - super.nodePropertyChanged(nodeId, property, oldValue, newValue); - diffs - .add(new GenericDiff( - (ObjectId) nodeId, - property, - oldValue, - newValue)); - } - - }; - - LifecycleCallbackRegistry callbackRegistry = clientServerChannel - .getEntityResolver() - .getCallbackRegistry(); - - try { - - callbackRegistry.addListener( - LifecycleEvent.POST_ADD, - MtTable1.class, - new ClientChannelServerDiffsListener1(), - "prePersist"); - - ClientChannel channel = new ClientChannel( - connection, - false, - new MockEventManager(), - false) { - - @Override - public GraphDiff onSync( - ObjectContext originatingContext, - GraphDiff changes, - int syncType) { - - GraphDiff serverDiff = super.onSync( - originatingContext, - changes, - syncType); - - assertNotNull(serverDiff); - serverDiff.apply(diffReader); - return serverDiff; - } - }; - - CayenneContext context = new CayenneContext(channel); - ClientMtTable1 o = context.newObject(ClientMtTable1.class); - ObjectId tempId = o.getObjectId(); - o.setServerAttribute1("YY"); - context.commitChanges(); - - assertEquals(2, diffReader.size); - assertEquals(1, diffs.size()); - assertEquals(tempId, diffs.get(0).sourceId); - assertEquals(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, diffs.get(0).property); - assertNull(diffs.get(0).oldValue); - assertEquals("XXX", diffs.get(0).newValue); - } - finally { - callbackRegistry.clear(); - } - } - - public void testReturnDiffClientArcChanges() { - - final NoopGraphChangeHandler diffReader = new NoopGraphChangeHandler(); - - ClientChannel channel = new ClientChannel( - connection, - false, - new MockEventManager(), - false) { - - @Override - public GraphDiff onSync( - ObjectContext originatingContext, - GraphDiff changes, - int syncType) { - - GraphDiff serverDiff = super - .onSync(originatingContext, changes, syncType); - - assertNotNull(serverDiff); - serverDiff.apply(diffReader); - return serverDiff; - } - }; - - CayenneContext context = new CayenneContext(channel); - ClientMtTable1 o = context.newObject(ClientMtTable1.class); - ClientMtTable2 o2 = context.newObject(ClientMtTable2.class); - o.addToTable2Array(o2); - context.commitChanges(); - - assertEquals(2, diffReader.size); - - diffReader.reset(); - - ClientMtTable2 o3 = context.newObject(ClientMtTable2.class); - o3.setTable1(o); - context.commitChanges(); - assertEquals(1, diffReader.size); - } - - class NoopGraphChangeHandler implements GraphChangeHandler { - - int size; - - void reset() { - size = 0; - } - - public void nodePropertyChanged( - Object nodeId, - String property, - Object oldValue, - Object newValue) { - - size++; - } - - public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) { - size++; - } - - public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) { - size++; - } - - public void nodeCreated(Object nodeId) { - size++; - } - - public void nodeIdChanged(Object nodeId, Object newId) { - size++; - } - - public void nodeRemoved(Object nodeId) { - size++; - } - } - - class GenericDiff { - - private String property; - private Object oldValue; - private Object newValue; - private ObjectId sourceId; - - GenericDiff(ObjectId sourceId, String property, Object oldValue, Object newValue) { - this.sourceId = sourceId; - this.property = property; - this.oldValue = oldValue; - this.newValue = newValue; - } - } -}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/LightSuperClassIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/LightSuperClassIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/LightSuperClassIT.java new file mode 100644 index 0000000..a3ff1b5 --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/LightSuperClassIT.java @@ -0,0 +1,95 @@ +/***************************************************************** + * 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.remote; + +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.di.Inject; +import org.apache.cayenne.query.RefreshQuery; +import org.apache.cayenne.query.SelectQuery; +import org.apache.cayenne.test.jdbc.DBHelper; +import org.apache.cayenne.testdo.persistent.Continent; +import org.apache.cayenne.testdo.persistent.Country; +import org.apache.cayenne.unit.di.client.ClientCase; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +/** + * Test for entites that are implemented in same class on client and server + */ +@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) +public class LightSuperClassIT extends RemoteCayenneCase { + + @Inject + private DBHelper dbHelper; + + private boolean server; + + @Override + public void setUpAfterInjection() throws Exception { + super.setUpAfterInjection(); + + dbHelper.deleteAll("CONTINENT"); + dbHelper.deleteAll("COUNTRY"); + } + + @Override + public void runBare() throws Throwable { + server = true; + super.runBare(); + server = false; + + // testing ROP with all serialization policies + runBareSimple(); + } + + private ObjectContext createContext() { + if (server) { + return serverContext; + } + else { + return createROPContext(); + } + } + + public void testServer() throws Exception { + ObjectContext context = createContext(); + Continent continent = context.newObject(Continent.class); + continent.setName("Europe"); + + Country country = new Country(); + context.registerNewObject(country); + + // TODO: setting property before object creation does not work on ROP (CAY-1320) + country.setName("Russia"); + + country.setContinent(continent); + assertEquals(continent.getCountries().size(), 1); + + context.commitChanges(); + + context.deleteObjects(country); + assertEquals(continent.getCountries().size(), 0); + continent.setName("Australia"); + + context.commitChanges(); + context.performQuery(new RefreshQuery()); + + assertEquals(context.performQuery(new SelectQuery(Country.class)).size(), 0); + assertEquals(context.performQuery(new SelectQuery(Continent.class)).size(), 1); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/LightSuperClassTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/LightSuperClassTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/LightSuperClassTest.java deleted file mode 100644 index 80853f3..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/LightSuperClassTest.java +++ /dev/null @@ -1,95 +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.remote; - -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.query.RefreshQuery; -import org.apache.cayenne.query.SelectQuery; -import org.apache.cayenne.test.jdbc.DBHelper; -import org.apache.cayenne.testdo.persistent.Continent; -import org.apache.cayenne.testdo.persistent.Country; -import org.apache.cayenne.unit.di.client.ClientCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -/** - * Test for entites that are implemented in same class on client and server - */ -@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) -public class LightSuperClassTest extends RemoteCayenneCase { - - @Inject - private DBHelper dbHelper; - - private boolean server; - - @Override - public void setUpAfterInjection() throws Exception { - super.setUpAfterInjection(); - - dbHelper.deleteAll("CONTINENT"); - dbHelper.deleteAll("COUNTRY"); - } - - @Override - public void runBare() throws Throwable { - server = true; - super.runBare(); - server = false; - - // testing ROP with all serialization policies - runBareSimple(); - } - - private ObjectContext createContext() { - if (server) { - return serverContext; - } - else { - return createROPContext(); - } - } - - public void testServer() throws Exception { - ObjectContext context = createContext(); - Continent continent = context.newObject(Continent.class); - continent.setName("Europe"); - - Country country = new Country(); - context.registerNewObject(country); - - // TODO: setting property before object creation does not work on ROP (CAY-1320) - country.setName("Russia"); - - country.setContinent(continent); - assertEquals(continent.getCountries().size(), 1); - - context.commitChanges(); - - context.deleteObjects(country); - assertEquals(continent.getCountries().size(), 0); - continent.setName("Australia"); - - context.commitChanges(); - context.performQuery(new RefreshQuery()); - - assertEquals(context.performQuery(new SelectQuery(Country.class)).size(), 0); - assertEquals(context.performQuery(new SelectQuery(Continent.class)).size(), 1); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextLocalIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextLocalIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextLocalIT.java new file mode 100644 index 0000000..991072f --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextLocalIT.java @@ -0,0 +1,58 @@ +/***************************************************************** + * 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.remote; + +import java.util.List; + +import org.apache.cayenne.BaseContext; +import org.apache.cayenne.configuration.rop.client.ClientRuntime; +import org.apache.cayenne.di.Inject; +import org.apache.cayenne.query.QueryCacheStrategy; +import org.apache.cayenne.query.SelectQuery; +import org.apache.cayenne.testdo.mt.ClientMtTable1; +import org.apache.cayenne.unit.di.client.ClientCase; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) +public class NestedObjectContextLocalIT extends RemoteCayenneCase { + + @Inject + private ClientRuntime runtime; + + public void testLocalCacheStaysLocal() { + + SelectQuery query = new SelectQuery(ClientMtTable1.class); + query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE); + + BaseContext child1 = (BaseContext) runtime.newContext(clientContext); + + assertNull(child1.getQueryCache().get( + query.getMetaData(child1.getEntityResolver()))); + + assertNull(clientContext.getQueryCache().get( + query.getMetaData(clientContext.getEntityResolver()))); + + List<?> results = child1.performQuery(query); + assertSame(results, child1.getQueryCache().get( + query.getMetaData(child1.getEntityResolver()))); + + assertNull(clientContext.getQueryCache().get( + query.getMetaData(clientContext.getEntityResolver()))); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextLocalTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextLocalTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextLocalTest.java deleted file mode 100644 index 24ddc82..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextLocalTest.java +++ /dev/null @@ -1,58 +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.remote; - -import java.util.List; - -import org.apache.cayenne.BaseContext; -import org.apache.cayenne.configuration.rop.client.ClientRuntime; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.query.QueryCacheStrategy; -import org.apache.cayenne.query.SelectQuery; -import org.apache.cayenne.testdo.mt.ClientMtTable1; -import org.apache.cayenne.unit.di.client.ClientCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) -public class NestedObjectContextLocalTest extends RemoteCayenneCase { - - @Inject - private ClientRuntime runtime; - - public void testLocalCacheStaysLocal() { - - SelectQuery query = new SelectQuery(ClientMtTable1.class); - query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE); - - BaseContext child1 = (BaseContext) runtime.newContext(clientContext); - - assertNull(child1.getQueryCache().get( - query.getMetaData(child1.getEntityResolver()))); - - assertNull(clientContext.getQueryCache().get( - query.getMetaData(clientContext.getEntityResolver()))); - - List<?> results = child1.performQuery(query); - assertSame(results, child1.getQueryCache().get( - query.getMetaData(child1.getEntityResolver()))); - - assertNull(clientContext.getQueryCache().get( - query.getMetaData(clientContext.getEntityResolver()))); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextParentEventsIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextParentEventsIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextParentEventsIT.java new file mode 100644 index 0000000..ba4ad9a --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextParentEventsIT.java @@ -0,0 +1,64 @@ +/***************************************************************** + * 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.remote; + +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.configuration.rop.client.ClientRuntime; +import org.apache.cayenne.di.Inject; +import org.apache.cayenne.test.jdbc.DBHelper; +import org.apache.cayenne.testdo.mt.ClientMtTable1; +import org.apache.cayenne.unit.di.client.ClientCase; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) +public class NestedObjectContextParentEventsIT extends RemoteCayenneCase { + + @Inject + private DBHelper dbHelper; + + @Inject + private ClientRuntime runtime; + + @Override + public void setUpAfterInjection() throws Exception { + super.setUpAfterInjection(); + + dbHelper.deleteAll("MT_TABLE2"); + dbHelper.deleteAll("MT_TABLE1"); + } + + public void testParentUpdatedId() throws Exception { + ObjectContext child = runtime.newContext(clientContext); + + ClientMtTable1 ac = child.newObject(ClientMtTable1.class); + ac.setGlobalAttribute1("X"); + child.commitChangesToParent(); + + ClientMtTable1 ap = (ClientMtTable1) clientContext.getGraphManager().getNode( + ac.getObjectId()); + assertNotNull(ap); + + assertTrue(ap.getObjectId().isTemporary()); + clientContext.commitChanges(); + + assertFalse(ap.getObjectId().isTemporary()); + assertEquals(ap.getObjectId(), ac.getObjectId()); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextParentEventsTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextParentEventsTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextParentEventsTest.java deleted file mode 100644 index 1f40a8f..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextParentEventsTest.java +++ /dev/null @@ -1,64 +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.remote; - -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.configuration.rop.client.ClientRuntime; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.test.jdbc.DBHelper; -import org.apache.cayenne.testdo.mt.ClientMtTable1; -import org.apache.cayenne.unit.di.client.ClientCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) -public class NestedObjectContextParentEventsTest extends RemoteCayenneCase { - - @Inject - private DBHelper dbHelper; - - @Inject - private ClientRuntime runtime; - - @Override - public void setUpAfterInjection() throws Exception { - super.setUpAfterInjection(); - - dbHelper.deleteAll("MT_TABLE2"); - dbHelper.deleteAll("MT_TABLE1"); - } - - public void testParentUpdatedId() throws Exception { - ObjectContext child = runtime.newContext(clientContext); - - ClientMtTable1 ac = child.newObject(ClientMtTable1.class); - ac.setGlobalAttribute1("X"); - child.commitChangesToParent(); - - ClientMtTable1 ap = (ClientMtTable1) clientContext.getGraphManager().getNode( - ac.getObjectId()); - assertNotNull(ap); - - assertTrue(ap.getObjectId().isTemporary()); - clientContext.commitChanges(); - - assertFalse(ap.getObjectId().isTemporary()); - assertEquals(ap.getObjectId(), ac.getObjectId()); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextPeerEventsIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextPeerEventsIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextPeerEventsIT.java new file mode 100644 index 0000000..5ad385a --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextPeerEventsIT.java @@ -0,0 +1,149 @@ +/***************************************************************** + * 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.remote; + +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.ObjectId; +import org.apache.cayenne.configuration.rop.client.ClientRuntime; +import org.apache.cayenne.di.Inject; +import org.apache.cayenne.test.jdbc.DBHelper; +import org.apache.cayenne.testdo.mt.ClientMtTable1; +import org.apache.cayenne.testdo.mt.ClientMtTable2; +import org.apache.cayenne.unit.di.client.ClientCase; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) +public class NestedObjectContextPeerEventsIT extends RemoteCayenneCase { + + @Inject + private ClientRuntime runtime; + + @Inject + private DBHelper dbHelper; + + @Override + public void setUpAfterInjection() throws Exception { + super.setUpAfterInjection(); + + dbHelper.deleteAll("MT_TABLE2"); + dbHelper.deleteAll("MT_TABLE1"); + } + + public void testPeerObjectUpdatedTempOID() throws Exception { + ObjectContext peer1 = runtime.newContext(clientContext); + ClientMtTable1 a1 = peer1.newObject(ClientMtTable1.class); + a1.setGlobalAttribute1("Y"); + ObjectId a1TempId = a1.getObjectId(); + + ObjectContext peer2 = runtime.newContext(clientContext); + ClientMtTable1 a2 = peer2.localObject(a1); + + assertEquals(a1TempId, a2.getObjectId()); + + peer1.commitChanges(); + assertFalse(a1.getObjectId().isTemporary()); + assertFalse(a2.getObjectId().isTemporary()); + assertEquals(a2.getObjectId(), a1.getObjectId()); + } + + public void testPeerObjectUpdatedSimpleProperty() throws Exception { + ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class); + a.setGlobalAttribute1("X"); + clientContext.commitChanges(); + + ObjectContext peer1 = runtime.newContext(clientContext); + ClientMtTable1 a1 = peer1.localObject(a); + + ObjectContext peer2 = runtime.newContext(clientContext); + ClientMtTable1 a2 = peer2.localObject(a); + + a1.setGlobalAttribute1("Y"); + assertEquals("X", a2.getGlobalAttribute1()); + peer1.commitChangesToParent(); + assertEquals("Y", a2.getGlobalAttribute1()); + + assertFalse( + "Peer data context became dirty on event processing", + peer2.hasChanges()); + } + + public void testPeerObjectUpdatedToOneRelationship() throws Exception { + ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class); + ClientMtTable1 altA = clientContext.newObject(ClientMtTable1.class); + + ClientMtTable2 p = clientContext.newObject(ClientMtTable2.class); + p.setTable1(a); + p.setGlobalAttribute("PPP"); + a.setGlobalAttribute1("X"); + altA.setGlobalAttribute1("Y"); + clientContext.commitChanges(); + + ObjectContext peer1 = runtime.newContext(clientContext); + ClientMtTable2 p1 = peer1.localObject(p); + ClientMtTable1 altA1 = peer1.localObject(altA); + + ObjectContext peer2 = runtime.newContext(clientContext); + ClientMtTable2 p2 = peer2.localObject(p); + ClientMtTable1 altA2 = peer2.localObject(altA); + ClientMtTable1 a2 = peer2.localObject(a); + + p1.setTable1(altA1); + assertSame(a2, p2.getTable1()); + peer1.commitChangesToParent(); + assertEquals(altA2, p2.getTable1()); + + assertFalse( + "Peer data context became dirty on event processing", + peer2.hasChanges()); + } + + public void testPeerObjectUpdatedToManyRelationship() throws Exception { + ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class); + a.setGlobalAttribute1("X"); + + ClientMtTable2 px = clientContext.newObject(ClientMtTable2.class); + px.setTable1(a); + px.setGlobalAttribute("PX"); + + ClientMtTable2 py = clientContext.newObject(ClientMtTable2.class); + py.setGlobalAttribute("PY"); + + clientContext.commitChanges(); + + ObjectContext peer1 = runtime.newContext(clientContext); + ClientMtTable2 py1 = peer1.localObject(py); + ClientMtTable1 a1 = peer1.localObject(a); + + ObjectContext peer2 = runtime.newContext(clientContext); + ClientMtTable2 py2 = peer2.localObject(py); + ClientMtTable1 a2 = peer2.localObject(a); + + a1.addToTable2Array(py1); + assertEquals(1, a2.getTable2Array().size()); + assertFalse(a2.getTable2Array().contains(py2)); + peer1.commitChangesToParent(); + assertEquals(2, a2.getTable2Array().size()); + assertTrue(a2.getTable2Array().contains(py2)); + + assertFalse( + "Peer data context became dirty on event processing", + peer2.hasChanges()); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextPeerEventsTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextPeerEventsTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextPeerEventsTest.java deleted file mode 100644 index fbb0e52..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextPeerEventsTest.java +++ /dev/null @@ -1,149 +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.remote; - -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.ObjectId; -import org.apache.cayenne.configuration.rop.client.ClientRuntime; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.test.jdbc.DBHelper; -import org.apache.cayenne.testdo.mt.ClientMtTable1; -import org.apache.cayenne.testdo.mt.ClientMtTable2; -import org.apache.cayenne.unit.di.client.ClientCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) -public class NestedObjectContextPeerEventsTest extends RemoteCayenneCase { - - @Inject - private ClientRuntime runtime; - - @Inject - private DBHelper dbHelper; - - @Override - public void setUpAfterInjection() throws Exception { - super.setUpAfterInjection(); - - dbHelper.deleteAll("MT_TABLE2"); - dbHelper.deleteAll("MT_TABLE1"); - } - - public void testPeerObjectUpdatedTempOID() throws Exception { - ObjectContext peer1 = runtime.newContext(clientContext); - ClientMtTable1 a1 = peer1.newObject(ClientMtTable1.class); - a1.setGlobalAttribute1("Y"); - ObjectId a1TempId = a1.getObjectId(); - - ObjectContext peer2 = runtime.newContext(clientContext); - ClientMtTable1 a2 = peer2.localObject(a1); - - assertEquals(a1TempId, a2.getObjectId()); - - peer1.commitChanges(); - assertFalse(a1.getObjectId().isTemporary()); - assertFalse(a2.getObjectId().isTemporary()); - assertEquals(a2.getObjectId(), a1.getObjectId()); - } - - public void testPeerObjectUpdatedSimpleProperty() throws Exception { - ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class); - a.setGlobalAttribute1("X"); - clientContext.commitChanges(); - - ObjectContext peer1 = runtime.newContext(clientContext); - ClientMtTable1 a1 = peer1.localObject(a); - - ObjectContext peer2 = runtime.newContext(clientContext); - ClientMtTable1 a2 = peer2.localObject(a); - - a1.setGlobalAttribute1("Y"); - assertEquals("X", a2.getGlobalAttribute1()); - peer1.commitChangesToParent(); - assertEquals("Y", a2.getGlobalAttribute1()); - - assertFalse( - "Peer data context became dirty on event processing", - peer2.hasChanges()); - } - - public void testPeerObjectUpdatedToOneRelationship() throws Exception { - ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class); - ClientMtTable1 altA = clientContext.newObject(ClientMtTable1.class); - - ClientMtTable2 p = clientContext.newObject(ClientMtTable2.class); - p.setTable1(a); - p.setGlobalAttribute("PPP"); - a.setGlobalAttribute1("X"); - altA.setGlobalAttribute1("Y"); - clientContext.commitChanges(); - - ObjectContext peer1 = runtime.newContext(clientContext); - ClientMtTable2 p1 = peer1.localObject(p); - ClientMtTable1 altA1 = peer1.localObject(altA); - - ObjectContext peer2 = runtime.newContext(clientContext); - ClientMtTable2 p2 = peer2.localObject(p); - ClientMtTable1 altA2 = peer2.localObject(altA); - ClientMtTable1 a2 = peer2.localObject(a); - - p1.setTable1(altA1); - assertSame(a2, p2.getTable1()); - peer1.commitChangesToParent(); - assertEquals(altA2, p2.getTable1()); - - assertFalse( - "Peer data context became dirty on event processing", - peer2.hasChanges()); - } - - public void testPeerObjectUpdatedToManyRelationship() throws Exception { - ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class); - a.setGlobalAttribute1("X"); - - ClientMtTable2 px = clientContext.newObject(ClientMtTable2.class); - px.setTable1(a); - px.setGlobalAttribute("PX"); - - ClientMtTable2 py = clientContext.newObject(ClientMtTable2.class); - py.setGlobalAttribute("PY"); - - clientContext.commitChanges(); - - ObjectContext peer1 = runtime.newContext(clientContext); - ClientMtTable2 py1 = peer1.localObject(py); - ClientMtTable1 a1 = peer1.localObject(a); - - ObjectContext peer2 = runtime.newContext(clientContext); - ClientMtTable2 py2 = peer2.localObject(py); - ClientMtTable1 a2 = peer2.localObject(a); - - a1.addToTable2Array(py1); - assertEquals(1, a2.getTable2Array().size()); - assertFalse(a2.getTable2Array().contains(py2)); - peer1.commitChangesToParent(); - assertEquals(2, a2.getTable2Array().size()); - assertTrue(a2.getTable2Array().contains(py2)); - - assertFalse( - "Peer data context became dirty on event processing", - peer2.hasChanges()); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextRollbackIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextRollbackIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextRollbackIT.java new file mode 100644 index 0000000..3fef10c --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextRollbackIT.java @@ -0,0 +1,71 @@ +/***************************************************************** + * 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.remote; + +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.configuration.rop.client.ClientRuntime; +import org.apache.cayenne.di.Inject; +import org.apache.cayenne.testdo.mt.ClientMtTable1; +import org.apache.cayenne.unit.di.client.ClientCase; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) +public class NestedObjectContextRollbackIT extends RemoteCayenneCase { + + @Inject + private ClientRuntime runtime; + + public void testRollbackChanges() { + ObjectContext child1 = runtime.newContext(clientContext); + + assertFalse(clientContext.hasChanges()); + assertFalse(child1.hasChanges()); + + clientContext.newObject(ClientMtTable1.class); + child1.newObject(ClientMtTable1.class); + + assertTrue(clientContext.hasChanges()); + assertTrue(child1.hasChanges()); + + child1.rollbackChanges(); + assertFalse(clientContext.hasChanges()); + assertFalse(child1.hasChanges()); + + clientContext.rollbackChanges(); + } + + public void testRollbackChangesLocally() { + ObjectContext child1 = runtime.newContext(clientContext); + + assertFalse(clientContext.hasChanges()); + assertFalse(child1.hasChanges()); + + clientContext.newObject(ClientMtTable1.class); + child1.newObject(ClientMtTable1.class); + + assertTrue(clientContext.hasChanges()); + assertTrue(child1.hasChanges()); + + child1.rollbackChangesLocally(); + assertTrue(clientContext.hasChanges()); + assertFalse(child1.hasChanges()); + + clientContext.rollbackChanges(); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextRollbackTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextRollbackTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextRollbackTest.java deleted file mode 100644 index fdf7c5d..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/NestedObjectContextRollbackTest.java +++ /dev/null @@ -1,71 +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.remote; - -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.configuration.rop.client.ClientRuntime; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.testdo.mt.ClientMtTable1; -import org.apache.cayenne.unit.di.client.ClientCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) -public class NestedObjectContextRollbackTest extends RemoteCayenneCase { - - @Inject - private ClientRuntime runtime; - - public void testRollbackChanges() { - ObjectContext child1 = runtime.newContext(clientContext); - - assertFalse(clientContext.hasChanges()); - assertFalse(child1.hasChanges()); - - clientContext.newObject(ClientMtTable1.class); - child1.newObject(ClientMtTable1.class); - - assertTrue(clientContext.hasChanges()); - assertTrue(child1.hasChanges()); - - child1.rollbackChanges(); - assertFalse(clientContext.hasChanges()); - assertFalse(child1.hasChanges()); - - clientContext.rollbackChanges(); - } - - public void testRollbackChangesLocally() { - ObjectContext child1 = runtime.newContext(clientContext); - - assertFalse(clientContext.hasChanges()); - assertFalse(child1.hasChanges()); - - clientContext.newObject(ClientMtTable1.class); - child1.newObject(ClientMtTable1.class); - - assertTrue(clientContext.hasChanges()); - assertTrue(child1.hasChanges()); - - child1.rollbackChangesLocally(); - assertTrue(clientContext.hasChanges()); - assertFalse(child1.hasChanges()); - - clientContext.rollbackChanges(); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/ROPPrefetchToManyMapIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/ROPPrefetchToManyMapIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/ROPPrefetchToManyMapIT.java new file mode 100644 index 0000000..b6b6875 --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/ROPPrefetchToManyMapIT.java @@ -0,0 +1,70 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ****************************************************************/ +package org.apache.cayenne.remote; + +import org.apache.cayenne.Cayenne; +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.di.Inject; +import org.apache.cayenne.query.RefreshQuery; +import org.apache.cayenne.query.SelectQuery; +import org.apache.cayenne.test.jdbc.DBHelper; +import org.apache.cayenne.testdo.mt.ClientMtMapToMany; +import org.apache.cayenne.testdo.mt.ClientMtMapToManyTarget; +import org.apache.cayenne.unit.di.DataChannelInterceptor; +import org.apache.cayenne.unit.di.UnitTestClosure; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +@UseServerRuntime("cayenne-multi-tier.xml") +public class ROPPrefetchToManyMapIT extends RemoteCayenneCase { + + @Inject + private DBHelper dbHelper; + + @Inject + private DataChannelInterceptor queryInterceptor; + + @Override + public void setUpAfterInjection() throws Exception { + dbHelper.deleteAll("MT_MAP_TO_MANY_TARGET"); + dbHelper.deleteAll("MT_MAP_TO_MANY"); + } + + public void test() throws Exception { + ObjectContext context = createROPContext(); + + ClientMtMapToMany map = context.newObject(ClientMtMapToMany.class); + ClientMtMapToManyTarget target = context.newObject(ClientMtMapToManyTarget.class); + target.setMapToMany(map); + context.commitChanges(); + + context.performQuery(new RefreshQuery()); + + SelectQuery query = new SelectQuery(ClientMtMapToMany.class); + query.addPrefetch("targets"); + + final ClientMtMapToMany mapToMany = (ClientMtMapToMany) Cayenne.objectForQuery(context, query); + + queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() { + + public void execute() { + assertEquals(mapToMany.getTargets().size(), 1); + } + }); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/ROPPrefetchToManyMapTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/ROPPrefetchToManyMapTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/ROPPrefetchToManyMapTest.java deleted file mode 100644 index 1951f41..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/ROPPrefetchToManyMapTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ -package org.apache.cayenne.remote; - -import org.apache.cayenne.Cayenne; -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.query.RefreshQuery; -import org.apache.cayenne.query.SelectQuery; -import org.apache.cayenne.test.jdbc.DBHelper; -import org.apache.cayenne.testdo.mt.ClientMtMapToMany; -import org.apache.cayenne.testdo.mt.ClientMtMapToManyTarget; -import org.apache.cayenne.unit.di.DataChannelInterceptor; -import org.apache.cayenne.unit.di.UnitTestClosure; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -@UseServerRuntime("cayenne-multi-tier.xml") -public class ROPPrefetchToManyMapTest extends RemoteCayenneCase { - - @Inject - private DBHelper dbHelper; - - @Inject - private DataChannelInterceptor queryInterceptor; - - @Override - public void setUpAfterInjection() throws Exception { - dbHelper.deleteAll("MT_MAP_TO_MANY_TARGET"); - dbHelper.deleteAll("MT_MAP_TO_MANY"); - } - - public void test() throws Exception { - ObjectContext context = createROPContext(); - - ClientMtMapToMany map = context.newObject(ClientMtMapToMany.class); - ClientMtMapToManyTarget target = context.newObject(ClientMtMapToManyTarget.class); - target.setMapToMany(map); - context.commitChanges(); - - context.performQuery(new RefreshQuery()); - - SelectQuery query = new SelectQuery(ClientMtMapToMany.class); - query.addPrefetch("targets"); - - final ClientMtMapToMany mapToMany = (ClientMtMapToMany) Cayenne.objectForQuery(context, query); - - queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() { - - public void execute() { - assertEquals(mapToMany.getTargets().size(), 1); - } - }); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/RelationshipChangeIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/RelationshipChangeIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/RelationshipChangeIT.java new file mode 100644 index 0000000..b488d80 --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/RelationshipChangeIT.java @@ -0,0 +1,60 @@ +/***************************************************************** + * 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.remote; + +import org.apache.cayenne.testdo.mt.ClientMtTable1; +import org.apache.cayenne.testdo.mt.ClientMtTable2; +import org.apache.cayenne.unit.di.client.ClientCase; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +/** + * This is a test primarily for CAY-1118 + */ +@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) +public class RelationshipChangeIT extends RemoteCayenneCase { + + public void testNullify() { + ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class); + ClientMtTable2 o2 = clientContext.newObject(ClientMtTable2.class); + + o2.setTable1(o1); + + assertEquals(1, o1.getTable2Array().size()); + clientContext.commitChanges(); + + o2.setTable1(null); + assertEquals(0, o1.getTable2Array().size()); + } + + public void testChange() { + ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class); + ClientMtTable2 o2 = clientContext.newObject(ClientMtTable2.class); + + ClientMtTable1 o3 = clientContext.newObject(ClientMtTable1.class); + + o2.setTable1(o1); + + assertEquals(1, o1.getTable2Array().size()); + clientContext.commitChanges(); + + o2.setTable1(o3); + assertEquals(0, o1.getTable2Array().size()); + assertEquals(1, o3.getTable2Array().size()); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/RelationshipChangeTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/RelationshipChangeTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/RelationshipChangeTest.java deleted file mode 100644 index 463e299..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/RelationshipChangeTest.java +++ /dev/null @@ -1,60 +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.remote; - -import org.apache.cayenne.testdo.mt.ClientMtTable1; -import org.apache.cayenne.testdo.mt.ClientMtTable2; -import org.apache.cayenne.unit.di.client.ClientCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -/** - * This is a test primarily for CAY-1118 - */ -@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) -public class RelationshipChangeTest extends RemoteCayenneCase { - - public void testNullify() { - ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class); - ClientMtTable2 o2 = clientContext.newObject(ClientMtTable2.class); - - o2.setTable1(o1); - - assertEquals(1, o1.getTable2Array().size()); - clientContext.commitChanges(); - - o2.setTable1(null); - assertEquals(0, o1.getTable2Array().size()); - } - - public void testChange() { - ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class); - ClientMtTable2 o2 = clientContext.newObject(ClientMtTable2.class); - - ClientMtTable1 o3 = clientContext.newObject(ClientMtTable1.class); - - o2.setTable1(o1); - - assertEquals(1, o1.getTable2Array().size()); - clientContext.commitChanges(); - - o2.setTable1(o3); - assertEquals(0, o1.getTable2Array().size()); - assertEquals(1, o3.getTable2Array().size()); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteCallbacksIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteCallbacksIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteCallbacksIT.java new file mode 100644 index 0000000..156b267 --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteCallbacksIT.java @@ -0,0 +1,118 @@ +/***************************************************************** + * 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.remote; + +import org.apache.cayenne.LifecycleListener; +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.testdo.mt.ClientMtLifecycles; +import org.apache.cayenne.unit.di.client.ClientCase; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) +public class RemoteCallbacksIT extends RemoteCayenneCase implements LifecycleListener { + private int added, loaded, prePersisted, postPersisted, preRemoved, postRemoved, preUpdated, postUpdated; + + @Override + public void setUpAfterInjection() throws Exception { + super.setUpAfterInjection(); + + added = 0; + loaded = 0; + prePersisted = 0; + postPersisted = 0; + preRemoved = 0; + postRemoved = 0; + preUpdated = 0; + postUpdated = 0; + } + + public void testDefault() throws InterruptedException { + ObjectContext context = createROPContext(); + context.getEntityResolver().getCallbackRegistry().addListener(ClientMtLifecycles.class, this); + + assertAll(0, 0, 0, 0, 0, 0, 0, 0); + ClientMtLifecycles l1 = context.newObject(ClientMtLifecycles.class); + + assertAll(1, 0, 0, 0, 0, 0, 0, 0); + l1.setName("x"); + assertAll(1, 0, 0, 0, 0, 0, 0, 0); + + context.commitChanges(); + Thread.sleep(5); //until commit + assertAll(1, 0, 1, 1, 0, 0, 0, 0); + + l1.setName("x2"); + assertAll(1, 0, 1, 1, 0, 0, 0, 0); + + context.commitChanges(); + Thread.sleep(5); //until commit + assertAll(1, 0, 1, 1, 1, 1, 0, 0); + + context.deleteObjects(l1); + assertAll(1, 0, 1, 1, 1, 1, 1, 0); + + context.commitChanges(); + Thread.sleep(5); //until commit + assertAll(1, 0, 1, 1, 1, 1, 1, 1); + } + + private void assertAll(int added, int loaded, int prePersisted, int postPersisted, + int preUpdated, int postUpdated, int preRemoved, int postRemoved) { + assertEquals(this.added, added); + assertEquals(this.loaded, loaded); + assertEquals(this.prePersisted, prePersisted); + assertEquals(this.postPersisted, postPersisted); + assertEquals(this.preRemoved, preRemoved); + assertEquals(this.postRemoved, postRemoved); + assertEquals(this.preUpdated, preUpdated); + assertEquals(this.postUpdated, postUpdated); + } + + public void postAdd(Object entity) { + added++; + } + + public void postLoad(Object entity) { + loaded++; + } + + public void postPersist(Object entity) { + postPersisted++; + } + + public void postRemove(Object entity) { + postRemoved++; + } + + public void postUpdate(Object entity) { + postUpdated++; + } + + public void prePersist(Object entity) { + prePersisted++; + } + + public void preRemove(Object entity) { + preRemoved++; + } + + public void preUpdate(Object entity) { + preUpdated++; + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteCallbacksTest.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteCallbacksTest.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteCallbacksTest.java deleted file mode 100644 index efecb70..0000000 --- a/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteCallbacksTest.java +++ /dev/null @@ -1,118 +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.remote; - -import org.apache.cayenne.LifecycleListener; -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.testdo.mt.ClientMtLifecycles; -import org.apache.cayenne.unit.di.client.ClientCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; - -@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) -public class RemoteCallbacksTest extends RemoteCayenneCase implements LifecycleListener { - private int added, loaded, prePersisted, postPersisted, preRemoved, postRemoved, preUpdated, postUpdated; - - @Override - public void setUpAfterInjection() throws Exception { - super.setUpAfterInjection(); - - added = 0; - loaded = 0; - prePersisted = 0; - postPersisted = 0; - preRemoved = 0; - postRemoved = 0; - preUpdated = 0; - postUpdated = 0; - } - - public void testDefault() throws InterruptedException { - ObjectContext context = createROPContext(); - context.getEntityResolver().getCallbackRegistry().addListener(ClientMtLifecycles.class, this); - - assertAll(0, 0, 0, 0, 0, 0, 0, 0); - ClientMtLifecycles l1 = context.newObject(ClientMtLifecycles.class); - - assertAll(1, 0, 0, 0, 0, 0, 0, 0); - l1.setName("x"); - assertAll(1, 0, 0, 0, 0, 0, 0, 0); - - context.commitChanges(); - Thread.sleep(5); //until commit - assertAll(1, 0, 1, 1, 0, 0, 0, 0); - - l1.setName("x2"); - assertAll(1, 0, 1, 1, 0, 0, 0, 0); - - context.commitChanges(); - Thread.sleep(5); //until commit - assertAll(1, 0, 1, 1, 1, 1, 0, 0); - - context.deleteObjects(l1); - assertAll(1, 0, 1, 1, 1, 1, 1, 0); - - context.commitChanges(); - Thread.sleep(5); //until commit - assertAll(1, 0, 1, 1, 1, 1, 1, 1); - } - - private void assertAll(int added, int loaded, int prePersisted, int postPersisted, - int preUpdated, int postUpdated, int preRemoved, int postRemoved) { - assertEquals(this.added, added); - assertEquals(this.loaded, loaded); - assertEquals(this.prePersisted, prePersisted); - assertEquals(this.postPersisted, postPersisted); - assertEquals(this.preRemoved, preRemoved); - assertEquals(this.postRemoved, postRemoved); - assertEquals(this.preUpdated, preUpdated); - assertEquals(this.postUpdated, postUpdated); - } - - public void postAdd(Object entity) { - added++; - } - - public void postLoad(Object entity) { - loaded++; - } - - public void postPersist(Object entity) { - postPersisted++; - } - - public void postRemove(Object entity) { - postRemoved++; - } - - public void postUpdate(Object entity) { - postUpdated++; - } - - public void prePersist(Object entity) { - prePersisted++; - } - - public void preRemove(Object entity) { - preRemoved++; - } - - public void preUpdate(Object entity) { - preUpdated++; - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/fcb1d536/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListIT.java ---------------------------------------------------------------------- diff --git a/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListIT.java b/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListIT.java new file mode 100644 index 0000000..82fe796 --- /dev/null +++ b/cayenne-client/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListIT.java @@ -0,0 +1,266 @@ +/***************************************************************** + * 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.remote; + +import org.apache.cayenne.CayenneContext; +import org.apache.cayenne.Persistent; +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.query.SortOrder; +import org.apache.cayenne.test.jdbc.DBHelper; +import org.apache.cayenne.test.jdbc.TableHelper; +import org.apache.cayenne.testdo.mt.ClientMtTable1; +import org.apache.cayenne.testdo.mt.MtTable1; +import org.apache.cayenne.unit.di.client.ClientCase; +import org.apache.cayenne.unit.di.server.UseServerRuntime; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT) +public class RemoteIncrementalFaultListIT extends ClientCase { + + private static final int COUNT = 25; + + @Inject + private CayenneContext clientContext; + + @Inject + private DBHelper dbHelper; + + private TableHelper tMTTable; + + private RemoteIncrementalFaultList list; + private SelectQuery query; + + @Override + protected void setUpAfterInjection() throws Exception { + dbHelper.deleteAll("MT_TABLE2"); + dbHelper.deleteAll("MT_TABLE1"); + + tMTTable = new TableHelper(dbHelper, "MT_TABLE1"); + tMTTable.setColumns("TABLE1_ID", "GLOBAL_ATTRIBUTE1", "SERVER_ATTRIBUTE1"); + } + + protected void createObjectsDataSet() throws Exception { + tMTTable.insert(1, "g1", "s1"); + tMTTable.insert(2, "g2", "s2"); + tMTTable.insert(3, "g3", "s3"); + tMTTable.insert(4, "g4", "s4"); + tMTTable.insert(5, "g5", "s5"); + tMTTable.insert(6, "g6", "s6"); + tMTTable.insert(7, "g7", "s7"); + tMTTable.insert(8, "g8", "s8"); + tMTTable.insert(9, "g9", "s9"); + tMTTable.insert(10, "g10", "s10"); + tMTTable.insert(11, "g11", "s11"); + tMTTable.insert(12, "g12", "s12"); + tMTTable.insert(13, "g13", "s13"); + tMTTable.insert(14, "g14", "s14"); + tMTTable.insert(15, "g15", "s15"); + tMTTable.insert(16, "g16", "s16"); + tMTTable.insert(17, "g17", "s17"); + tMTTable.insert(18, "g18", "s18"); + tMTTable.insert(19, "g19", "s19"); + tMTTable.insert(20, "g20", "s20"); + tMTTable.insert(21, "g21", "s21"); + tMTTable.insert(22, "g22", "s22"); + tMTTable.insert(23, "g23", "s23"); + tMTTable.insert(24, "g24", "s24"); + tMTTable.insert(25, "g25", "s25"); + } + + private void prepareList(int pageSize) throws Exception { + + createObjectsDataSet(); + + query = new SelectQuery(ClientMtTable1.class); + + // make sure total number of objects is not divisable + // by the page size, to test the last smaller page + query.setPageSize(pageSize); + query.addOrdering("db:" + MtTable1.TABLE1_ID_PK_COLUMN, SortOrder.ASCENDING); + + list = new RemoteIncrementalFaultList(clientContext, query); + } + + public void testSize() throws Exception { + prepareList(6); + assertEquals(COUNT, list.size()); + } + + public void testIteratorPageSize1() throws Exception { + doTestIterator(1); + } + + public void testIteratorPageSize5() throws Exception { + // size divisiable by page size + doTestIterator(5); + } + + public void testIteratorPageSize6() throws Exception { + // size not divisable by page size + doTestIterator(6); + } + + public void testIteratorPageSize25() throws Exception { + // size equals to page size + doTestIterator(COUNT); + } + + public void testIteratorPageSize26() throws Exception { + // size exceeding page size + doTestIterator(COUNT + 1); + } + + public void testListIterator() throws Exception { + prepareList(6); + ListIterator<?> it = list.listIterator(); + + assertTrue(it.hasNext()); + + int counter = 0; + while (it.hasNext()) { + Object obj = it.next(); + assertNotNull(obj); + assertTrue(obj instanceof Persistent); + + // iterator must be resolved page by page + int expectedResolved = list.pageIndex(counter) + * list.getPageSize() + + list.getPageSize(); + if (expectedResolved > list.size()) { + expectedResolved = list.size(); + } + + assertEquals(list.size() - expectedResolved, list.getUnfetchedObjects()); + + counter++; + } + } + + public void testUnfetchedObjects() throws Exception { + prepareList(6); + assertEquals(COUNT - 6, list.getUnfetchedObjects()); + list.get(7); + assertEquals(COUNT - 12, list.getUnfetchedObjects()); + list.resolveAll(); + assertEquals(0, list.getUnfetchedObjects()); + } + + public void testPageIndex() throws Exception { + prepareList(6); + assertEquals(0, list.pageIndex(0)); + assertEquals(0, list.pageIndex(1)); + assertEquals(1, list.pageIndex(6)); + + try { + assertEquals(13, list.pageIndex(82)); + fail("Element index beyound array size must throw an IndexOutOfBoundsException."); + } + catch (IndexOutOfBoundsException ex) { + // exception expercted + } + } + + public void testPagesRead1() throws Exception { + prepareList(6); + assertTrue(list.elements.get(0) instanceof ClientMtTable1); + assertSame(RemoteIncrementalFaultList.PLACEHOLDER, list.elements.get(8)); + + list.resolveInterval(5, 10); + assertTrue(list.elements.get(7) instanceof ClientMtTable1); + + list.resolveAll(); + assertTrue((list.elements.get(list.size() - 1)) instanceof ClientMtTable1); + } + + public void testGet1() throws Exception { + prepareList(6); + assertTrue(list.elements.get(0) instanceof ClientMtTable1); + assertSame(RemoteIncrementalFaultList.PLACEHOLDER, list.elements.get(8)); + + Object a = list.get(8); + + assertNotNull(a); + assertTrue(a instanceof ClientMtTable1); + assertTrue(list.elements.get(8) instanceof ClientMtTable1); + } + + public void testIndexOf() throws Exception { + prepareList(6); + + Expression qual = ExpressionFactory.matchExp( + ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, + "g20"); + SelectQuery query = new SelectQuery(ClientMtTable1.class, qual); + List<?> artists = list.context.performQuery(query); + + assertEquals(1, artists.size()); + + ClientMtTable1 row = (ClientMtTable1) artists.get(0); + assertEquals(19, list.indexOf(row)); + assertEquals(-1, list.indexOf(list.context.newObject(ClientMtTable1.class))); + } + + public void testLastIndexOf() throws Exception { + prepareList(6); + Expression qual = ExpressionFactory.matchExp( + ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, + "g20"); + SelectQuery query = new SelectQuery(ClientMtTable1.class, qual); + List<?> objects = list.context.performQuery(query); + + assertEquals(1, objects.size()); + + ClientMtTable1 row = (ClientMtTable1) objects.get(0); + assertEquals(19, list.lastIndexOf(row)); + assertEquals(-1, list.lastIndexOf(list.context.newObject(ClientMtTable1.class))); + } + + private void doTestIterator(int size) throws Exception { + prepareList(size); + Iterator<?> it = list.iterator(); + + assertTrue(it.hasNext()); + + int counter = 0; + while (it.hasNext()) { + Object obj = it.next(); + assertNotNull(obj); + assertTrue(obj instanceof Persistent); + + // iterator must be resolved page by page + int expectedResolved = list.pageIndex(counter) + * list.getPageSize() + + list.getPageSize(); + if (expectedResolved > list.size()) { + expectedResolved = list.size(); + } + + assertEquals(list.size() - expectedResolved, list.getUnfetchedObjects()); + + counter++; + } + } +}
