BGPCEP-704: Add restart session rpc
[bgpcep.git] / pcep / segment-routing / src / test / java / org / opendaylight / protocol / pcep / segment / routing / SrRroSubobjectParserTest.java
index 37811ade435c471e1453fb85bcfc616194bfdc38..6eada789336ec5eba5914c8ef8b3df527a663bed 100644 (file)
@@ -18,14 +18,14 @@ import org.junit.Test;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.SidType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.add.lsp.input.arguments.rro.subobject.subobject.type.SrRroTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpAdjacencyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.IpNodeIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.UnnumberedAdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.SidType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.add.lsp.input.arguments.rro.subobject.subobject.type.SrRroTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.IpAdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.IpNodeIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.UnnumberedAdjacencyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder;
 
 public class SrRroSubobjectParserTest {
@@ -86,17 +86,20 @@ public class SrRroSubobjectParserTest {
 
     private SimplePCEPExtensionProviderContext ctx;
     private SegmentRoutingActivator act;
+    private boolean isIanaAssignedType;
+    private SrRroSubobjectParser parser;
 
     @Before
     public void setUp() {
         this.ctx = new SimplePCEPExtensionProviderContext();
         this.act = new SegmentRoutingActivator();
         this.act.start(this.ctx);
+        this.isIanaAssignedType = false;
+        this.parser = new SrRroSubobjectParser(this.isIanaAssignedType);
     }
 
     @Test
     public void testSrRroSubobjectIpv4NodeIdNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setSid(123456L);
@@ -105,15 +108,14 @@ public class SrRroSubobjectParserTest {
         builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
         final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
 
-        assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv4NodeID, 2))));
+        assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv4NodeID, 2))));
         final ByteBuf buffer = Unpooled.buffer();
-        parser.serializeSubobject(subobjBuilder.build(), buffer);
+        this.parser.serializeSubobject(subobjBuilder.build(), buffer);
         assertArrayEquals(srRroSubobjectWithIpv4NodeID, ByteArray.getAllBytes(buffer));
     }
 
     @Test
     public void testSrRroSubobjectIpv6NodeIdNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv6NodeId);
         builder.setCFlag(false);
@@ -122,15 +124,14 @@ public class SrRroSubobjectParserTest {
         builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729c"))).build());
         final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
 
-        assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv6NodeID, 2))));
+        assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv6NodeID, 2))));
         final ByteBuf buffer = Unpooled.buffer();
-        parser.serializeSubobject(subobjBuilder.build(), buffer);
+        this.parser.serializeSubobject(subobjBuilder.build(), buffer);
         assertArrayEquals(srRroSubobjectWithIpv6NodeID, ByteArray.getAllBytes(buffer));
     }
 
     @Test
     public void testSrRroSubobjectIpv4AdjacencyNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv4Adjacency);
         builder.setSid(123456L);
@@ -140,15 +141,14 @@ public class SrRroSubobjectParserTest {
                 .setRemoteIpAddress(new IpAddress(new Ipv4Address("74.125.43.100"))).build());
         final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
 
-        assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv4Adjacency, 2))));
+        assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv4Adjacency, 2))));
         final ByteBuf buffer = Unpooled.buffer();
-        parser.serializeSubobject(subobjBuilder.build(), buffer);
+        this.parser.serializeSubobject(subobjBuilder.build(), buffer);
         assertArrayEquals(srRroSubobjectWithIpv4Adjacency, ByteArray.getAllBytes(buffer));
     }
 
     @Test
     public void testSrRroSubobjectIpv6AdjacencyNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv6Adjacency);
         builder.setSid(123456L);
@@ -158,15 +158,14 @@ public class SrRroSubobjectParserTest {
                 .setRemoteIpAddress(new IpAddress(new Ipv6Address("fe80:cd00::211e:729d"))).build());
         final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
 
-        assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv6Adjacency, 2))));
+        assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithIpv6Adjacency, 2))));
         final ByteBuf buffer = Unpooled.buffer();
-        parser.serializeSubobject(subobjBuilder.build(), buffer);
+        this.parser.serializeSubobject(subobjBuilder.build(), buffer);
         assertArrayEquals(srRroSubobjectWithIpv6Adjacency, ByteArray.getAllBytes(buffer));
     }
 
     @Test
     public void testSrRroSubobjectUnnumberedNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Unnumbered);
         builder.setSid(123456L);
@@ -175,15 +174,14 @@ public class SrRroSubobjectParserTest {
         builder.setNai(new UnnumberedAdjacencyBuilder().setLocalNodeId(1L).setLocalInterfaceId(2L).setRemoteNodeId(3L).setRemoteInterfaceId(4L).build());
         final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
 
-        assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithUnnumbered, 2))));
+        assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithUnnumbered, 2))));
         final ByteBuf buffer = Unpooled.buffer();
-        parser.serializeSubobject(subobjBuilder.build(), buffer);
+        this.parser.serializeSubobject(subobjBuilder.build(), buffer);
         assertArrayEquals(srRroSubobjectWithUnnumbered, ByteArray.getAllBytes(buffer));
     }
 
     @Test
     public void testSrRroSubobjectWithoutNAI() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setSid(123470L);
@@ -191,15 +189,14 @@ public class SrRroSubobjectParserTest {
         builder.setMFlag(true);
         final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
 
-        assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithoutNAI, 2))));
+        assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithoutNAI, 2))));
         final ByteBuf buffer = Unpooled.buffer();
-        parser.serializeSubobject(subobjBuilder.build(), buffer);
+        this.parser.serializeSubobject(subobjBuilder.build(), buffer);
         assertArrayEquals(srRroSubobjectWithoutNAI, ByteArray.getAllBytes(buffer));
     }
 
     @Test
     public void testSrRroSubobjectWithoutBody() throws PCEPDeserializerException {
-        final SrRroSubobjectParser parser = new SrRroSubobjectParser();
         final SrRroTypeBuilder builder = new SrRroTypeBuilder();
         builder.setSidType(SidType.Ipv4NodeId);
         builder.setCFlag(false);
@@ -207,9 +204,9 @@ public class SrRroSubobjectParserTest {
         builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
         final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
 
-        assertEquals(subobjBuilder.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithoutSID, 2))));
+        assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srRroSubobjectWithoutSID, 2))));
         final ByteBuf buffer = Unpooled.buffer();
-        parser.serializeSubobject(subobjBuilder.build(), buffer);
+        this.parser.serializeSubobject(subobjBuilder.build(), buffer);
         assertArrayEquals(srRroSubobjectWithoutSID, ByteArray.getAllBytes(buffer));
     }
 }