* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.pcep.segment.routing;
import static org.junit.Assert.assertArrayEquals;
public class SrEroSubobjectParserTest {
- private static final byte[] srEroSubobjectWithIpv4NodeID = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITH_IPV4_NODEID = {
0x05,0x0c,(byte) 0x10,0x00,
0x00,0x01,(byte) 0xe2,0x40,
0x4A,0x7D,0x2b,0x63,
};
- private static final byte[] srEroSubobjectWithIpv6NodeID = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITH_IPV6_NODEID = {
0x05,0x18,(byte) 0x20,0x00,
0x00,0x01,(byte) 0xe2,0x40,
(byte) 0xFE,(byte) 0x80,(byte) 0xCD,0x00,
0x21,0x1E,0x72,(byte) 0x9C,
};
- private static final byte[] srEroSubobjectWithIpv4Adjacency = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITH_IPV4_ADJ = {
0x05,0x10,(byte) 0x30,0x00,
0x00,0x01,(byte) 0xe2,0x40,
0x4A,0x7D,0x2b,0x63,
0x4A,0x7D,0x2b,0x64,
};
- private static final byte[] srEroSubobjectWithIpv6Adjacency = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITH_IPV6_ADJ = {
0x05,0x28,(byte) 0x40,0x00,
0x00,0x01,(byte) 0xe2,0x40,
(byte) 0xFE,(byte) 0x80,(byte) 0xCD,0x00,
0x21,0x1E,0x72,(byte) 0x9D,
};
- private static final byte[] srEroSubobjectWithUnnumbered = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITH_UNNUMBERED = {
0x05,0x18,(byte) 0x50,0x00,
0x00,0x01,(byte) 0xe2,0x40,
0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x04
};
- private static final byte[] srEroSubobjectWithoutNAI = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITHOUT_NAI = {
0x05,0x08,(byte) 0x10,0x08,
0x00,0x01,(byte) 0xe2,0x40
};
- private static final byte[] srEroSubobjectWithoutSID = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITHOUT_SID = {
0x05,0x08,(byte) 0x10,0x04,
0x4A,0x7D,0x2b,0x63,
};
- private static final byte[] srEroSubobjectWithIpv4NodeIDMFlag = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITH_IPV4_NODEID_MFLAG = {
0x05,0x0c,(byte) 0x10,0x01,
0x07,0x5B,(byte) 0xCD,0x15,
0x4A,0x7D,0x2b,0x63,
};
- private static final byte[] srEroSubobjectWithIpv4NodeIDMFlagAfter = {
+ private static final byte[] SR_ERO_SUBOBJECT_WITH_IPV4_NODEID_MFLAG_AFTER = {
0x05,0x0c,(byte) 0x10,0x01,
0x07,0x5B,(byte) 0xC0,0x00,
0x4A,0x7D,0x2b,0x63,
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
- builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.99"))).build());
+ builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.99")))
+ .build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
- assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv4NodeID, 2)), false));
+ assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(
+ ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITH_IPV4_NODEID, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
- assertArrayEquals(srEroSubobjectWithIpv4NodeID, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(SR_ERO_SUBOBJECT_WITH_IPV4_NODEID, ByteArray.getAllBytes(buffer));
}
@Test
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
- builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("fe80:cd00::211e:729c"))).build());
+ builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(
+ new Ipv6AddressNoZone("fe80:cd00::211e:729c"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
- assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv6NodeID, 2)), false));
+ assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(
+ ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITH_IPV6_NODEID, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
- assertArrayEquals(srEroSubobjectWithIpv6NodeID, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(SR_ERO_SUBOBJECT_WITH_IPV6_NODEID, ByteArray.getAllBytes(buffer));
}
@Test
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
- builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.99")))
+ builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(
+ new Ipv4AddressNoZone("74.125.43.99")))
.setRemoteIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.100"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
- assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv4Adjacency, 2)), false));
+ assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(
+ ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITH_IPV4_ADJ, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
- assertArrayEquals(srEroSubobjectWithIpv4Adjacency, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(SR_ERO_SUBOBJECT_WITH_IPV4_ADJ, ByteArray.getAllBytes(buffer));
}
@Test
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
- builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("fe80:cd00::211e:729c")))
+ builder.setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(
+ new Ipv6AddressNoZone("fe80:cd00::211e:729c")))
.setRemoteIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("fe80:cd00::211e:729d"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
- assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv6Adjacency, 2)), false));
+ assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(
+ ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITH_IPV6_ADJ, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
- assertArrayEquals(srEroSubobjectWithIpv6Adjacency, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(SR_ERO_SUBOBJECT_WITH_IPV6_ADJ, ByteArray.getAllBytes(buffer));
}
@Test
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
- builder.setNai(new UnnumberedAdjacencyBuilder().setLocalNodeId(1L).setLocalInterfaceId(2L).setRemoteNodeId(3L).setRemoteInterfaceId(4L).build());
+ builder.setNai(new UnnumberedAdjacencyBuilder().setLocalNodeId(1L).setLocalInterfaceId(2L)
+ .setRemoteNodeId(3L).setRemoteInterfaceId(4L).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
- assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithUnnumbered, 2)), false));
+ assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(
+ ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITH_UNNUMBERED, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
- assertArrayEquals(srEroSubobjectWithUnnumbered, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(SR_ERO_SUBOBJECT_WITH_UNNUMBERED, ByteArray.getAllBytes(buffer));
}
@Test
builder.setMFlag(false);
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
- assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithoutNAI, 2)), false));
+ assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(
+ ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITHOUT_NAI, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
- assertArrayEquals(srEroSubobjectWithoutNAI, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(SR_ERO_SUBOBJECT_WITHOUT_NAI, ByteArray.getAllBytes(buffer));
}
@Test
builder.setSidType(SidType.Ipv4NodeId);
builder.setCFlag(false);
builder.setMFlag(false);
- builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.99"))).build());
+ builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(
+ new Ipv4AddressNoZone("74.125.43.99"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
- assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithoutSID, 2)), false));
+ assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(
+ ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITHOUT_SID, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
- assertArrayEquals(srEroSubobjectWithoutSID, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(SR_ERO_SUBOBJECT_WITHOUT_SID, ByteArray.getAllBytes(buffer));
}
@Test
builder.setMFlag(true);
builder.setSidType(SidType.Ipv4NodeId);
builder.setSid(30140L);
- builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.99"))).build());
+ builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.99")))
+ .build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
- assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithIpv4NodeIDMFlag, 2)), false));
+ assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(
+ ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITH_IPV4_NODEID_MFLAG, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
- assertArrayEquals(srEroSubobjectWithIpv4NodeIDMFlagAfter, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(SR_ERO_SUBOBJECT_WITH_IPV4_NODEID_MFLAG_AFTER, ByteArray.getAllBytes(buffer));
}
}