import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
this.mock = new BGPMock(new EventBus("test"), ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry(), Lists.newArrayList(fixMessages(bgpMessages)));
Mockito.doReturn(GlobalEventExecutor.INSTANCE.newSucceededFuture(null)).when(this.dispatcher).createReconnectingClient(
- Mockito.any(InetSocketAddress.class), Mockito.any(AsNumber.class),
- Mockito.any(BGPPeerRegistry.class), Mockito.eq(this.tcpStrategyFactory), Mockito.eq(this.sessionStrategy),
- Mockito.any(KeyMapping.class));
+ Mockito.any(InetSocketAddress.class), Mockito.any(BGPPeerRegistry.class), Mockito.eq(this.tcpStrategyFactory), Mockito.any(KeyMapping.class));
this.ext1 = new SimpleRIBExtensionProviderContext();
this.ext2 = new SimpleRIBExtensionProviderContext();
final List<BgpTableType> tables = ImmutableList.of(
(BgpTableType) new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), new AsNumber(72L), new Ipv4Address("127.0.0.1"), null, this.ext2, this.dispatcher, this.tcpStrategyFactory, this.codecFactory, this.sessionStrategy, getDataBroker(), getDomBroker(), tables, GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
+ assertTablesExists(tables, true);
rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
final BGPPeer peer = new BGPPeer("peer-" + this.mock.toString(), rib);
final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
reg.close();
- assertTablesExists(tables);
}
@Test
final List<BgpTableType> tables = ImmutableList.of((BgpTableType) new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), new AsNumber(72L), new Ipv4Address("127.0.0.1"), null, this.ext1, this.dispatcher, this.tcpStrategyFactory, this.codecFactory, this.sessionStrategy, getDataBroker(), getDomBroker(), tables, GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
+ assertTablesExists(tables, true);
final BGPPeer peer = new BGPPeer("peer-" + this.mock.toString(), rib);
final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
reg.close();
- assertTablesExists(tables);
}
- private Collection<byte[]> fixMessages(final Collection<byte[]> bgpMessages) {
+ private static Collection<byte[]> fixMessages(final Collection<byte[]> bgpMessages) {
return Collections2.transform(bgpMessages, new Function<byte[], byte[]>() {
@Nullable
});
}
- private void assertTablesExists(final List<BgpTableType> expectedTables) throws InterruptedException, ExecutionException {
+ private void assertTablesExists(final List<BgpTableType> expectedTables, final boolean uptodate) throws InterruptedException, ExecutionException {
final Optional<LocRib> lockRib = getLocRibTable();
assertTrue(lockRib.isPresent());
final List<Tables> tables = lockRib.get().getTables();
for (final Tables table : tables) {
if(table.getAfi().equals(tableType.getAfi()) && table.getSafi().equals(tableType.getSafi())) {
found = true;
+ assertTrue(Boolean.valueOf(uptodate).equals(table.getAttributes().isUptodate()));
}
}
assertTrue(found);