package org.opendaylight.protocol.rsvp.parser.spi;
import static org.junit.Assert.assertArrayEquals;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.lang.reflect.Constructor;
public class EROSubobjectUtilTest {
- @Test(expected=UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
+ @SuppressWarnings({"checkstyle:IllegalCatch", "checkstyle:IllegalThrows"})
public void testPrivateConstructor() throws Throwable {
final Constructor<EROSubobjectUtil> c = EROSubobjectUtil.class.getDeclaredConstructor();
c.setAccessible(true);
@Test
public void testFormatSubobject1() {
- final byte[] array = new byte[] {2, 3};
- final byte[] expected = new byte[] {(byte)0x81, 4, 2, 3};
+ final byte[] array = new byte[]{2, 3};
+ final byte[] expected = new byte[]{(byte) 0x81, 4, 2, 3};
final ByteBuf body = Unpooled.copiedBuffer(array);
final ByteBuf aggregator = Unpooled.buffer(4);
EROSubobjectUtil.formatSubobject(1, Boolean.TRUE, body, aggregator);
@Test
public void testFormatSubobject2() {
- final byte[] array = new byte[] {2, 3};
- final byte[] expected = new byte[] {1, 4, 2, 3};
+ final byte[] array = new byte[]{2, 3};
+ final byte[] expected = new byte[]{1, 4, 2, 3};
final ByteBuf body = Unpooled.copiedBuffer(array);
final ByteBuf aggregator = Unpooled.buffer(4);
EROSubobjectUtil.formatSubobject(1, Boolean.FALSE, body, aggregator);
@Test
public void testFormatSubobject3() {
- final byte[] array = new byte[] {2, 3};
- final byte[] expected = new byte[] {1, 4, 2, 3};
+ final byte[] array = new byte[]{2, 3};
+ final byte[] expected = new byte[]{1, 4, 2, 3};
final ByteBuf body = Unpooled.copiedBuffer(array);
final ByteBuf aggregator = Unpooled.buffer(4);
EROSubobjectUtil.formatSubobject(1, null, body, aggregator);
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.lang.reflect.Constructor;
public class ServiceLoaderRSVPExtensionProviderContextTest {
- private final SimpleRSVPExtensionProviderContext context = (SimpleRSVPExtensionProviderContext) ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance();
+ private final SimpleRSVPExtensionProviderContext context = (SimpleRSVPExtensionProviderContext)
+ ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance();
private final RSVPTeObjectParser rsvpTeParser = Mockito.mock(RSVPTeObjectParser.class);
private final RSVPTeObjectSerializer rsvpTeSerializer = Mockito.mock(RSVPTeObjectSerializer.class);
private final RROSubobjectParser rroParser = Mockito.mock(RROSubobjectParser.class);
private final RROSubobjectSerializer rroSerializer = Mockito.mock(RROSubobjectSerializer.class);
- private final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer rroSubObj = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer.class);
- private final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType rroSubObjType = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType.class);
+ private final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route
+ .subobjects.list.SubobjectContainer rroSubObj = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight
+ .params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer.class);
+ private final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route
+ .subobjects.SubobjectType rroSubObjType = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params
+ .xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType.class);
private final EROSubobjectParser eroParser = Mockito.mock(EROSubobjectParser.class);
private final EROSubobjectSerializer eroSerializer = Mockito.mock(EROSubobjectSerializer.class);
- private final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer eroSubObj = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer.class);
+ private final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
+ .subobjects.list.SubobjectContainer eroSubObj = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight
+ .params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer.class);
private final LabelParser labelParser = Mockito.mock(LabelParser.class);
private final LabelSerializer labelSerializer = Mockito.mock(LabelSerializer.class);
Mockito.doReturn(this.parsedRsvpTeObj).when(this.rsvpTeParser).parseObject(Mockito.any(ByteBuf.class));
Mockito.doReturn(RsvpTeObject.class).when(this.parsedRsvpTeObj).getImplementedInterface();
Mockito.doReturn("parsedRsvpTeObj").when(this.parsedRsvpTeObj).toString();
- Mockito.doNothing().when(this.rsvpTeSerializer).serializeObject(Mockito.any(RsvpTeObject.class), Mockito.any(ByteBuf.class));
+ Mockito.doNothing().when(this.rsvpTeSerializer).serializeObject(Mockito.any(RsvpTeObject.class),
+ Mockito.any(ByteBuf.class));
- Mockito.doReturn(this.subObj).when(this.xroObjParser).parseSubobject(Mockito.any(ByteBuf.class), Mockito.any(Boolean.class));
+ Mockito.doReturn(this.subObj).when(this.xroObjParser).parseSubobject(Mockito.any(ByteBuf.class),
+ Mockito.any(Boolean.class));
Mockito.doReturn(this.subObjType).when(this.subObj).getSubobjectType();
Mockito.doReturn("SubobjectContainer").when(this.subObj).toString();
Mockito.doReturn(SubobjectType.class).when(this.subObjType).getImplementedInterface();
- Mockito.doNothing().when(this.xroObjSerializer).serializeSubobject(Mockito.any(SubobjectContainer.class), Mockito.any(ByteBuf.class));
+ Mockito.doNothing().when(this.xroObjSerializer).serializeSubobject(Mockito.any(SubobjectContainer.class),
+ Mockito.any(ByteBuf.class));
Mockito.doReturn(this.rroSubObj).when(this.rroParser).parseSubobject(Mockito.any(ByteBuf.class));
Mockito.doReturn(this.rroSubObjType).when(this.rroSubObj).getSubobjectType();
Mockito.doReturn("SubobjectContainer").when(this.rroSubObj).toString();
- Mockito.doReturn(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType.class).when(this.rroSubObjType).getImplementedInterface();
- Mockito.doNothing().when(this.rroSerializer).serializeSubobject(Mockito.any(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer.class), Mockito.any(ByteBuf.class));
-
- Mockito.doReturn(this.eroSubObj).when(this.eroParser).parseSubobject(Mockito.any(ByteBuf.class), Mockito.any(Boolean.class));
+ Mockito.doReturn(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route
+ .subobjects.SubobjectType.class).when(this.rroSubObjType).getImplementedInterface();
+ Mockito.doNothing().when(this.rroSerializer).serializeSubobject(Mockito.any(org.opendaylight.yang.gen.v1.urn
+ .opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer.class),
+ Mockito.any(ByteBuf.class));
+
+ Mockito.doReturn(this.eroSubObj).when(this.eroParser).parseSubobject(Mockito.any(ByteBuf.class),
+ Mockito.any(Boolean.class));
Mockito.doReturn(this.subObjType).when(this.eroSubObj).getSubobjectType();
Mockito.doReturn("EROSubobjectContainer").when(this.eroSubObj).toString();
Mockito.doReturn(SubobjectType.class).when(this.subObjType).getImplementedInterface();
- Mockito.doNothing().when(this.eroSerializer).serializeSubobject(Mockito.any(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer.class), Mockito.any(ByteBuf.class));
+ Mockito.doNothing().when(this.eroSerializer).serializeSubobject(Mockito.any(org.opendaylight.yang.gen.v1.urn
+ .opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer.class),
+ Mockito.any(ByteBuf.class));
Mockito.doReturn(this.labelType).when(this.labelParser).parseLabel(Mockito.any(ByteBuf.class));
Mockito.doReturn(LabelType.class).when(this.labelType).getImplementedInterface();
Mockito.doReturn("LabelType").when(this.labelType).toString();
- Mockito.doNothing().when(this.labelSerializer).serializeLabel(Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(LabelType.class), Mockito.any(ByteBuf.class));
+ Mockito.doNothing().when(this.labelSerializer).serializeLabel(Mockito.anyBoolean(), Mockito.anyBoolean(),
+ Mockito.any(LabelType.class), Mockito.any(ByteBuf.class));
}
@Test
assertEquals(this.parsedRsvpTeObj, this.context.getRsvpRegistry().parseRSPVTe(1, 1, buffer));
this.context.registerRsvpObjectSerializer(RsvpTeObject.class, this.rsvpTeSerializer);
this.context.getRsvpRegistry().serializeRSPVTe(this.parsedRsvpTeObj, buffer);
- Mockito.verify(this.rsvpTeSerializer).serializeObject(Mockito.any(RsvpTeObject.class), Mockito.any(ByteBuf.class));
+ Mockito.verify(this.rsvpTeSerializer).serializeObject(Mockito.any(RsvpTeObject.class),
+ Mockito.any(ByteBuf.class));
}
@Test
this.context.registerRROSubobjectParser(3, this.rroParser);
final ByteBuf buffer = Unpooled.buffer();
assertEquals(this.rroSubObj, this.context.getRROSubobjectHandlerRegistry().parseSubobject(3, buffer));
- this.context.registerRROSubobjectSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType.class, this.rroSerializer);
+ this.context.registerRROSubobjectSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .rsvp.rev150820.record.route.subobjects.SubobjectType.class, this.rroSerializer);
this.context.getRROSubobjectHandlerRegistry().serializeSubobject(this.rroSubObj, buffer);
Mockito.verify(this.rroSerializer).serializeSubobject(this.rroSubObj, buffer);
}
this.context.registerEROSubobjectParser(4, this.eroParser);
final ByteBuf buffer = Unpooled.buffer();
assertEquals(this.eroSubObj, this.context.getEROSubobjectHandlerRegistry().parseSubobject(4, buffer, false));
- this.context.registerEROSubobjectSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType.class, this.eroSerializer);
+ this.context.registerEROSubobjectSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType.class, this.eroSerializer);
this.context.getEROSubobjectHandlerRegistry().serializeSubobject(this.eroSubObj, buffer);
Mockito.verify(this.eroSerializer).serializeSubobject(this.eroSubObj, buffer);
}
}
@Test(expected = UnsupportedOperationException.class)
+ @SuppressWarnings("checkstyle:IllegalThrows")
public void testPrivateConstructor() throws Throwable {
- final Constructor<ServiceLoaderRSVPExtensionProviderContext> c = ServiceLoaderRSVPExtensionProviderContext.class.getDeclaredConstructor();
+ final Constructor<ServiceLoaderRSVPExtensionProviderContext> c =
+ ServiceLoaderRSVPExtensionProviderContext.class.getDeclaredConstructor();
c.setAccessible(true);
try {
c.newInstance();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Before;
public void setUp() throws RSVPParsingException {
MockitoAnnotations.initMocks(this);
this.simpleEROSubobjectRegistry.registerSubobjectParser(this.subObjectTypeOne, this.rroSubobjectParser);
- Mockito.doReturn(new SubobjectContainerBuilder().build()).when(this.rroSubobjectParser).parseSubobject(this.input, false);
+ Mockito.doReturn(new SubobjectContainerBuilder().build()).when(this.rroSubobjectParser)
+ .parseSubobject(this.input, false);
final ArgumentCaptor<SubobjectContainer> arg = ArgumentCaptor.forClass(SubobjectContainer.class);
final ArgumentCaptor<ByteBuf> bufArg = ArgumentCaptor.forClass(ByteBuf.class);
Mockito.doAnswer(invocation -> {
final int wrongType = 99;
assertNull(this.simpleEROSubobjectRegistry.parseSubobject(wrongType, this.input, false));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
- final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new
- LabelCaseBuilder().build()).build();
+ final SubobjectContainer container = new SubobjectContainerBuilder()
+ .setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleEROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(0, output.readableBytes());
}
@Test
public void testParserRegistration() throws RSVPParsingException {
- assertNotNull(this.simpleEROSubobjectRegistry.registerSubobjectParser(this.subObjectTypeOne, this
- .rroSubobjectParser));
+ assertNotNull(this.simpleEROSubobjectRegistry.registerSubobjectParser(this.subObjectTypeOne,
+ this.rroSubobjectParser));
assertNotNull(this.simpleEROSubobjectRegistry.parseSubobject(this.subObjectTypeOne, this.input, false));
}
public void testSerializerRegistration() {
assertNotNull(this.simpleEROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this
.rroSubobjectSerializer));
- final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new
- LabelCaseBuilder().build()).build();
+ final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(
+ new LabelCaseBuilder().build()).build();
final ByteBuf output = Unpooled.buffer();
this.simpleEROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(1, output.readableBytes());
import org.opendaylight.yangtools.yang.binding.DataContainer;
public class SimpleLabelRegistryTest {
- final short cTypeOne = 1;
+ private final short ctype = 1;
private final SimpleLabelRegistry simpleLabelRegistry = new SimpleLabelRegistry();
private final ByteBuf input = Unpooled.wrappedBuffer(new byte[]{1, 2, 3});
@Mock
@Before
public void setUp() throws RSVPParsingException {
MockitoAnnotations.initMocks(this);
- this.simpleLabelRegistry.registerLabelParser(this.cTypeOne, this.labelParser);
+ this.simpleLabelRegistry.registerLabelParser(this.ctype, this.labelParser);
this.simpleLabelRegistry.registerLabelSerializer(MockLabel.class, this.labelSerializer);
Mockito.doReturn(new MockLabel()).when(this.labelParser).parseLabel(this.input);
final ArgumentCaptor<LabelType> tlvArg = ArgumentCaptor.forClass(LabelType.class);
final ArgumentCaptor<ByteBuf> bufArg = ArgumentCaptor.forClass(ByteBuf.class);
- Mockito.doNothing().when(this.labelSerializer).serializeLabel(Mockito.anyBoolean(), Mockito.anyBoolean(), tlvArg.capture(), bufArg.capture());
+ Mockito.doNothing().when(this.labelSerializer).serializeLabel(Mockito.anyBoolean(), Mockito.anyBoolean(),
+ tlvArg.capture(), bufArg.capture());
}
@Test
public void testParserRegistration() {
- assertNotNull(this.simpleLabelRegistry.registerLabelParser(this.cTypeOne, this.labelParser));
+ assertNotNull(this.simpleLabelRegistry.registerLabelParser(this.ctype, this.labelParser));
}
@Test
@Test
public void testParseLabel() throws RSVPParsingException {
- final LabelType output = this.simpleLabelRegistry.parseLabel(this.cTypeOne, this.input);
+ final LabelType output = this.simpleLabelRegistry.parseLabel(this.ctype, this.input);
assertNotNull(output);
assertTrue(output instanceof MockLabel);
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Before;
public void setUp() throws RSVPParsingException {
MockitoAnnotations.initMocks(this);
this.simpleRROSubobjectRegistry.registerSubobjectParser(this.subObjectTypeOne, this.rroSubobjectParser);
- Mockito.doReturn(new SubobjectContainerBuilder().build()).when(this.rroSubobjectParser).parseSubobject(this.input);
+ Mockito.doReturn(new SubobjectContainerBuilder().build()).when(this.rroSubobjectParser)
+ .parseSubobject(this.input);
final ArgumentCaptor<SubobjectContainer> arg = ArgumentCaptor.forClass(SubobjectContainer.class);
final ArgumentCaptor<ByteBuf> bufArg = ArgumentCaptor.forClass(ByteBuf.class);
Mockito.doAnswer(invocation -> {
final int wrongType = 99;
assertNull(this.simpleRROSubobjectRegistry.parseSubobject(wrongType, this.input));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
- final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new
- LabelCaseBuilder().build()).build();
+ final SubobjectContainer container = new SubobjectContainerBuilder()
+ .setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleRROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(0, output.readableBytes());
}
@Test
public void testParserRegistration() throws RSVPParsingException {
- assertNotNull(this.simpleRROSubobjectRegistry.registerSubobjectParser(this.subObjectTypeOne, this
- .rroSubobjectParser));
+ assertNotNull(this.simpleRROSubobjectRegistry.registerSubobjectParser(this.subObjectTypeOne,
+ this.rroSubobjectParser));
assertNotNull(this.simpleRROSubobjectRegistry.parseSubobject(this.subObjectTypeOne, this.input));
}
@Test
public void testSerializerRegistration() {
- assertNotNull(this.simpleRROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this
- .rroSubobjectSerializer));
+ assertNotNull(this.simpleRROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class,
+ this.rroSubobjectSerializer));
final ByteBuf output = Unpooled.buffer();
- final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new
- LabelCaseBuilder().build()).build();
+ final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(
+ new LabelCaseBuilder().build()).build();
this.simpleRROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(1, output.readableBytes());
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Before;
@Before
public void setUp() throws RSVPParsingException {
MockitoAnnotations.initMocks(this);
- this.simpleRSVPObjectRegistry.registerRsvpObjectParser(this.subObjectTypeOne, this.subObjectCTypeOne, this.rsvpTeObjectParser);
- this.simpleRSVPObjectRegistry.registerRsvpObjectSerializer(SecondaryExplicitRouteObject.class, this.rsvpTeObjectSerializer);
- Mockito.doReturn(new SecondaryExplicitRouteObjectBuilder().build()).when(this.rsvpTeObjectParser).parseObject(this.input);
+ this.simpleRSVPObjectRegistry.registerRsvpObjectParser(this.subObjectTypeOne, this.subObjectCTypeOne,
+ this.rsvpTeObjectParser);
+ this.simpleRSVPObjectRegistry.registerRsvpObjectSerializer(SecondaryExplicitRouteObject.class,
+ this.rsvpTeObjectSerializer);
+ Mockito.doReturn(new SecondaryExplicitRouteObjectBuilder().build()).when(this.rsvpTeObjectParser)
+ .parseObject(this.input);
final ArgumentCaptor<RsvpTeObject> arg = ArgumentCaptor.forClass(RsvpTeObject.class);
final ArgumentCaptor<ByteBuf> bufArg = ArgumentCaptor.forClass(ByteBuf.class);
Mockito.doNothing().when(this.rsvpTeObjectSerializer).serializeObject(arg.capture(), bufArg.capture());
@Test
public void testParserRegistration() {
- this.simpleRSVPObjectRegistry.registerRsvpObjectParser(this.subObjectTypeOne, this.subObjectCTypeOne, this.rsvpTeObjectParser);
+ this.simpleRSVPObjectRegistry.registerRsvpObjectParser(this.subObjectTypeOne, this.subObjectCTypeOne,
+ this.rsvpTeObjectParser);
}
@Test
public void testSerializerRegistration() {
- this.simpleRSVPObjectRegistry.registerRsvpObjectSerializer(SecondaryExplicitRouteObject.class, this.rsvpTeObjectSerializer);
+ this.simpleRSVPObjectRegistry.registerRsvpObjectSerializer(SecondaryExplicitRouteObject.class,
+ this.rsvpTeObjectSerializer);
}
@Test
@Test
public void testParseRSVP() throws RSVPParsingException {
- final RsvpTeObject output = this.simpleRSVPObjectRegistry.parseRSPVTe(this.subObjectTypeOne, this.subObjectCTypeOne, this.input);
+ final RsvpTeObject output = this.simpleRSVPObjectRegistry.parseRSPVTe(this.subObjectTypeOne,
+ this.subObjectCTypeOne, this.input);
assertNotNull(output);
assertTrue(output instanceof SecondaryExplicitRouteObject);
@Test(expected = IllegalArgumentException.class)
public void testRegisterWrongType() {
final int wrongType = 65536;
- this.simpleRSVPObjectRegistry.registerRsvpObjectParser(wrongType, this.subObjectCTypeOne, this.rsvpTeObjectParser);
+ this.simpleRSVPObjectRegistry.registerRsvpObjectParser(wrongType, this.subObjectCTypeOne,
+ this.rsvpTeObjectParser);
}
}
\ No newline at end of file
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Before;
public class CUISubobjectParserTest {
private final Long routerId = 3735928559L;
private final Long interfaceId = 3736059631L;
- final CommonUnnumberedInterfaceSubobjectParser parser = new CommonUnnumberedInterfaceSubobjectParser();
- final Unnumbered unnumbered1 = new UnnumberedBuilder().setRouterId(null).build();
- final Unnumbered unnumbered2 = new UnnumberedBuilder().setRouterId(1L).setInterfaceId(null).build();
+ private final Unnumbered unnumbered1 = new UnnumberedBuilder().setRouterId(null).build();
+ private final Unnumbered unnumbered2 = new UnnumberedBuilder().setRouterId(1L).setInterfaceId(null).build();
@Test
public void testProcessing() {
assertArrayEquals(input.array(), bytebuf.array());
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testException1() {
CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(this.unnumbered1, Unpooled.EMPTY_BUFFER);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testException2() {
CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(this.unnumbered2, Unpooled.buffer(4));
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
public class CommonPathKeyParserTest {
+ private final byte[] bytes = new byte[]{0, 1, 2, 3};
private PathKey key1;
private PathKey key2;
private PathKey key3;
- private final byte[] bytes = new byte[] {0,1,2,3};
@Before
public void setUp() {
this.key1 = new PathKeyBuilder().build();
- this.key2 = new PathKeyBuilder()
- .setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey(1))
+ this.key2 = new PathKeyBuilder().setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
+ .yang.rsvp.rev150820.PathKey(1))
.build();
- this.key3 = new PathKeyBuilder()
- .setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey(1))
- .setPceId(new PceId(new byte[] {2, 3}))
+ this.key3 = new PathKeyBuilder().setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
+ .yang.rsvp.rev150820.PathKey(1))
+ .setPceId(new PceId(new byte[]{2, 3}))
.build();
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testSerializationExcption1() {
CommonPathKeyParser.serializePathKey(this.key1);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testSerializationExcption2() {
CommonPathKeyParser.serializePathKey(this.key2);
}
private final SubobjectContainer subObj = Mockito.mock(SubobjectContainer.class);
private final RsvpTeObject rsvpTeObj = Mockito.mock(RsvpTeObject.class);
private final EroListParser parser = new EroListParser(this.registry);
- private final byte[] inputList = new byte[] {1, 3, 1, 2, 4, 1, 2};
- private final byte[] emptyInput = new byte[] {1, 2};
- private final byte[] wrongInput = new byte[] {1, 3};
+ private final byte[] inputList = new byte[]{1, 3, 1, 2, 4, 1, 2};
+ private final byte[] emptyInput = new byte[]{1, 2};
+ private final byte[] wrongInput = new byte[]{1, 3};
private final List<SubobjectContainer> subobjects = Arrays.asList(this.subObj, this.subObj);
@Before
}).when(this.registry).serializeSubobject(Mockito.any(SubobjectContainer.class), Mockito.any(ByteBuf.class));
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testParsingException() throws RSVPParsingException {
this.parser.parseList(null);
}
- @Test(expected=RSVPParsingException.class)
+ @Test(expected = RSVPParsingException.class)
public void testWrongInput() throws RSVPParsingException {
this.parser.parseList(Unpooled.copiedBuffer(this.wrongInput));
}
@Test
public void testAbstractRSVPObjParser() throws RSVPParsingException {
final ByteBuf byteAggregator = Unpooled.buffer(4);
- byte[] output = new byte[] {0, 1, 2, 3};
+ byte[] output = new byte[]{0, 1, 2, 3};
EroListParser.serializeAttributeHeader(1, (short) 2, (short) 3, byteAggregator);
assertArrayEquals(output, byteAggregator.array());
final ByteBuf body = Unpooled.buffer(4);
- output = new byte[] {0, 0, 0, 1};
+ output = new byte[]{0, 0, 0, 1};
final AttributeFilter filter = new AttributeFilter(1L);
EroListParser.writeAttributeFilter(filter, body);
assertArrayEquals(output, body.array());
}
private class EroListParser extends EROSubobjectListParser {
- public EroListParser(final EROSubobjectRegistry subobjReg) {
+ EroListParser(final EROSubobjectRegistry subobjReg) {
super(subobjReg);
}
+
@Override
protected void localSerializeObject(final RsvpTeObject rsvpTeObject, final ByteBuf output) {
output.writeByte(3);
}
+
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
return EROSubobjectListParserTest.this.rsvpTeObj;
package org.opendaylight.protocol.rsvp.parser.spi.subobjects;
import static org.junit.Assert.assertEquals;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Arrays;
private final RROSubobjectRegistry registry = Mockito.mock(RROSubobjectRegistry.class);
private final SubobjectContainer subObj = Mockito.mock(SubobjectContainer.class);
private final RroListParser parser = new RroListParser(this.registry);
- private final byte[] inputList = new byte[] {1, 3, 1, 2, 4, 1, 2};
- private final byte[] emptyInput = new byte[] {1, 2};
- private final byte[] wrongInput = new byte[] {1, 3};
+ private final byte[] inputList = new byte[]{1, 3, 1, 2, 4, 1, 2};
+ private final byte[] emptyInput = new byte[]{1, 2};
+ private final byte[] wrongInput = new byte[]{1, 3};
private final List<SubobjectContainer> subobjects = Arrays.asList(this.subObj, this.subObj);
@Before
}).when(this.registry).serializeSubobject(Mockito.any(SubobjectContainer.class), Mockito.any(ByteBuf.class));
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testParsingException() throws RSVPParsingException {
this.parser.parseList(null);
}
- @Test(expected=RSVPParsingException.class)
+ @Test(expected = RSVPParsingException.class)
public void testWrongInput() throws RSVPParsingException {
this.parser.parseList(Unpooled.copiedBuffer(this.wrongInput));
}
}
private class RroListParser extends RROSubobjectListParser {
- public RroListParser(final RROSubobjectRegistry subobjReg) {
+ RroListParser(final RROSubobjectRegistry subobjReg) {
super(subobjReg);
}
+
@Override
protected void localSerializeObject(final RsvpTeObject rsvpTeObject, final ByteBuf output) {
}
+
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
return null;
package org.opendaylight.protocol.rsvp.parser.spi.subobjects;
import static org.junit.Assert.assertEquals;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Arrays;
private final XROSubobjectRegistry registry = Mockito.mock(XROSubobjectRegistry.class);
private final SubobjectContainer subObj = Mockito.mock(SubobjectContainer.class);
private final XroListParser parser = new XroListParser(this.registry);
- private final byte[] inputList = new byte[] {1, 3, 1, 2, 4, 1, 2};
- private final byte[] emptyInput = new byte[] {1, 2};
- private final byte[] wrongInput = new byte[] {1, 3};
+ private final byte[] inputList = new byte[]{1, 3, 1, 2, 4, 1, 2};
+ private final byte[] emptyInput = new byte[]{1, 2};
+ private final byte[] wrongInput = new byte[]{1, 3};
private final List<SubobjectContainer> subobjects = Arrays.asList(this.subObj, this.subObj);
@Before
}).when(this.registry).serializeSubobject(Mockito.any(SubobjectContainer.class), Mockito.any(ByteBuf.class));
}
- @Test(expected=RSVPParsingException.class)
+ @Test(expected = RSVPParsingException.class)
public void testWrongInput() throws RSVPParsingException {
this.parser.parseList(Unpooled.copiedBuffer(this.wrongInput));
}
}
private class XroListParser extends XROSubobjectListParser {
- public XroListParser(final XROSubobjectRegistry subobjReg) {
+ XroListParser(final XROSubobjectRegistry subobjReg) {
super(subobjReg);
}
+
@Override
protected void localSerializeObject(final RsvpTeObject rsvpTeObject, final ByteBuf output) {
}
+
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
return null;