@Test public void testReadWrite() throws Exception { ByteBuf input = Unpooled.copiedBuffer(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED); // FIXME should invoke the overall reader once implemented OFBsnGentableEntryDelete bsnGentableEntryDelete = OFBsnGentableEntryDeleteVer13.READER.readFrom(input); assertEquals(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED.length, input.readerIndex()); // write message again ByteBuf bb = Unpooled.buffer(); bsnGentableEntryDelete.writeTo(bb); byte[] written = new byte[bb.readableBytes()]; bb.readBytes(written); assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED)); }
@Test public void testRead() throws Exception { OFBsnGentableEntryDelete.Builder builder = factory.buildBsnGentableEntryDelete(); builder .setXid(0x12345678) .setTableId(GenTableId.of(20)) .setKey( ImmutableList.<OFBsnTlv>of( factory.bsnTlvs().port(OFPort.of(5)), factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab")))); OFBsnGentableEntryDelete bsnGentableEntryDeleteBuilt = builder.build(); ByteBuf input = Unpooled.copiedBuffer(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED); // FIXME should invoke the overall reader once implemented OFBsnGentableEntryDelete bsnGentableEntryDeleteRead = OFBsnGentableEntryDeleteVer13.READER.readFrom(input); assertEquals(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED.length, input.readerIndex()); assertEquals(bsnGentableEntryDeleteBuilt, bsnGentableEntryDeleteRead); }