Search in sources :

Example 1 with PCEPTopologyConfiguration

use of org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyConfiguration in project bgpcep by opendaylight.

the class AbstractPCEPSessionTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    this.receivedMsgs = new ArrayList<>();
    doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        AbstractPCEPSessionTest.this.receivedMsgs.add((Notification) args[0]);
        return this.channelFuture;
    }).when(this.clientListener).writeAndFlush(any(Notification.class));
    doReturn(null).when(this.channelFuture).addListener(Mockito.any());
    doReturn("TestingChannel").when(this.clientListener).toString();
    doReturn(this.pipeline).when(this.clientListener).pipeline();
    doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class));
    doReturn(this.eventLoop).when(this.clientListener).eventLoop();
    doNothing().when(this.statsRegistry).bind(any(), any());
    doNothing().when(this.statsRegistry).unbind(any());
    doReturn(null).when(this.eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
    doReturn(true).when(this.clientListener).isActive();
    final InetSocketAddress ra = new InetSocketAddress(this.testAddress, 4189);
    doReturn(ra).when(this.clientListener).remoteAddress();
    final InetSocketAddress la = new InetSocketAddress(this.testAddress, InetSocketAddressUtil.getRandomPort());
    doReturn(la).when(this.clientListener).localAddress();
    doReturn(mock(ChannelFuture.class)).when(this.clientListener).close();
    doReturn(getDataBroker()).when(this.topologyDependencies).getDataBroker();
    doReturn(this.statsRegistry).when(this.topologyDependencies).getStateRegistry();
    @SuppressWarnings("unchecked") final T listenerFactory = (T) ((Class) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]).newInstance();
    doReturn(new IpAddress(new Ipv4Address(this.testAddress))).when(this.sessionConfig).getListenAddress();
    doReturn(new PortNumber(4189)).when(this.sessionConfig).getListenPort();
    doReturn(RPC_TIMEOUT).when(this.sessionConfig).getRpcTimeout();
    doReturn(TEST_TOPOLOGY_ID).when(this.topology).getTopologyId();
    doReturn(Collections.emptyList()).when(this.topology).getNode();
    final PCEPTopologyConfiguration configDep = new PCEPTopologyConfiguration(this.sessionConfig, this.topology);
    this.manager = new ServerSessionManager(this.topologyDependencies, listenerFactory, configDep);
    startSessionManager();
    this.neg = new DefaultPCEPSessionNegotiator(this.promise, this.clientListener, this.manager.getSessionListener(), (short) 1, 5, this.localPrefs);
    this.topologyRpcs = new TopologyRPCs(this.manager);
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) PCEPTopologyConfiguration(org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyConfiguration) InetSocketAddress(java.net.InetSocketAddress) ChannelHandler(io.netty.channel.ChannelHandler) Notification(org.opendaylight.yangtools.yang.binding.Notification) TimeUnit(java.util.concurrent.TimeUnit) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) DefaultPCEPSessionNegotiator(org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiator) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Before(org.junit.Before)

Aggregations

ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelHandler (io.netty.channel.ChannelHandler)1 InetSocketAddress (java.net.InetSocketAddress)1 TimeUnit (java.util.concurrent.TimeUnit)1 Before (org.junit.Before)1 PCEPTopologyConfiguration (org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyConfiguration)1 DefaultPCEPSessionNegotiator (org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiator)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)1 Notification (org.opendaylight.yangtools.yang.binding.Notification)1