Search in sources :

Example 1 with BGPExtensionConsumerContext

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);
}
Also used : BGPExtensionConsumerContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Before(org.junit.Before)

Example 2 with BGPExtensionConsumerContext

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());
}
Also used : LlGracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler) BGPExtensionConsumerContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext) Before(org.junit.Before)

Example 3 with BGPExtensionConsumerContext

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();
        }
    }
}
Also used : BGPUpdateMessageParser(org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser) BGPExtensionConsumerContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext) InputStream(java.io.InputStream) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)3 BGPExtensionConsumerContext (org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext)3 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 BGPUpdateMessageParser (org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser)1 LlGracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler)1 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)1 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)1