X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=bgp%2Frib-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fbgp%2Frib%2Fimpl%2FBestPathSelectorTest.java;h=a21ceec88fb989652e8089fd0d7264a4ccc4a214;hb=3c135df98a164d4207775de96a5217a392d1949e;hp=2e201d35b7eb6f4ca8d2b54cf46415a636331c29;hpb=9d13ee03a6468b357dace1214e6462f4fc9a1c6e;p=bgpcep.git diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BestPathSelectorTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BestPathSelectorTest.java index 2e201d35b7..a21ceec88f 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BestPathSelectorTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BestPathSelectorTest.java @@ -12,10 +12,10 @@ import static org.junit.Assert.assertNotEquals; import com.google.common.primitives.UnsignedInteger; import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AsPath; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.LocalPref; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.MultiExitDisc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Origin; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.AsPath; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.LocalPref; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.MultiExitDisc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.Origin; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; @@ -36,70 +36,70 @@ public class BestPathSelectorTest { private final UnsignedInteger ROUTER_ID2 = RouterIds.routerIdForPeerId(new PeerId("bgp://127.0.0.1")); private final UnsignedInteger ROUTER_ID3 = RouterIds.routerIdForPeerId(new PeerId("bgp://127.0.0.2")); private final BestPathState STATE = new BestPathState(createStateFromPrefMedOriginASPath()); - private final BestPath originBestPath = new BestPath(ROUTER_ID, STATE); + private final BestPath originBestPath = new BestPath(this.ROUTER_ID, this.STATE); private final BestPathSelector selector = new BestPathSelector(20L); private DataContainerNodeAttrBuilder dataContBuilder; @Test public void testBestPathForEquality() { - selector.processPath(ROUTER_ID2, createStateFromPrefMedOriginASPath()); - final BestPath processedPath = selector.result(); - - assertEquals(originBestPath.getRouterId(), processedPath.getRouterId()); - assertEquals(originBestPath.getState().getAsPathLength(), processedPath.getState().getAsPathLength()); - assertEquals(originBestPath.getState().getLocalPref(), processedPath.getState().getLocalPref()); - assertEquals(originBestPath.getState().getMultiExitDisc(), processedPath.getState().getMultiExitDisc()); - assertEquals(originBestPath.getState().getOrigin(), processedPath.getState().getOrigin()); - assertEquals(originBestPath.getState().getPeerAs(), processedPath.getState().getPeerAs()); + this.selector.processPath(this.ROUTER_ID2, createStateFromPrefMedOriginASPath()); + final BestPath processedPath = this.selector.result(); + + assertEquals(this.originBestPath.getRouterId(), processedPath.getRouterId()); + assertEquals(this.originBestPath.getState().getAsPathLength(), processedPath.getState().getAsPathLength()); + assertEquals(this.originBestPath.getState().getLocalPref(), processedPath.getState().getLocalPref()); + assertEquals(this.originBestPath.getState().getMultiExitDisc(), processedPath.getState().getMultiExitDisc()); + assertEquals(this.originBestPath.getState().getOrigin(), processedPath.getState().getOrigin()); + assertEquals(this.originBestPath.getState().getPeerAs(), processedPath.getState().getPeerAs()); } @Test public void testBestPathWithHigherLocalPref() { - selector.processPath(ROUTER_ID2, createStateFromPrefMedOrigin()); // local-pref 123 - BestPath processedPath = selector.result(); + this.selector.processPath(this.ROUTER_ID2, createStateFromPrefMedOrigin()); // local-pref 123 + BestPath processedPath = this.selector.result(); assertEquals(123L, processedPath.getState().getLocalPref().longValue()); - selector.processPath(ROUTER_ID2, createStateFromPrefMedOriginASPath()); // local-pref 321 - processedPath = selector.result(); + this.selector.processPath(this.ROUTER_ID2, createStateFromPrefMedOriginASPath()); // local-pref 321 + processedPath = this.selector.result(); assertEquals(321L, processedPath.getState().getLocalPref().longValue()); - selector.processPath(ROUTER_ID2, createStateFromPrefMedOrigin()); // local-pref 123 - processedPath = selector.result(); + this.selector.processPath(this.ROUTER_ID2, createStateFromPrefMedOrigin()); // local-pref 123 + processedPath = this.selector.result(); assertEquals(321L, processedPath.getState().getLocalPref().longValue()); } @Test public void testBestPathForNonEquality() { - selector.processPath(ROUTER_ID3, createStateFromPrefMedOrigin()); - final BestPath processedPath = selector.result(); - - assertNotEquals(originBestPath.getRouterId(), processedPath.getRouterId()); - assertEquals(originBestPath.getState().getAsPathLength(), processedPath.getState().getAsPathLength()); - assertNotEquals(originBestPath.getState().getLocalPref(), processedPath.getState().getLocalPref()); - assertNotEquals(originBestPath.getState().getMultiExitDisc(), processedPath.getState().getMultiExitDisc()); - assertNotEquals(originBestPath.getState().getOrigin(), processedPath.getState().getOrigin()); + this.selector.processPath(this.ROUTER_ID3, createStateFromPrefMedOrigin()); + final BestPath processedPath = this.selector.result(); + + assertNotEquals(this.originBestPath.getRouterId(), processedPath.getRouterId()); + assertEquals(this.originBestPath.getState().getAsPathLength(), processedPath.getState().getAsPathLength()); + assertNotEquals(this.originBestPath.getState().getLocalPref(), processedPath.getState().getLocalPref()); + assertNotEquals(this.originBestPath.getState().getMultiExitDisc(), processedPath.getState().getMultiExitDisc()); + assertNotEquals(this.originBestPath.getState().getOrigin(), processedPath.getState().getOrigin()); assertEquals(0L, (long)processedPath.getState().getPeerAs()); } private ContainerNode createStateFromPrefMedOrigin() { - dataContBuilder = createContBuilder(DATA_QNAME); + this.dataContBuilder = createContBuilder(this.DATA_QNAME); // local pref - dataContBuilder.addChild(createContBuilder(LocalPref.QNAME).addChild(createValueBuilder(123L, LocalPref.QNAME, "pref").build()).build()); + this.dataContBuilder.addChild(createContBuilder(LocalPref.QNAME).addChild(createValueBuilder(123L, LocalPref.QNAME, "pref").build()).build()); // multi exit disc - dataContBuilder.addChild(createContBuilder(MultiExitDisc.QNAME).addChild(createValueBuilder(1234L, MultiExitDisc.QNAME, "med").build()).build()); + this.dataContBuilder.addChild(createContBuilder(MultiExitDisc.QNAME).addChild(createValueBuilder(1234L, MultiExitDisc.QNAME, "med").build()).build()); // origin - dataContBuilder.addChild(createContBuilder(Origin.QNAME).addChild(createValueBuilder("igp", Origin.QNAME, "value").build()).build()); - return dataContBuilder.build(); + this.dataContBuilder.addChild(createContBuilder(Origin.QNAME).addChild(createValueBuilder("igp", Origin.QNAME, "value").build()).build()); + return this.dataContBuilder.build(); } private ContainerNode createStateFromPrefMedOriginASPath() { - dataContBuilder = createContBuilder(DATA_QNAME); + this.dataContBuilder = createContBuilder(this.DATA_QNAME); // local pref - dataContBuilder.addChild(createContBuilder(LocalPref.QNAME).addChild(createValueBuilder(321L, LocalPref.QNAME, "pref").build()).build()); + this.dataContBuilder.addChild(createContBuilder(LocalPref.QNAME).addChild(createValueBuilder(321L, LocalPref.QNAME, "pref").build()).build()); // multi exit disc - dataContBuilder.addChild(createContBuilder(MultiExitDisc.QNAME).addChild(createValueBuilder(4321L, MultiExitDisc.QNAME, "med").build()).build()); + this.dataContBuilder.addChild(createContBuilder(MultiExitDisc.QNAME).addChild(createValueBuilder(4321L, MultiExitDisc.QNAME, "med").build()).build()); // origin - dataContBuilder.addChild(createContBuilder(Origin.QNAME).addChild(createValueBuilder("egp", Origin.QNAME, "value").build()).build()); + this.dataContBuilder.addChild(createContBuilder(Origin.QNAME).addChild(createValueBuilder("egp", Origin.QNAME, "value").build()).build()); // as path final DataContainerNodeAttrBuilder asPathContBuilder = ImmutableContainerNodeSchemaAwareBuilder.create(); asPathContBuilder.withNodeIdentifier(new NodeIdentifier(AsPath.QNAME)); @@ -114,8 +114,8 @@ public class BestPathSelectorTest { segments.addChild(segmentBuilder.build()); asPathContBuilder.addChild(segments.build()); - dataContBuilder.addChild(asPathContBuilder.build()); - return dataContBuilder.build(); + this.dataContBuilder.addChild(asPathContBuilder.build()); + return this.dataContBuilder.build(); } private DataContainerNodeAttrBuilder createContBuilder(final QName qname) {