use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext in project bgpcep by opendaylight.
the class AbstractBGPDispatcherTest method setUp.
@Before
public void setUp() {
if (!Epoll.isAvailable()) {
this.boss = new NioEventLoopGroup();
this.worker = new NioEventLoopGroup();
}
this.registry = new StrictBGPPeerRegistry();
this.clientListener = new SimpleSessionListener();
this.serverListener = new SimpleSessionListener();
final BGPExtensionConsumerContext ctx = ServiceLoader.load(BGPExtensionConsumerContext.class).findFirst().orElseThrow();
this.serverDispatcher = new BGPDispatcherImpl(ctx, this.boss, this.worker, this.registry);
this.clientAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
final IpAddressNoZone clientPeerIp = new IpAddressNoZone(new Ipv4AddressNoZone(this.clientAddress.getAddress().getHostAddress()));
this.registry.addPeer(clientPeerIp, this.clientListener, createPreferences(this.clientAddress));
this.clientDispatcher = new BGPDispatcherImpl(ctx, this.boss, this.worker, this.registry);
}
use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext in project bgpcep by opendaylight.
the class LlGracefulCapabilityHandlerTest method setUp.
@Before
public void setUp() {
doReturn(Ipv4AddressFamily.class).when(this.afir).classForFamily(1);
doReturn(Ipv6AddressFamily.class).when(this.afir).classForFamily(2);
doReturn(null).when(this.afir).classForFamily(256);
doReturn(UnicastSubsequentAddressFamily.class).when(this.safir).classForFamily(1);
doReturn(null).when(this.safir).classForFamily(-123);
final BGPExtensionConsumerContext ctx = ServiceLoader.load(BGPExtensionConsumerContext.class).findFirst().orElseThrow();
this.handler = new LlGracefulCapabilityHandler(ctx.getAddressFamilyRegistry(), ctx.getSubsequentAddressFamilyRegistry());
}
use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext in project bgpcep by opendaylight.
the class ParserTest method setUp.
@Before
public void setUp() throws Exception {
final BGPExtensionConsumerContext context = ServiceLoader.load(BGPExtensionConsumerContext.class).findFirst().orElseThrow();
msgReg = context.getMessageRegistry();
updateParser = new BGPUpdateMessageParser(context.getAttributeRegistry(), mock(NlriRegistry.class));
for (int i = 1; i <= COUNTER; i++) {
final String name = "/up" + i + ".bin";
try (InputStream is = ParserTest.class.getResourceAsStream(name)) {
if (is == null) {
throw new IOException("Failed to get resource " + name);
}
final ByteArrayOutputStream bis = new ByteArrayOutputStream();
final byte[] data = new byte[MAX_SIZE];
int numRead;
while ((numRead = is.read(data, 0, data.length)) != -1) {
bis.write(data, 0, numRead);
}
bis.flush();
INPUT_BYTES.add(bis.toByteArray());
is.close();
}
}
}
Aggregations