X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fmatch%2FMatchTest.java;h=e3333cf78c9e4123e2a7876bf83df5837d15e061;hp=5dcb898dfbb9db5e4420e0cafa06b8977979d8af;hb=f4f0a778c5e55053750590b0686d6e2b838031e6;hpb=96d2f3b1bc12f6db46bece17ef2982d4b7c73f80 diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/match/MatchTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/match/MatchTest.java index 5dcb898dfb..e3333cf78c 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/match/MatchTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/match/MatchTest.java @@ -532,6 +532,8 @@ public class MatchTest { InetAddress ipm2 = InetAddress.getByName("255.255.255.0"); InetAddress ip3 = InetAddress.getByName("1.3.0.0"); InetAddress ipm3 = InetAddress.getByName("255.255.0.0"); + InetAddress ip4 = InetAddress.getByName("1.3.4.4"); + InetAddress ipm4 = InetAddress.getByName("255.255.255.0"); Match m1 = new Match(); m1.setField(MatchType.DL_TYPE, ethType); @@ -562,17 +564,25 @@ public class MatchTest { Match i = m1.getIntersection(m2); Assert.assertTrue(((Short)i.getField(MatchType.DL_TYPE).getValue()).equals(ethType)); - Assert.assertTrue(((InetAddress)i.getField(MatchType.NW_SRC).getValue()).equals(ip2)); - Assert.assertTrue(((InetAddress)i.getField(MatchType.NW_SRC).getMask()).equals(ipm2)); + // Verify intersection of IP addresses is correct + Assert.assertTrue(((InetAddress)i.getField(MatchType.NW_SRC).getValue()).equals(ip1)); + Assert.assertNull(i.getField(MatchType.NW_SRC).getMask()); + // Empty set i = m2.getIntersection(m3); - Assert.assertTrue(i.getMatches() == 0); + Assert.assertNull(i); Match m4 = new Match(); m4.setField(MatchType.DL_TYPE, ethType); m4.setField(MatchType.NW_PROTO, IPProtocols.TCP.byteValue()); + m3.setField(MatchType.NW_SRC, ip4, ipm4); Assert.assertTrue(m4.intersetcs(m3)); + // Verify intersection of IP and IP mask addresses is correct + Match ii = m3.getIntersection(m4); + Assert.assertTrue(((InetAddress)ii.getField(MatchType.NW_SRC).getValue()).equals(ip4)); + Assert.assertTrue(((InetAddress)ii.getField(MatchType.NW_SRC).getMask()).equals(ipm4)); + Match m5 = new Match(); m5.setField(MatchType.DL_TYPE, ethType); m3.setField(MatchType.NW_SRC, ip3, ipm3); @@ -608,9 +618,12 @@ public class MatchTest { Assert.assertTrue(m6.intersetcs(m6)); Assert.assertTrue(m6.getIntersection(m6).equals(m6)); - // Empty match, represents the empty set - Match o = new Match(); - Assert.assertTrue(m6.getIntersection(o).equals(o)); - Assert.assertTrue(o.getIntersection(m6).equals(o)); + // Empty match, represents the universal set (all packets) + Match u = new Match(); + Assert.assertTrue(m6.getIntersection(u).equals(m6)); + Assert.assertTrue(u.getIntersection(m6).equals(m6)); + + // No intersection with null match, empty set + Assert.assertNull(m6.getIntersection(null)); } }