public void testEmptyFooInner() throws Exception { ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(new Bar()); ArrayList<Foo> foos = new ArrayList<Foo>(); Foo foo = new Foo(); foo.setSomeBar(bars); foos.add(foo); ByteArrayOutputStream out = new ByteArrayOutputStream(); writeListTo(out, foos, SerializableObjects.foo.cachedSchema()); byte[] data = out.toByteArray(); ByteArrayInputStream in = new ByteArrayInputStream(data); List<Foo> parsedFoos = parseListFrom(in, SerializableObjects.foo.cachedSchema()); assertTrue(parsedFoos.size() == foos.size()); int i = 0; for (Foo f : parsedFoos) SerializableObjects.assertEquals(foos.get(i++), f); }
public void testEmptyInnerFooDelimited() throws Exception { Foo fooCompare = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(new Bar()); fooCompare.setSomeBar(bars); ByteArrayOutputStream out = new ByteArrayOutputStream(); writeDelimitedTo(out, fooCompare); byte[] data = out.toByteArray(); ByteArrayInputStream in = new ByteArrayInputStream(data); Foo foo = new Foo(); mergeDelimitedFrom(in, foo, foo.cachedSchema()); SerializableObjects.assertEquals(foo, fooCompare); }
public void testPartialEmptyFoo() throws Exception { Bar bar = new Bar(); ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(bar); Foo foo = new Foo(); ArrayList<Integer> someInt = new ArrayList<Integer>(); someInt.add(1); foo.setSomeInt(someInt); foo.setSomeBar(bars); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testEmptyFooInner() throws Exception { Bar bar = new Bar(); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(bar); foo.setSomeBar(bars); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testEmptyFooInner() throws Exception { Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(new Bar()); foo.setSomeBar(bars); byte[] data = JsonIOUtil.toByteArray(foo, foo.cachedSchema(), false); assertEquals(new String(data, "UTF-8"), "{\"someBar\":[{}]}"); Foo parsedFoo = new Foo(); JsonIOUtil.mergeFrom(data, parsedFoo, parsedFoo.cachedSchema(), false); SerializableObjects.assertEquals(foo, parsedFoo); }
public void testEmptyInnerFoo() throws Exception { Foo fooCompare = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(new Bar()); fooCompare.setSomeBar(bars); byte[] data = toByteArray(fooCompare, fooCompare.cachedSchema()); ByteArrayOutputStream out = new ByteArrayOutputStream(); writeTo(out, fooCompare, fooCompare.cachedSchema()); byte[] data2 = out.toByteArray(); String text = STRING.deser(data); String text2 = STRING.deser(data2); assertEquals(text, text2); print(text); }
public void testPartialEmptyFooWithEmptyString() throws Exception { Baz baz = new Baz(); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); ArrayList<String> strings = new ArrayList<String>(); strings.add(""); foo.setSomeString(strings); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testPartialEmptyFooWithEmptyString() throws Exception { Baz baz = new Baz(); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); ArrayList<String> strings = new ArrayList<String>(); strings.add(""); foo.setSomeString(strings); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testPartialEmptyFooWithString() throws Exception { Baz baz = new Baz(); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); ArrayList<String> strings = new ArrayList<String>(); strings.add("someString"); foo.setSomeString(strings); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testPartialEmptyFooWithString() throws Exception { Baz baz = new Baz(); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); ArrayList<String> strings = new ArrayList<String>(); strings.add("someString"); foo.setSomeString(strings); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testEmptyFooDeeper() throws Exception { Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); Bar bar = new Bar(); bar.setSomeBaz(new Baz()); bars.add(bar); foo.setSomeBar(bars); byte[] data = JsonIOUtil.toByteArray(foo, foo.cachedSchema(), false); assertEquals(new String(data, "UTF-8"), "{\"someBar\":[{\"someBaz\":{}}]}"); Foo parsedFoo = new Foo(); JsonIOUtil.mergeFrom(data, parsedFoo, parsedFoo.cachedSchema(), false); SerializableObjects.assertEquals(foo, parsedFoo); }
public void testEmptyDeeperFoo() throws Exception { Bar bar = new Bar(); Baz baz = new Baz(); bar.setSomeBaz(baz); ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(bar); Foo foo = new Foo(); foo.setSomeBar(bars); byte[] data = toByteArray(foo, foo.cachedSchema()); ByteArrayOutputStream out = new ByteArrayOutputStream(); writeTo(out, foo, foo.cachedSchema()); byte[] data2 = out.toByteArray(); String text = STRING.deser(data); String text2 = STRING.deser(data2); assertEquals(text, text2); print(text); }
@Test public void testEmptyFooInner() throws Exception { Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(new Bar()); foo.setSomeBar(bars); byte[] data = XmlIOUtil.toByteArray(foo, foo.cachedSchema()); /* * assertEquals(new String(data, "UTF-8"), "<?xml version='1.0' encoding='UTF-8'?>" + "<Foo>" + "<someBar>" + * "<Bar/>" + "</someBar>" + "</Foo>"); */ Foo parsedFoo = new Foo(); XmlIOUtil.mergeFrom(data, parsedFoo, parsedFoo.cachedSchema()); SerializableObjects.assertEquals(foo, parsedFoo); }
public void testPartialEmptyFooInner() throws Exception { Baz baz = new Baz(); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testPartialEmptyFooInner() throws Exception { Baz baz = new Baz(); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testPartialEmptyFooInnerWithEmptyString() throws Exception { Baz baz = new Baz(); baz.setName(""); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testPartialEmptyFooInnerWithString() throws Exception { Baz baz = new Baz(); baz.setName("asdfsf"); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testPartialEmptyFooInnerWithEmptyString() throws Exception { Baz baz = new Baz(); baz.setName(""); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
public void testPartialEmptyFooInnerWithString() throws Exception { Baz baz = new Baz(); baz.setName("asdfsf"); Bar bar = new Bar(); bar.setSomeBaz(baz); Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); foo.setSomeBar(bars); byte[] output = toByteArray(foo); Foo parsedFoo = new Foo(); mergeFrom(output, 0, output.length, parsedFoo, parsedFoo.cachedSchema()); }
@Test public void testEmptyFooDeeper() throws Exception { Foo foo = new Foo(); ArrayList<Bar> bars = new ArrayList<Bar>(); Bar bar = new Bar(); bar.setSomeBaz(new Baz()); bars.add(bar); foo.setSomeBar(bars); byte[] data = XmlIOUtil.toByteArray(foo, foo.cachedSchema()); /* * assertEquals(new String(data, "UTF-8"), "<?xml version='1.0' encoding='UTF-8'?>" + "<Foo>" + "<someBar>" + * "<Bar>" + "<someBaz>" + "<Baz/>" + "</someBaz>" + "</Bar>" + "</someBar>" + "</Foo>"); */ Foo parsedFoo = new Foo(); XmlIOUtil.mergeFrom(data, parsedFoo, parsedFoo.cachedSchema()); SerializableObjects.assertEquals(foo, parsedFoo); }