use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber in project bgpcep by opendaylight.
the class FSMTest method setUp.
@Before
public void setUp() throws UnknownHostException {
MockitoAnnotations.initMocks(this);
final List<BgpParameters> tlvs = Lists.newArrayList();
final List<OptionalCapabilities> capas = Lists.newArrayList();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build()).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(this.linkstatett.getAfi()).setSafi(this.linkstatett.getSafi()).build()).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(30L)).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setGracefulRestartCapability(new GracefulRestartCapabilityBuilder().build()).build()).build()).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
final BGPSessionPreferences prefs = new BGPSessionPreferences(new AsNumber(30L), (short) 3, new BgpId("1.1.1.1"), new AsNumber(30L), tlvs);
final ChannelFuture f = mock(ChannelFuture.class);
doReturn(null).when(f).addListener(any(GenericFutureListener.class));
final InetAddress peerAddress = InetAddress.getByName("1.1.1.2");
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
FSMTest.this.receivedMsgs.add((Notification) args[0]);
return f;
}).when(this.speakerListener).writeAndFlush(any(Notification.class));
doReturn(this.eventLoop).when(this.speakerListener).eventLoop();
doReturn(null).when(this.eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
doReturn("TestingChannel").when(this.speakerListener).toString();
doReturn(new InetSocketAddress(peerAddress, 179)).when(this.speakerListener).remoteAddress();
doReturn(new InetSocketAddress(peerAddress, 179)).when(this.speakerListener).localAddress();
doReturn(this.pipeline).when(this.speakerListener).pipeline();
doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class));
doReturn(null).when(this.pipeline).replace(Matchers.<Class<ChannelHandler>>any(), any(String.class), any(ChannelHandler.class));
doReturn(this.pipeline).when(this.pipeline).addLast(any(ChannelHandler.class));
doReturn(mock(ChannelFuture.class)).when(this.speakerListener).close();
final BGPPeerRegistry peerRegistry = new StrictBGPPeerRegistry();
peerRegistry.addPeer(new IpAddress(new Ipv4Address(peerAddress.getHostAddress())), new SimpleSessionListener(), prefs);
this.clientSession = new BGPClientSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), this.speakerListener, peerRegistry);
this.classicOpen = new OpenBuilder().setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).setBgpParameters(tlvs).setBgpIdentifier(new Ipv4Address("1.1.1.2")).build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber in project bgpcep by opendaylight.
the class AbstractBGPDispatcherTest method createPreferences.
protected BGPSessionPreferences createPreferences(final InetSocketAddress socketAddress) {
final List<BgpParameters> tlvs = Lists.newArrayList();
final List<OptionalCapabilities> capas = Lists.newArrayList();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(IPV_4_TT.getAfi()).setSafi(IPV_4_TT.getSafi()).build()).build()).setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(30L)).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
final BgpId bgpId = new BgpId(new Ipv4Address(socketAddress.getAddress().getHostAddress()));
return new BGPSessionPreferences(AS_NUMBER, HOLD_TIMER, bgpId, AS_NUMBER, tlvs);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber in project bgpcep by opendaylight.
the class RibImpl method isGlobalEqual.
Boolean isGlobalEqual(final Global global) {
final List<AfiSafi> globalAfiSafi = getAfiSafiWithDefault(global.getAfiSafis(), true);
final Config globalConfig = global.getConfig();
final AsNumber globalAs = globalConfig.getAs();
final Ipv4Address globalRouterId = global.getConfig().getRouterId();
final ClusterIdentifier globalClusterId = getGlobalClusterIdentifier(globalConfig);
return this.afiSafi.containsAll(globalAfiSafi) && globalAfiSafi.containsAll(this.afiSafi) && globalAs.equals(this.asNumber) && globalRouterId.getValue().equals(this.routerId.getValue()) && globalClusterId.getValue().equals(this.clusterId.getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber in project bgpcep by opendaylight.
the class EROSubobjectParserTest method testEROAsNumberSubobject.
@Test
public void testEROAsNumberSubobject() throws RSVPParsingException {
final EROAsNumberSubobjectParser parser = new EROAsNumberSubobjectParser();
final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
subs.setLoose(true);
subs.setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x64L)).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(AS_NUMBER_BYTES, 2)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
Assert.assertArrayEquals(AS_NUMBER_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
Assert.fail();
} catch (final IllegalArgumentException e) {
Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
Assert.fail();
} catch (final IllegalArgumentException e) {
Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber in project bgpcep by opendaylight.
the class EROSubobjectParserTest method testEROExrsSubobject.
@Test
public void testEROExrsSubobject() throws Exception {
final EROExplicitExclusionRouteSubobjectParser parser = new EROExplicitExclusionRouteSubobjectParser(this.ctx.getXROSubobjectHandlerRegistry());
final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
subs.setLoose(true);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.Exrs> list = Lists.newArrayList();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder();
builder.setMandatory(true);
builder.setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x64L)).build()).build());
list.add(builder.build());
subs.setSubobjectType(new ExrsCaseBuilder().setExrs(new ExrsBuilder().setExrs(list).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(EXRS_BYTES, 2)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
Assert.assertArrayEquals(EXRS_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
Assert.fail();
} catch (final IllegalArgumentException e) {
Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
Assert.fail();
} catch (final IllegalArgumentException e) {
Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
Aggregations