use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class GenericResponseTest method testSerializationWithHessian.
@Test
public void testSerializationWithHessian() throws Exception {
List<Object> list = new ArrayList<>();
list.add(new HashMap());
GenericResponse r = new GenericResponse();
r.addBatchUpdateCount(new int[] { 1, 2, 3 });
r.addResultList(list);
GenericResponse sr = (GenericResponse) HessianUtil.cloneViaClientServerSerialization(r, new EntityResolver());
assertNotNull(sr);
assertEquals(2, sr.size());
assertTrue(sr.next());
assertFalse(sr.isList());
int[] srInt = sr.currentUpdateCount();
assertEquals(3, srInt.length);
assertEquals(2, srInt[1]);
assertTrue(sr.next());
assertTrue(sr.isList());
assertEquals(list, sr.currentList());
assertFalse(sr.next());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class ObjectDetachOperationIT method testDetachHollow.
@Test
public void testDetachHollow() throws Exception {
tMtTable1.insert(4, "g1", "s1");
EntityResolver serverResover = serverContext.getEntityResolver();
EntityResolver clientResolver = serverResover.getClientEntityResolver();
ObjectDetachOperation op = new ObjectDetachOperation(clientResolver);
ObjectId oid = ObjectId.of("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 4);
MtTable1 so = new MtTable1();
so.setObjectId(oid);
so.setPersistenceState(PersistenceState.HOLLOW);
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("g1", co.getGlobalAttribute1());
assertEquals(PersistenceState.TRANSIENT, co.getPersistenceState());
assertNull(co.getObjectContext());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class NodeDiffTest method testHessianSerialization.
@Test
public void testHessianSerialization() throws Exception {
// id must be a serializable object...
String id = "abcd";
NodeDiff diff = new ConcreteNodeDiff(id);
Object d = HessianUtil.cloneViaClientServerSerialization(diff, new EntityResolver());
assertNotNull(d);
assertNotNull(((NodeDiff) d).getNodeId());
assertEquals(id, ((NodeDiff) d).getNodeId());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class ObjectIdQueryTest method testSerializabilityWithHessian.
@Test
public void testSerializabilityWithHessian() throws Exception {
ObjectId oid = ObjectId.of("test", "a", "b");
ObjectIdQuery query = new ObjectIdQuery(oid);
Object o = HessianUtil.cloneViaClientServerSerialization(query, new EntityResolver());
assertNotNull(o);
assertTrue(o instanceof ObjectIdQuery);
assertEquals(oid, ((ObjectIdQuery) o).getObjectId());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class SQLTemplateTest method testSerializabilityWithHessian.
@Test
public void testSerializabilityWithHessian() throws Exception {
SQLTemplate o = new SQLTemplate("Test", "DO SQL");
Object clone = HessianUtil.cloneViaClientServerSerialization(o, new EntityResolver());
assertTrue(clone instanceof SQLTemplate);
SQLTemplate c1 = (SQLTemplate) clone;
assertNotSame(o, c1);
assertEquals(o.getRoot(), c1.getRoot());
assertEquals(o.getDefaultTemplate(), c1.getDefaultTemplate());
// set immutable parameters ... query must recast them to mutable
// version
o.setParams(Collections.<String, Object>emptyMap());
HessianUtil.cloneViaClientServerSerialization(o, new EntityResolver());
}
Aggregations