use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class ObjectContextChangeLogSubListMessageFactoryTest method testGetDiffsSerializable.
@Test
public void testGetDiffsSerializable() throws Exception {
ObjectContextChangeLog recorder = new ObjectContextChangeLog();
recorder.addOperation(new NodeCreateOperation(new ObjectId("test")));
CompoundDiff diff = (CompoundDiff) recorder.getDiffs();
byte[] data = serializationService.serialize(diff);
CompoundDiff diff0 = serializationService.deserialize(data, CompoundDiff.class);
assertNotNull(diff0);
assertEquals(1, diff0.getDiffs().size());
}
use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class ObjectContextChangeLogTest method testGetDiffsSerializableWithHessian.
@Test
public void testGetDiffsSerializableWithHessian() throws Exception {
ObjectContextChangeLog recorder = new ObjectContextChangeLog();
// id must be a serializable object
recorder.addOperation(new NodeCreateOperation("id-string"));
CompoundDiff diff = (CompoundDiff) recorder.getDiffs();
Object clone = HessianUtil.cloneViaClientServerSerialization(diff, new EntityResolver());
assertNotNull(clone);
assertTrue(clone instanceof CompoundDiff);
CompoundDiff d1 = (CompoundDiff) clone;
assertEquals(1, d1.getDiffs().size());
}
use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class ClientServerChannelIT method testSynchronizeCommit.
@Test
public void testSynchronizeCommit() throws Exception {
SelectQuery query = new SelectQuery(MtTable1.class);
// no changes...
clientServerChannel.onSync(serverContext, mock(GraphDiff.class), DataChannel.FLUSH_CASCADE_SYNC);
assertEquals(0, serverContext.performQuery(query).size());
// introduce changes
clientServerChannel.onSync(serverContext, new NodeCreateOperation(new ObjectId("MtTable1")), DataChannel.FLUSH_CASCADE_SYNC);
assertEquals(1, serverContext.performQuery(query).size());
}
use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class SyncMessageTest method testHessianSerialization.
@Test
public void testHessianSerialization() throws Exception {
// id must be a serializable object; source doesn't have to be
ObjectContext source = mock(ObjectContext.class);
GraphDiff diff = new NodeCreateOperation("id-string");
SyncMessage message = new SyncMessage(source, DataChannel.FLUSH_NOCASCADE_SYNC, diff);
Object d = HessianUtil.cloneViaClientServerSerialization(message, new EntityResolver());
assertNotNull(d);
assertTrue(d instanceof SyncMessage);
SyncMessage ds = (SyncMessage) d;
assertNull(ds.getSource());
assertEquals(message.getType(), ds.getType());
assertNotNull(ds.getSenderChanges());
}
Aggregations