use of org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl in project bgpcep by opendaylight.
the class BmpMockTest method setUp.
@Before
public void setUp() {
final BmpExtensionProviderContext ctx = new SimpleBmpExtensionProviderContext();
this.bmpActivator = new BmpActivator(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance());
this.bmpActivator.start(ctx);
this.bmpDispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), ctx.getBmpMessageRegistry(), new DefaultBmpSessionFactory());
}
use of org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl in project bgpcep by opendaylight.
the class BmpMonitorImplTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
doAnswer(invocationOnMock -> {
BmpMonitorImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
this.singletonService.instantiateServiceInstance();
return BmpMonitorImplTest.this.singletonServiceRegistration;
}).when(this.clusterSSProv).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService.closeServiceInstance()).when(this.singletonServiceRegistration).close();
doAnswer(invocationOnMock -> {
this.singletonService2 = (ClusterSingletonService) invocationOnMock.getArguments()[0];
this.singletonService2.instantiateServiceInstance();
return BmpMonitorImplTest.this.singletonServiceRegistration2;
}).when(this.clusterSSProv2).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService2.closeServiceInstance()).when(this.singletonServiceRegistration2).close();
this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(InitiationMessage.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(CParameters1.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(SentOpen.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(ReceivedOpen.class));
this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
this.ribActivator = new RIBActivator();
this.ribExtension = new SimpleRIBExtensionProviderContext();
this.ribActivator.startRIBExtensionProvider(this.ribExtension);
this.bgpActivator = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
this.bgpActivator.start(context);
final SimpleBmpExtensionProviderContext ctx = new SimpleBmpExtensionProviderContext();
this.bmpActivator = new BmpActivator(context);
this.bmpActivator.start(ctx);
this.msgRegistry = ctx.getBmpMessageRegistry();
this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), ctx.getBmpMessageRegistry(), new DefaultBmpSessionFactory());
final InetSocketAddress inetAddress = new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS), MONITOR_LOCAL_PORT);
final DOMDataWriteTransaction wTx = getDomBroker().newWriteOnlyTransaction();
final ContainerNode parentNode = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(BmpMonitor.QNAME)).addChild(ImmutableNodes.mapNodeBuilder(Monitor.QNAME).build()).build();
wTx.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(BmpMonitor.QNAME), parentNode);
wTx.submit();
final BmpDeployerDependencies bmpDependecies = new BmpDeployerDependencies(getDataBroker(), getDomBroker(), this.ribExtension, this.mappingService.getCodecFactory(), getSchemaContext(), this.clusterSSProv);
this.bmpApp = new BmpMonitoringStationImpl(bmpDependecies, this.dispatcher, MONITOR_ID, inetAddress, null);
readDataOperational(getDataBroker(), BMP_II, monitor -> {
assertEquals(1, monitor.getMonitor().size());
final Monitor bmpMonitor = monitor.getMonitor().get(0);
assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
assertEquals(0, bmpMonitor.getRouter().size());
assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
assertEquals(0, bmpMonitor.getRouter().size());
return monitor;
});
}
use of org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl in project bgpcep by opendaylight.
the class BmpDispatcherImplTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
doNothing().when(this.mockedSession).handlerRemoved(any(ChannelHandlerContext.class));
doNothing().when(this.mockedSession).handlerAdded(any(ChannelHandlerContext.class));
doNothing().when(this.mockedSession).channelRegistered(any(ChannelHandlerContext.class));
doNothing().when(this.mockedSession).channelActive(any(ChannelHandlerContext.class));
doNothing().when(this.mockedSession).channelInactive(any(ChannelHandlerContext.class));
doNothing().when(this.mockedSession).channelUnregistered(any(ChannelHandlerContext.class));
doNothing().when(this.mockedSession).channelReadComplete(any(ChannelHandlerContext.class));
this.bgpActivator = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
this.bgpActivator.start(context);
final SimpleBmpExtensionProviderContext ctx = new SimpleBmpExtensionProviderContext();
this.bmpActivator = new BmpActivator(context);
this.bmpActivator.start(ctx);
final BmpMessageRegistry messageRegistry = ctx.getBmpMessageRegistry();
this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), messageRegistry, (channel, sessionListenerFactory) -> BmpDispatcherImplTest.this.mockedSession);
}
use of org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl in project bgpcep by opendaylight.
the class BmpMockDispatcherTest method testCreateClient.
@Test
public void testCreateClient() throws Exception {
final int port = InetSocketAddressUtil.getRandomPort();
final InetSocketAddress serverAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
final BmpDispatcherImpl bmpDispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), this.registry, this.sessionFactory);
final ChannelFuture futureServer = bmpDispatcher.createServer(serverAddr, this.slf, KeyMapping.getKeyMapping());
waitFutureSuccess(futureServer);
final ChannelFuture channelFuture = this.bmpMockDispatcher.createClient(InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0), serverAddr);
waitFutureSuccess(channelFuture);
final Channel channel = channelFuture.sync().channel();
assertTrue(channel.isActive());
checkEquals(() -> assertTrue(this.sl.getStatus()));
channel.close();
bmpDispatcher.close();
checkEquals(() -> assertFalse(this.sl.getStatus()));
final BmpDispatcherImpl bmpDispatcher2 = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), this.registry, this.sessionFactory);
final ChannelFuture futureServer2 = bmpDispatcher2.createServer(serverAddr, this.slf, KeyMapping.getKeyMapping());
waitFutureSuccess(futureServer2);
checkEquals(() -> assertTrue(this.sl.getStatus()));
bmpDispatcher2.close();
this.bmpMockDispatcher.close();
checkEquals(() -> assertFalse(this.sl.getStatus()));
}
use of org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl in project bgpcep by opendaylight.
the class BmpMockDispatcherTest method testCreateServer.
@Test
public void testCreateServer() throws Exception {
final int port = InetSocketAddressUtil.getRandomPort();
final BmpDispatcherImpl bmpDispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), this.registry, this.sessionFactory);
final ChannelFuture futureServer = this.bmpMockDispatcher.createServer(new InetSocketAddress(InetAddresses.forString("0.0.0.0"), port));
waitFutureSuccess(futureServer);
final ChannelFuture channelFuture = bmpDispatcher.createClient(InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port), this.slf, KeyMapping.getKeyMapping());
waitFutureSuccess(channelFuture);
final Channel channel = channelFuture.sync().channel();
assertTrue(channel.isActive());
checkEquals(() -> assertTrue(this.sl.getStatus()));
assertTrue(futureServer.channel().isActive());
channel.close();
bmpDispatcher.close();
this.bmpMockDispatcher.close();
checkEquals(() -> assertFalse(this.sl.getStatus()));
}
Aggregations