*/
@Test
public void testGetAsyncReplyMessage() {
- ByteBuf bb = BufferHelper.buildBuffer("00 00 00 06 "+
- "00 00 00 05 "+
+ ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 "+
+ "00 00 00 00 "+
"00 00 00 07 "+
"00 00 00 00 "+
- "00 00 00 03 "+
- "00 00 00 0A");
+ "00 00 00 0F "+
+ "00 00 00 00");
GetAsyncOutput builtByFactory = BufferHelper.deserialize(asyncFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
- Assert.assertEquals("Wrong packetInMask",createPacketInMask(),
- builtByFactory.getPacketInMask());
- Assert.assertEquals("Wrong portStatusMask",createPortStatusMask(),
- builtByFactory.getPortStatusMask());
- Assert.assertEquals("Wrong flowRemovedMask",createFlowRemovedMask(),
- builtByFactory.getFlowRemovedMask());
+ Assert.assertEquals("Wrong packetInMask",createPacketInMask(), builtByFactory.getPacketInMask());
+ Assert.assertEquals("Wrong portStatusMask",createPortStatusMask(), builtByFactory.getPortStatusMask());
+ Assert.assertEquals("Wrong flowRemovedMask",createFlowRemovedMask(), builtByFactory.getFlowRemovedMask());
}
-
+
private static List<PacketInMask> createPacketInMask() {
List<PacketInMask> inMasks = new ArrayList<>();
PacketInMaskBuilder maskBuilder;
// OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
maskBuilder = new PacketInMaskBuilder();
List<PacketInReason> reasons = new ArrayList<>();
+ reasons.add(PacketInReason.OFPRNOMATCH);
reasons.add(PacketInReason.OFPRACTION);
reasons.add(PacketInReason.OFPRINVALIDTTL);
maskBuilder.setMask(reasons);
// OFPCR_ROLE_SLAVE
maskBuilder = new PacketInMaskBuilder();
reasons = new ArrayList<>();
- reasons.add(PacketInReason.OFPRNOMATCH);
- reasons.add(PacketInReason.OFPRINVALIDTTL);
maskBuilder.setMask(reasons);
inMasks.add(maskBuilder.build());
return inMasks;
}
-
+
private static List<PortStatusMask> createPortStatusMask() {
List<PortStatusMask> inMasks = new ArrayList<>();
PortStatusMaskBuilder maskBuilder;
inMasks.add(maskBuilder.build());
return inMasks;
}
-
+
private static List<FlowRemovedMask> createFlowRemovedMask() {
List<FlowRemovedMask> inMasks = new ArrayList<>();
FlowRemovedMaskBuilder maskBuilder;
List<FlowRemovedReason> reasons = new ArrayList<>();
reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+ reasons.add(FlowRemovedReason.OFPRRDELETE);
+ reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
maskBuilder.setMask(reasons);
inMasks.add(maskBuilder.build());
// OFPCR_ROLE_SLAVE
maskBuilder = new FlowRemovedMaskBuilder();
reasons = new ArrayList<>();
- reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
- reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
maskBuilder.setMask(reasons);
inMasks.add(maskBuilder.build());
return inMasks;
}
-}
+}
\ No newline at end of file
Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());
}
-}
+ /**
+ * Testing {@link OF10PacketInMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testWithNoAdditionalData(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00");
+ PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
+
+ Assert.assertNull("Wrong data", builtByFactory.getData());
+ }
+}
\ No newline at end of file
Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue());
Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue());
}
-}
+
+ /**
+ * Testing {@link PortStatusMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testWithDifferentBitmaps(){
+ ByteBuf bb = BufferHelper.buildBuffer("01 00 00 00 00 00 00 00 " + //reason, padding
+ "00 01 02 03 00 00 00 00 " + //port no, padding
+ "08 00 27 00 B0 EB 00 00 " + //mac address, padding
+ "73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port name, String "s1-eth1"
+ "00 00 00 24 " + //port config
+ "00 00 00 02 " + //port state
+ "00 00 00 81 00 00 00 A1 " + //current + advertised features
+ "00 00 FF FF 00 00 00 00 " + //supported + peer features
+ "00 00 00 81 00 00 00 80" //curr speed, max speed
+ );
+ PortStatusMessage message = BufferHelper.deserialize(statusFactory, bb);
+
+ Assert.assertEquals("Wrong portConfig", new PortConfig(true, false, true, false), message.getConfig());
+ Assert.assertEquals("Wrong portState", new PortState(true, false, false), message.getState());
+ Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, true, true,
+ true, true, true, true, true, true, true, true, true, true, true, true),
+ message.getSupportedFeatures());
+ Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false,
+ false, false), message.getPeerFeatures());
+ }
+}
\ No newline at end of file
@Test\r
public void testMultipartReplyExperimenter() {\r
factory.injectDeserializerRegistry(registry);\r
- ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+\r
- "00 00 00 0F "+// types\r
- "00 00 00 0F "+// capabilities\r
- "00 00 00 01 "+// max groups\r
- "00 00 00 02 "+// max groups\r
- "00 00 00 03 "+// max groups\r
- "00 00 00 04 "+// max groups\r
- "0F FF 98 01 "+// actions bitmap (all actions included)\r
- "00 00 00 00 "+// actions bitmap (no actions included)\r
- "00 00 00 00 "+// actions bitmap (no actions included)\r
- "00 00 00 00"// actions bitmap (no actions included)\r
- );\r
+ ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "\r
+ + "00 00 00 01 00 00 00 02"); // expID, expType\r
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);\r
\r
BufferHelper.checkHeaderV13(builtByFactory);\r
--- /dev/null
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Matchers;\r
+import org.mockito.Mock;\r
+import org.mockito.Mockito;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+@RunWith(MockitoJUnitRunner.class)\r
+public class OF10StatsReplyExperimenterTest {\r
+\r
+ @Mock DeserializerRegistry registry;\r
+\r
+ /**\r
+ * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation\r
+ */\r
+ @Test\r
+ public void test() {\r
+ OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory();\r
+ factory.injectDeserializerRegistry(registry);\r
+\r
+ ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "\r
+ + "00 00 00 01"); // expID\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);\r
+\r
+ BufferHelper.checkHeaderV10(builtByFactory);\r
+ Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue());\r
+ Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+ Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class));\r
+ }\r
+}
\ No newline at end of file