use of com.groupon.jesos.TestProtos.ExtBase in project jesos by groupon.
the class TestProtobufRegistry method testRoundtrip.
@Test
public void testRoundtrip() throws Exception {
ExtensionRegistry e = ProtobufRegistry.INSTANCE.mutableExtensionRegistry();
TestProtos.registerAllExtensions(e);
ExtBase extBase = ExtBase.newBuilder().setA("172.42.1.2").setB("br0").setD(24).setC("172.42.1.1").setE("00:11:22:33:44:55").build();
Base base = Base.newBuilder().setExtension(ExtBase.type, extBase).setType(Base.Type.EXT_BASE).build();
byte[] bytes = base.toByteArray();
Base generated = Base.parseFrom(new ByteArrayInputStream(bytes), e);
ExtBase extGenerated = generated.getExtension(ExtBase.type);
assertEquals(extBase.getA(), extGenerated.getA());
assertEquals(extBase.getB(), extGenerated.getB());
assertEquals(extBase.getC(), extGenerated.getC());
assertEquals(extBase.getD(), extGenerated.getD());
assertEquals(extBase.getE(), extGenerated.getE());
}
Aggregations