- /**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
- */
- @Test
- public void testMultipartReplyPortDescBody(){
- final byte MAX_PORT_NAME_LEN = 16;
- ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 01 00 00 00 00 "+
- "00 01 02 03 "+ //portNo
- "00 00 00 00 "+ //padding01
- "08 00 27 00 B0 EB " + //mac address
- "00 00"); //padding02
- //port name
- String portName = "SampleText";
- byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN];
- portNameBytes = portName.getBytes();
- bb.writeBytes(portNameBytes);
- bb.writeZero(MAX_PORT_NAME_LEN - portNameBytes.length);
-
- ByteBuf bb2 = BufferHelper.buildBuffer("00 00 00 41 " + //port config
- "00 00 00 05 " + //port state
- "00 00 00 81 " + //current features
- "00 00 81 81 " + //advertised features
- "00 00 C1 89 " + //supported features
- "00 00 C5 8D " + //peer features
- "00 00 00 81 " + //curr speed
- "00 00 00 80" //max speed
- );
- bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid
-
- MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
- BufferHelper.checkHeaderV13(builtByFactory);
- Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
- MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
- MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
- Assert.assertEquals("Wrong portNo", 66051L, message.getPorts().get(0).getPortNo().longValue());
- Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"),
- message.getPorts().get(0).getHwAddr());
- Assert.assertEquals("Wrong portName", "SampleText",
- message.getPorts().get(0).getName());
- Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true),
- message.getPorts().get(0).getConfig());
- Assert.assertEquals("Wrong portState", new PortState(false, true, true),
- message.getPorts().get(0).getState());
- Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false,
- false, true, false, false,
- false, true, false, false,
- false, false, false, false),
- message.getPorts().get(0).getCurrentFeatures());
- Assert.assertEquals("Wrong advertisedFeatures",
- new PortFeatures(true, false, false, false,
- false, true, false, false,
- false, true, false, false,
- false, false, false, true),
- message.getPorts().get(0).getAdvertisedFeatures());
- Assert.assertEquals("Wrong supportedFeatures",
- new PortFeatures(true, true, false, false,
- false, true, false, false,
- false, true, false, false,
- false, false, true, true),
- message.getPorts().get(0).getSupportedFeatures());
- Assert.assertEquals("Wrong peerFeatures",
- new PortFeatures(true, true, true, false,
- false, true, false, false,
- false, true, false, false,
- false, true, true, true),
- message.getPorts().get(0).getPeerFeatures());
- Assert.assertEquals("Wrong currSpeed", 129L, message.getPorts().get(0).getCurrSpeed().longValue());
- Assert.assertEquals("Wrong maxSpeed", 128L, message.getPorts().get(0).getMaxSpeed().longValue());