Add decoder constraint based on treat-as-withdrawn configuration
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / ParserToSalTest.java
index 4b1e0859b48a2598c02ea228e6b62f47e0e666a8..45d9fc35150c86cb1bc248dc13718525c0c5777f 100755 (executable)
@@ -40,7 +40,6 @@ import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionPr
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
 import org.opendaylight.protocol.bgp.rib.mock.BGPMock;
 import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
-import org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker;
 import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
 import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
 import org.opendaylight.protocol.bgp.util.HexDumpBGPFileParser;
@@ -67,14 +66,12 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
     private static final TablesKey TABLE_KEY
             = new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
     private static final InstanceIdentifier<BgpRib> BGP_IID = InstanceIdentifier.create(BgpRib.class);
+    private final IpAddress localAddress = new IpAddress(new Ipv4Address("127.0.0.1"));
     private BGPMock mock;
     private AbstractRIBExtensionProviderActivator baseact, lsact;
     private RIBExtensionProviderContext ext1, ext2;
-    private final IpAddress localAddress = new IpAddress(new Ipv4Address("127.0.0.1"));
-
     @Mock
     private BGPDispatcher dispatcher;
-    private final BGPPeerTracker peerTracker = new BGPPeerTrackerImpl();
     private CodecsRegistryImpl codecsRegistry;
 
     @Before
@@ -112,15 +109,15 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
         final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(LinkstateAddressFamily.class,
                 LinkstateSubsequentAddressFamily.class));
 
-        final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2, this.dispatcher,
-                this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, tables,
-                Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
-                        .createBestPathSelectionStrategy(this.peerTracker)));
+        final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2,
+                this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
+                tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
+                .createBestPathSelectionStrategy()));
         rib.instantiateServiceInstance();
         assertTablesExists(tables);
         rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
-        final BGPPeer peer = new BGPPeer(this.localAddress, rib, PeerRole.Ibgp, null, Collections.emptySet(),
-                Collections.emptySet());
+        final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.localAddress.getIpv4Address(),
+                rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
         peer.instantiateServiceInstance();
         final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
         reg.close();
@@ -130,15 +127,15 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
     public void testWithoutLinkstate() throws ReadFailedException {
         final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class,
                 UnicastSubsequentAddressFamily.class));
-        final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1, this.dispatcher,
-                this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, tables,
-                Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
-                        .createBestPathSelectionStrategy(this.peerTracker)));
+        final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1,
+                this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
+                tables, Collections.singletonMap(TABLE_KEY,
+                BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
         rib.instantiateServiceInstance();
         rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
         assertTablesExists(tables);
-        final BGPPeer peer = new BGPPeer(this.localAddress, rib, PeerRole.Ibgp, null, Collections.emptySet(),
-                Collections.emptySet());
+        final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.localAddress.getIpv4Address(),
+                rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
         peer.instantiateServiceInstance();
         final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
         reg.close();
@@ -164,7 +161,7 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
                 for (final Tables table : tables) {
                     if (table.getAfi().equals(tableType.getAfi()) && table.getSafi().equals(tableType.getSafi())) {
                         found = true;
-                        assertEquals(Boolean.valueOf(true), table.getAttributes().isUptodate());
+                        assertEquals(Boolean.TRUE, table.getAttributes().isUptodate());
                     }
                 }
                 assertTrue(found);