Search in sources :

Example 1 with BGPSessionImpl

use of org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl in project bgpcep by opendaylight.

the class BGPPeerAcceptorImplTest method testBGPPeerAcceptorImpl.

@Test
public void testBGPPeerAcceptorImpl() throws Exception {
    final InetSocketAddress inetServerAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
    final IpAddressNoZone serverIpAddress = new IpAddressNoZone(new Ipv4AddressNoZone(InetSocketAddressUtil.toHostAndPort(inetServerAddress).getHost()));
    final PortNumber portNumber = new PortNumber(Uint16.valueOf(InetSocketAddressUtil.toHostAndPort(inetServerAddress).getPort()));
    this.registry.addPeer(serverIpAddress, this.serverListener, createPreferences(inetServerAddress));
    final BGPPeerAcceptorImpl bgpPeerAcceptor = new BGPPeerAcceptorImpl(serverIpAddress, portNumber, this.serverDispatcher);
    bgpPeerAcceptor.start();
    final Future<BGPSessionImpl> futureClient = this.clientDispatcher.createClient(this.clientAddress, inetServerAddress, 2, true);
    waitFutureSuccess(futureClient);
    final BGPSessionImpl session = futureClient.get();
    Assert.assertEquals(State.UP, this.clientListener.getState());
    Assert.assertEquals(AS_NUMBER, session.getAsNumber());
    Assert.assertEquals(Sets.newHashSet(IPV_4_TT), session.getAdvertisedTableTypes());
    session.close();
    checkIdleState(this.clientListener);
    bgpPeerAcceptor.close();
}
Also used : Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) InetSocketAddress(java.net.InetSocketAddress) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) BGPSessionImpl(org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl) AbstractBGPDispatcherTest(org.opendaylight.protocol.bgp.rib.impl.AbstractBGPDispatcherTest) Test(org.junit.Test)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 Test (org.junit.Test)1 AbstractBGPDispatcherTest (org.opendaylight.protocol.bgp.rib.impl.AbstractBGPDispatcherTest)1 BGPSessionImpl (org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl)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 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)1