public void testPayment() throws Exception { RuntimeSchema<Payment> schema = getSchema(Payment.class); Payment payment = MathObjectsTest.filledPayment(); roundTrip(payment, schema, schema.getPipeSchema()); }
public void testProtostuff() throws Exception { Schema<Payment> schema = RuntimeSchema.getSchema(Payment.class); Payment p = filledPayment(); byte[] data = ProtostuffIOUtil.toByteArray(p, schema, buf()); Payment p2 = new Payment(); ProtostuffIOUtil.mergeFrom(data, 0, data.length, 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(); ProtostuffIOUtil.writeListTo(out, list, schema, buf()); byte[] listData = out.toByteArray(); ByteArrayInputStream in = new ByteArrayInputStream(listData); List<Payment> parsedList = ProtostuffIOUtil.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); }