[ONOS-4163] Provider side changes to support stateful PCE and PCECC

Change-Id: I0a57ed1d1e505a2e94921fd5f5d92426a105ad12
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
index debef2f..ce8a452 100644
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
+++ b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
@@ -555,4 +555,40 @@
         assertThat(testOpenMsg, is(openMsg));
 
     }
+
+    /**
+     * This test case checks open object with LSR id encoded.
+     */
+    @Test
+    public void openMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
+
+        byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, // common header
+                0x01, 0x10, 0x00, 0x14, // common object header
+                0x20, 0x05, 0x1E, 0x01, // OPEN object
+                (byte) 0xFF, 0x05, 0x00, 0x08, // Node attribute TLV
+                0x00, 0x11, 0x00, 0x04,  // PCEP-LS-IPv4-ROUTER-ID sub tlv
+                0x02, 0x02, 0x02, 0x02
+        };
+
+        byte[] testOpenMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(openMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepOpenMsg.class));
+
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testOpenMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testOpenMsg = new byte[readLen];
+        buf.readBytes(testOpenMsg, 0, readLen);
+        assertThat(testOpenMsg, is(openMsg));
+
+    }
 }
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
index 1804b38..9692119 100644
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
+++ b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
@@ -184,14 +184,14 @@
                 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
                 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
                 0x07, 0x10, 0x00, 0x14, //ERO object
-                0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+                0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
                 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
                 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
                 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
                 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, //RRO IPv4 subobjects
                 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
                 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
                 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
@@ -216,4 +216,83 @@
 
         assertThat(testReportMsg, is(reportMsg));
     }
+
+    /**
+     * Tests PCRpt msg with Path-Setup-Type TLV as SR.
+     *
+     * @throws PcepParseException
+     * @throws PcepOutOfBoundMessageException
+     */
+    @Test
+    public void reportMessageTest43() throws PcepParseException, PcepOutOfBoundMessageException {
+
+        byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
+                0x21, 0x10, 0x00, 0x14,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x01, //SRP object
+                0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
+                0x00, 0x00, 0x00, 0x01,
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+                0x07, 0x10, 0x00, 0x14, //ERO object
+                0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
+                0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+                };
+
+        byte[] testReportMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(reportMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+        assertThat(message, instanceOf(PcepReportMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+
+        int readLen = buf.writerIndex();
+        testReportMsg = new byte[readLen];
+        buf.readBytes(testReportMsg, 0, readLen);
+
+        assertThat(testReportMsg, is(reportMsg));
+    }
+
+    /**
+     * Tests PCRpt msg with Path-Setup-Type TLV as "without SR and without signalling".
+     *
+     * @throws PcepParseException
+     * @throws PcepOutOfBoundMessageException
+     */
+    @Test
+    public void reportMessageTest44() throws PcepParseException, PcepOutOfBoundMessageException {
+
+        byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
+                0x21, 0x10, 0x00, 0x14,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x01, //SRP object
+                0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
+                0x00, 0x00, 0x00, 0x02,
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+                0x07, 0x10, 0x00, 0x14, //ERO object
+                0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
+                0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+                };
+
+        byte[] testReportMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(reportMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+        assertThat(message, instanceOf(PcepReportMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+
+        int readLen = buf.writerIndex();
+        testReportMsg = new byte[readLen];
+        buf.readBytes(testReportMsg, 0, readLen);
+
+        assertThat(testReportMsg, is(reportMsg));
+    }
+
 }