use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextClientChannelEventsIT method testSyncSimpleProperty.
@Test
public void testSyncSimpleProperty() throws Exception {
tMtTable1.insert(1, "g1", "s1");
CayenneContext c1 = (CayenneContext) runtime.newContext();
CayenneContext c2 = (CayenneContext) runtime.newContext();
assertNotSame(c1, c2);
ClientMtTable1 o1 = (ClientMtTable1) Cayenne.objectForQuery(c1, new ObjectIdQuery(new ObjectId("MtTable1", "TABLE1_ID", 1)));
ClientMtTable1 o2 = (ClientMtTable1) Cayenne.objectForQuery(c2, new ObjectIdQuery(new ObjectId("MtTable1", "TABLE1_ID", 1)));
assertEquals("g1", o1.getGlobalAttribute1());
assertEquals("g1", o2.getGlobalAttribute1());
o1.setGlobalAttribute1("X");
c1.commitChanges();
// let the events propagate to peers
Thread.sleep(500);
assertEquals("X", o2.getGlobalAttribute1());
assertFalse(c1.internalGraphManager().hasChanges());
assertFalse(c2.internalGraphManager().hasChanges());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextClientChannelEventsIT method testSyncNewObjectIntoDirtyContext.
@Test
public void testSyncNewObjectIntoDirtyContext() throws Exception {
CayenneContext c1 = (CayenneContext) runtime.newContext();
CayenneContext c2 = (CayenneContext) runtime.newContext();
assertNotSame(c1, c2);
// make sure c2 has uncommitted changes
c2.newObject(ClientMtTable1.class);
ClientMtTable1 o1 = c1.newObject(ClientMtTable1.class);
o1.setGlobalAttribute1("X");
c1.commitChanges();
ClientMtTable1 o2 = (ClientMtTable1) c2.getGraphManager().getNode(o1.getObjectId());
assertNull(o2);
// now fetch it fresh
o2 = (ClientMtTable1) c2.performQuery(new ObjectIdQuery(o1.getObjectId())).get(0);
assertNotNull(o2);
assertEquals("X", o2.getGlobalAttribute1());
assertEquals(PersistenceState.COMMITTED, o2.getPersistenceState());
assertFalse(c1.internalGraphManager().hasChanges());
assertTrue(c2.internalGraphManager().hasChanges());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextEJBQLIT method testEJBQLSelectMixed.
@Test
public void testEJBQLSelectMixed() throws Exception {
createTwoRecords();
EJBQLQuery query = new EJBQLQuery("SELECT COUNT(a), a, a.serverAttribute1 FROM MtTable1 a Group By a ORDER BY a.serverAttribute1");
List<Object[]> results = context.performQuery(query);
assertEquals(2, results.size());
assertEquals(Long.valueOf(1), results.get(0)[0]);
assertTrue(results.get(0)[1] instanceof ClientMtTable1);
assertEquals("s1", results.get(0)[2]);
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextGraphDiffCompressorIT method testMultipleSimpleProperties.
@Test
public void testMultipleSimpleProperties() {
ClientMtTable1 o1 = context.newObject(ClientMtTable1.class);
o1.setGlobalAttribute1("v1");
o1.setGlobalAttribute1("v2");
DataChannelSyncStats stats = clientServerInterceptor.runWithSyncStatsCollection(new UnitTestClosure() {
public void execute() {
context.commitChanges();
}
});
assertEquals(1, stats.nodePropertiesChanged);
assertEquals(1, stats.nodesCreated);
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextGraphDiffCompressorIT method testComplimentaryArcs.
@Test
public void testComplimentaryArcs() {
ClientMtTable1 o1 = context.newObject(ClientMtTable1.class);
ClientMtTable2 o2 = context.newObject(ClientMtTable2.class);
o2.setTable1(o1);
o2.setTable1(null);
DataChannelSyncStats stats = clientServerInterceptor.runWithSyncStatsCollection(new UnitTestClosure() {
public void execute() {
context.commitChanges();
}
});
assertEquals(0, stats.nodePropertiesChanged);
assertEquals(2, stats.nodesCreated);
assertEquals(0, stats.arcsCreated);
assertEquals(0, stats.arcsDeleted);
}
Aggregations