@Test public void serialize__NoAddresses() throws Exception { RlocBuilder rb = new RlocBuilder(); rb.setAddressType(ExplicitLocatorPathLcaf.class); rb.setVirtualNetworkId(null); rb.setAddress( (Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types .rev151105.lisp.address.address.ExplicitLocatorPathBuilder() .build()); ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(rb.build())); LispAddressSerializer.getInstance().serialize(buf, rb.build()); ByteBuffer expectedBuf = hexToByteBuffer( "40 03 00 00 " + // "0A 00 00 00"); ArrayAssert.assertEquals(expectedBuf.array(), buf.array()); }
@Test public void serialize__Simple() throws Exception { List<Hop> hops = new ArrayList<Hop>(); hops.add( new HopBuilder() .setAddress(SimpleAddressBuilder.getDefaultInstance("170.187.204.221")) .build()); hops.add( new HopBuilder() .setAddress(SimpleAddressBuilder.getDefaultInstance("17.34.51.68")) .build()); ExplicitLocatorPathBuilder elpb = new ExplicitLocatorPathBuilder(); elpb.setHop(hops); RlocBuilder rb = new RlocBuilder(); rb.setAddressType(ExplicitLocatorPathLcaf.class); rb.setVirtualNetworkId(null); rb.setAddress( (Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types .rev151105.lisp.address.address.ExplicitLocatorPathBuilder() .setExplicitLocatorPath(elpb.build()) .build()); ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(rb.build())); LispAddressSerializer.getInstance().serialize(buf, rb.build()); ByteBuffer expectedBuf = hexToByteBuffer( "40 03 00 00 " + // "0A 00 00 10 " + // "00 00 00 01 AA BB CC DD " + // IPv4 "00 00 00 01 11 22 33 44"); // IPv4 ArrayAssert.assertEquals(expectedBuf.array(), buf.array()); }