use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class RemoteRollbackIT method testRollbackNewObject.
@Test
public void testRollbackNewObject() {
String o1Name = "revertTestClientMtTable1";
ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class);
o1.setGlobalAttribute1(o1Name);
clientContext.rollbackChanges();
assertEquals(PersistenceState.TRANSIENT, o1.getPersistenceState());
clientContext.commitChanges();
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class HessianROPSerializationServiceIT method testByteArraySerialization.
@Test
public void testByteArraySerialization() throws Exception {
ClientMtTable1 table1 = context.newObject(ClientMtTable1.class);
table1.setGlobalAttribute1("Test table1");
ClientMtTable2 table2 = context.newObject(ClientMtTable2.class);
table2.setGlobalAttribute("Test table2");
table2.setTable1(table1);
ROPSerializationService clientService = createClientSerializationService();
ROPSerializationService serverService = createServerSerializationService();
// test client to server serialization
byte[] data = clientService.serialize(table2);
ClientMtTable2 serverTable2 = serverService.deserialize(data, ClientMtTable2.class);
assertEquals("Test table2", serverTable2.getGlobalAttribute());
assertEquals("Test table1", serverTable2.getTable1().getGlobalAttribute1());
// test server to client serialization
data = serverService.serialize(table2);
ClientMtTable2 clientTable2 = clientService.deserialize(data, ClientMtTable2.class);
assertEquals("Test table2", clientTable2.getGlobalAttribute());
assertEquals("Test table1", clientTable2.getTable1().getGlobalAttribute1());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ObjectDetachOperationIT method testDetachCommitted.
@Test
public void testDetachCommitted() {
EntityResolver serverResover = serverContext.getEntityResolver();
EntityResolver clientResolver = serverResover.getClientEntityResolver();
ObjectDetachOperation op = new ObjectDetachOperation(clientResolver);
ObjectId oid = new ObjectId("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 456);
MtTable1 so = new MtTable1();
so.setObjectId(oid);
so.setGlobalAttribute1("gx");
so.setPersistenceState(PersistenceState.COMMITTED);
so.setObjectContext(serverContext);
serverContext.getGraphManager().registerNode(oid, so);
Object detached = op.detach(so, serverResover.getClassDescriptor("MtTable1"), null);
assertNotNull(detached);
assertNotSame(so, detached);
assertTrue(detached instanceof ClientMtTable1);
ClientMtTable1 co = (ClientMtTable1) detached;
assertEquals(oid, co.getObjectId());
assertEquals("gx", co.getGlobalAttribute1());
assertEquals(PersistenceState.TRANSIENT, co.getPersistenceState());
assertNull(co.getObjectContext());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class PersistentObjectListTest method testResolvedHessianSerialization.
@Test
public void testResolvedHessianSerialization() throws Exception {
ClientMtTable1 owner = new ClientMtTable1();
owner.setPersistenceState(PersistenceState.COMMITTED);
owner.setGlobalAttribute1("a");
PersistentObjectList list = new PersistentObjectList(owner, "x");
List<Object> objects = new ArrayList<>();
objects.add("a");
objects.add("b");
list.setObjectList(objects);
assertFalse(list.isFault());
Object deserialized = HessianUtil.cloneViaServerClientSerialization(list, new EntityResolver());
assertNotNull(deserialized);
assertTrue("Invalid deserialized: " + deserialized.getClass().getName(), deserialized instanceof PersistentObjectList);
PersistentObjectList dlist = (PersistentObjectList) deserialized;
assertFalse(dlist.isFault());
assertNotNull(dlist.getRelationshipOwner());
assertEquals("x", dlist.getRelationshipName());
assertEquals(objects, dlist.objectList);
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class PersistentObjectListTest method testFaultHessianSerialization.
@Test
public void testFaultHessianSerialization() throws Exception {
ClientMtTable1 owner = new ClientMtTable1();
owner.setPersistenceState(PersistenceState.COMMITTED);
owner.setGlobalAttribute1("a");
PersistentObjectList list = new PersistentObjectList(owner, "x");
assertTrue(list.isFault());
Object deserialized = HessianUtil.cloneViaServerClientSerialization(list, new EntityResolver());
// faults are writtens as nulls
assertNull(deserialized);
}
Aggregations