use of org.opendaylight.protocol.bgp.inet.RIBActivator in project bgpcep by opendaylight.
the class AbstractAddPathTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
this.ribActivator = new RIBActivator();
this.ribExtension = new SimpleRIBExtensionProviderContext();
this.ribActivator.startRIBExtensionProvider(this.ribExtension);
this.bgpActivator = new BGPActivator();
this.inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
this.context = new SimpleBGPExtensionProviderContext();
this.bgpActivator.start(this.context);
this.inetActivator.start(this.context);
this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
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(BgpRib.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Attributes1.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MpReachNlri.class));
this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
this.schemaContext = moduleInfoBackedContext.getSchemaContext();
if (!Epoll.isAvailable()) {
this.worker = new NioEventLoopGroup();
this.boss = new NioEventLoopGroup();
}
this.serverRegistry = new StrictBGPPeerRegistry();
this.serverDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker, this.serverRegistry);
doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
this.codecsRegistry = CodecsRegistryImpl.create(this.mappingService.getCodecFactory(), this.ribExtension.getClassLoadingStrategy());
}
use of org.opendaylight.protocol.bgp.inet.RIBActivator in project bgpcep by opendaylight.
the class AbstractRIBTestSetup method mockRib.
public void mockRib() throws Exception {
final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
final ModuleInfoBackedContext strategy = createClassLoadingStrategy();
final SchemaContext schemaContext = strategy.tryToCreateSchemaContext().get();
this.codecFactory = createCodecFactory(strategy, schemaContext);
final List<BgpTableType> localTables = new ArrayList<>();
localTables.add(new BgpTableTypeImpl(AFI, SAFI));
this.a1 = new RIBActivator();
this.a1.startRIBExtensionProvider(context);
final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(this.codecFactory, GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
mockedMethods();
doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
this.rib = new RIBImpl(new RibId("test"), new AsNumber(5L), RIB_ID, context, this.dispatcher, codecsRegistry, this.dom, getDataBroker(), this.policies, this.peerTracker, localTables, Collections.singletonMap(new TablesKey(AFI, SAFI), BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
this.rib.onGlobalContextUpdated(schemaContext);
this.ribSupport = getRib().getRibSupportContext().getRIBSupport(KEY);
}
use of org.opendaylight.protocol.bgp.inet.RIBActivator in project bgpcep by opendaylight.
the class ParserToSalTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
final String hexMessages = "/bgp_hex.txt";
final List<byte[]> bgpMessages = HexDumpBGPFileParser.parseMessages(ParserToSalTest.class.getResourceAsStream(hexMessages));
this.mock = new BGPMock(new EventBus("test"), ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry(), Lists.newArrayList(fixMessages(bgpMessages)));
Mockito.doReturn(GlobalEventExecutor.INSTANCE.newSucceededFuture(null)).when(this.dispatcher).createReconnectingClient(Mockito.any(InetSocketAddress.class), Mockito.anyInt(), Mockito.any(KeyMapping.class));
this.ext1 = new SimpleRIBExtensionProviderContext();
this.ext2 = new SimpleRIBExtensionProviderContext();
this.baseact = new RIBActivator();
this.lsact = new org.opendaylight.protocol.bgp.linkstate.impl.RIBActivator();
this.baseact.startRIBExtensionProvider(this.ext1);
this.lsact.startRIBExtensionProvider(this.ext2);
this.codecsRegistry = CodecsRegistryImpl.create(this.bindingCodecTreeFactory, GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
}
use of org.opendaylight.protocol.bgp.inet.RIBActivator 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;
});
}
Aggregations