-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add test cases - remove TODOs - fix small bug where the intermediate representation used the as path of the output route
- Loading branch information
1 parent
09ed57b
commit 99e2db4
Showing
12 changed files
with
111 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...tocol/src/test/java/org/batfish/datamodel/routing_policy/statement/ExcludeAsPathTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.batfish.datamodel.routing_policy.statement; | ||
|
||
import static org.batfish.datamodel.AsPath.ofSingletonAsSets; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import com.google.common.collect.Lists; | ||
import java.util.List; | ||
import org.batfish.datamodel.Bgpv4Route; | ||
import org.batfish.datamodel.Configuration; | ||
import org.batfish.datamodel.ConfigurationFormat; | ||
import org.batfish.datamodel.routing_policy.Environment; | ||
import org.batfish.datamodel.routing_policy.expr.AsExpr; | ||
import org.batfish.datamodel.routing_policy.expr.ExplicitAs; | ||
import org.batfish.datamodel.routing_policy.expr.LiteralAsList; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public class ExcludeAsPathTest { | ||
|
||
private static Environment newTestEnvironment(Bgpv4Route.Builder outputRoute) { | ||
Configuration c = new Configuration("host", ConfigurationFormat.CISCO_IOS); | ||
return Environment.builder(c).setOutputRoute(outputRoute).build(); | ||
} | ||
|
||
@Test | ||
public void testExclude() { | ||
List<AsExpr> exclude = Lists.newArrayList(new ExplicitAs(3)); | ||
ExcludeAsPath operation = new ExcludeAsPath(new LiteralAsList(exclude)); | ||
Bgpv4Route.Builder builder = Bgpv4Route.testBuilder(); | ||
builder.setAsPath(ofSingletonAsSets(3L, 4L)); | ||
Environment env = newTestEnvironment(builder); | ||
|
||
operation.execute(env); | ||
assertThat(builder.getAsPath(), equalTo(ofSingletonAsSets(4L))); | ||
} | ||
|
||
@Test | ||
public void testExcludeWithIntermediateAttributes() { | ||
List<AsExpr> exclude = Lists.newArrayList(new ExplicitAs(3)); | ||
ExcludeAsPath operation = new ExcludeAsPath(new LiteralAsList(exclude)); | ||
Bgpv4Route.Builder outputRoute = Bgpv4Route.testBuilder(); | ||
outputRoute.setAsPath(ofSingletonAsSets(3L, 4L)); | ||
|
||
Bgpv4Route.Builder intermediateAttributes = Bgpv4Route.testBuilder(); | ||
intermediateAttributes.setAsPath(ofSingletonAsSets(3L, 5L)); | ||
Environment env = newTestEnvironment(outputRoute); | ||
env.setIntermediateBgpAttributes(intermediateAttributes); | ||
env.setWriteToIntermediateBgpAttributes(true); | ||
|
||
operation.execute(env); | ||
assertThat(outputRoute.getAsPath(), equalTo(ofSingletonAsSets(4L))); | ||
assertThat(intermediateAttributes.getAsPath(), equalTo(ofSingletonAsSets(5L))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters