public void testBar() throws Exception { Bar bar = SerializableObjects.bar; roundTrip(bar, Bar.getSchema(), Bar.getPipeSchema()); }
public void testBar() throws Exception { Bar bar = SerializableObjects.bar; protobufRoundTrip(bar, Bar.getSchema(), Bar.getPipeSchema(), false); protostuffRoundTrip(bar, Bar.getSchema(), Bar.getPipeSchema(), false); // numeric protobufRoundTrip(bar, Bar.getSchema(), Bar.getPipeSchema(), true); protostuffRoundTrip(bar, Bar.getSchema(), Bar.getPipeSchema(), true); }
public void testBar() throws Exception { Schema<Bar> schema = Bar.getSchema(); for (Bar message : new Bar[] { bar, negativeBar }) { byte[] data = XmlXIOUtil.toByteArray(message, schema, buf()); ByteArrayOutputStream out = new ByteArrayOutputStream(); XmlXIOUtil.writeTo(out, message, schema, buf()); assertTrue(Arrays.equals(data, out.toByteArray())); } }
if (message.someBar == null) message.someBar = new ArrayList<Bar>(); message.someBar.add(input.mergeObject(null, Bar.getSchema())); break; case 4:
public void testBar() throws Exception { Schema<Bar> schema = Bar.getSchema(); Bar message = SerializableObjects.bar; ByteArrayOutputStream out = new ByteArrayOutputStream(); int size = optWriteDelimitedTo(out, message, schema, buf()); int delimSize = ProtobufOutput.computeRawVarint32Size(size); byte[] data = out.toByteArray(); int expectedSize = size + delimSize; assertEquals(expectedSize, data.length); verifyOptData(data, message, schema, buf()); ByteArrayInputStream in = new ByteArrayInputStream(data); Bar parsedMessage = schema.newMessage(); boolean merged = optMergeDelimitedFrom(in, parsedMessage, schema, buf()); assertTrue(merged); assertEquals(message, parsedMessage); }
public void testBarTooLarge2() throws Exception { Schema<Bar> schema = Bar.getSchema(); Bar message = new Bar(); message.setSomeBytes(ByteString.wrap( new byte[StringSerializer.THREE_BYTE_LOWER_LIMIT - 1])); ByteArrayOutputStream out = new ByteArrayOutputStream(); int size = optWriteDelimitedTo(out, message, schema, buf()); int delimSize = ProtobufOutput.computeRawVarint32Size(size); byte[] data = out.toByteArray(); int expectedSize = size + delimSize; assertEquals(expectedSize, data.length); verifyOptData(data, message, schema, buf()); ByteArrayInputStream in = new ByteArrayInputStream(data); Bar parsedMessage = schema.newMessage(); boolean merged = optMergeDelimitedFrom(in, parsedMessage, schema, buf(256)); assertFalse(merged); }
public void testBarTooLarge3() throws Exception { Schema<Bar> schema = Bar.getSchema(); Bar message = new Bar(); message.setSomeBytes(ByteString.wrap( new byte[StringSerializer.FOUR_BYTE_LOWER_LIMIT - 1])); ByteArrayOutputStream out = new ByteArrayOutputStream(); int size = optWriteDelimitedTo(out, message, schema, buf()); int delimSize = ProtobufOutput.computeRawVarint32Size(size); byte[] data = out.toByteArray(); int expectedSize = size + delimSize; assertEquals(expectedSize, data.length); verifyOptData(data, message, schema, buf()); ByteArrayInputStream in = new ByteArrayInputStream(data); Bar parsedMessage = schema.newMessage(); boolean merged = optMergeDelimitedFrom(in, parsedMessage, schema, buf(256)); assertFalse(merged); } }
static void compareBar() { io.protostuff.Bar bar1 = io.protostuff.SerializableObjects.bar; Schema<io.protostuff.Bar> schema1 = io.protostuff.Bar .getSchema(); Bar bar2 = SerializableObjects.bar; Schema<Bar> schema2 = RuntimeSchema.getSchema(Bar.class); Schema<io.protostuff.Bar> schema3 = RuntimeSchema .getSchema(io.protostuff.Bar.class); byte[] byte1 = ProtostuffIOUtil.toByteArray(bar1, schema1, buf()); byte[] byte2 = ProtostuffIOUtil.toByteArray(bar2, schema2, buf()); byte[] byte3 = ProtostuffIOUtil.toByteArray(bar1, schema3, buf()); assertArrayEquals(byte1, byte2); assertArrayEquals(byte1, byte3); }
output.writeObject(3, value, Bar.getSchema(), true);