-
- }
-
- /**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
- */
- @Test
- public void testMultipartReplyExperimenterBody(){
- ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+
- "00 00 00 0F "+//experimenterId
- "00 00 00 FF "+//expType
- "00 00 01 01 00 00 01 01"
- );
-
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
-
- BufferHelper.checkHeaderV13(builtByFactory);
- Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue());
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
- MultipartReplyExperimenterCase messageCase = (MultipartReplyExperimenterCase) builtByFactory.getMultipartReplyBody();
- MultipartReplyExperimenter message = messageCase.getMultipartReplyExperimenter();
- Assert.assertEquals("Wrong experimenterId", 15, message.getExperimenter().intValue());
- Assert.assertEquals("Wrong expType", 255, message.getExpType().intValue());
- Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01},
- message.getData());
- }
-
- /**
- * 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);
- ByteBufUtils.padBuffer((MAX_PORT_NAME_LEN - portNameBytes.length), bb);
-
- 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.decodeV13(MultipartReplyMessageFactory.getInstance(), 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());