use of org.opendaylight.protocol.bmp.api.BmpSessionListenerFactory in project bgpcep by opendaylight.
the class BmpMockTest method testMainInPassiveMode.
@Test
public void testMainInPassiveMode() throws Exception {
final InetSocketAddress serverAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
final BmpSessionListenerFactory bmpSessionListenerFactory = () -> BmpMockTest.this.sessionListener;
// create a local server in passive mode instead
BmpMock.main(new String[] { "--local_address", InetSocketAddressUtil.toHostAndPort(serverAddr).toString(), "--peers_count", "3", "--pre_policy_routes", "3", "--passive" });
final ChannelFuture futureServer = this.bmpDispatcher.createClient(serverAddr, bmpSessionListenerFactory, KeyMapping.getKeyMapping());
waitFutureSuccess(futureServer);
final Channel serverChannel;
final int sessionUpWait;
if (futureServer.isSuccess()) {
serverChannel = futureServer.channel();
sessionUpWait = 10;
} else {
serverChannel = null;
// wait longer for the reconnection attempt
sessionUpWait = 40;
}
verify(this.sessionListener, Mockito.timeout(TimeUnit.SECONDS.toMillis(sessionUpWait))).onSessionUp(Mockito.any(BmpSession.class));
// 1 * Initiate message + 3 * PeerUp Notification + 9 * Route Monitoring message
verify(this.sessionListener, Mockito.timeout(TimeUnit.SECONDS.toMillis(10)).times(13)).onMessage(Mockito.any(Notification.class));
if (serverChannel != null) {
serverChannel.close().sync();
}
}
use of org.opendaylight.protocol.bmp.api.BmpSessionListenerFactory in project bgpcep by opendaylight.
the class BmpMockTest method testMain.
@Test
public void testMain() throws Exception {
final InetSocketAddress serverAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
final BmpSessionListenerFactory bmpSessionListenerFactory = () -> BmpMockTest.this.sessionListener;
final ChannelFuture futureServer = this.bmpDispatcher.createServer(serverAddr, bmpSessionListenerFactory, KeyMapping.getKeyMapping());
waitFutureSuccess(futureServer);
final Channel serverChannel;
final int sessionUpWait;
if (futureServer.isSuccess()) {
serverChannel = futureServer.channel();
sessionUpWait = 10;
} else {
serverChannel = null;
// wait longer for the reconnection attempt
sessionUpWait = 40;
}
BmpMock.main(new String[] { "--remote_address", InetSocketAddressUtil.toHostAndPort(serverAddr).toString(), "--peers_count", "3", "--pre_policy_routes", "3" });
verify(this.sessionListener, Mockito.timeout(TimeUnit.SECONDS.toMillis(sessionUpWait))).onSessionUp(Mockito.any(BmpSession.class));
// 1 * Initiate message + 3 * PeerUp Notification + 9 * Route Monitoring message
verify(this.sessionListener, Mockito.timeout(TimeUnit.SECONDS.toMillis(10)).times(13)).onMessage(Mockito.any(Notification.class));
if (serverChannel != null) {
serverChannel.close().sync();
}
}
Aggregations