Improvided PIM Hello option handling by creating the
PIMHelloOption class. Also fixed a typo for pim regsiter
stop message type.
Change-Id: Iff06ce7d2746ebc34811205f4c4a4d4784e2740c
diff --git a/utils/misc/src/test/java/org/onlab/packet/PIMTest.java b/utils/misc/src/test/java/org/onlab/packet/PIMTest.java
index bed4733..7fba3cd 100644
--- a/utils/misc/src/test/java/org/onlab/packet/PIMTest.java
+++ b/utils/misc/src/test/java/org/onlab/packet/PIMTest.java
@@ -46,6 +46,11 @@
private PIM pimJoinPrune;
private PIMJoinPrune joinPrune;
+ /**
+ * Create PIM Hello and Join/Prune packets to be used in testing.
+ *
+ * @throws Exception if packet creation fails
+ */
@Before
public void setUp() throws Exception {
@@ -56,9 +61,7 @@
pimHello.setChecksum((short) 0);
hello = new PIMHello();
- hello.addHoldtime(0xd2);
- hello.addPriority(44);
- hello.addGenId(0xf00d);
+ hello.createDefaultOptions();
pimHello.setPayload(hello);
hello.setParent(pimHello);
@@ -81,20 +84,32 @@
deserializer = PIM.deserializer();
}
+ /**
+ * Make sure our deserializer throws an exception if we recieve bad input.
+ *
+ * @throws Exception if we are given bad input.
+ */
@Test
- public void testDerserializeBadInput() throws Exception {
+ public void testDeserializeBadInput() throws Exception {
PacketTestUtils.testDeserializeBadInput(deserializer);
}
+ /**
+ * Verify we throw an exception if we receive a truncated Join/Prune message.
+ *
+ * @throws Exception if we receive a truncated Join/Prune message.
+ */
@Test
public void testDeserializeTruncated() throws Exception {
- //byte [] bits = pimHello.serialize();
- //PacketTestUtils.testDeserializeTruncated(deserializer, bits);
-
byte [] bits = pimJoinPrune.serialize();
PacketTestUtils.testDeserializeTruncated(deserializer, bits);
}
+ /**
+ * Verify that we correctly deserialize hello messages.
+ *
+ * @throws Exception if our input is bad or truncated.
+ */
@Test
public void testDeserializeHello() throws Exception {
byte [] data = pimHello.serialize();
@@ -102,6 +117,11 @@
assertTrue(pim.equals(pimHello));
}
+ /**
+ * Verify that we correctly deserialize Join/Prune messages.
+ *
+ * @throws Exception if our input is bad or truncated.
+ */
@Test
public void testDeserializeJoinPrune() throws Exception {
byte [] data = pimJoinPrune.serialize();