@Override protected <T> void writeListTo(OutputStream out, List<T> messages, Schema<T> schema) throws IOException { ProtobufIOUtil.writeListTo(out, messages, schema, buf()); }
public void testProtobuf() throws Exception { Schema<Entity> schema = RuntimeSchema.getSchema(Entity.class); Entity p = filledEntity(); byte[] data = ProtobufIOUtil.toByteArray(p, schema, LinkedBuffer.allocate(512)); Entity p2 = new Entity(); ProtostuffIOUtil.mergeFrom(data, p2, schema); assertEquals(p, p2); List<Entity> list = new ArrayList<Entity>(); list.add(p); list.add(p2); ByteArrayOutputStream out = new ByteArrayOutputStream(); ProtobufIOUtil.writeListTo(out, list, schema, buf()); byte[] listData = out.toByteArray(); ByteArrayInputStream in = new ByteArrayInputStream(listData); List<Entity> parsedList = ProtobufIOUtil.parseListFrom(in, schema); assertEquals(list, parsedList); }
public void testProtobuf() throws Exception { Schema<Zoo> schema = RuntimeSchema.getSchema(Zoo.class); Zoo p = filledZoo(); byte[] data = ProtobufIOUtil.toByteArray(p, schema, buf()); // System.err.println("protobuf: " + data.length); Zoo p2 = new Zoo(); ProtobufIOUtil.mergeFrom(data, p2, schema); assertEquals(p, p2); List<Zoo> list = new ArrayList<Zoo>(); list.add(p); list.add(p2); ByteArrayOutputStream out = new ByteArrayOutputStream(); ProtobufIOUtil.writeListTo(out, list, schema, buf()); byte[] listData = out.toByteArray(); ByteArrayInputStream in = new ByteArrayInputStream(listData); List<Zoo> parsedList = ProtobufIOUtil.parseListFrom(in, schema); assertEquals(list, parsedList); }
public void testProtobuf() throws Exception { Schema<Payment> schema = RuntimeSchema.getSchema(Payment.class); Payment p = filledPayment(); byte[] data = ProtobufIOUtil.toByteArray(p, schema, buf()); Payment p2 = new Payment(); ProtobufIOUtil.mergeFrom(data, p2, schema); /* * System.err.println(p2.getId()); System.err.println(p2.getBd()); System.err.println(p2.getBi()); * System.err.println(p2.getBdList()); System.err.println(p2.getBiList()); */ assertEquals(p, p2); List<Payment> list = new ArrayList<Payment>(); list.add(p); list.add(p2); ByteArrayOutputStream out = new ByteArrayOutputStream(); ProtobufIOUtil.writeListTo(out, list, schema, buf()); byte[] listData = out.toByteArray(); ByteArrayInputStream in = new ByteArrayInputStream(listData); List<Payment> parsedList = ProtobufIOUtil.parseListFrom(in, schema); assertEquals(list, parsedList); }