public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); byte[] data = XmlIOUtil.toByteArray(bazCompare, schema); XmlIOUtil.mergeFrom(data, dbaz, schema); SerializableObjects.assertEquals(bazCompare, dbaz); } }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); byte[] data = JsonIOUtil.toByteArray(bazCompare, schema, false); JsonIOUtil.mergeFrom(data, dbaz, schema, false); SerializableObjects.assertEquals(bazCompare, dbaz); } }
public void testFoo() throws Exception { Schema<Foo> schema = RuntimeSchema.getSchema(Foo.class); Foo fooCompare = foo; Foo dfoo = new Foo(); byte[] data = JsonIOUtil.toByteArray(fooCompare, schema, true); JsonIOUtil.mergeFrom(data, dfoo, schema, true); SerializableObjects.assertEquals(fooCompare, dfoo); }
public void testFoo() throws Exception { Schema<Foo> schema = RuntimeSchema.getSchema(Foo.class); Foo fooCompare = foo; Foo dfoo = new Foo(); byte[] data = XmlIOUtil.toByteArray(fooCompare, schema); XmlIOUtil.mergeFrom(data, dfoo, schema); SerializableObjects.assertEquals(fooCompare, dfoo); }
public void testBar() throws Exception { Schema<Bar> schema = RuntimeSchema.getSchema(Bar.class); for (Bar barCompare : new Bar[] { bar, negativeBar }) { Bar dbar = new Bar(); byte[] data = XmlIOUtil.toByteArray(barCompare, schema); XmlIOUtil.mergeFrom(data, dbar, schema); SerializableObjects.assertEquals(barCompare, dbar); } }
public void testFoo() throws Exception { Schema<Foo> schema = RuntimeSchema.getSchema(Foo.class); Foo fooCompare = foo; Foo dfoo = new Foo(); byte[] data = JsonIOUtil.toByteArray(fooCompare, schema, false); JsonIOUtil.mergeFrom(data, dfoo, schema, false); SerializableObjects.assertEquals(fooCompare, dfoo); }
public void testBar() throws Exception { Schema<Bar> schema = RuntimeSchema.getSchema(Bar.class); for (Bar barCompare : new Bar[] { bar, negativeBar }) { Bar dbar = new Bar(); byte[] data = JsonIOUtil.toByteArray(barCompare, schema, false); JsonIOUtil.mergeFrom(data, dbar, schema, false); SerializableObjects.assertEquals(barCompare, dbar); } }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); byte[] data = JsonIOUtil.toByteArray(bazCompare, schema, true); JsonIOUtil.mergeFrom(data, dbaz, schema, true); SerializableObjects.assertEquals(bazCompare, dbaz); } }
public void testBar() throws Exception { Schema<Bar> schema = RuntimeSchema.getSchema(Bar.class); for (Bar barCompare : new Bar[] { bar, negativeBar }) { Bar dbar = new Bar(); byte[] data = JsonIOUtil.toByteArray(barCompare, schema, true); JsonIOUtil.mergeFrom(data, dbar, schema, true); SerializableObjects.assertEquals(barCompare, dbar); } }
public void testPolymorphicStreamed() throws Exception { Zoo zooCompare = PolymorphicSerializationTest.filledZoo(); Zoo dzoo = new Zoo(); ByteArrayOutputStream out = new ByteArrayOutputStream(); LinkedBuffer buffer = buf(); try { MsgpackXIOUtil.writeTo(out, zooCompare, ZOO_SCHEMA, true, buffer); } finally { buffer.clear(); } byte[] data = out.toByteArray(); MsgpackIOUtil.mergeFrom(data, dzoo, ZOO_SCHEMA, true); SerializableObjects.assertEquals(zooCompare, dzoo); }
public void testFoo() throws Exception { Schema<Foo> schema = RuntimeSchema.getSchema(Foo.class); Foo fooCompare = foo; Foo dfoo = new Foo(); byte[] data = JsonXIOUtil.toByteArray(fooCompare, schema, true, buf()); JsonIOUtil.mergeFrom(data, dfoo, schema, true); SerializableObjects.assertEquals(fooCompare, dfoo); }
public void testBar() throws Exception { Schema<Bar> schema = RuntimeSchema.getSchema(Bar.class); for (Bar barCompare : new Bar[] { bar, negativeBar }) { Bar dbar = new Bar(); byte[] data = JsonXIOUtil.toByteArray(barCompare, schema, true, buf()); JsonIOUtil.mergeFrom(data, dbar, schema, true); SerializableObjects.assertEquals(barCompare, dbar); } }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); byte[] data = JsonXIOUtil.toByteArray(bazCompare, schema, true, buf()); JsonIOUtil.mergeFrom(data, dbaz, schema, true); SerializableObjects.assertEquals(bazCompare, dbaz); } }
public void testPolymorphic() throws Exception { Schema<Zoo> schema = RuntimeSchema.getSchema(Zoo.class); Zoo zooCompare = PolymorphicSerializationTest.filledZoo(); Zoo dzoo = new Zoo(); byte[] data = JsonIOUtil.toByteArray(zooCompare, schema, true); JsonIOUtil.mergeFrom(data, dzoo, schema, true); SerializableObjects.assertEquals(zooCompare, dzoo); }
public void testPolymorphic() throws Exception { Zoo zooCompare = PolymorphicSerializationTest.filledZoo(); Zoo dzoo = new Zoo(); byte[] data = MsgpackXIOUtil.toByteArray(zooCompare, ZOO_SCHEMA, true, buf()); MsgpackIOUtil.mergeFrom(data, dzoo, ZOO_SCHEMA, true); SerializableObjects.assertEquals(zooCompare, dzoo); }
public void testPolymorphic() throws Exception { Schema<Zoo> schema = RuntimeSchema.getSchema(Zoo.class); Zoo zooCompare = PolymorphicSerializationTest.filledZoo(); Zoo dzoo = new Zoo(); byte[] data = JsonXIOUtil.toByteArray(zooCompare, schema, true, buf()); JsonIOUtil.mergeFrom(data, dzoo, schema, true); SerializableObjects.assertEquals(zooCompare, dzoo); }
public void testFoo() throws Exception { Schema<Foo> schema = RuntimeSchema.getSchema(Foo.class); Foo fooCompare = foo; Foo dfoo = new Foo(); byte[] deferred = toByteArray(fooCompare, schema); // ComputedSizeOutput is format compatible with protobuf // E.g collections are not serialized ... only its members/elements are. if (!RuntimeEnv.COLLECTION_SCHEMA_ON_REPEATED_FIELDS) assertTrue(deferred.length == ComputedSizeOutput.getSize( fooCompare, schema)); ProtostuffIOUtil.mergeFrom(deferred, dfoo, schema); SerializableObjects.assertEquals(fooCompare, dfoo); }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); int expectedSize = ComputedSizeOutput.getSize(bazCompare, schema); byte[] deferred = toByteArray(bazCompare, schema); assertTrue(deferred.length == expectedSize); ProtostuffIOUtil.mergeFrom(deferred, dbaz, schema); SerializableObjects.assertEquals(bazCompare, dbaz); // System.err.println(dbaz.getId()); // System.err.println(dbaz.getName()); // System.err.println(dbaz.getTimestamp()); } }
public void testBar() throws Exception { Schema<Bar> schema = RuntimeSchema.getSchema(Bar.class); for (Bar barCompare : new Bar[] { bar, negativeBar }) { Bar dbar = new Bar(); int expectedSize = ComputedSizeOutput.getSize(barCompare, schema); byte[] deferred = toByteArray(barCompare, schema); assertTrue(deferred.length == expectedSize); ProtostuffIOUtil.mergeFrom(deferred, dbar, schema); SerializableObjects.assertEquals(barCompare, dbar); // System.err.println(dbar.getSomeInt()); // System.err.println(dbar.getSomeLong()); // System.err.println(dbar.getSomeFloat()); // System.err.println(dbar.getSomeDouble()); // System.err.println(dbar.getSomeBytes()); // System.err.println(dbar.getSomeString()); // System.err.println(dbar.getSomeEnum()); // System.err.println(dbar.getSomeBoolean()); } }
static void assertEquals(HasBar h1, HasBar h2) { // true if both are null if (h1 == h2) return; assertTrue(h1.getId() == h2.getId()); assertEquals(h1.getName(), h2.getName()); SerializableObjects.assertEquals(h1.getBar(), h2.getBar()); }