static ByteString bs(String text) { return ByteString.copyFromUtf8(text); }
new Double[] { null, 1.1d, null, 2.2d, null }, new String[] { null, "a", null, "b", null }, new ByteString[] { null, ByteString.copyFromUtf8("a"), null, ByteString.copyFromUtf8("b"), null }, new byte[][] { null, new byte[] { 'a' }, null, new byte[] { 'b' }, null }, new BigDecimal[] { null, new BigDecimal(1.1d), null, new BigDecimal(2.2d), null },
new Double[] { 1.1d, null, 2.2d }, new String[] { "a", null, "b" }, new ByteString[] { ByteString.copyFromUtf8("a"), null, ByteString.copyFromUtf8("b") }, new byte[][] { new byte[] { 'a' }, null, new byte[] { 'b' } }, new BigDecimal[] { new BigDecimal(1.1d), null, new BigDecimal(2.2d) },
new Double[] { null, 1.1d, 2.2d, null }, new String[] { null, "a", "b", null }, new ByteString[] { null, ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("b"), null }, new byte[][] { null, new byte[] { 'a' }, new byte[] { 'b' }, null }, new BigDecimal[] { null, new BigDecimal(1.1d), new BigDecimal(2.2d), null },
new Double[] { 1.1d, 2.2d, null }, new String[] { "a", "b", null }, new ByteString[] { ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("b"), null }, new byte[][] { new byte[] { 'a' }, new byte[] { 'b' }, null }, new BigDecimal[] { new BigDecimal(1.1d), new BigDecimal(2.2d), null },
new Double[] { 1.1d, null, 2.2d }, new String[] { "a", null, "b" }, new ByteString[] { ByteString.copyFromUtf8("a"), null, ByteString.copyFromUtf8("b") }, new byte[][] { new byte[] { 'a' }, null, new byte[] { 'b' } }, new BigDecimal[] { new BigDecimal(1.1d), null, new BigDecimal(2.2d) },
new Double[] { null, 1.1d, 2.2d }, new String[] { null, "a", "b" }, new ByteString[] { null, ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("b") }, new byte[][] { null, new byte[] { 'a' }, new byte[] { 'b' } }, new BigDecimal[] { null, new BigDecimal(1.1d), new BigDecimal(2.2d) },
new Double[] { null, 1.1d, null, 2.2d, null }, new String[] { null, "a", null, "b", null }, new ByteString[] { null, ByteString.copyFromUtf8("a"), null, ByteString.copyFromUtf8("b"), null }, new byte[][] { null, new byte[] { 'a' }, null, new byte[] { 'b' }, null }, new BigDecimal[] { null, new BigDecimal(1.1d), null, new BigDecimal(2.2d), null },
new Double[] { null, 1.1d, 2.2d }, new String[] { null, "a", "b" }, new ByteString[] { null, ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("b") }, new byte[][] { null, new byte[] { 'a' }, new byte[] { 'b' } }, new BigDecimal[] { null, new BigDecimal(1.1d), new BigDecimal(2.2d) },
new Double[] { 1.1d, 2.2d, null }, new String[] { "a", "b", null }, new ByteString[] { ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("b"), null }, new byte[][] { new byte[] { 'a' }, new byte[] { 'b' }, null }, new BigDecimal[] { new BigDecimal(1.1d), new BigDecimal(2.2d), null },
new Double[] { null, 1.1d, 2.2d, null }, new String[] { null, "a", "b", null }, new ByteString[] { null, ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("b"), null }, new byte[][] { null, new byte[] { 'a' }, new byte[] { 'b' }, null }, new BigDecimal[] { null, new BigDecimal(1.1d), new BigDecimal(2.2d), null },
public void testFooTooLarge() throws Exception { Schema<Foo> schema = Foo.getSchema(); Foo message = SerializableObjects.newFoo( new Integer[] { 90210, -90210, 0, 128 }, new String[] { "ab", "cd" }, new Bar[] { SerializableObjects.bar, SerializableObjects.negativeBar }, new EnumSample[] { EnumSample.TYPE0, EnumSample.TYPE2 }, new ByteString[] { ByteString.copyFromUtf8("ef"), ByteString.copyFromUtf8("gh") }, new Boolean[] { true, false }, new Float[] { 1234.4321f, -1234.4321f, 0f }, new Double[] { 12345678.87654321d, -12345678.87654321d, 0d }, new Long[] { 7060504030201l, -7060504030201l, 0l }); ByteArrayOutputStream out = new ByteArrayOutputStream(); int size = optWriteDelimitedTo(out, message, schema, buf()); int delimSize = ProtobufOutput.computeRawVarint32Size(size); byte[] data = out.toByteArray(); int expectedSize = size + delimSize; // 258 assertEquals(expectedSize, data.length); verifyOptData(data, message, schema, buf()); ByteArrayInputStream in = new ByteArrayInputStream(data); Foo parsedMessage = schema.newMessage(); boolean merged = optMergeDelimitedFrom(in, parsedMessage, schema, buf(256)); assertFalse(merged); }
SerializableObjects.bar, SerializableObjects.negativeBar }, new EnumSample[] { EnumSample.TYPE0, EnumSample.TYPE2 }, new ByteString[] { ByteString.copyFromUtf8("ef"), ByteString.copyFromUtf8("gh") }, new Boolean[] { true, false }, new Float[] { 1234.4321f, -1234.4321f, 0f },
public void testFoo() throws Exception { Bar bar = new Bar(); bar.setSomeInt(1); bar.setSomeBytes(ByteString.copyFromUtf8(ESCAPE_TARGET)); bar.setSomeString(ESCAPE_TARGET); ArrayList<Bar> bars = new ArrayList<Bar>(); bars.add(bar); bars.add(bar); ArrayList<String> strings = new ArrayList<String>(); strings.add(ESCAPE_TARGET); strings.add(""); strings.add(ESCAPE_TARGET); Foo foo = new Foo(); foo.setSomeBar(bars); foo.setSomeString(strings); byte[] protostuff = ProtostuffIOUtil.toByteArray(foo, foo.cachedSchema(), buf()); byte[] json = JsonIOUtil.toByteArray(ProtostuffIOUtil.newPipe(protostuff), Foo.getPipeSchema(), false); byte[] json2 = JsonXIOUtil.toByteArray(ProtostuffIOUtil.newPipe(protostuff), Foo.getPipeSchema(), false, buf()); assertTrue(json.length == json2.length); String strJson = STRING.deser(json); String strJson2 = STRING.deser(json2); assertEquals(strJson, strJson2); System.err.println(strJson); System.err.println(strJson2); }
expectDouble = Double.valueOf(1234567.7654321d); expectString = "foo"; expectByteString = ByteString.copyFromUtf8("gg");
@Test public void testBarWithEmptyStringAndByteString() throws Exception { Bar barCompare = new Bar(); barCompare.setSomeBytes(ByteString.copyFromUtf8(new String(""))); barCompare.setSomeString(new String("")); Bar dbar = new Bar(); byte[] data = XmlIOUtil.toByteArray(barCompare, barCompare.cachedSchema()); XmlIOUtil.mergeFrom(data, dbar, dbar.cachedSchema()); SerializableObjects.assertEquals(barCompare, dbar); // test equal serialization on both xml outputs byte[] actuals = XmlXIOUtil.toByteArray(barCompare, barCompare.cachedSchema(), LinkedBuffer.allocate(256)); assertArrayEquals(data, actuals); }
public void testBar() throws Exception { Bar bar = new Bar(); bar.setSomeInt(1); bar.setSomeBytes(ByteString.copyFromUtf8(ESCAPE_TARGET)); bar.setSomeString(ESCAPE_TARGET); byte[] protostuff = ProtostuffIOUtil.toByteArray(bar, bar.cachedSchema(), buf()); byte[] json = JsonIOUtil.toByteArray(ProtostuffIOUtil.newPipe(protostuff), Bar.getPipeSchema(), false); byte[] json2 = JsonXIOUtil.toByteArray(ProtostuffIOUtil.newPipe(protostuff), Bar.getPipeSchema(), false, buf()); assertTrue(json.length == json2.length); String strJson = STRING.deser(json); String strJson2 = STRING.deser(json2); assertEquals(strJson, strJson2); System.err.println(strJson); System.err.println(strJson2); }