use of org.apache.cayenne.testdo.mt.ClientMtTable2 in project cayenne by apache.
the class RemoteRollbackIT method testRollbackNew.
@Test
public void testRollbackNew() {
ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class);
o1.setGlobalAttribute1("a");
ClientMtTable2 p1 = clientContext.newObject(ClientMtTable2.class);
p1.setGlobalAttribute("p1");
p1.setTable1(o1);
ClientMtTable2 p2 = clientContext.newObject(ClientMtTable2.class);
p2.setGlobalAttribute("p2");
p2.setTable1(o1);
ClientMtTable2 p3 = clientContext.newObject(ClientMtTable2.class);
p3.setGlobalAttribute("p3");
p3.setTable1(o1);
// before:
assertEquals(o1, p1.getTable1());
assertEquals(3, o1.getTable2Array().size());
clientContext.rollbackChanges();
// after:
assertEquals(PersistenceState.TRANSIENT, o1.getPersistenceState());
// TODO: should we expect relationships to be unset?
// assertNull(p1.getToClientMtTable1());
// assertEquals(0, o1.getClientMtTable2Array().size());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable2 in project cayenne by apache.
the class HessianROPSerializationServiceIT method testStreamSerialization.
@Test
public void testStreamSerialization() 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();
ByteArrayOutputStream out = new ByteArrayOutputStream();
// test client to server serialization
clientService.serialize(table2, out);
out.flush();
ClientMtTable2 serverTable2 = serverService.deserialize(new ByteArrayInputStream(out.toByteArray()), ClientMtTable2.class);
assertEquals("Test table2", serverTable2.getGlobalAttribute());
assertEquals("Test table1", serverTable2.getTable1().getGlobalAttribute1());
// test server to client serialization
out = new ByteArrayOutputStream();
serverService.serialize(table2, out);
out.flush();
ClientMtTable2 clientTable2 = clientService.deserialize(new ByteArrayInputStream(out.toByteArray()), ClientMtTable2.class);
assertEquals("Test table2", clientTable2.getGlobalAttribute());
assertEquals("Test table1", clientTable2.getTable1().getGlobalAttribute1());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable2 in project cayenne by apache.
the class ShallowMergeOperation_ClientIT method testMerge_Relationship.
@Test
public void testMerge_Relationship() throws Exception {
ObjectContext childContext = runtime.newContext(context);
final ShallowMergeOperation op = new ShallowMergeOperation(childContext);
ClientMtTable1 _new = context.newObject(ClientMtTable1.class);
final ClientMtTable2 _new2 = context.newObject(ClientMtTable2.class);
_new.addToTable2Array(_new2);
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
ClientMtTable2 child2 = op.merge(_new2);
assertEquals(PersistenceState.COMMITTED, child2.getPersistenceState());
assertNotNull(child2.getTable1());
assertEquals(PersistenceState.COMMITTED, child2.getTable1().getPersistenceState());
}
});
}
Aggregations