diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/AdministrativeGroupTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/AdministrativeGroupTlvTest.java
index 297bd06..b3ff2cb 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/AdministrativeGroupTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/AdministrativeGroupTlvTest.java
@@ -1,38 +1,38 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.AdministrativeGroupTlv;
-
-/**
- * Test of the AdministrativeGroupTlv.
- */
-public class AdministrativeGroupTlvTest {
-    private final AdministrativeGroupTlv tlv1 = AdministrativeGroupTlv.of(1);
-    private final AdministrativeGroupTlv sameAsTlv1 = AdministrativeGroupTlv.of(1);
-    private final AdministrativeGroupTlv tlv2 = AdministrativeGroupTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.AdministrativeGroupTlv;
+
+/**
+ * Test of the AdministrativeGroupTlv.
+ */
+public class AdministrativeGroupTlvTest {
+    private final AdministrativeGroupTlv tlv1 = AdministrativeGroupTlv.of(1);
+    private final AdministrativeGroupTlv sameAsTlv1 = AdministrativeGroupTlv.of(1);
+    private final AdministrativeGroupTlv tlv2 = AdministrativeGroupTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/AutonomousSystemTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/AutonomousSystemTlvTest.java
index bf4eb0a..7a0078f 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/AutonomousSystemTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/AutonomousSystemTlvTest.java
@@ -1,38 +1,38 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.AutonomousSystemTlv;
-
-/**
- * Test of the AutonomousSystemTlv.
- */
-public class AutonomousSystemTlvTest {
-    private final AutonomousSystemTlv tlv1 = AutonomousSystemTlv.of(1);
-    private final AutonomousSystemTlv sameAsTlv1 = AutonomousSystemTlv.of(1);
-    private final AutonomousSystemTlv tlv2 = AutonomousSystemTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.AutonomousSystemTlv;
+
+/**
+ * Test of the AutonomousSystemTlv.
+ */
+public class AutonomousSystemTlvTest {
+    private final AutonomousSystemTlv tlv1 = AutonomousSystemTlv.of(1);
+    private final AutonomousSystemTlv sameAsTlv1 = AutonomousSystemTlv.of(1);
+    private final AutonomousSystemTlv tlv2 = AutonomousSystemTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/BGPLSidentifierTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/BGPLSidentifierTlvTest.java
index 78963e4..d7a1f852 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/BGPLSidentifierTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/BGPLSidentifierTlvTest.java
@@ -1,38 +1,38 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.BGPLSidentifierTlv;
-
-/**
- * Test of the BGPLSidentifierTlv.
- */
-public class BGPLSidentifierTlvTest {
-    private final BGPLSidentifierTlv tlv1 = BGPLSidentifierTlv.of(1);
-    private final BGPLSidentifierTlv sameAsTlv1 = BGPLSidentifierTlv.of(1);
-    private final BGPLSidentifierTlv tlv2 = BGPLSidentifierTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.BGPLSidentifierTlv;
+
+/**
+ * Test of the BGPLSidentifierTlv.
+ */
+public class BGPLSidentifierTlvTest {
+    private final BGPLSidentifierTlv tlv1 = BGPLSidentifierTlv.of(1);
+    private final BGPLSidentifierTlv sameAsTlv1 = BGPLSidentifierTlv.of(1);
+    private final BGPLSidentifierTlv tlv2 = BGPLSidentifierTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/GmplsCapabilityTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/GmplsCapabilityTlvTest.java
index 435a52c..3a5c972bc 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/GmplsCapabilityTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/GmplsCapabilityTlvTest.java
@@ -1,38 +1,38 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.GmplsCapabilityTlv;
-
-/**
- * Test of the GmplsCapabilityTlv.
- */
-public class GmplsCapabilityTlvTest {
-    private final GmplsCapabilityTlv tlv1 = GmplsCapabilityTlv.of(1);
-    private final GmplsCapabilityTlv sameAsTlv1 = GmplsCapabilityTlv.of(1);
-    private final GmplsCapabilityTlv tlv2 = GmplsCapabilityTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.GmplsCapabilityTlv;
+
+/**
+ * Test of the GmplsCapabilityTlv.
+ */
+public class GmplsCapabilityTlvTest {
+    private final GmplsCapabilityTlv tlv1 = GmplsCapabilityTlv.of(1);
+    private final GmplsCapabilityTlv sameAsTlv1 = GmplsCapabilityTlv.of(1);
+    private final GmplsCapabilityTlv tlv2 = GmplsCapabilityTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IGPMetricTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IGPMetricTlvTest.java
index 046183b..583b704 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IGPMetricTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IGPMetricTlvTest.java
@@ -1,40 +1,40 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IGPMetricTlv;
-
-/**
- * Test of the IGPMetricTlv.
- */
-public class IGPMetricTlvTest {
-    private final byte[] b1 = new byte[] {0x01, 0x02};
-    private final byte[] b2 = new byte[] {0x01, 0x02};
-    private final IGPMetricTlv tlv1 = IGPMetricTlv.of(b1, (short) 2);
-    private final IGPMetricTlv sameAsTlv1 = IGPMetricTlv.of(b1, (short) 2);
-    private final IGPMetricTlv tlv2 = IGPMetricTlv.of(b2, (short) 2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IGPMetricTlv;
+
+/**
+ * Test of the IGPMetricTlv.
+ */
+public class IGPMetricTlvTest {
+    private final byte[] b1 = new byte[] {0x01, 0x02};
+    private final byte[] b2 = new byte[] {0x01, 0x02};
+    private final IGPMetricTlv tlv1 = IGPMetricTlv.of(b1, (short) 2);
+    private final IGPMetricTlv sameAsTlv1 = IGPMetricTlv.of(b1, (short) 2);
+    private final IGPMetricTlv tlv2 = IGPMetricTlv.of(b2, (short) 2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4InterfaceAddressTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4InterfaceAddressTlvTest.java
index fffb47a..c25a6b5 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4InterfaceAddressTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4InterfaceAddressTlvTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv4InterfaceAddressTlv;
-
-/**
- * Test of the IPv4InterfaceAddressTlv.
- */
-public class IPv4InterfaceAddressTlvTest {
-
-    private final IPv4InterfaceAddressTlv tlv1 = IPv4InterfaceAddressTlv.of(2);
-    private final IPv4InterfaceAddressTlv sameAsTlv1 = IPv4InterfaceAddressTlv.of(2);
-    private final IPv4InterfaceAddressTlv tlv2 = IPv4InterfaceAddressTlv.of(3);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv4InterfaceAddressTlv;
+
+/**
+ * Test of the IPv4InterfaceAddressTlv.
+ */
+public class IPv4InterfaceAddressTlvTest {
+
+    private final IPv4InterfaceAddressTlv tlv1 = IPv4InterfaceAddressTlv.of(2);
+    private final IPv4InterfaceAddressTlv sameAsTlv1 = IPv4InterfaceAddressTlv.of(2);
+    private final IPv4InterfaceAddressTlv tlv2 = IPv4InterfaceAddressTlv.of(3);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4NeighborAddressTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4NeighborAddressTlvTest.java
index 130e618..60a4f12 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4NeighborAddressTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4NeighborAddressTlvTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv4NeighborAddressTlv;
-
-/**
- * Test of the IPv4NeighborAddressTlv.
- */
-public class IPv4NeighborAddressTlvTest {
-
-    private final IPv4NeighborAddressTlv tlv1 = IPv4NeighborAddressTlv.of(2);
-    private final IPv4NeighborAddressTlv sameAsTlv1 = IPv4NeighborAddressTlv.of(2);
-    private final IPv4NeighborAddressTlv tlv2 = IPv4NeighborAddressTlv.of(3);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv4NeighborAddressTlv;
+
+/**
+ * Test of the IPv4NeighborAddressTlv.
+ */
+public class IPv4NeighborAddressTlvTest {
+
+    private final IPv4NeighborAddressTlv tlv1 = IPv4NeighborAddressTlv.of(2);
+    private final IPv4NeighborAddressTlv sameAsTlv1 = IPv4NeighborAddressTlv.of(2);
+    private final IPv4NeighborAddressTlv tlv2 = IPv4NeighborAddressTlv.of(3);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4SubObjectTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4SubObjectTest.java
index a99911c..08b4987 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4SubObjectTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4SubObjectTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv4SubObject;
-
-/**
- * Test of the IPv4SubObject.
- */
-public class IPv4SubObjectTest {
-
-    private final IPv4SubObject subObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0);
-    private final IPv4SubObject sameAsSubObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0);
-    private final IPv4SubObject subObj2 = IPv4SubObject.of(3, (byte) 16, (byte) 0);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(subObj1, sameAsSubObj1)
-        .addEqualityGroup(subObj2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv4SubObject;
+
+/**
+ * Test of the IPv4SubObject.
+ */
+public class IPv4SubObjectTest {
+
+    private final IPv4SubObject subObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0);
+    private final IPv4SubObject sameAsSubObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0);
+    private final IPv4SubObject subObj2 = IPv4SubObject.of(3, (byte) 16, (byte) 0);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(subObj1, sameAsSubObj1)
+        .addEqualityGroup(subObj2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java
index 82009ad..d04be23 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv4TERouterIdOfLocalNodeTlv;
-
-/**
- * Test of the IPv4TERouterIdOfLocalNodeTlv.
- */
-public class IPv4TERouterIdOfLocalNodeTlvTest {
-
-    private final IPv4TERouterIdOfLocalNodeTlv tlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2);
-    private final IPv4TERouterIdOfLocalNodeTlv sameAsTlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2);
-    private final IPv4TERouterIdOfLocalNodeTlv tlv2 = IPv4TERouterIdOfLocalNodeTlv.of(3);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv4TERouterIdOfLocalNodeTlv;
+
+/**
+ * Test of the IPv4TERouterIdOfLocalNodeTlv.
+ */
+public class IPv4TERouterIdOfLocalNodeTlvTest {
+
+    private final IPv4TERouterIdOfLocalNodeTlv tlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2);
+    private final IPv4TERouterIdOfLocalNodeTlv sameAsTlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2);
+    private final IPv4TERouterIdOfLocalNodeTlv tlv2 = IPv4TERouterIdOfLocalNodeTlv.of(3);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java
index 2bf1b73..fb8c965 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv4TERouterIdOfRemoteNodeTlv;
-
-/**
- * Test of the IPv4TERouterIdOfRemoteNodeTlv.
- */
-public class IPv4TERouterIdOfRemoteNodeTlvTest {
-
-    private final IPv4TERouterIdOfRemoteNodeTlv tlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2);
-    private final IPv4TERouterIdOfRemoteNodeTlv sameAsTlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2);
-    private final IPv4TERouterIdOfRemoteNodeTlv tlv2 = IPv4TERouterIdOfRemoteNodeTlv.of(3);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv4TERouterIdOfRemoteNodeTlv;
+
+/**
+ * Test of the IPv4TERouterIdOfRemoteNodeTlv.
+ */
+public class IPv4TERouterIdOfRemoteNodeTlvTest {
+
+    private final IPv4TERouterIdOfRemoteNodeTlv tlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2);
+    private final IPv4TERouterIdOfRemoteNodeTlv sameAsTlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2);
+    private final IPv4TERouterIdOfRemoteNodeTlv tlv2 = IPv4TERouterIdOfRemoteNodeTlv.of(3);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6InterfaceAddressTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6InterfaceAddressTlvTest.java
index 00f5912..6eb771d 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6InterfaceAddressTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6InterfaceAddressTlvTest.java
@@ -1,44 +1,44 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv6InterfaceAddressTlv;
-
-/**
- * Test of the IPv6InterfaceAddressTlv.
- */
-public class IPv6InterfaceAddressTlvTest {
-
-    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
-    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
-    private final IPv6InterfaceAddressTlv tlv1 = IPv6InterfaceAddressTlv.of(b1);
-    private final IPv6InterfaceAddressTlv sameAsTlv1 = IPv6InterfaceAddressTlv.of(b1);
-    private final IPv6InterfaceAddressTlv tlv2 = IPv6InterfaceAddressTlv.of(b2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv6InterfaceAddressTlv;
+
+/**
+ * Test of the IPv6InterfaceAddressTlv.
+ */
+public class IPv6InterfaceAddressTlvTest {
+
+    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+    private final IPv6InterfaceAddressTlv tlv1 = IPv6InterfaceAddressTlv.of(b1);
+    private final IPv6InterfaceAddressTlv sameAsTlv1 = IPv6InterfaceAddressTlv.of(b1);
+    private final IPv6InterfaceAddressTlv tlv2 = IPv6InterfaceAddressTlv.of(b2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6NeighborAddressTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6NeighborAddressTlvTest.java
index 4a1ee37..17fa9a3 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6NeighborAddressTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6NeighborAddressTlvTest.java
@@ -1,44 +1,44 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv6NeighborAddressTlv;
-
-/**
- * Test of the IPv6NeighborAddressTlv.
- */
-public class IPv6NeighborAddressTlvTest {
-
-    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
-    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
-    private final IPv6NeighborAddressTlv tlv1 = IPv6NeighborAddressTlv.of(b1);
-    private final IPv6NeighborAddressTlv sameAsTlv1 = IPv6NeighborAddressTlv.of(b1);
-    private final IPv6NeighborAddressTlv tlv2 = IPv6NeighborAddressTlv.of(b2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv6NeighborAddressTlv;
+
+/**
+ * Test of the IPv6NeighborAddressTlv.
+ */
+public class IPv6NeighborAddressTlvTest {
+
+    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+    private final IPv6NeighborAddressTlv tlv1 = IPv6NeighborAddressTlv.of(b1);
+    private final IPv6NeighborAddressTlv sameAsTlv1 = IPv6NeighborAddressTlv.of(b1);
+    private final IPv6NeighborAddressTlv tlv2 = IPv6NeighborAddressTlv.of(b2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6SubObjectTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6SubObjectTest.java
index 8ca2dd2..08a4723 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6SubObjectTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6SubObjectTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv6SubObject;
-
-/**
- * Test of the IPv6SubObject.
- */
-public class IPv6SubObjectTest {
-
-    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
-    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
-    private final IPv6SubObject subObj1 = IPv6SubObject.of(b1);
-    private final IPv6SubObject sameAsSubObj1 = IPv6SubObject.of(b1);
-    private final IPv6SubObject subObj2 = IPv6SubObject.of(b2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(subObj1, sameAsSubObj1).addEqualityGroup(subObj2).testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv6SubObject;
+
+/**
+ * Test of the IPv6SubObject.
+ */
+public class IPv6SubObjectTest {
+
+    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+    private final IPv6SubObject subObj1 = IPv6SubObject.of(b1);
+    private final IPv6SubObject sameAsSubObj1 = IPv6SubObject.of(b1);
+    private final IPv6SubObject subObj2 = IPv6SubObject.of(b2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(subObj1, sameAsSubObj1).addEqualityGroup(subObj2).testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofLocalNodeTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofLocalNodeTlvTest.java
index 397a3ab..b37cb3d 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofLocalNodeTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofLocalNodeTlvTest.java
@@ -1,44 +1,44 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv6TERouterIdofLocalNodeTlv;
-
-/**
- * Test of the IPv6TERouterIdofLocalNodeTlv.
- */
-public class IPv6TERouterIdofLocalNodeTlvTest {
-
-    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
-    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
-    private final IPv6TERouterIdofLocalNodeTlv tlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1);
-    private final IPv6TERouterIdofLocalNodeTlv sameAsTlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1);
-    private final IPv6TERouterIdofLocalNodeTlv tlv2 = IPv6TERouterIdofLocalNodeTlv.of(b2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv6TERouterIdofLocalNodeTlv;
+
+/**
+ * Test of the IPv6TERouterIdofLocalNodeTlv.
+ */
+public class IPv6TERouterIdofLocalNodeTlvTest {
+
+    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+    private final IPv6TERouterIdofLocalNodeTlv tlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1);
+    private final IPv6TERouterIdofLocalNodeTlv sameAsTlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1);
+    private final IPv6TERouterIdofLocalNodeTlv tlv2 = IPv6TERouterIdofLocalNodeTlv.of(b2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofRemoteNodeTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofRemoteNodeTlvTest.java
index e4c565f..e572e35 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofRemoteNodeTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofRemoteNodeTlvTest.java
@@ -1,44 +1,44 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv6TERouterIdofRemoteNodeTlv;
-
-/**
- * Test of the IPv6TERouterIdofRemoteNodeTlv.
- */
-public class IPv6TERouterIdofRemoteNodeTlvTest {
-
-    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
-    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
-    private final IPv6TERouterIdofRemoteNodeTlv tlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1);
-    private final IPv6TERouterIdofRemoteNodeTlv sameAsTlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1);
-    private final IPv6TERouterIdofRemoteNodeTlv tlv2 = IPv6TERouterIdofRemoteNodeTlv.of(b2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv6TERouterIdofRemoteNodeTlv;
+
+/**
+ * Test of the IPv6TERouterIdofRemoteNodeTlv.
+ */
+public class IPv6TERouterIdofRemoteNodeTlvTest {
+
+    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+    private final IPv6TERouterIdofRemoteNodeTlv tlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1);
+    private final IPv6TERouterIdofRemoteNodeTlv sameAsTlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1);
+    private final IPv6TERouterIdofRemoteNodeTlv tlv2 = IPv6TERouterIdofRemoteNodeTlv.of(b2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/ISISAreaIdentifierTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/ISISAreaIdentifierTlvTest.java
index 1e137b0..7bea1a9 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/ISISAreaIdentifierTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/ISISAreaIdentifierTlvTest.java
@@ -1,42 +1,42 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.ISISAreaIdentifierTlv;
-
-/**
- * Test of the ISISAreaIdentifierTlv.
- */
-public class ISISAreaIdentifierTlvTest {
-
-    private final byte[] b1 = new byte[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
-    private final byte[] b2 = new byte[] {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
-
-    private final ISISAreaIdentifierTlv tlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20);
-    private final ISISAreaIdentifierTlv sameAsTlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20);
-    private final ISISAreaIdentifierTlv tlv2 = ISISAreaIdentifierTlv.of(b2, (short) 20);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.ISISAreaIdentifierTlv;
+
+/**
+ * Test of the ISISAreaIdentifierTlv.
+ */
+public class ISISAreaIdentifierTlvTest {
+
+    private final byte[] b1 = new byte[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+    private final byte[] b2 = new byte[] {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
+
+    private final ISISAreaIdentifierTlv tlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20);
+    private final ISISAreaIdentifierTlv sameAsTlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20);
+    private final ISISAreaIdentifierTlv tlv2 = ISISAreaIdentifierTlv.of(b2, (short) 20);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LabelSubObjectTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LabelSubObjectTest.java
index 9494de6..41d1f4b 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LabelSubObjectTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LabelSubObjectTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.LabelSubObject;
-
-/**
- * Test of the LabelSubObject.
- */
-public class LabelSubObjectTest {
-
-    private final LabelSubObject subObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20);
-    private final LabelSubObject sameAsSubObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20);
-    private final LabelSubObject subObj2 = LabelSubObject.of((byte) 0, (byte) 1, 30);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(subObj1, sameAsSubObj1)
-        .addEqualityGroup(subObj2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.LabelSubObject;
+
+/**
+ * Test of the LabelSubObject.
+ */
+public class LabelSubObjectTest {
+
+    private final LabelSubObject subObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20);
+    private final LabelSubObject sameAsSubObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20);
+    private final LabelSubObject subObj2 = LabelSubObject.of((byte) 0, (byte) 1, 30);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(subObj1, sameAsSubObj1)
+        .addEqualityGroup(subObj2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkLocalRemoteIdentifiersTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkLocalRemoteIdentifiersTlvTest.java
index d3ecf4a..1d04b47 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkLocalRemoteIdentifiersTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkLocalRemoteIdentifiersTlvTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.LinkLocalRemoteIdentifiersTlv;
-
-/**
- * Test of the LinkLocalRemoteIdentifiersTlv.
- */
-public class LinkLocalRemoteIdentifiersTlvTest {
-
-    private final LinkLocalRemoteIdentifiersTlv tlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20);
-    private final LinkLocalRemoteIdentifiersTlv sameAsTlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20);
-    private final LinkLocalRemoteIdentifiersTlv tlv2 = LinkLocalRemoteIdentifiersTlv.of(20, 30);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.LinkLocalRemoteIdentifiersTlv;
+
+/**
+ * Test of the LinkLocalRemoteIdentifiersTlv.
+ */
+public class LinkLocalRemoteIdentifiersTlvTest {
+
+    private final LinkLocalRemoteIdentifiersTlv tlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20);
+    private final LinkLocalRemoteIdentifiersTlv sameAsTlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20);
+    private final LinkLocalRemoteIdentifiersTlv tlv2 = LinkLocalRemoteIdentifiersTlv.of(20, 30);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkNameTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkNameTlvTest.java
index c89a77f..5236be9 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkNameTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkNameTlvTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.LinkNameTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Equality test for LinkNameTlv.
- */
-public class LinkNameTlvTest {
-    private final byte[] rawValue1 = new byte[] {0x01, 0x00};
-    private final byte[] rawValue2 = new byte[] {0x02, 0x00};
-
-    private final LinkNameTlv tlv1 = new LinkNameTlv(rawValue1, (short) rawValue1.length);
-    private final LinkNameTlv sameAsTlv1 = LinkNameTlv.of(tlv1.getValue(), tlv1.getLength());
-    private final LinkNameTlv tlv2 = new LinkNameTlv(rawValue2, (short) 0);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.LinkNameTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Equality test for LinkNameTlv.
+ */
+public class LinkNameTlvTest {
+    private final byte[] rawValue1 = new byte[] {0x01, 0x00};
+    private final byte[] rawValue2 = new byte[] {0x02, 0x00};
+
+    private final LinkNameTlv tlv1 = new LinkNameTlv(rawValue1, (short) rawValue1.length);
+    private final LinkNameTlv sameAsTlv1 = LinkNameTlv.of(tlv1.getValue(), tlv1.getLength());
+    private final LinkNameTlv tlv2 = new LinkNameTlv(rawValue2, (short) 0);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkProtectionTypeTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkProtectionTypeTlvTest.java
index f6deae7..4eea1b0 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkProtectionTypeTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkProtectionTypeTlvTest.java
@@ -1 +1,41 @@
-/* * Copyright 2015 Open Networking Laboratory * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.onosproject.pcepio;import org.junit.Test;import org.onosproject.pcepio.types.LinkProtectionTypeTlv;import com.google.common.testing.EqualsTester;/** * Test of the LinkProtectionTypeTlv. */public class LinkProtectionTypeTlvTest {    private final byte rawValue1 = 0x0A;    private final byte rawValue2 = 0x0B;    private final LinkProtectionTypeTlv tlv1 = new LinkProtectionTypeTlv(rawValue1);    private final LinkProtectionTypeTlv sameAsTlv1 = new LinkProtectionTypeTlv(rawValue1);    private final LinkProtectionTypeTlv tlv2 = new LinkProtectionTypeTlv(rawValue2, (byte) 0);    @Test    public void basics() {        new EqualsTester()        .addEqualityGroup(tlv1, sameAsTlv1)        .addEqualityGroup(tlv2)        .testEquals();    }}
\ No newline at end of file
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.LinkProtectionTypeTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the LinkProtectionTypeTlv.
+ */
+public class LinkProtectionTypeTlvTest {
+    private final byte rawValue1 = 0x0A;
+    private final byte rawValue2 = 0x0B;
+
+    private final LinkProtectionTypeTlv tlv1 = new LinkProtectionTypeTlv(rawValue1);
+    private final LinkProtectionTypeTlv sameAsTlv1 = new LinkProtectionTypeTlv(rawValue1);
+    private final LinkProtectionTypeTlv tlv2 = new LinkProtectionTypeTlv(rawValue2, (byte) 0);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LocalTENodeDescriptorsTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LocalTENodeDescriptorsTlvTest.java
index 43e337f..3311a96 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/LocalTENodeDescriptorsTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/LocalTENodeDescriptorsTlvTest.java
@@ -1 +1,56 @@
-/* * Copyright 2015 Open Networking Laboratory * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.onosproject.pcepio;import com.google.common.testing.EqualsTester;import org.junit.Test;import java.util.LinkedList;import org.onosproject.pcepio.types.LocalTENodeDescriptorsTlv;import org.onosproject.pcepio.types.AutonomousSystemTlv;import org.onosproject.pcepio.types.BGPLSidentifierTlv;import org.onosproject.pcepio.types.PcepValueType;/** * Test of the LocalTENodeDescriptorsTlv. */public class LocalTENodeDescriptorsTlvTest {    private final AutonomousSystemTlv baAutoSysTlvRawValue1 = new AutonomousSystemTlv(1);    private final BGPLSidentifierTlv baBgplsIdRawValue1 = new BGPLSidentifierTlv(1);    private final AutonomousSystemTlv baAutoSysTlvRawValue2 = new AutonomousSystemTlv(2);    private final BGPLSidentifierTlv baBgplsIdRawValue2 = new BGPLSidentifierTlv(2);    private final LinkedList<PcepValueType> llNodeDescriptorSubTLVs1 = new LinkedList<PcepValueType>();    private final boolean a = llNodeDescriptorSubTLVs1.add(baAutoSysTlvRawValue1);    private final boolean b = llNodeDescriptorSubTLVs1.add(baBgplsIdRawValue1);    private final LinkedList<PcepValueType> llNodeDescriptorSubTLVs2 = new LinkedList<PcepValueType>();    private final boolean c = llNodeDescriptorSubTLVs2.add(baAutoSysTlvRawValue2);    private final boolean d = llNodeDescriptorSubTLVs2.add(baBgplsIdRawValue2);    private final LocalTENodeDescriptorsTlv tlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1);    private final LocalTENodeDescriptorsTlv sameAstlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1);    private final LocalTENodeDescriptorsTlv tlv2 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs2);    @Test    public void basics() {        new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals();    }}
\ No newline at end of file
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+import org.onosproject.pcepio.types.LocalTENodeDescriptorsTlv;
+import org.onosproject.pcepio.types.AutonomousSystemTlv;
+import org.onosproject.pcepio.types.BGPLSidentifierTlv;
+import org.onosproject.pcepio.types.PcepValueType;
+
+/**
+ * Test of the LocalTENodeDescriptorsTlv.
+ */
+public class LocalTENodeDescriptorsTlvTest {
+
+    private final AutonomousSystemTlv baAutoSysTlvRawValue1 = new AutonomousSystemTlv(1);
+    private final BGPLSidentifierTlv baBgplsIdRawValue1 = new BGPLSidentifierTlv(1);
+
+    private final AutonomousSystemTlv baAutoSysTlvRawValue2 = new AutonomousSystemTlv(2);
+    private final BGPLSidentifierTlv baBgplsIdRawValue2 = new BGPLSidentifierTlv(2);
+
+    private final LinkedList<PcepValueType> llNodeDescriptorSubTLVs1 = new LinkedList<PcepValueType>();
+    private final boolean a = llNodeDescriptorSubTLVs1.add(baAutoSysTlvRawValue1);
+    private final boolean b = llNodeDescriptorSubTLVs1.add(baBgplsIdRawValue1);
+
+    private final LinkedList<PcepValueType> llNodeDescriptorSubTLVs2 = new LinkedList<PcepValueType>();
+    private final boolean c = llNodeDescriptorSubTLVs2.add(baAutoSysTlvRawValue2);
+    private final boolean d = llNodeDescriptorSubTLVs2.add(baBgplsIdRawValue2);
+
+    private final LocalTENodeDescriptorsTlv tlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1);
+    private final LocalTENodeDescriptorsTlv sameAstlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1);
+    private final LocalTENodeDescriptorsTlv tlv2 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/MPLSProtocolMaskTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/MPLSProtocolMaskTlvTest.java
index d395db4..eda99a3 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/MPLSProtocolMaskTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/MPLSProtocolMaskTlvTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.MPLSProtocolMaskTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the MPLSProtocolMaskTlv.
- */
-public class MPLSProtocolMaskTlvTest {
-    private final byte rawValue1 = 0x0A;
-    private final byte rawValue2 = 0x0B;
-
-    private final MPLSProtocolMaskTlv tlv1 = new MPLSProtocolMaskTlv(rawValue1);
-    private final MPLSProtocolMaskTlv sameAsTlv1 = new MPLSProtocolMaskTlv(rawValue1);
-    private final MPLSProtocolMaskTlv tlv2 = MPLSProtocolMaskTlv.of(rawValue2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.MPLSProtocolMaskTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the MPLSProtocolMaskTlv.
+ */
+public class MPLSProtocolMaskTlvTest {
+    private final byte rawValue1 = 0x0A;
+    private final byte rawValue2 = 0x0B;
+
+    private final MPLSProtocolMaskTlv tlv1 = new MPLSProtocolMaskTlv(rawValue1);
+    private final MPLSProtocolMaskTlv sameAsTlv1 = new MPLSProtocolMaskTlv(rawValue1);
+    private final MPLSProtocolMaskTlv tlv2 = MPLSProtocolMaskTlv.of(rawValue2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumLinkBandwidthTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumLinkBandwidthTlvTest.java
index 8e5ba2b..50902ac 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumLinkBandwidthTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumLinkBandwidthTlvTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.MaximumLinkBandwidthTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the MaximumLinkBandwidthTlv.
- */
-public class MaximumLinkBandwidthTlvTest {
-    private final int rawValue1 = 0x0A;
-    private final int rawValue2 = 0x0B;
-
-    private final MaximumLinkBandwidthTlv tlv1 = new MaximumLinkBandwidthTlv(rawValue1);
-    private final MaximumLinkBandwidthTlv sameAsTlv1 = new MaximumLinkBandwidthTlv(rawValue1);
-    private final MaximumLinkBandwidthTlv tlv2 = MaximumLinkBandwidthTlv.of(rawValue2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.MaximumLinkBandwidthTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the MaximumLinkBandwidthTlv.
+ */
+public class MaximumLinkBandwidthTlvTest {
+    private final int rawValue1 = 0x0A;
+    private final int rawValue2 = 0x0B;
+
+    private final MaximumLinkBandwidthTlv tlv1 = new MaximumLinkBandwidthTlv(rawValue1);
+    private final MaximumLinkBandwidthTlv sameAsTlv1 = new MaximumLinkBandwidthTlv(rawValue1);
+    private final MaximumLinkBandwidthTlv tlv2 = MaximumLinkBandwidthTlv.of(rawValue2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumReservableLinkBandwidthTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumReservableLinkBandwidthTlvTest.java
index d601f0d..da72c5f 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumReservableLinkBandwidthTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumReservableLinkBandwidthTlvTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.MaximumReservableLinkBandwidthTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the MaximumReservableLinkBandwidthTlv.
- */
-public class MaximumReservableLinkBandwidthTlvTest {
-    private final int rawValue1 = 0x0A;
-    private final int rawValue2 = 0x0B;
-
-    private final MaximumReservableLinkBandwidthTlv tlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1);
-    private final MaximumReservableLinkBandwidthTlv sameAsTlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1);
-    private final MaximumReservableLinkBandwidthTlv tlv2 = MaximumReservableLinkBandwidthTlv.of(rawValue2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.MaximumReservableLinkBandwidthTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the MaximumReservableLinkBandwidthTlv.
+ */
+public class MaximumReservableLinkBandwidthTlvTest {
+    private final int rawValue1 = 0x0A;
+    private final int rawValue2 = 0x0B;
+
+    private final MaximumReservableLinkBandwidthTlv tlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1);
+    private final MaximumReservableLinkBandwidthTlv sameAsTlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1);
+    private final MaximumReservableLinkBandwidthTlv tlv2 = MaximumReservableLinkBandwidthTlv.of(rawValue2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java
index 53f75ec..27539fa 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.NexthopIPv4addressTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Equality test for NexthopIPv4addressTlv.
- */
-public class NexthopIPv4addressTlvTest {
-
-    private final NexthopIPv4addressTlv tlv1 = new NexthopIPv4addressTlv(0x0A);
-    private final NexthopIPv4addressTlv sameAsTlv1 = new NexthopIPv4addressTlv(0x0A);
-    private final NexthopIPv4addressTlv tlv2 = NexthopIPv4addressTlv.of(0x0B);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.NexthopIPv4addressTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Equality test for NexthopIPv4addressTlv.
+ */
+public class NexthopIPv4addressTlvTest {
+
+    private final NexthopIPv4addressTlv tlv1 = new NexthopIPv4addressTlv(0x0A);
+    private final NexthopIPv4addressTlv sameAsTlv1 = new NexthopIPv4addressTlv(0x0A);
+    private final NexthopIPv4addressTlv tlv2 = NexthopIPv4addressTlv.of(0x0B);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java
index 36a610b..457b934 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.NexthopUnnumberedIPv4IDTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Equality test for NexthopUnnumberedIPv4IDTlv.
- */
-public class NexthopUnnumberedIPv4IDTlvTest {
-
-    private final NexthopUnnumberedIPv4IDTlv tlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);
-    private final NexthopUnnumberedIPv4IDTlv sameAsTlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);
-    private final NexthopUnnumberedIPv4IDTlv tlv2 = NexthopUnnumberedIPv4IDTlv.of(0x0B, 0x0B);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.NexthopUnnumberedIPv4IDTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Equality test for NexthopUnnumberedIPv4IDTlv.
+ */
+public class NexthopUnnumberedIPv4IDTlvTest {
+
+    private final NexthopUnnumberedIPv4IDTlv tlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);
+    private final NexthopUnnumberedIPv4IDTlv sameAsTlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);
+    private final NexthopUnnumberedIPv4IDTlv tlv2 = NexthopUnnumberedIPv4IDTlv.of(0x0B, 0x0B);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeFlagBitsTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeFlagBitsTlvTest.java
index 76e32e6..a50062a 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeFlagBitsTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeFlagBitsTlvTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.NodeFlagBitsTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the NodeFlagBitsTlv.
- */
-public class NodeFlagBitsTlvTest {
-    private final byte rawValue1 = 0x0A;
-    private final byte rawValue2 = 0x0B;
-
-    private final NodeFlagBitsTlv tlv1 = new NodeFlagBitsTlv(rawValue1);
-    private final NodeFlagBitsTlv sameAsTlv1 = new NodeFlagBitsTlv(rawValue1);
-    private final NodeFlagBitsTlv tlv2 = NodeFlagBitsTlv.of(rawValue2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.NodeFlagBitsTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the NodeFlagBitsTlv.
+ */
+public class NodeFlagBitsTlvTest {
+    private final byte rawValue1 = 0x0A;
+    private final byte rawValue2 = 0x0B;
+
+    private final NodeFlagBitsTlv tlv1 = new NodeFlagBitsTlv(rawValue1);
+    private final NodeFlagBitsTlv sameAsTlv1 = new NodeFlagBitsTlv(rawValue1);
+    private final NodeFlagBitsTlv tlv2 = NodeFlagBitsTlv.of(rawValue2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeNameTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeNameTlvTest.java
index de0e937..bb35ed9 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeNameTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeNameTlvTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.NodeNameTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the NodeNameTlv.
- */
-public class NodeNameTlvTest {
-    private final byte[] rawValue1 = new byte[] {0x01, 0x02};
-    private final byte[] rawValue2 = new byte[] {0x14, 0x15};
-
-    private final NodeNameTlv tlv1 = new NodeNameTlv(rawValue1, (short) rawValue1.length);
-    private final NodeNameTlv sameAsTlv1 = NodeNameTlv.of(tlv1.getValue(), tlv1.getLength());
-    private final NodeNameTlv tlv2 = new NodeNameTlv(rawValue2, (short) 0);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.NodeNameTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the NodeNameTlv.
+ */
+public class NodeNameTlvTest {
+    private final byte[] rawValue1 = new byte[] {0x01, 0x02};
+    private final byte[] rawValue2 = new byte[] {0x14, 0x15};
+
+    private final NodeNameTlv tlv1 = new NodeNameTlv(rawValue1, (short) rawValue1.length);
+    private final NodeNameTlv sameAsTlv1 = NodeNameTlv.of(tlv1.getValue(), tlv1.getLength());
+    private final NodeNameTlv tlv2 = new NodeNameTlv(rawValue2, (short) 0);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/OSPFareaIDsubTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/OSPFareaIDsubTlvTest.java
index f287450..4b67a90 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/OSPFareaIDsubTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/OSPFareaIDsubTlvTest.java
@@ -1,38 +1,38 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.OSPFareaIDsubTlv;
-
-/**
- * Test of the OSPFareaIDsubTlv.
- */
-public class OSPFareaIDsubTlvTest {
-    private final int rawValue1 = 0x0A;
-
-    private final OSPFareaIDsubTlv tlv1 = new OSPFareaIDsubTlv(rawValue1);
-    private final OSPFareaIDsubTlv tlv2 = OSPFareaIDsubTlv.of(tlv1.getInt());
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import com.google.common.testing.EqualsTester;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.OSPFareaIDsubTlv;
+
+/**
+ * Test of the OSPFareaIDsubTlv.
+ */
+public class OSPFareaIDsubTlvTest {
+    private final int rawValue1 = 0x0A;
+
+    private final OSPFareaIDsubTlv tlv1 = new OSPFareaIDsubTlv(rawValue1);
+    private final OSPFareaIDsubTlv tlv2 = OSPFareaIDsubTlv.of(tlv1.getInt());
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/OpaqueLinkAttributeTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/OpaqueLinkAttributeTlvTest.java
index 784b8ba..cda77a0 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/OpaqueLinkAttributeTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/OpaqueLinkAttributeTlvTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.OpaqueLinkAttributeTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the OpaqueLinkAttributeTlv.
- */
-public class OpaqueLinkAttributeTlvTest {
-    private final byte[] rawValue1 = new byte[] {0x01, 0x02};
-    private final byte[] rawValue2 = new byte[] {0x14, 0x15};
-
-    private final OpaqueLinkAttributeTlv tlv1 = new OpaqueLinkAttributeTlv(rawValue1, (short) rawValue1.length);
-    private final OpaqueLinkAttributeTlv sameAsTlv1 = OpaqueLinkAttributeTlv.of(tlv1.getValue(), tlv1.getLength());
-    private final OpaqueLinkAttributeTlv tlv2 = new OpaqueLinkAttributeTlv(rawValue2, (short) 0);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.OpaqueLinkAttributeTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the OpaqueLinkAttributeTlv.
+ */
+public class OpaqueLinkAttributeTlvTest {
+    private final byte[] rawValue1 = new byte[] {0x01, 0x02};
+    private final byte[] rawValue2 = new byte[] {0x14, 0x15};
+
+    private final OpaqueLinkAttributeTlv tlv1 = new OpaqueLinkAttributeTlv(rawValue1, (short) rawValue1.length);
+    private final OpaqueLinkAttributeTlv sameAsTlv1 = OpaqueLinkAttributeTlv.of(tlv1.getValue(), tlv1.getLength());
+    private final OpaqueLinkAttributeTlv tlv2 = new OpaqueLinkAttributeTlv(rawValue2, (short) 0);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java
index 2229c49..cab4379 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.PathKeySubObject;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the PathKeySubObject.
- */
-public class PathKeySubObjectTest {
-
-    private final PathKeySubObject tlv1 = new PathKeySubObject((short) 0x0A, 0x0A);
-    private final PathKeySubObject sameAsTlv1 = PathKeySubObject.of((short) 0x0A, 0x0A);
-    private final PathKeySubObject tlv2 = new PathKeySubObject((short) 0x0B, 0x0B);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.PathKeySubObject;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the PathKeySubObject.
+ */
+public class PathKeySubObjectTest {
+
+    private final PathKeySubObject tlv1 = new PathKeySubObject((short) 0x0A, 0x0A);
+    private final PathKeySubObject sameAsTlv1 = PathKeySubObject.of((short) 0x0A, 0x0A);
+    private final PathKeySubObject tlv2 = new PathKeySubObject((short) 0x0B, 0x0B);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathSetupTypeTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathSetupTypeTlvTest.java
index 633cf37..e56c96e 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathSetupTypeTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathSetupTypeTlvTest.java
@@ -1,36 +1,36 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.PathSetupTypeTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the PathSetupTypeTlv.
- */
-public class PathSetupTypeTlvTest {
-
-    private final PathSetupTypeTlv tlv1 = PathSetupTypeTlv.of(0x0A);
-    private final PathSetupTypeTlv sameAsTlv1 = PathSetupTypeTlv.of(0x0A);
-    private final PathSetupTypeTlv tlv2 = PathSetupTypeTlv.of(0x0B);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.PathSetupTypeTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the PathSetupTypeTlv.
+ */
+public class PathSetupTypeTlvTest {
+
+    private final PathSetupTypeTlv tlv1 = PathSetupTypeTlv.of(0x0A);
+    private final PathSetupTypeTlv sameAsTlv1 = PathSetupTypeTlv.of(0x0A);
+    private final PathSetupTypeTlv tlv2 = PathSetupTypeTlv.of(0x0B);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PceccCapabilityTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PceccCapabilityTlvTest.java
index 6a68f33..a8d521a 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PceccCapabilityTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PceccCapabilityTlvTest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.PceccCapabilityTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test of the PceccCapabilityTlv.
- */
-public class PceccCapabilityTlvTest {
-    private final int rawValue1 = 0x0A;
-    private final int rawValue2 = 0x0B;
-
-    private final PceccCapabilityTlv tlv1 = new PceccCapabilityTlv(rawValue1);
-    private final PceccCapabilityTlv sameAsTlv1 = new PceccCapabilityTlv(rawValue1);
-    private final PceccCapabilityTlv tlv2 = PceccCapabilityTlv.of(rawValue2);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, sameAsTlv1)
-        .addEqualityGroup(tlv2)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.PceccCapabilityTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test of the PceccCapabilityTlv.
+ */
+public class PceccCapabilityTlvTest {
+    private final int rawValue1 = 0x0A;
+    private final int rawValue2 = 0x0B;
+
+    private final PceccCapabilityTlv tlv1 = new PceccCapabilityTlv(rawValue1);
+    private final PceccCapabilityTlv sameAsTlv1 = new PceccCapabilityTlv(rawValue1);
+    private final PceccCapabilityTlv tlv2 = PceccCapabilityTlv.of(rawValue2);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, sameAsTlv1)
+        .addEqualityGroup(tlv2)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepCloseMsgTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepCloseMsgTest.java
index 84b63ca..43a65d9 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepCloseMsgTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepCloseMsgTest.java
@@ -1,60 +1,60 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepCloseMsg;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsSame.sameInstance;
-
-public class PcepCloseMsgTest {
-
-    /**
-     * Common header, reason to close.
-     */
-    @Test
-    public void closeMessageTest1() throws PcepParseException {
-
-        byte[] closeMsg = new byte[] {0x20, 0x07, 0x00, 0x0C, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02 };
-
-        byte[] testCloseMsg = {0 };
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(closeMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message;
-
-        message = reader.readFrom(buffer);
-        assertThat(message, sameInstance((PcepCloseMsg) message));
-
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testCloseMsg = buf.array();
-
-        int readLen = buf.writerIndex();
-        testCloseMsg = new byte[readLen];
-        buf.readBytes(testCloseMsg, 0, readLen);
-        assertThat(testCloseMsg, is(closeMsg));
-    }
-}
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepCloseMsg;
+import org.onosproject.pcepio.protocol.PcepFactories;
+import org.onosproject.pcepio.protocol.PcepMessage;
+import org.onosproject.pcepio.protocol.PcepMessageReader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsSame.sameInstance;
+
+public class PcepCloseMsgTest {
+
+    /**
+     * Common header, reason to close.
+     */
+    @Test
+    public void closeMessageTest1() throws PcepParseException {
+
+        byte[] closeMsg = new byte[] {0x20, 0x07, 0x00, 0x0C, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02 };
+
+        byte[] testCloseMsg = {0 };
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(closeMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message;
+
+        message = reader.readFrom(buffer);
+        assertThat(message, sameInstance((PcepCloseMsg) message));
+
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testCloseMsg = buf.array();
+
+        int readLen = buf.writerIndex();
+        testCloseMsg = new byte[readLen];
+        buf.readBytes(testCloseMsg, 0, readLen);
+        assertThat(testCloseMsg, is(closeMsg));
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgExtTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgExtTest.java
index dca124a..9da4c62 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgExtTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgExtTest.java
@@ -1,1686 +1,1686 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepInitiateMsg;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.Matchers.instanceOf;
-
-public class PcepInitiateMsgExtTest {
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv),
-     * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest1() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
-         * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA4,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03,
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, //ERO object
-                0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
-                0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, //Metric object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv,
-     * StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest2() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
-         * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x48, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
-                0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS,
-     * ERO, LSPA, BANDWIDTH objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest3() throws PcepParseException {
-
-        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
-         * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
-                //0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv),
-     * END-POINTS, ERO, LSPA objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest4() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
-         * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
-                // 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest5() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
-         * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA,
-     * BANDWIDTH OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest6() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
-         * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO,
-     * LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest7() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
-         * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x98,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest8() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
-         * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x90,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest9() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
-         * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest10() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
-         * END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA OBJECT
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest11() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
-         * END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7C,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03,
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest12() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
-         * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x78,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest13() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
-         * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-     * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest14() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-         * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7c,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-     * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest15() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-         * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-     * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest16() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-         * END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest17() throws PcepParseException {
-
-        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
-     * BANDWIDTH OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest18() throws PcepParseException {
-
-        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03,
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
-     * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest19() throws PcepParseException {
-
-        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
-     * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest20() throws PcepParseException {
-
-        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
-     * BANDWIDTH OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest21() throws PcepParseException {
-
-        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO,
-     * LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest22() throws PcepParseException {
-
-        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-     * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest23() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-     * END-POINTS, ERO, LSPA BANDWIDTH OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest25() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
-     * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest26() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
-         * ERO, LSPA, BANDWIDTH, METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x6C,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA,
-     * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest27() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO,
-     * LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest28() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
-     * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest29() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4C,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
-     * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest30() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5C,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT
-     * objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest31() throws PcepParseException {
-
-        /* SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-     * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest32() throws PcepParseException {
-
-        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-         * ERO, LSPA, BANDWIDTH, METRIC OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-     * ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest33() throws PcepParseException {
-
-        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-         * ERO, LSPA, BANDWIDTH OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-     * ERO, LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest34() throws PcepParseException {
-
-        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-         * ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x04, //ERO object
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-     * ERO, LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest35() throws PcepParseException {
-
-        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-         * ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-     * ERO, LSPA OBJECT objects in PcInitiate message.
-     */
-    @Test
-    public void initiateMessageTest36() throws PcepParseException {
-
-        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
-         * ERO, LSPA OBJECT.
-         */
-        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
-                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
-        byte[] testInitiateCreationMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(initiateCreationMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepInitiateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
-        message.writeTo(buf);
-
-        testInitiateCreationMsg = buf.array();
-
-        int iReadLen = buf.writerIndex();
-        testInitiateCreationMsg = new byte[iReadLen];
-        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
-        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
-    }
-}
-
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepFactories;
+import org.onosproject.pcepio.protocol.PcepInitiateMsg;
+import org.onosproject.pcepio.protocol.PcepMessage;
+import org.onosproject.pcepio.protocol.PcepMessageReader;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.Matchers.instanceOf;
+
+public class PcepInitiateMsgExtTest {
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv),
+     * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest1() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+         * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA4,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03,
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, //ERO object
+                0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+                0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, //Metric object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv,
+     * StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest2() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+         * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x48, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
+                0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS,
+     * ERO, LSPA, BANDWIDTH objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest3() throws PcepParseException {
+
+        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+         * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
+                //0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv),
+     * END-POINTS, ERO, LSPA objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest4() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+         * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
+                // 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest5() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+         * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA,
+     * BANDWIDTH OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest6() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+         * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO,
+     * LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest7() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+         * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x98,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest8() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
+         * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x90,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest9() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
+         * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest10() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+         * END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA OBJECT
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest11() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
+         * END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7C,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03,
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest12() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+         * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x78,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest13() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
+         * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+     * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest14() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+         * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7c,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+     * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest15() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+         * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+     * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest16() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+         * END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest17() throws PcepParseException {
+
+        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
+     * BANDWIDTH OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest18() throws PcepParseException {
+
+        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03,
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
+     * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest19() throws PcepParseException {
+
+        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
+     * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest20() throws PcepParseException {
+
+        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
+     * BANDWIDTH OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest21() throws PcepParseException {
+
+        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO,
+     * LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest22() throws PcepParseException {
+
+        /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+     * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest23() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+     * END-POINTS, ERO, LSPA BANDWIDTH OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest25() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
+     * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest26() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
+         * ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x6C,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA,
+     * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest27() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO,
+     * LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest28() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
+     * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest29() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4C,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
+     * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest30() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5C,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT
+     * objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest31() throws PcepParseException {
+
+        /* SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+     * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest32() throws PcepParseException {
+
+        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+         * ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+     * ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest33() throws PcepParseException {
+
+        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+         * ERO, LSPA, BANDWIDTH OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+     * ERO, LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest34() throws PcepParseException {
+
+        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+         * ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x04, //ERO object
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+     * ERO, LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest35() throws PcepParseException {
+
+        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+         * ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+     * ERO, LSPA OBJECT objects in PcInitiate message.
+     */
+    @Test
+    public void initiateMessageTest36() throws PcepParseException {
+
+        /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+         * ERO, LSPA OBJECT.
+         */
+        byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+                0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+        byte[] testInitiateCreationMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(initiateCreationMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepInitiateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+        message.writeTo(buf);
+
+        testInitiateCreationMsg = buf.array();
+
+        int iReadLen = buf.writerIndex();
+        testInitiateCreationMsg = new byte[iReadLen];
+        buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+        assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+    }
+}
+
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4NodeIdTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4NodeIdTest.java
index 852e726..bcd69be 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4NodeIdTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4NodeIdTest.java
@@ -1,36 +1,36 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.PcepNaiIpv4NodeId;
-
-import com.google.common.testing.EqualsTester;
-
-public class PcepNaiIpv4NodeIdTest {
-
-    private final PcepNaiIpv4NodeId tlv1 = PcepNaiIpv4NodeId.of(1);
-    private final PcepNaiIpv4NodeId tlv2 = PcepNaiIpv4NodeId.of(1);
-    private final PcepNaiIpv4NodeId tlv3 = PcepNaiIpv4NodeId.of(3);
-
-    @Test
-    public void basics() {
-        new EqualsTester()
-        .addEqualityGroup(tlv1, tlv2)
-        .addEqualityGroup(tlv3)
-        .testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.PcepNaiIpv4NodeId;
+
+import com.google.common.testing.EqualsTester;
+
+public class PcepNaiIpv4NodeIdTest {
+
+    private final PcepNaiIpv4NodeId tlv1 = PcepNaiIpv4NodeId.of(1);
+    private final PcepNaiIpv4NodeId tlv2 = PcepNaiIpv4NodeId.of(1);
+    private final PcepNaiIpv4NodeId tlv3 = PcepNaiIpv4NodeId.of(3);
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+        .addEqualityGroup(tlv1, tlv2)
+        .addEqualityGroup(tlv3)
+        .testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6AdjacencyTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6AdjacencyTest.java
index 53b70a6..5b68193 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6AdjacencyTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6AdjacencyTest.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.PcepNaiIpv6Adjacency;
-
-import com.google.common.testing.EqualsTester;
-
-public class PcepNaiIpv6AdjacencyTest {
-    private final byte[] localIpv6Addr1 = {(byte) 0x01010101 };
-    private final byte[] remoteIpv6Addr1 = {(byte) 0x02020202 };
-    private final byte[] localIpv6Addr2 = {(byte) 0x01010101 };
-    private final byte[] remoteIpv6Addr2 = {(byte) 0x02020202 };
-    private final byte[] localIpv6Addr3 = {(byte) 0x05050505 };
-    private final byte[] remoteIpv6Addr3 = {(byte) 0x06060606 };
-
-    private final PcepNaiIpv6Adjacency tlv1 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1);
-    private final PcepNaiIpv6Adjacency tlv2 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1);
-    private final PcepNaiIpv6Adjacency tlv3 = PcepNaiIpv6Adjacency.of(localIpv6Addr3, remoteIpv6Addr3);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.PcepNaiIpv6Adjacency;
+
+import com.google.common.testing.EqualsTester;
+
+public class PcepNaiIpv6AdjacencyTest {
+    private final byte[] localIpv6Addr1 = {(byte) 0x01010101 };
+    private final byte[] remoteIpv6Addr1 = {(byte) 0x02020202 };
+    private final byte[] localIpv6Addr2 = {(byte) 0x01010101 };
+    private final byte[] remoteIpv6Addr2 = {(byte) 0x02020202 };
+    private final byte[] localIpv6Addr3 = {(byte) 0x05050505 };
+    private final byte[] remoteIpv6Addr3 = {(byte) 0x06060606 };
+
+    private final PcepNaiIpv6Adjacency tlv1 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1);
+    private final PcepNaiIpv6Adjacency tlv2 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1);
+    private final PcepNaiIpv6Adjacency tlv3 = PcepNaiIpv6Adjacency.of(localIpv6Addr3, remoteIpv6Addr3);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
 }
\ No newline at end of file
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.java
index 65f62ac..d45bae8 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.java
@@ -1,51 +1,51 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.PcepNaiUnnumberedAdjacencyIpv4;
-
-import com.google.common.testing.EqualsTester;
-
-public class PcepNaiUnnumberedAdjacencyIpv4Test {
-
-    private final int localNodeId1 = 1;
-    private final int localInterfaceId1 = 1;
-    private final int remoteNodeId1 = 1;
-    private final int remoteInterfaceId1 = 1;
-    private final PcepNaiUnnumberedAdjacencyIpv4 tlv1 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId1,
-            localInterfaceId1, remoteNodeId1, remoteInterfaceId1);
-
-    private final int localNodeId2 = 1;
-    private final int localInterfaceId2 = 1;
-    private final int remoteNodeId2 = 1;
-    private final int remoteInterfaceId2 = 1;
-    private final PcepNaiUnnumberedAdjacencyIpv4 tlv2 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId2,
-            localInterfaceId2, remoteNodeId2, remoteInterfaceId2);
-
-    private final int localNodeId3 = 2;
-    private final int localInterfaceId3 = 2;
-    private final int remoteNodeId3 = 2;
-    private final int remoteInterfaceId3 = 2;
-
-    private final PcepNaiUnnumberedAdjacencyIpv4 tlv3 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId3,
-            localInterfaceId3, remoteNodeId3, remoteInterfaceId3);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.PcepNaiUnnumberedAdjacencyIpv4;
+
+import com.google.common.testing.EqualsTester;
+
+public class PcepNaiUnnumberedAdjacencyIpv4Test {
+
+    private final int localNodeId1 = 1;
+    private final int localInterfaceId1 = 1;
+    private final int remoteNodeId1 = 1;
+    private final int remoteInterfaceId1 = 1;
+    private final PcepNaiUnnumberedAdjacencyIpv4 tlv1 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId1,
+            localInterfaceId1, remoteNodeId1, remoteInterfaceId1);
+
+    private final int localNodeId2 = 1;
+    private final int localInterfaceId2 = 1;
+    private final int remoteNodeId2 = 1;
+    private final int remoteInterfaceId2 = 1;
+    private final PcepNaiUnnumberedAdjacencyIpv4 tlv2 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId2,
+            localInterfaceId2, remoteNodeId2, remoteInterfaceId2);
+
+    private final int localNodeId3 = 2;
+    private final int localInterfaceId3 = 2;
+    private final int remoteNodeId3 = 2;
+    private final int remoteInterfaceId3 = 2;
+
+    private final PcepNaiUnnumberedAdjacencyIpv4 tlv3 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId3,
+            localInterfaceId3, remoteNodeId3, remoteInterfaceId3);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgExtTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgExtTest.java
index 4b0174c..1f95617 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgExtTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgExtTest.java
@@ -1,1275 +1,1275 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.Matchers.instanceOf;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepUpdateMsg;
-
-/**
- *  Test cases for PCEP update message.
- */
-public class PcepUpdateMsgExtTest {
-
-    /**
-     * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
-     * Metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest1() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
-     * LSPA, Bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest2() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSP object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object, ERO object, LSPA, bandwidth object
-     * Metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest3() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,bandwidth object
-     * Metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest4() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,bandwidth object
-     * Metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest5() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, LSPA, bandwidth object
-     * Metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest6() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
-     * bandwidth object Metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest7() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
-     * bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest8() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
-     * bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest9() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x18, 0x00, 0x00, 0x10, 0x03,
-                0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
-                0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
-     * bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest10() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPa object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
-     * bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest11() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
-     * bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest12() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,LSPA
-     * bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest13() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
-     * metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest14() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object, ERO object,LSPA
-     * metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest15() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //lspa object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,LSPA
-     * metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest16() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
-     * metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest17() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
-     * metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest18() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
-     * metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest19() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
-     * Bandwidth , metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest20() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object, ERO object,
-     * Bandwidth , metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest21() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
-     * Bandwidth , metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest22() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,
-     * Bandwidth , metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest23() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,
-     * Bandwidth , metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest24() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
-     * Bandwidth , metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest25() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
-     * LSPA object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest26() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object, ERO object,
-     * bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest27() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
-     * metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest28() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
-     * lspa object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest29() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
-     * bandwidth object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest30() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
-     * metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest31() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
-     * Metric object in PcepUpdate message.
-     */
-    @Test
-    public void pcepUpdateMsgTest32() throws PcepParseException {
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, instanceOf(PcepUpdateMsg.class));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-}
-
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.Matchers.instanceOf;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepFactories;
+import org.onosproject.pcepio.protocol.PcepMessage;
+import org.onosproject.pcepio.protocol.PcepMessageReader;
+import org.onosproject.pcepio.protocol.PcepUpdateMsg;
+
+/**
+ *  Test cases for PCEP update message.
+ */
+public class PcepUpdateMsgExtTest {
+
+    /**
+     * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
+     * Metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest1() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
+     * LSPA, Bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest2() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSP object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object, ERO object, LSPA, bandwidth object
+     * Metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest3() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,bandwidth object
+     * Metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest4() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,bandwidth object
+     * Metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest5() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, LSPA, bandwidth object
+     * Metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest6() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
+     * bandwidth object Metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest7() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
+     * bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest8() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
+     * bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest9() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x18, 0x00, 0x00, 0x10, 0x03,
+                0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
+                0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
+     * bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest10() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPa object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
+     * bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest11() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
+     * bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest12() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,LSPA
+     * bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest13() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
+     * metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest14() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object, ERO object,LSPA
+     * metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest15() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //lspa object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,LSPA
+     * metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest16() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
+     * metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest17() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
+     * metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest18() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
+     * metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest19() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
+     * Bandwidth , metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest20() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object, ERO object,
+     * Bandwidth , metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest21() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
+     * Bandwidth , metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest22() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,
+     * Bandwidth , metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest23() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,
+     * Bandwidth , metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest24() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
+     * Bandwidth , metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest25() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
+     * LSPA object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest26() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object, ERO object,
+     * bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest27() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
+     * metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest28() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
+     * lspa object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest29() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
+     * bandwidth object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest30() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
+     * metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest31() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
+     * Metric object in PcepUpdate message.
+     */
+    @Test
+    public void pcepUpdateMsgTest32() throws PcepParseException {
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, instanceOf(PcepUpdateMsg.class));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+}
+
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgTest.java
index 8e9afee..7bf6daf 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgTest.java
@@ -1,1427 +1,1427 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsSame.sameInstance;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import static org.hamcrest.MatcherAssert.assertThat;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepUpdateMsg;
-
-public class PcepUpdateMsgTest {
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), ERO in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest1() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
-                0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x04 }; //ERO object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP(SymbolicPathNameTlv), LSP (StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO, LSPA, Metric-list in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest2() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object // lsp object
-                0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
-                0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x24, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
-                0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
-     * ERO objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest3() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x04 }; //ERO object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv), ERO objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest4() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x04 }; //ERO object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv), ERO objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest5() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x04 }; //ERO object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest6() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x04 };
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest7() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x04}; //ERO object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject) objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest8() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x0c, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00 };
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject) objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest9() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00 };
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), LSPA objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest10() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest11() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest12() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest13() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
-     * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric Object objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest14() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
-     * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest15() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
-     * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest16() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
-     * ERO (IPv4SubObject, IPv4SubObject),LSPA objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest17() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
-     * ERO (IPv4SubObject, IPv4SubObject),Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest18() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
-     * ERO (IPv4SubObject, IPv4SubObject),Metric-list objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest19() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
-                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv),ERO (IPv4SubObject, IPv4SubObject),LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest20() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
-     * ERO (IPv4SubObject, IPv4SubObject), Bandwidth objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest21() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest22() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
-                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest23() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest24() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest25() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
-     * Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest26() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
-     * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
-     * Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest27() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
-     * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),
-     * LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest28() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest29() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
-                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP,
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest30() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (StatefulLspErrorCodeTlv),
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest31() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP,
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest32() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv),
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest33() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
-                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-
-    /**
-     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
-     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
-     */
-    @Test
-    public void pcepUpdateMsgTest34() throws PcepParseException {
-
-        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
-                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
-                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
-                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
-                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
-                0x01, 0x01, 0x04, 0x00,
-                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
-                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
-
-        byte[] testupdateMsg = {0};
-        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-        buffer.writeBytes(updateMsg);
-
-        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
-        PcepMessage message = null;
-
-        message = reader.readFrom(buffer);
-
-        assertThat(message, sameInstance((PcepUpdateMsg) message));
-        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-        message.writeTo(buf);
-        testupdateMsg = buf.array();
-
-        int readLen = buf.writerIndex() - 0;
-        testupdateMsg = new byte[readLen];
-        buf.readBytes(testupdateMsg, 0, readLen);
-
-        assertThat(testupdateMsg, is(updateMsg));
-    }
-}
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsSame.sameInstance;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import static org.hamcrest.MatcherAssert.assertThat;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepFactories;
+import org.onosproject.pcepio.protocol.PcepMessage;
+import org.onosproject.pcepio.protocol.PcepMessageReader;
+import org.onosproject.pcepio.protocol.PcepUpdateMsg;
+
+public class PcepUpdateMsgTest {
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), ERO in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest1() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
+                0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x04 }; //ERO object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP(SymbolicPathNameTlv), LSP (StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO, LSPA, Metric-list in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest2() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object // lsp object
+                0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
+                0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x24, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+                0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+     * ERO objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest3() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x04 }; //ERO object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv), ERO objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest4() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x04 }; //ERO object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv), ERO objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest5() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x04 }; //ERO object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest6() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x04 };
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest7() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x04}; //ERO object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject) objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest8() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x0c, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00 };
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject) objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest9() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00 };
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), LSPA objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest10() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest11() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest12() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest13() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+     * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric Object objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest14() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+     * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest15() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+     * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest16() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+     * ERO (IPv4SubObject, IPv4SubObject),LSPA objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest17() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+     * ERO (IPv4SubObject, IPv4SubObject),Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest18() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+     * ERO (IPv4SubObject, IPv4SubObject),Metric-list objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest19() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+                0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv),ERO (IPv4SubObject, IPv4SubObject),LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest20() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+     * ERO (IPv4SubObject, IPv4SubObject), Bandwidth objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest21() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest22() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+                0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest23() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest24() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest25() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
+     * Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest26() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+     * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
+     * Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest27() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+     * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),
+     * LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest28() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest29() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+                (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP,
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest30() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (StatefulLspErrorCodeTlv),
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest31() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP,
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest32() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv),
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest33() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+                0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+
+    /**
+     * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
+     * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+     */
+    @Test
+    public void pcepUpdateMsgTest34() throws PcepParseException {
+
+        byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
+                0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+                0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+                0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+                0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+                0x01, 0x01, 0x04, 0x00,
+                0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 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
+
+        byte[] testupdateMsg = {0};
+        ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+        buffer.writeBytes(updateMsg);
+
+        PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+        PcepMessage message = null;
+
+        message = reader.readFrom(buffer);
+
+        assertThat(message, sameInstance((PcepUpdateMsg) message));
+        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+        message.writeTo(buf);
+        testupdateMsg = buf.array();
+
+        int readLen = buf.writerIndex() - 0;
+        testupdateMsg = new byte[readLen];
+        buf.readBytes(testupdateMsg, 0, readLen);
+
+        assertThat(testupdateMsg, is(updateMsg));
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/RemoteTENodeDescriptorsTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/RemoteTENodeDescriptorsTlvTest.java
index 5ba7dd1..3b189c0 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/RemoteTENodeDescriptorsTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/RemoteTENodeDescriptorsTlvTest.java
@@ -1,57 +1,57 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import java.util.LinkedList;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.AutonomousSystemTlv;
-import org.onosproject.pcepio.types.BGPLSidentifierTlv;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.RemoteTENodeDescriptorsTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for Remote TE Node Descriptors tlv.
- */
-public class RemoteTENodeDescriptorsTlvTest {
-
-    private final AutonomousSystemTlv autonomousSystemTlv1 = new AutonomousSystemTlv(10);
-    private final BGPLSidentifierTlv bGPLSidentifierTlv1 = new BGPLSidentifierTlv(20);
-
-    private final AutonomousSystemTlv autonomousSystemTlv2 = new AutonomousSystemTlv(20);
-    private final BGPLSidentifierTlv bGPLSidentifierTlv2 = new BGPLSidentifierTlv(30);
-
-    private final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLV1 = new LinkedList<>();
-    private final boolean a = llRemoteTENodeDescriptorSubTLV1.add(autonomousSystemTlv1);
-    private final boolean b = llRemoteTENodeDescriptorSubTLV1.add(bGPLSidentifierTlv1);
-
-    private final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLV2 = new LinkedList<>();
-    private final boolean c = llRemoteTENodeDescriptorSubTLV2.add(autonomousSystemTlv2);
-    private final boolean d = llRemoteTENodeDescriptorSubTLV2.add(bGPLSidentifierTlv2);
-
-    private final RemoteTENodeDescriptorsTlv tlv1 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1);
-    private final RemoteTENodeDescriptorsTlv sameAsTlv1 =
-            RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1);
-    private final RemoteTENodeDescriptorsTlv tlv2 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import java.util.LinkedList;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.AutonomousSystemTlv;
+import org.onosproject.pcepio.types.BGPLSidentifierTlv;
+import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.RemoteTENodeDescriptorsTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for Remote TE Node Descriptors tlv.
+ */
+public class RemoteTENodeDescriptorsTlvTest {
+
+    private final AutonomousSystemTlv autonomousSystemTlv1 = new AutonomousSystemTlv(10);
+    private final BGPLSidentifierTlv bGPLSidentifierTlv1 = new BGPLSidentifierTlv(20);
+
+    private final AutonomousSystemTlv autonomousSystemTlv2 = new AutonomousSystemTlv(20);
+    private final BGPLSidentifierTlv bGPLSidentifierTlv2 = new BGPLSidentifierTlv(30);
+
+    private final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLV1 = new LinkedList<>();
+    private final boolean a = llRemoteTENodeDescriptorSubTLV1.add(autonomousSystemTlv1);
+    private final boolean b = llRemoteTENodeDescriptorSubTLV1.add(bGPLSidentifierTlv1);
+
+    private final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLV2 = new LinkedList<>();
+    private final boolean c = llRemoteTENodeDescriptorSubTLV2.add(autonomousSystemTlv2);
+    private final boolean d = llRemoteTENodeDescriptorSubTLV2.add(bGPLSidentifierTlv2);
+
+    private final RemoteTENodeDescriptorsTlv tlv1 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1);
+    private final RemoteTENodeDescriptorsTlv sameAsTlv1 =
+            RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1);
+    private final RemoteTENodeDescriptorsTlv tlv2 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/RouterIDSubTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/RouterIDSubTlvTest.java
index 993ac90..95d143f 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/RouterIDSubTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/RouterIDSubTlvTest.java
@@ -1,44 +1,44 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.RouterIDSubTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for Router ID Sub tlv.
- */
-public class RouterIDSubTlvTest {
-
-    private final byte[] value1 = {1, 2 };
-    private final Short length1 = new Short((short) 2);
-    private final RouterIDSubTlv tlv1 = RouterIDSubTlv.of(value1, length1);
-
-    private final Short length2 = new Short((short) 2);
-    private final RouterIDSubTlv tlv2 = RouterIDSubTlv.of(value1, length2);
-
-    private final byte[] value3 = {1, 2, 3 };
-    private final Short length3 = new Short((short) 3);
-    private final RouterIDSubTlv tlv3 = RouterIDSubTlv.of(value3, length3);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.RouterIDSubTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for Router ID Sub tlv.
+ */
+public class RouterIDSubTlvTest {
+
+    private final byte[] value1 = {1, 2 };
+    private final Short length1 = new Short((short) 2);
+    private final RouterIDSubTlv tlv1 = RouterIDSubTlv.of(value1, length1);
+
+    private final Short length2 = new Short((short) 2);
+    private final RouterIDSubTlv tlv2 = RouterIDSubTlv.of(value1, length2);
+
+    private final byte[] value3 = {1, 2, 3 };
+    private final Short length3 = new Short((short) 3);
+    private final RouterIDSubTlv tlv3 = RouterIDSubTlv.of(value3, length3);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/SharedRiskLinkGroupTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/SharedRiskLinkGroupTlvTest.java
index 98e968d..b09deb5 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/SharedRiskLinkGroupTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/SharedRiskLinkGroupTlvTest.java
@@ -1,43 +1,43 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.SharedRiskLinkGroupTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for Shared Risk Link Group tlv.
- */
-public class SharedRiskLinkGroupTlvTest {
-
-    private final int[] raw = {1 };
-    private final Short hLength = new Short((short) 2);
-    private final SharedRiskLinkGroupTlv tlv1 = SharedRiskLinkGroupTlv.of(raw, hLength);
-
-    private final SharedRiskLinkGroupTlv sameAsTlv1 = SharedRiskLinkGroupTlv.of(raw, hLength);
-
-    private final int[] raw2 = {2 };
-    private final Short hLength2 = new Short((short) 3);
-    private final SharedRiskLinkGroupTlv tlv2 = SharedRiskLinkGroupTlv.of(raw2, hLength2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.SharedRiskLinkGroupTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for Shared Risk Link Group tlv.
+ */
+public class SharedRiskLinkGroupTlvTest {
+
+    private final int[] raw = {1 };
+    private final Short hLength = new Short((short) 2);
+    private final SharedRiskLinkGroupTlv tlv1 = SharedRiskLinkGroupTlv.of(raw, hLength);
+
+    private final SharedRiskLinkGroupTlv sameAsTlv1 = SharedRiskLinkGroupTlv.of(raw, hLength);
+
+    private final int[] raw2 = {2 };
+    private final Short hLength2 = new Short((short) 3);
+    private final SharedRiskLinkGroupTlv tlv2 = SharedRiskLinkGroupTlv.of(raw2, hLength2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/SrEroSubObjectTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/SrEroSubObjectTest.java
index 12f4e2b..47ea584 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/SrEroSubObjectTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/SrEroSubObjectTest.java
@@ -1,61 +1,61 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.protocol.PcepNai;
-import org.onosproject.pcepio.types.SrEroSubObject;
-
-import com.google.common.testing.EqualsTester;
-
-public class SrEroSubObjectTest {
-
-    private final boolean bFFlag = false;
-    private final boolean bSFlag = false;
-    private final boolean bCFlag = false;
-    private final boolean bMFlag = false;
-    private final byte st = 1;
-    private final int sID = 1;
-    private final PcepNai nai = null;
-
-    private final SrEroSubObject tlv1 = SrEroSubObject.of(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
-
-    private final boolean bFFlag1 = false;
-    private final boolean bSFlag1 = false;
-    private final boolean bCFlag1 = false;
-    private final boolean bMFlag1 = false;
-    private final byte st1 = 1;
-    private final int sID1 = 1;
-    private final PcepNai nai1 = null;
-
-    private final SrEroSubObject tlv2 = SrEroSubObject.of(st1, bFFlag1, bSFlag1, bCFlag1, bMFlag1, sID1, nai1);
-
-    private final boolean bFFlag2 = true;
-    private final boolean bSFlag2 = true;
-    private final boolean bCFlag2 = true;
-    private final boolean bMFlag2 = true;
-    private final byte st2 = 2;
-    private final int sID2 = 2;
-    private final PcepNai nai2 = null;
-
-    private final SrEroSubObject tlv3 = SrEroSubObject.of(st2, bFFlag2, bSFlag2, bCFlag2, bMFlag2, sID2, nai2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.protocol.PcepNai;
+import org.onosproject.pcepio.types.SrEroSubObject;
+
+import com.google.common.testing.EqualsTester;
+
+public class SrEroSubObjectTest {
+
+    private final boolean bFFlag = false;
+    private final boolean bSFlag = false;
+    private final boolean bCFlag = false;
+    private final boolean bMFlag = false;
+    private final byte st = 1;
+    private final int sID = 1;
+    private final PcepNai nai = null;
+
+    private final SrEroSubObject tlv1 = SrEroSubObject.of(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+
+    private final boolean bFFlag1 = false;
+    private final boolean bSFlag1 = false;
+    private final boolean bCFlag1 = false;
+    private final boolean bMFlag1 = false;
+    private final byte st1 = 1;
+    private final int sID1 = 1;
+    private final PcepNai nai1 = null;
+
+    private final SrEroSubObject tlv2 = SrEroSubObject.of(st1, bFFlag1, bSFlag1, bCFlag1, bMFlag1, sID1, nai1);
+
+    private final boolean bFFlag2 = true;
+    private final boolean bSFlag2 = true;
+    private final boolean bCFlag2 = true;
+    private final boolean bMFlag2 = true;
+    private final byte st2 = 2;
+    private final int sID2 = 2;
+    private final PcepNai nai2 = null;
+
+    private final SrEroSubObject tlv3 = SrEroSubObject.of(st2, bFFlag2, bSFlag2, bCFlag2, bMFlag2, sID2, nai2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulIPv4LspIdentidiersTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulIPv4LspIdentidiersTlvTest.java
index 856f276..f03c8ba 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulIPv4LspIdentidiersTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulIPv4LspIdentidiersTlvTest.java
@@ -1,57 +1,57 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
-
-import com.google.common.testing.EqualsTester;
-
-public class StatefulIPv4LspIdentidiersTlvTest {
-
-    private final int ipv4IngressAddress = 1;
-    private final short lspId = 1;
-    private final short tunnelId = 1;
-    private final int extendedTunnelId = 1;
-    private final int ipv4EgressAddress = 1;
-
-    private final StatefulIPv4LspIdentidiersTlv tlv1 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress, lspId,
-            tunnelId, extendedTunnelId, ipv4EgressAddress);
-
-    private final int ipv4IngressAddress1 = 1;
-    private final short lspId1 = 1;
-    private final short tunnelId1 = 1;
-    private final int extendedTunnelId1 = 1;
-    private final int ipv4EgressAddress1 = 1;
-
-    private final StatefulIPv4LspIdentidiersTlv tlv2 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress1, lspId1,
-            tunnelId1, extendedTunnelId1, ipv4EgressAddress1);
-
-    private final int ipv4IngressAddress2 = 2;
-    private final short lspId2 = 2;
-    private final short tunnelId2 = 2;
-    private final int extendedTunnelId2 = 2;
-    private final int ipv4EgressAddress2 = 2;
-
-    private final StatefulIPv4LspIdentidiersTlv tlv3 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress2, lspId2,
-            tunnelId2, extendedTunnelId2, ipv4EgressAddress2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
+
+import com.google.common.testing.EqualsTester;
+
+public class StatefulIPv4LspIdentidiersTlvTest {
+
+    private final int ipv4IngressAddress = 1;
+    private final short lspId = 1;
+    private final short tunnelId = 1;
+    private final int extendedTunnelId = 1;
+    private final int ipv4EgressAddress = 1;
+
+    private final StatefulIPv4LspIdentidiersTlv tlv1 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress, lspId,
+            tunnelId, extendedTunnelId, ipv4EgressAddress);
+
+    private final int ipv4IngressAddress1 = 1;
+    private final short lspId1 = 1;
+    private final short tunnelId1 = 1;
+    private final int extendedTunnelId1 = 1;
+    private final int ipv4EgressAddress1 = 1;
+
+    private final StatefulIPv4LspIdentidiersTlv tlv2 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress1, lspId1,
+            tunnelId1, extendedTunnelId1, ipv4EgressAddress1);
+
+    private final int ipv4IngressAddress2 = 2;
+    private final short lspId2 = 2;
+    private final short tunnelId2 = 2;
+    private final int extendedTunnelId2 = 2;
+    private final int ipv4EgressAddress2 = 2;
+
+    private final StatefulIPv4LspIdentidiersTlv tlv3 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress2, lspId2,
+            tunnelId2, extendedTunnelId2, ipv4EgressAddress2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspDbVerTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspDbVerTlvTest.java
index 55a344e..21bb346 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspDbVerTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspDbVerTlvTest.java
@@ -1,37 +1,37 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for Stateful Lsp Db Ver tlv.
- */
-public class StatefulLspDbVerTlvTest {
-
-    private final StatefulLspDbVerTlv tlv1 = StatefulLspDbVerTlv.of(1);
-    private final StatefulLspDbVerTlv tlv2 = StatefulLspDbVerTlv.of(1);
-    private final StatefulLspDbVerTlv tlv3 = StatefulLspDbVerTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for Stateful Lsp Db Ver tlv.
+ */
+public class StatefulLspDbVerTlvTest {
+
+    private final StatefulLspDbVerTlv tlv1 = StatefulLspDbVerTlv.of(1);
+    private final StatefulLspDbVerTlv tlv2 = StatefulLspDbVerTlv.of(1);
+    private final StatefulLspDbVerTlv tlv3 = StatefulLspDbVerTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspErrorCodeTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspErrorCodeTlvTest.java
index c132c8c..8137ca0 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspErrorCodeTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspErrorCodeTlvTest.java
@@ -1,32 +1,32 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv;
-import com.google.common.testing.EqualsTester;
-
-public class StatefulLspErrorCodeTlvTest {
-
-    private final StatefulLspErrorCodeTlv tlv1 = StatefulLspErrorCodeTlv.of(1);
-    private final StatefulLspErrorCodeTlv tlv2 = StatefulLspErrorCodeTlv.of(1);
-    private final StatefulLspErrorCodeTlv tlv3 = StatefulLspErrorCodeTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv;
+import com.google.common.testing.EqualsTester;
+
+public class StatefulLspErrorCodeTlvTest {
+
+    private final StatefulLspErrorCodeTlv tlv1 = StatefulLspErrorCodeTlv.of(1);
+    private final StatefulLspErrorCodeTlv tlv2 = StatefulLspErrorCodeTlv.of(1);
+    private final StatefulLspErrorCodeTlv tlv3 = StatefulLspErrorCodeTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulPceCapabilityTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulPceCapabilityTlvTest.java
index 15e86d4..29018d5 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulPceCapabilityTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulPceCapabilityTlvTest.java
@@ -1,35 +1,35 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for Stateful Pce Capability tlv.
- */
-public class StatefulPceCapabilityTlvTest {
-
-    private final StatefulPceCapabilityTlv tlv1 = StatefulPceCapabilityTlv.of(1);
-    private final StatefulPceCapabilityTlv tlv2 = StatefulPceCapabilityTlv.of(1);
-    private final StatefulPceCapabilityTlv tlv3 = StatefulPceCapabilityTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for Stateful Pce Capability tlv.
+ */
+public class StatefulPceCapabilityTlvTest {
+
+    private final StatefulPceCapabilityTlv tlv1 = StatefulPceCapabilityTlv.of(1);
+    private final StatefulPceCapabilityTlv tlv2 = StatefulPceCapabilityTlv.of(1);
+    private final StatefulPceCapabilityTlv tlv3 = StatefulPceCapabilityTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/SymbolicPathNameTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/SymbolicPathNameTlvTest.java
index 3552fcb..0b71bc5 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/SymbolicPathNameTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/SymbolicPathNameTlvTest.java
@@ -1,45 +1,45 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.SymbolicPathNameTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for Symbolic path tlv.
- */
-public class SymbolicPathNameTlvTest {
-
-    private final byte[] value1 = {0x41 };
-    private final Short length1 = new Short((short) 2);
-    private final SymbolicPathNameTlv tlv1 = SymbolicPathNameTlv.of(value1, length1);
-
-    private final byte[] value2 = {0x41 };
-    private final Short length2 = new Short((short) 2);
-    private final SymbolicPathNameTlv tlv2 = SymbolicPathNameTlv.of(value1, length2);
-
-    private final byte[] value3 = {0x41, 0x43 };
-    private final Short length3 = new Short((short) 3);
-    private final SymbolicPathNameTlv tlv3 = SymbolicPathNameTlv.of(value3, length3);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.SymbolicPathNameTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for Symbolic path tlv.
+ */
+public class SymbolicPathNameTlvTest {
+
+    private final byte[] value1 = {0x41 };
+    private final Short length1 = new Short((short) 2);
+    private final SymbolicPathNameTlv tlv1 = SymbolicPathNameTlv.of(value1, length1);
+
+    private final byte[] value2 = {0x41 };
+    private final Short length2 = new Short((short) 2);
+    private final SymbolicPathNameTlv tlv2 = SymbolicPathNameTlv.of(value1, length2);
+
+    private final byte[] value3 = {0x41, 0x43 };
+    private final Short length3 = new Short((short) 3);
+    private final SymbolicPathNameTlv tlv3 = SymbolicPathNameTlv.of(value3, length3);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TEDefaultMetricTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TEDefaultMetricTlvTest.java
index 913c99e..32fa0af 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TEDefaultMetricTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TEDefaultMetricTlvTest.java
@@ -1,36 +1,36 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.TEDefaultMetricTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for TE Default Metric tlv.
- */
-public class TEDefaultMetricTlvTest {
-
-    private final TEDefaultMetricTlv tlv1 = TEDefaultMetricTlv.of(1);
-    private final TEDefaultMetricTlv tlv2 = TEDefaultMetricTlv.of(1);
-    private final TEDefaultMetricTlv tlv3 = TEDefaultMetricTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.TEDefaultMetricTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for TE Default Metric tlv.
+ */
+public class TEDefaultMetricTlvTest {
+
+    private final TEDefaultMetricTlv tlv1 = TEDefaultMetricTlv.of(1);
+    private final TEDefaultMetricTlv tlv2 = TEDefaultMetricTlv.of(1);
+    private final TEDefaultMetricTlv tlv3 = TEDefaultMetricTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
 }
\ No newline at end of file
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkAttributesTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkAttributesTlvTest.java
index 3834468..1e2101a 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkAttributesTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkAttributesTlvTest.java
@@ -1,59 +1,59 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import java.util.LinkedList;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.AdministrativeGroupTlv;
-import org.onosproject.pcepio.types.MaximumReservableLinkBandwidthTlv;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.TELinkAttributesTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for TE Link Attribute Tlv.
- */
-public class TELinkAttributesTlvTest {
-
-    private final AdministrativeGroupTlv administrativeGroupTlv1 = new AdministrativeGroupTlv(10);
-    private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv1 =
-            new MaximumReservableLinkBandwidthTlv(20);
-
-    private final AdministrativeGroupTlv administrativeGroupTlv2 = new AdministrativeGroupTlv(20);
-    private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv2 =
-            new MaximumReservableLinkBandwidthTlv(30);
-
-    private final LinkedList<PcepValueType> llLinkAttributesSubTLV1 = new LinkedList<>();
-    private final boolean a = llLinkAttributesSubTLV1.add(administrativeGroupTlv1);
-    private final boolean b = llLinkAttributesSubTLV1.add(maximumReservableLinkBandwidthTlv1);
-
-    private final LinkedList<PcepValueType> llLinkAttributesSubTLV2 = new LinkedList<>();
-
-    private final boolean c = llLinkAttributesSubTLV2.add(administrativeGroupTlv2);
-    private final boolean d = llLinkAttributesSubTLV2.add(maximumReservableLinkBandwidthTlv2);
-
-    private final TELinkAttributesTlv tlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1);
-    private final TELinkAttributesTlv sameAsTlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1);
-    private final TELinkAttributesTlv tlv2 = TELinkAttributesTlv.of(llLinkAttributesSubTLV2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import java.util.LinkedList;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.AdministrativeGroupTlv;
+import org.onosproject.pcepio.types.MaximumReservableLinkBandwidthTlv;
+import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.TELinkAttributesTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for TE Link Attribute Tlv.
+ */
+public class TELinkAttributesTlvTest {
+
+    private final AdministrativeGroupTlv administrativeGroupTlv1 = new AdministrativeGroupTlv(10);
+    private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv1 =
+            new MaximumReservableLinkBandwidthTlv(20);
+
+    private final AdministrativeGroupTlv administrativeGroupTlv2 = new AdministrativeGroupTlv(20);
+    private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv2 =
+            new MaximumReservableLinkBandwidthTlv(30);
+
+    private final LinkedList<PcepValueType> llLinkAttributesSubTLV1 = new LinkedList<>();
+    private final boolean a = llLinkAttributesSubTLV1.add(administrativeGroupTlv1);
+    private final boolean b = llLinkAttributesSubTLV1.add(maximumReservableLinkBandwidthTlv1);
+
+    private final LinkedList<PcepValueType> llLinkAttributesSubTLV2 = new LinkedList<>();
+
+    private final boolean c = llLinkAttributesSubTLV2.add(administrativeGroupTlv2);
+    private final boolean d = llLinkAttributesSubTLV2.add(maximumReservableLinkBandwidthTlv2);
+
+    private final TELinkAttributesTlv tlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1);
+    private final TELinkAttributesTlv sameAsTlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1);
+    private final TELinkAttributesTlv tlv2 = TELinkAttributesTlv.of(llLinkAttributesSubTLV2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkDescriptorsTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkDescriptorsTlvTest.java
index 6c323c0..89565b3 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkDescriptorsTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkDescriptorsTlvTest.java
@@ -1,57 +1,57 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import java.util.LinkedList;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv4InterfaceAddressTlv;
-import org.onosproject.pcepio.types.LinkLocalRemoteIdentifiersTlv;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.TELinkDescriptorsTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for TE link descriptors Tlv.
- */
-public class TELinkDescriptorsTlvTest {
-    private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv1 = new
-            LinkLocalRemoteIdentifiersTlv(10, 10);
-    private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv1 = new IPv4InterfaceAddressTlv(0x01010101);
-
-    private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv2 = new
-            LinkLocalRemoteIdentifiersTlv(20, 20);
-    private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv2 = new IPv4InterfaceAddressTlv(0x02020202);
-
-    private final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs1 = new LinkedList<>();
-    private final boolean a = llLinkDescriptorsSubTLVs1.add(linkLocalRemoteIdentifiersTlv1);
-    private final boolean b = llLinkDescriptorsSubTLVs1.add(iPv4InterfaceAddressTlv1);
-
-    private final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs2 = new LinkedList<>();
-    private final boolean c = llLinkDescriptorsSubTLVs2.add(linkLocalRemoteIdentifiersTlv2);
-    private final boolean d = llLinkDescriptorsSubTLVs2.add(iPv4InterfaceAddressTlv2);
-
-    private final TELinkDescriptorsTlv tlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1);
-    private final TELinkDescriptorsTlv sameAstlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1);
-    private final TELinkDescriptorsTlv tlv2 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import java.util.LinkedList;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv4InterfaceAddressTlv;
+import org.onosproject.pcepio.types.LinkLocalRemoteIdentifiersTlv;
+import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.TELinkDescriptorsTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for TE link descriptors Tlv.
+ */
+public class TELinkDescriptorsTlvTest {
+    private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv1 = new
+            LinkLocalRemoteIdentifiersTlv(10, 10);
+    private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv1 = new IPv4InterfaceAddressTlv(0x01010101);
+
+    private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv2 = new
+            LinkLocalRemoteIdentifiersTlv(20, 20);
+    private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv2 = new IPv4InterfaceAddressTlv(0x02020202);
+
+    private final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs1 = new LinkedList<>();
+    private final boolean a = llLinkDescriptorsSubTLVs1.add(linkLocalRemoteIdentifiersTlv1);
+    private final boolean b = llLinkDescriptorsSubTLVs1.add(iPv4InterfaceAddressTlv1);
+
+    private final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs2 = new LinkedList<>();
+    private final boolean c = llLinkDescriptorsSubTLVs2.add(linkLocalRemoteIdentifiersTlv2);
+    private final boolean d = llLinkDescriptorsSubTLVs2.add(iPv4InterfaceAddressTlv2);
+
+    private final TELinkDescriptorsTlv tlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1);
+    private final TELinkDescriptorsTlv sameAstlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1);
+    private final TELinkDescriptorsTlv tlv2 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TENodeAttributesTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TENodeAttributesTlvTest.java
index 4faa499..17d4409 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TENodeAttributesTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TENodeAttributesTlvTest.java
@@ -1,59 +1,59 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import java.util.LinkedList;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.IPv4TERouterIdOfLocalNodeTlv;
-import org.onosproject.pcepio.types.NodeFlagBitsTlv;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.TENodeAttributesTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for TE Node Attribute tlv.
- */
-public class TENodeAttributesTlvTest {
-
-    private final NodeFlagBitsTlv nodeFlagBitsTlv1 = new NodeFlagBitsTlv((byte) 10);
-    private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv1 = new
-            IPv4TERouterIdOfLocalNodeTlv(0x01010101);
-
-    private final NodeFlagBitsTlv nodeFlagBitsTlv2 = new NodeFlagBitsTlv((byte) 20);
-    private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv2 = new
-            IPv4TERouterIdOfLocalNodeTlv(0x02020202);
-
-    private final LinkedList<PcepValueType> llNodeAttributesSubTLV1 = new LinkedList<>();
-    private final boolean a = llNodeAttributesSubTLV1.add(nodeFlagBitsTlv1);
-    private final boolean b = llNodeAttributesSubTLV1.add(iPv4TERouterIdOfLocalNodeTlv1);
-
-    private final LinkedList<PcepValueType> llNodeAttributesSubTLV2 = new LinkedList<>();
-
-    private final boolean c = llNodeAttributesSubTLV2.add(nodeFlagBitsTlv2);
-    private final boolean d = llNodeAttributesSubTLV2.add(iPv4TERouterIdOfLocalNodeTlv2);
-
-    private final TENodeAttributesTlv tlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1);
-    private final TENodeAttributesTlv sameAsTlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1);
-    private final TENodeAttributesTlv tlv2 = TENodeAttributesTlv.of(llNodeAttributesSubTLV2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import java.util.LinkedList;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.IPv4TERouterIdOfLocalNodeTlv;
+import org.onosproject.pcepio.types.NodeFlagBitsTlv;
+import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.TENodeAttributesTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for TE Node Attribute tlv.
+ */
+public class TENodeAttributesTlvTest {
+
+    private final NodeFlagBitsTlv nodeFlagBitsTlv1 = new NodeFlagBitsTlv((byte) 10);
+    private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv1 = new
+            IPv4TERouterIdOfLocalNodeTlv(0x01010101);
+
+    private final NodeFlagBitsTlv nodeFlagBitsTlv2 = new NodeFlagBitsTlv((byte) 20);
+    private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv2 = new
+            IPv4TERouterIdOfLocalNodeTlv(0x02020202);
+
+    private final LinkedList<PcepValueType> llNodeAttributesSubTLV1 = new LinkedList<>();
+    private final boolean a = llNodeAttributesSubTLV1.add(nodeFlagBitsTlv1);
+    private final boolean b = llNodeAttributesSubTLV1.add(iPv4TERouterIdOfLocalNodeTlv1);
+
+    private final LinkedList<PcepValueType> llNodeAttributesSubTLV2 = new LinkedList<>();
+
+    private final boolean c = llNodeAttributesSubTLV2.add(nodeFlagBitsTlv2);
+    private final boolean d = llNodeAttributesSubTLV2.add(iPv4TERouterIdOfLocalNodeTlv2);
+
+    private final TENodeAttributesTlv tlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1);
+    private final TENodeAttributesTlv sameAsTlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1);
+    private final TENodeAttributesTlv tlv2 = TENodeAttributesTlv.of(llNodeAttributesSubTLV2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TedCapabilityTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TedCapabilityTlvTest.java
index d94bbde..4e18e86 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/TedCapabilityTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/TedCapabilityTlvTest.java
@@ -1,36 +1,36 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.TedCapabilityTlv;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test case for TED Capability tlv.
- */
-public class TedCapabilityTlvTest {
-
-    private final TedCapabilityTlv tlv1 = TedCapabilityTlv.of(1);
-    private final TedCapabilityTlv tlv2 = TedCapabilityTlv.of(1);
-    private final TedCapabilityTlv tlv3 = TedCapabilityTlv.of(2);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.TedCapabilityTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test case for TED Capability tlv.
+ */
+public class TedCapabilityTlvTest {
+
+    private final TedCapabilityTlv tlv1 = TedCapabilityTlv.of(1);
+    private final TedCapabilityTlv tlv2 = TedCapabilityTlv.of(1);
+    private final TedCapabilityTlv tlv3 = TedCapabilityTlv.of(2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/UnreservedBandwidthTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/UnreservedBandwidthTlvTest.java
index 1fb197c..e4cb9b1 100644
--- a/pcep/pcepio/src/test/java/org/onosproject/pcepio/UnreservedBandwidthTlvTest.java
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/UnreservedBandwidthTlvTest.java
@@ -1,37 +1,37 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio;
-
-import org.junit.Test;
-import org.onosproject.pcepio.types.UnreservedBandwidthTlv;
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit Test case for Unreserved Bandwidth Tlv.
- */
-public class UnreservedBandwidthTlvTest {
-
-    // Objects of unreserved bandwidth tlv
-    private final UnreservedBandwidthTlv tlv1 = UnreservedBandwidthTlv.of(100);
-    private final UnreservedBandwidthTlv tlv2 = UnreservedBandwidthTlv.of(100);
-    private final UnreservedBandwidthTlv tlv3 = UnreservedBandwidthTlv.of(200);
-
-    @Test
-    public void basics() {
-        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-    }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.UnreservedBandwidthTlv;
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Unit Test case for Unreserved Bandwidth Tlv.
+ */
+public class UnreservedBandwidthTlvTest {
+
+    // Objects of unreserved bandwidth tlv
+    private final UnreservedBandwidthTlv tlv1 = UnreservedBandwidthTlv.of(100);
+    private final UnreservedBandwidthTlv tlv2 = UnreservedBandwidthTlv.of(100);
+    private final UnreservedBandwidthTlv tlv3 = UnreservedBandwidthTlv.of(200);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+
+}
