Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow.criteria; |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 17 | |
| 18 | import org.junit.Test; |
alshabib | caf1ca2 | 2015-06-25 15:18:16 -0700 | [diff] [blame] | 19 | import org.onlab.packet.EthType; |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 20 | import org.onlab.packet.Ip6Address; |
| 21 | import org.onlab.packet.IpPrefix; |
| 22 | import org.onlab.packet.MacAddress; |
| 23 | import org.onlab.packet.MplsLabel; |
| 24 | import org.onlab.packet.TpPort; |
| 25 | import org.onlab.packet.VlanId; |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 26 | import org.onosproject.net.ChannelSpacing; |
| 27 | import org.onosproject.net.GridType; |
| 28 | import org.onosproject.net.Lambda; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 29 | import org.onosproject.net.PortNumber; |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 30 | |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 31 | import com.google.common.testing.EqualsTester; |
Sho SHIMIZU | 585bed9 | 2015-05-13 11:08:45 -0700 | [diff] [blame] | 32 | import org.onosproject.net.OchSignalType; |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 33 | |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 34 | import static org.hamcrest.MatcherAssert.assertThat; |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 35 | import static org.hamcrest.Matchers.equalTo; |
| 36 | import static org.hamcrest.Matchers.instanceOf; |
| 37 | import static org.hamcrest.Matchers.is; |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 38 | import static org.hamcrest.Matchers.notNullValue; |
| 39 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 40 | import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 41 | import static org.onosproject.net.PortNumber.portNumber; |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * Unit tests for the Criteria class and its subclasses. |
| 45 | */ |
| 46 | public class CriteriaTest { |
| 47 | |
| 48 | final PortNumber port1 = portNumber(1); |
| 49 | final PortNumber port2 = portNumber(2); |
| 50 | |
| 51 | Criterion matchInPort1 = Criteria.matchInPort(port1); |
| 52 | Criterion sameAsMatchInPort1 = Criteria.matchInPort(port1); |
| 53 | Criterion matchInPort2 = Criteria.matchInPort(port2); |
| 54 | |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 55 | Criterion matchInPhyPort1 = Criteria.matchInPhyPort(port1); |
| 56 | Criterion sameAsMatchInPhyPort1 = Criteria.matchInPhyPort(port1); |
| 57 | Criterion matchInPhyPort2 = Criteria.matchInPhyPort(port2); |
| 58 | |
| 59 | long metadata1 = 1; |
| 60 | long metadata2 = 2; |
| 61 | Criterion matchMetadata1 = Criteria.matchMetadata(metadata1); |
| 62 | Criterion sameAsMatchMetadata1 = Criteria.matchMetadata(metadata1); |
| 63 | Criterion matchMetadata2 = Criteria.matchMetadata(metadata2); |
| 64 | |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 65 | private static final String MAC1 = "00:00:00:00:00:01"; |
| 66 | private static final String MAC2 = "00:00:00:00:00:02"; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 67 | private MacAddress mac1 = MacAddress.valueOf(MAC1); |
| 68 | private MacAddress mac2 = MacAddress.valueOf(MAC2); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 69 | Criterion matchEth1 = Criteria.matchEthSrc(mac1); |
| 70 | Criterion sameAsMatchEth1 = Criteria.matchEthSrc(mac1); |
| 71 | Criterion matchEth2 = Criteria.matchEthDst(mac2); |
| 72 | |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 73 | int ethType1 = 1; |
| 74 | int ethType2 = 2; |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 75 | Criterion matchEthType1 = Criteria.matchEthType(ethType1); |
| 76 | Criterion sameAsMatchEthType1 = Criteria.matchEthType(ethType1); |
| 77 | Criterion matchEthType2 = Criteria.matchEthType(ethType2); |
| 78 | |
| 79 | short vlan1 = 1; |
| 80 | short vlan2 = 2; |
| 81 | VlanId vlanId1 = VlanId.vlanId(vlan1); |
| 82 | VlanId vlanId2 = VlanId.vlanId(vlan2); |
| 83 | Criterion matchVlanId1 = Criteria.matchVlanId(vlanId1); |
| 84 | Criterion sameAsMatchVlanId1 = Criteria.matchVlanId(vlanId1); |
| 85 | Criterion matchVlanId2 = Criteria.matchVlanId(vlanId2); |
| 86 | |
| 87 | byte vlanPcp1 = 1; |
| 88 | byte vlanPcp2 = 2; |
| 89 | Criterion matchVlanPcp1 = Criteria.matchVlanPcp(vlanPcp1); |
| 90 | Criterion sameAsMatchVlanPcp1 = Criteria.matchVlanPcp(vlanPcp1); |
| 91 | Criterion matchVlanPcp2 = Criteria.matchVlanPcp(vlanPcp2); |
| 92 | |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 93 | byte ipDscp1 = 1; |
| 94 | byte ipDscp2 = 2; |
| 95 | Criterion matchIpDscp1 = Criteria.matchIPDscp(ipDscp1); |
| 96 | Criterion sameAsMatchIpDscp1 = Criteria.matchIPDscp(ipDscp1); |
| 97 | Criterion matchIpDscp2 = Criteria.matchIPDscp(ipDscp2); |
| 98 | |
| 99 | byte ipEcn1 = 1; |
| 100 | byte ipEcn2 = 2; |
| 101 | Criterion matchIpEcn1 = Criteria.matchIPEcn(ipEcn1); |
| 102 | Criterion sameAsMatchIpEcn1 = Criteria.matchIPEcn(ipEcn1); |
| 103 | Criterion matchIpEcn2 = Criteria.matchIPEcn(ipEcn2); |
| 104 | |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 105 | short protocol1 = 1; |
| 106 | short protocol2 = 2; |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 107 | Criterion matchIpProtocol1 = Criteria.matchIPProtocol(protocol1); |
| 108 | Criterion sameAsMatchIpProtocol1 = Criteria.matchIPProtocol(protocol1); |
| 109 | Criterion matchIpProtocol2 = Criteria.matchIPProtocol(protocol2); |
| 110 | |
| 111 | private static final String IP1 = "1.2.3.4/24"; |
| 112 | private static final String IP2 = "5.6.7.8/24"; |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 113 | private static final String IPV61 = "fe80::1/64"; |
| 114 | private static final String IPV62 = "fc80::2/64"; |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 115 | private IpPrefix ip1 = IpPrefix.valueOf(IP1); |
| 116 | private IpPrefix ip2 = IpPrefix.valueOf(IP2); |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 117 | private IpPrefix ipv61 = IpPrefix.valueOf(IPV61); |
| 118 | private IpPrefix ipv62 = IpPrefix.valueOf(IPV62); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 119 | Criterion matchIp1 = Criteria.matchIPSrc(ip1); |
| 120 | Criterion sameAsMatchIp1 = Criteria.matchIPSrc(ip1); |
| 121 | Criterion matchIp2 = Criteria.matchIPSrc(ip2); |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 122 | Criterion matchIpv61 = Criteria.matchIPSrc(ipv61); |
| 123 | Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61); |
| 124 | Criterion matchIpv62 = Criteria.matchIPSrc(ipv62); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 125 | |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 126 | private TpPort tpPort1 = TpPort.tpPort(1); |
| 127 | private TpPort tpPort2 = TpPort.tpPort(2); |
| 128 | Criterion matchTcpPort1 = Criteria.matchTcpSrc(tpPort1); |
| 129 | Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(tpPort1); |
| 130 | Criterion matchTcpPort2 = Criteria.matchTcpDst(tpPort2); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 131 | |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 132 | Criterion matchUdpPort1 = Criteria.matchUdpSrc(tpPort1); |
| 133 | Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(tpPort1); |
| 134 | Criterion matchUdpPort2 = Criteria.matchUdpDst(tpPort2); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 135 | |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 136 | Criterion matchSctpPort1 = Criteria.matchSctpSrc(tpPort1); |
| 137 | Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(tpPort1); |
| 138 | Criterion matchSctpPort2 = Criteria.matchSctpDst(tpPort2); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 139 | |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 140 | short icmpType1 = 1; |
| 141 | short icmpType2 = 2; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 142 | Criterion matchIcmpType1 = Criteria.matchIcmpType(icmpType1); |
| 143 | Criterion sameAsMatchIcmpType1 = Criteria.matchIcmpType(icmpType1); |
| 144 | Criterion matchIcmpType2 = Criteria.matchIcmpType(icmpType2); |
| 145 | |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 146 | short icmpCode1 = 1; |
| 147 | short icmpCode2 = 2; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 148 | Criterion matchIcmpCode1 = Criteria.matchIcmpCode(icmpCode1); |
| 149 | Criterion sameAsMatchIcmpCode1 = Criteria.matchIcmpCode(icmpCode1); |
| 150 | Criterion matchIcmpCode2 = Criteria.matchIcmpCode(icmpCode2); |
| 151 | |
| 152 | int flowLabel1 = 1; |
| 153 | int flowLabel2 = 2; |
| 154 | Criterion matchFlowLabel1 = Criteria.matchIPv6FlowLabel(flowLabel1); |
| 155 | Criterion sameAsMatchFlowLabel1 = Criteria.matchIPv6FlowLabel(flowLabel1); |
| 156 | Criterion matchFlowLabel2 = Criteria.matchIPv6FlowLabel(flowLabel2); |
| 157 | |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 158 | short icmpv6Type1 = 1; |
| 159 | short icmpv6Type2 = 2; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 160 | Criterion matchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1); |
| 161 | Criterion sameAsMatchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1); |
| 162 | Criterion matchIcmpv6Type2 = Criteria.matchIcmpv6Type(icmpv6Type2); |
| 163 | |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 164 | short icmpv6Code1 = 1; |
| 165 | short icmpv6Code2 = 2; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 166 | Criterion matchIcmpv6Code1 = Criteria.matchIcmpv6Code(icmpv6Code1); |
| 167 | Criterion sameAsMatchIcmpv6Code1 = Criteria.matchIcmpv6Code(icmpv6Code1); |
| 168 | Criterion matchIcmpv6Code2 = Criteria.matchIcmpv6Code(icmpv6Code2); |
| 169 | |
| 170 | private static final String IPV6_ADDR1 = "fe80::1"; |
| 171 | private static final String IPV6_ADDR2 = "fe80::2"; |
| 172 | private Ip6Address ip6TargetAddress1 = Ip6Address.valueOf(IPV6_ADDR1); |
| 173 | private Ip6Address ip6TargetAddress2 = Ip6Address.valueOf(IPV6_ADDR2); |
| 174 | Criterion matchIpv6TargetAddr1 = |
| 175 | Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); |
| 176 | Criterion sameAsMatchIpv6TargetAddr1 = |
| 177 | Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); |
| 178 | Criterion matchIpv6TargetAddr2 = |
| 179 | Criteria.matchIPv6NDTargetAddress(ip6TargetAddress2); |
| 180 | |
| 181 | private static final String LL_MAC1 = "00:00:00:00:00:01"; |
| 182 | private static final String LL_MAC2 = "00:00:00:00:00:02"; |
| 183 | private MacAddress llMac1 = MacAddress.valueOf(LL_MAC1); |
| 184 | private MacAddress llMac2 = MacAddress.valueOf(LL_MAC2); |
| 185 | Criterion matchSrcLlAddr1 = |
| 186 | Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); |
| 187 | Criterion sameAsMatchSrcLlAddr1 = |
| 188 | Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); |
| 189 | Criterion matchSrcLlAddr2 = |
| 190 | Criteria.matchIPv6NDSourceLinkLayerAddress(llMac2); |
| 191 | Criterion matchTargetLlAddr1 = |
| 192 | Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); |
| 193 | Criterion sameAsMatchTargetLlAddr1 = |
| 194 | Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); |
| 195 | Criterion matchTargetLlAddr2 = |
| 196 | Criteria.matchIPv6NDTargetLinkLayerAddress(llMac2); |
| 197 | |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 198 | MplsLabel mpls1 = MplsLabel.mplsLabel(1); |
| 199 | MplsLabel mpls2 = MplsLabel.mplsLabel(2); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 200 | Criterion matchMpls1 = Criteria.matchMplsLabel(mpls1); |
| 201 | Criterion sameAsMatchMpls1 = Criteria.matchMplsLabel(mpls1); |
| 202 | Criterion matchMpls2 = Criteria.matchMplsLabel(mpls2); |
| 203 | |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 204 | long tunnelId1 = 1; |
| 205 | long tunnelId2 = 2; |
| 206 | Criterion matchTunnelId1 = Criteria.matchTunnelId(tunnelId1); |
| 207 | Criterion sameAsMatchTunnelId1 = Criteria.matchTunnelId(tunnelId1); |
| 208 | Criterion matchTunnelId2 = Criteria.matchTunnelId(tunnelId2); |
| 209 | |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 210 | int ipv6ExthdrFlags1 = |
| 211 | Criterion.IPv6ExthdrFlags.NONEXT.getValue() | |
| 212 | Criterion.IPv6ExthdrFlags.ESP.getValue() | |
| 213 | Criterion.IPv6ExthdrFlags.AUTH.getValue() | |
| 214 | Criterion.IPv6ExthdrFlags.DEST.getValue() | |
| 215 | Criterion.IPv6ExthdrFlags.FRAG.getValue() | |
| 216 | Criterion.IPv6ExthdrFlags.ROUTER.getValue() | |
| 217 | Criterion.IPv6ExthdrFlags.HOP.getValue() | |
| 218 | Criterion.IPv6ExthdrFlags.UNREP.getValue(); |
| 219 | int ipv6ExthdrFlags2 = ipv6ExthdrFlags1 | |
| 220 | Criterion.IPv6ExthdrFlags.UNSEQ.getValue(); |
| 221 | Criterion matchIpv6ExthdrFlags1 = |
| 222 | Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); |
| 223 | Criterion sameAsMatchIpv6ExthdrFlags1 = |
| 224 | Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); |
| 225 | Criterion matchIpv6ExthdrFlags2 = |
| 226 | Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags2); |
| 227 | |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 228 | Criterion matchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID); |
| 229 | Criterion sameAsMatchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID); |
Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -0700 | [diff] [blame] | 230 | Criterion matchOchSignalType2 = Criteria.matchOchSignalType(OchSignalType.FLEX_GRID); |
| 231 | |
Sho SHIMIZU | efc2e28 | 2015-05-04 15:26:23 -0700 | [diff] [blame] | 232 | Criterion matchIndexedLambda1 = Criteria.matchLambda(Lambda.indexedLambda(1)); |
| 233 | Criterion sameAsMatchIndexedLambda1 = Criteria.matchLambda(Lambda.indexedLambda(1)); |
| 234 | Criterion matchIndexedLambda2 = Criteria.matchLambda(Lambda.indexedLambda(2)); |
| 235 | |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 236 | Criterion matchOchSignal1 = |
| 237 | Criteria.matchLambda(Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 4, 8)); |
| 238 | Criterion sameAsMatchOchSignal1 = |
| 239 | Criteria.matchLambda(Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 4, 8)); |
| 240 | Criterion matchOchSignal2 = |
| 241 | Criteria.matchLambda(Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 4, 8)); |
| 242 | |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 243 | /** |
| 244 | * Checks that a Criterion object has the proper type, and then converts |
| 245 | * it to the proper type. |
| 246 | * |
| 247 | * @param criterion Criterion object to convert |
| 248 | * @param type Enumerated type value for the Criterion class |
| 249 | * @param clazz Desired Criterion class |
| 250 | * @param <T> The type the caller wants returned |
| 251 | * @return converted object |
| 252 | */ |
| 253 | @SuppressWarnings("unchecked") |
| 254 | private <T> T checkAndConvert(Criterion criterion, Criterion.Type type, Class clazz) { |
| 255 | assertThat(criterion, is(notNullValue())); |
| 256 | assertThat(criterion.type(), is(equalTo(type))); |
Ray Milkey | 7808105 | 2014-11-05 10:38:12 -0800 | [diff] [blame] | 257 | assertThat(criterion, instanceOf(clazz)); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 258 | return (T) criterion; |
| 259 | } |
| 260 | |
| 261 | /** |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 262 | * Check that the Criteria class is a valid utility class. |
| 263 | */ |
| 264 | @Test |
| 265 | public void testCriteriaUtility() { |
| 266 | assertThatClassIsUtility(Criteria.class); |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Check that the Criteria implementations are immutable. |
| 271 | */ |
| 272 | @Test |
| 273 | public void testCriteriaImmutability() { |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 274 | assertThatClassIsImmutable(PortCriterion.class); |
| 275 | assertThatClassIsImmutable(MetadataCriterion.class); |
| 276 | assertThatClassIsImmutable(EthCriterion.class); |
| 277 | assertThatClassIsImmutable(EthTypeCriterion.class); |
| 278 | assertThatClassIsImmutable(VlanIdCriterion.class); |
| 279 | assertThatClassIsImmutable(VlanPcpCriterion.class); |
| 280 | assertThatClassIsImmutable(IPDscpCriterion.class); |
| 281 | assertThatClassIsImmutable(IPEcnCriterion.class); |
| 282 | assertThatClassIsImmutable(IPProtocolCriterion.class); |
| 283 | assertThatClassIsImmutable(IPCriterion.class); |
| 284 | assertThatClassIsImmutable(TcpPortCriterion.class); |
| 285 | assertThatClassIsImmutable(UdpPortCriterion.class); |
| 286 | assertThatClassIsImmutable(SctpPortCriterion.class); |
| 287 | assertThatClassIsImmutable(IcmpTypeCriterion.class); |
| 288 | assertThatClassIsImmutable(IcmpCodeCriterion.class); |
| 289 | assertThatClassIsImmutable(IPv6FlowLabelCriterion.class); |
| 290 | assertThatClassIsImmutable(Icmpv6TypeCriterion.class); |
| 291 | assertThatClassIsImmutable(Icmpv6CodeCriterion.class); |
| 292 | assertThatClassIsImmutable(IPv6NDTargetAddressCriterion.class); |
| 293 | assertThatClassIsImmutable(IPv6NDLinkLayerAddressCriterion.class); |
| 294 | assertThatClassIsImmutable(MplsCriterion.class); |
| 295 | assertThatClassIsImmutable(IPv6ExthdrFlagsCriterion.class); |
| 296 | assertThatClassIsImmutable(LambdaCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | // PortCriterion class |
| 300 | |
| 301 | /** |
| 302 | * Test the matchInPort method. |
| 303 | */ |
| 304 | @Test |
| 305 | public void testMatchInPortMethod() { |
| 306 | PortNumber p1 = portNumber(1); |
| 307 | Criterion matchInPort = Criteria.matchInPort(p1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 308 | PortCriterion portCriterion = |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 309 | checkAndConvert(matchInPort, |
| 310 | Criterion.Type.IN_PORT, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 311 | PortCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 312 | assertThat(portCriterion.port(), is(equalTo(p1))); |
| 313 | } |
| 314 | |
| 315 | /** |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 316 | * Test the matchInPhyPort method. |
| 317 | */ |
| 318 | @Test |
| 319 | public void testMatchInPhyPortMethod() { |
| 320 | PortNumber p1 = portNumber(1); |
| 321 | Criterion matchInPhyPort = Criteria.matchInPhyPort(p1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 322 | PortCriterion portCriterion = |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 323 | checkAndConvert(matchInPhyPort, |
| 324 | Criterion.Type.IN_PHY_PORT, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 325 | PortCriterion.class); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 326 | assertThat(portCriterion.port(), is(equalTo(p1))); |
| 327 | } |
| 328 | |
| 329 | /** |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 330 | * Test the equals() method of the PortCriterion class. |
| 331 | */ |
| 332 | @Test |
| 333 | public void testPortCriterionEquals() { |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 334 | new EqualsTester() |
| 335 | .addEqualityGroup(matchInPort1, sameAsMatchInPort1) |
| 336 | .addEqualityGroup(matchInPort2) |
| 337 | .testEquals(); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 338 | |
| 339 | new EqualsTester() |
| 340 | .addEqualityGroup(matchInPhyPort1, sameAsMatchInPhyPort1) |
| 341 | .addEqualityGroup(matchInPhyPort2) |
| 342 | .testEquals(); |
| 343 | } |
| 344 | |
| 345 | // MetadataCriterion class |
| 346 | |
| 347 | /** |
| 348 | * Test the matchMetadata method. |
| 349 | */ |
| 350 | @Test |
| 351 | public void testMatchMetadataMethod() { |
| 352 | Long metadata = 12L; |
| 353 | Criterion matchMetadata = Criteria.matchMetadata(metadata); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 354 | MetadataCriterion metadataCriterion = |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 355 | checkAndConvert(matchMetadata, |
| 356 | Criterion.Type.METADATA, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 357 | MetadataCriterion.class); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 358 | assertThat(metadataCriterion.metadata(), is(equalTo(metadata))); |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * Test the equals() method of the MetadataCriterion class. |
| 363 | */ |
| 364 | @Test |
| 365 | public void testMetadataCriterionEquals() { |
| 366 | new EqualsTester() |
| 367 | .addEqualityGroup(matchMetadata1, sameAsMatchMetadata1) |
| 368 | .addEqualityGroup(matchMetadata2) |
| 369 | .testEquals(); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | // EthCriterion class |
| 373 | |
| 374 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 375 | * Test the matchEthDst method. |
| 376 | */ |
| 377 | @Test |
| 378 | public void testMatchEthDstMethod() { |
| 379 | Criterion matchEthDst = Criteria.matchEthDst(mac1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 380 | EthCriterion ethCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 381 | checkAndConvert(matchEthDst, |
| 382 | Criterion.Type.ETH_DST, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 383 | EthCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 384 | assertThat(ethCriterion.mac(), is(equalTo(mac1))); |
| 385 | } |
| 386 | |
| 387 | /** |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 388 | * Test the matchEthSrc method. |
| 389 | */ |
| 390 | @Test |
| 391 | public void testMatchEthSrcMethod() { |
| 392 | Criterion matchEthSrc = Criteria.matchEthSrc(mac1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 393 | EthCriterion ethCriterion = |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 394 | checkAndConvert(matchEthSrc, |
| 395 | Criterion.Type.ETH_SRC, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 396 | EthCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 397 | assertThat(ethCriterion.mac(), is(mac1)); |
| 398 | } |
| 399 | |
| 400 | /** |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 401 | * Test the equals() method of the EthCriterion class. |
| 402 | */ |
| 403 | @Test |
| 404 | public void testEthCriterionEquals() { |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 405 | new EqualsTester() |
| 406 | .addEqualityGroup(matchEth1, sameAsMatchEth1) |
| 407 | .addEqualityGroup(matchEth2) |
| 408 | .testEquals(); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 409 | } |
| 410 | |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 411 | // EthTypeCriterion class |
| 412 | |
| 413 | /** |
| 414 | * Test the matchEthType method. |
| 415 | */ |
| 416 | @Test |
| 417 | public void testMatchEthTypeMethod() { |
alshabib | caf1ca2 | 2015-06-25 15:18:16 -0700 | [diff] [blame] | 418 | EthType ethType = new EthType(12); |
| 419 | Criterion matchEthType = Criteria.matchEthType(new EthType(12)); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 420 | EthTypeCriterion ethTypeCriterion = |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 421 | checkAndConvert(matchEthType, |
| 422 | Criterion.Type.ETH_TYPE, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 423 | EthTypeCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 424 | assertThat(ethTypeCriterion.ethType(), is(equalTo(ethType))); |
| 425 | } |
| 426 | |
| 427 | /** |
| 428 | * Test the equals() method of the EthTypeCriterion class. |
| 429 | */ |
| 430 | @Test |
| 431 | public void testEthTypeCriterionEquals() { |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 432 | new EqualsTester() |
| 433 | .addEqualityGroup(matchEthType1, sameAsMatchEthType1) |
| 434 | .addEqualityGroup(matchEthType2) |
| 435 | .testEquals(); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 436 | } |
| 437 | |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 438 | // VlanIdCriterion class |
| 439 | |
| 440 | /** |
| 441 | * Test the matchVlanId method. |
| 442 | */ |
| 443 | @Test |
| 444 | public void testMatchVlanIdMethod() { |
| 445 | Criterion matchVlanId = Criteria.matchVlanId(vlanId1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 446 | VlanIdCriterion vlanIdCriterion = |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 447 | checkAndConvert(matchVlanId, |
| 448 | Criterion.Type.VLAN_VID, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 449 | VlanIdCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 450 | assertThat(vlanIdCriterion.vlanId(), is(equalTo(vlanId1))); |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * Test the equals() method of the VlanIdCriterion class. |
| 455 | */ |
| 456 | @Test |
| 457 | public void testVlanIdCriterionEquals() { |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 458 | new EqualsTester() |
| 459 | .addEqualityGroup(matchVlanId1, sameAsMatchVlanId1) |
| 460 | .addEqualityGroup(matchVlanId2) |
| 461 | .testEquals(); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | // VlanPcpCriterion class |
| 465 | |
| 466 | /** |
| 467 | * Test the matchVlanPcp method. |
| 468 | */ |
| 469 | @Test |
| 470 | public void testMatchVlanPcpMethod() { |
| 471 | Criterion matchVlanPcp = Criteria.matchVlanPcp(vlanPcp1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 472 | VlanPcpCriterion vlanPcpCriterion = |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 473 | checkAndConvert(matchVlanPcp, |
| 474 | Criterion.Type.VLAN_PCP, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 475 | VlanPcpCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 476 | assertThat(vlanPcpCriterion.priority(), is(equalTo(vlanPcp1))); |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * Test the equals() method of the VlanPcpCriterion class. |
| 481 | */ |
| 482 | @Test |
| 483 | public void testVlanPcpCriterionEquals() { |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 484 | new EqualsTester() |
| 485 | .addEqualityGroup(matchVlanPcp1, sameAsMatchVlanPcp1) |
| 486 | .addEqualityGroup(matchVlanPcp2) |
| 487 | .testEquals(); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 488 | } |
| 489 | |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 490 | // IPDscpCriterion class |
| 491 | |
| 492 | /** |
| 493 | * Test the matchIPDscp method. |
| 494 | */ |
| 495 | @Test |
| 496 | public void testMatchIPDscpMethod() { |
| 497 | Criterion matchIPDscp = Criteria.matchIPDscp(ipDscp1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 498 | IPDscpCriterion ipDscpCriterion = |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 499 | checkAndConvert(matchIPDscp, |
| 500 | Criterion.Type.IP_DSCP, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 501 | IPDscpCriterion.class); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 502 | assertThat(ipDscpCriterion.ipDscp(), is(equalTo(ipDscp1))); |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * Test the equals() method of the IPDscpCriterion class. |
| 507 | */ |
| 508 | @Test |
| 509 | public void testIPDscpCriterionEquals() { |
| 510 | new EqualsTester() |
| 511 | .addEqualityGroup(matchIpDscp1, sameAsMatchIpDscp1) |
| 512 | .addEqualityGroup(matchIpDscp2) |
| 513 | .testEquals(); |
| 514 | } |
| 515 | |
| 516 | // IPEcnCriterion class |
| 517 | |
| 518 | /** |
| 519 | * Test the matchIPEcn method. |
| 520 | */ |
| 521 | @Test |
| 522 | public void testMatchIPEcnMethod() { |
| 523 | Criterion matchIPEcn = Criteria.matchIPEcn(ipEcn1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 524 | IPEcnCriterion ipEcnCriterion = |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 525 | checkAndConvert(matchIPEcn, |
| 526 | Criterion.Type.IP_ECN, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 527 | IPEcnCriterion.class); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 528 | assertThat(ipEcnCriterion.ipEcn(), is(equalTo(ipEcn1))); |
| 529 | } |
| 530 | |
| 531 | /** |
| 532 | * Test the equals() method of the IPEcnCriterion class. |
| 533 | */ |
| 534 | @Test |
| 535 | public void testIPEcnCriterionEquals() { |
| 536 | new EqualsTester() |
| 537 | .addEqualityGroup(matchIpEcn1, sameAsMatchIpEcn1) |
| 538 | .addEqualityGroup(matchIpEcn2) |
| 539 | .testEquals(); |
| 540 | } |
| 541 | |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 542 | // IpProtocolCriterion class |
| 543 | |
| 544 | /** |
| 545 | * Test the matchIpProtocol method. |
| 546 | */ |
| 547 | @Test |
| 548 | public void testMatchIpProtocolMethod() { |
| 549 | Criterion matchIPProtocol = Criteria.matchIPProtocol(protocol1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 550 | IPProtocolCriterion ipProtocolCriterion = |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 551 | checkAndConvert(matchIPProtocol, |
| 552 | Criterion.Type.IP_PROTO, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 553 | IPProtocolCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 554 | assertThat(ipProtocolCriterion.protocol(), is(equalTo(protocol1))); |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Test the equals() method of the IpProtocolCriterion class. |
| 559 | */ |
| 560 | @Test |
| 561 | public void testIpProtocolCriterionEquals() { |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 562 | new EqualsTester() |
| 563 | .addEqualityGroup(matchIpProtocol1, sameAsMatchIpProtocol1) |
| 564 | .addEqualityGroup(matchIpProtocol2) |
| 565 | .testEquals(); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | // IPCriterion class |
| 569 | |
| 570 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 571 | * Test the matchIPSrc method: IPv4. |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 572 | */ |
| 573 | @Test |
| 574 | public void testMatchIPSrcMethod() { |
| 575 | Criterion matchIpSrc = Criteria.matchIPSrc(ip1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 576 | IPCriterion ipCriterion = |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 577 | checkAndConvert(matchIpSrc, |
| 578 | Criterion.Type.IPV4_SRC, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 579 | IPCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 580 | assertThat(ipCriterion.ip(), is(ip1)); |
| 581 | } |
| 582 | |
| 583 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 584 | * Test the matchIPDst method: IPv4. |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 585 | */ |
| 586 | @Test |
| 587 | public void testMatchIPDstMethod() { |
| 588 | Criterion matchIPDst = Criteria.matchIPDst(ip1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 589 | IPCriterion ipCriterion = |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 590 | checkAndConvert(matchIPDst, |
| 591 | Criterion.Type.IPV4_DST, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 592 | IPCriterion.class); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 593 | assertThat(ipCriterion.ip(), is(equalTo(ip1))); |
| 594 | } |
| 595 | |
| 596 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 597 | * Test the matchIPSrc method: IPv6. |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 598 | */ |
| 599 | @Test |
| 600 | public void testMatchIPv6SrcMethod() { |
| 601 | Criterion matchIpv6Src = Criteria.matchIPv6Src(ipv61); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 602 | IPCriterion ipCriterion = |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 603 | checkAndConvert(matchIpv6Src, |
| 604 | Criterion.Type.IPV6_SRC, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 605 | IPCriterion.class); |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 606 | assertThat(ipCriterion.ip(), is(ipv61)); |
| 607 | } |
| 608 | |
| 609 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 610 | * Test the matchIPDst method: IPv6. |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 611 | */ |
| 612 | @Test |
| 613 | public void testMatchIPv6DstMethod() { |
| 614 | Criterion matchIPv6Dst = Criteria.matchIPv6Dst(ipv61); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 615 | IPCriterion ipCriterion = |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 616 | checkAndConvert(matchIPv6Dst, |
| 617 | Criterion.Type.IPV6_DST, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 618 | IPCriterion.class); |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 619 | assertThat(ipCriterion.ip(), is(equalTo(ipv61))); |
| 620 | } |
| 621 | |
| 622 | /** |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 623 | * Test the equals() method of the IpCriterion class. |
| 624 | */ |
| 625 | @Test |
| 626 | public void testIPCriterionEquals() { |
Ray Milkey | fff20b5 | 2014-11-06 14:45:10 -0800 | [diff] [blame] | 627 | new EqualsTester() |
| 628 | .addEqualityGroup(matchIp1, sameAsMatchIp1) |
| 629 | .addEqualityGroup(matchIp2) |
| 630 | .testEquals(); |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 631 | |
| 632 | new EqualsTester() |
| 633 | .addEqualityGroup(matchIpv61, sameAsMatchIpv61) |
| 634 | .addEqualityGroup(matchIpv62) |
| 635 | .testEquals(); |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 636 | } |
| 637 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 638 | // TcpPortCriterion class |
| 639 | |
| 640 | /** |
| 641 | * Test the matchTcpSrc method. |
| 642 | */ |
| 643 | @Test |
| 644 | public void testMatchTcpSrcMethod() { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 645 | Criterion matchTcpSrc = Criteria.matchTcpSrc(tpPort1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 646 | TcpPortCriterion tcpPortCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 647 | checkAndConvert(matchTcpSrc, |
| 648 | Criterion.Type.TCP_SRC, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 649 | TcpPortCriterion.class); |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 650 | assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1))); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | /** |
| 654 | * Test the matchTcpDst method. |
| 655 | */ |
| 656 | @Test |
| 657 | public void testMatchTcpDstMethod() { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 658 | Criterion matchTcpDst = Criteria.matchTcpDst(tpPort1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 659 | TcpPortCriterion tcpPortCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 660 | checkAndConvert(matchTcpDst, |
| 661 | Criterion.Type.TCP_DST, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 662 | TcpPortCriterion.class); |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 663 | assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1))); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | /** |
| 667 | * Test the equals() method of the TcpPortCriterion class. |
| 668 | */ |
| 669 | @Test |
| 670 | public void testTcpPortCriterionEquals() { |
| 671 | new EqualsTester() |
| 672 | .addEqualityGroup(matchTcpPort1, sameAsMatchTcpPort1) |
| 673 | .addEqualityGroup(matchTcpPort2) |
| 674 | .testEquals(); |
| 675 | } |
| 676 | |
| 677 | // UdpPortCriterion class |
| 678 | |
| 679 | /** |
| 680 | * Test the matchUdpSrc method. |
| 681 | */ |
| 682 | @Test |
| 683 | public void testMatchUdpSrcMethod() { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 684 | Criterion matchUdpSrc = Criteria.matchUdpSrc(tpPort1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 685 | UdpPortCriterion udpPortCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 686 | checkAndConvert(matchUdpSrc, |
| 687 | Criterion.Type.UDP_SRC, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 688 | UdpPortCriterion.class); |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 689 | assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1))); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | /** |
| 693 | * Test the matchUdpDst method. |
| 694 | */ |
| 695 | @Test |
| 696 | public void testMatchUdpDstMethod() { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 697 | Criterion matchUdpDst = Criteria.matchUdpDst(tpPort1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 698 | UdpPortCriterion udpPortCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 699 | checkAndConvert(matchUdpDst, |
| 700 | Criterion.Type.UDP_DST, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 701 | UdpPortCriterion.class); |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 702 | assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1))); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | /** |
| 706 | * Test the equals() method of the UdpPortCriterion class. |
| 707 | */ |
| 708 | @Test |
| 709 | public void testUdpPortCriterionEquals() { |
| 710 | new EqualsTester() |
| 711 | .addEqualityGroup(matchUdpPort1, sameAsMatchUdpPort1) |
| 712 | .addEqualityGroup(matchUdpPort2) |
| 713 | .testEquals(); |
| 714 | } |
| 715 | |
| 716 | // SctpPortCriterion class |
| 717 | |
| 718 | /** |
| 719 | * Test the matchSctpSrc method. |
| 720 | */ |
| 721 | @Test |
| 722 | public void testMatchSctpSrcMethod() { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 723 | Criterion matchSctpSrc = Criteria.matchSctpSrc(tpPort1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 724 | SctpPortCriterion sctpPortCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 725 | checkAndConvert(matchSctpSrc, |
| 726 | Criterion.Type.SCTP_SRC, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 727 | SctpPortCriterion.class); |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 728 | assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1))); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | /** |
| 732 | * Test the matchSctpDst method. |
| 733 | */ |
| 734 | @Test |
| 735 | public void testMatchSctpDstMethod() { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 736 | Criterion matchSctpDst = Criteria.matchSctpDst(tpPort1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 737 | SctpPortCriterion sctpPortCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 738 | checkAndConvert(matchSctpDst, |
| 739 | Criterion.Type.SCTP_DST, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 740 | SctpPortCriterion.class); |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 741 | assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1))); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | /** |
| 745 | * Test the equals() method of the SctpPortCriterion class. |
| 746 | */ |
| 747 | @Test |
| 748 | public void testSctpPortCriterionEquals() { |
| 749 | new EqualsTester() |
| 750 | .addEqualityGroup(matchSctpPort1, sameAsMatchSctpPort1) |
| 751 | .addEqualityGroup(matchSctpPort2) |
| 752 | .testEquals(); |
| 753 | } |
| 754 | |
| 755 | // IcmpTypeCriterion class |
| 756 | |
| 757 | /** |
| 758 | * Test the matchIcmpType method. |
| 759 | */ |
| 760 | @Test |
| 761 | public void testMatchIcmpTypeMethod() { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 762 | short icmpType = 12; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 763 | Criterion matchIcmpType = Criteria.matchIcmpType(icmpType); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 764 | IcmpTypeCriterion icmpTypeCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 765 | checkAndConvert(matchIcmpType, |
| 766 | Criterion.Type.ICMPV4_TYPE, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 767 | IcmpTypeCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 768 | assertThat(icmpTypeCriterion.icmpType(), is(equalTo(icmpType))); |
| 769 | } |
| 770 | |
| 771 | /** |
| 772 | * Test the equals() method of the IcmpTypeCriterion class. |
| 773 | */ |
| 774 | @Test |
| 775 | public void testIcmpTypeCriterionEquals() { |
| 776 | new EqualsTester() |
| 777 | .addEqualityGroup(matchIcmpType1, sameAsMatchIcmpType1) |
| 778 | .addEqualityGroup(matchIcmpType2) |
| 779 | .testEquals(); |
| 780 | } |
| 781 | |
| 782 | // IcmpCodeCriterion class |
| 783 | |
| 784 | /** |
| 785 | * Test the matchIcmpCode method. |
| 786 | */ |
| 787 | @Test |
| 788 | public void testMatchIcmpCodeMethod() { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 789 | short icmpCode = 12; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 790 | Criterion matchIcmpCode = Criteria.matchIcmpCode(icmpCode); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 791 | IcmpCodeCriterion icmpCodeCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 792 | checkAndConvert(matchIcmpCode, |
| 793 | Criterion.Type.ICMPV4_CODE, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 794 | IcmpCodeCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 795 | assertThat(icmpCodeCriterion.icmpCode(), is(equalTo(icmpCode))); |
| 796 | } |
| 797 | |
| 798 | /** |
| 799 | * Test the equals() method of the IcmpCodeCriterion class. |
| 800 | */ |
| 801 | @Test |
| 802 | public void testIcmpCodeCriterionEquals() { |
| 803 | new EqualsTester() |
| 804 | .addEqualityGroup(matchIcmpCode1, sameAsMatchIcmpCode1) |
| 805 | .addEqualityGroup(matchIcmpCode2) |
| 806 | .testEquals(); |
| 807 | } |
| 808 | |
| 809 | // IPv6FlowLabelCriterion class |
| 810 | |
| 811 | /** |
| 812 | * Test the matchIPv6FlowLabel method. |
| 813 | */ |
| 814 | @Test |
| 815 | public void testMatchIPv6FlowLabelMethod() { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 816 | int flowLabel = 12; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 817 | Criterion matchFlowLabel = Criteria.matchIPv6FlowLabel(flowLabel); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 818 | IPv6FlowLabelCriterion flowLabelCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 819 | checkAndConvert(matchFlowLabel, |
| 820 | Criterion.Type.IPV6_FLABEL, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 821 | IPv6FlowLabelCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 822 | assertThat(flowLabelCriterion.flowLabel(), is(equalTo(flowLabel))); |
| 823 | } |
| 824 | |
| 825 | /** |
| 826 | * Test the equals() method of the IPv6FlowLabelCriterion class. |
| 827 | */ |
| 828 | @Test |
| 829 | public void testIPv6FlowLabelCriterionEquals() { |
| 830 | new EqualsTester() |
| 831 | .addEqualityGroup(matchFlowLabel1, sameAsMatchFlowLabel1) |
| 832 | .addEqualityGroup(matchFlowLabel2) |
| 833 | .testEquals(); |
| 834 | } |
| 835 | |
| 836 | // Icmpv6TypeCriterion class |
| 837 | |
| 838 | /** |
| 839 | * Test the matchIcmpv6Type method. |
| 840 | */ |
| 841 | @Test |
| 842 | public void testMatchIcmpv6TypeMethod() { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 843 | short icmpv6Type = 12; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 844 | Criterion matchIcmpv6Type = Criteria.matchIcmpv6Type(icmpv6Type); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 845 | Icmpv6TypeCriterion icmpv6TypeCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 846 | checkAndConvert(matchIcmpv6Type, |
| 847 | Criterion.Type.ICMPV6_TYPE, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 848 | Icmpv6TypeCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 849 | assertThat(icmpv6TypeCriterion.icmpv6Type(), is(equalTo(icmpv6Type))); |
| 850 | } |
| 851 | |
| 852 | /** |
| 853 | * Test the equals() method of the Icmpv6TypeCriterion class. |
| 854 | */ |
| 855 | @Test |
| 856 | public void testIcmpv6TypeCriterionEquals() { |
| 857 | new EqualsTester() |
| 858 | .addEqualityGroup(matchIcmpv6Type1, sameAsMatchIcmpv6Type1) |
| 859 | .addEqualityGroup(matchIcmpv6Type2) |
| 860 | .testEquals(); |
| 861 | } |
| 862 | |
| 863 | // Icmpv6CodeCriterion class |
| 864 | |
| 865 | /** |
| 866 | * Test the matchIcmpv6Code method. |
| 867 | */ |
| 868 | @Test |
| 869 | public void testMatchIcmpv6CodeMethod() { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 870 | short icmpv6Code = 12; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 871 | Criterion matchIcmpv6Code = Criteria.matchIcmpv6Code(icmpv6Code); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 872 | Icmpv6CodeCriterion icmpv6CodeCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 873 | checkAndConvert(matchIcmpv6Code, |
| 874 | Criterion.Type.ICMPV6_CODE, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 875 | Icmpv6CodeCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 876 | assertThat(icmpv6CodeCriterion.icmpv6Code(), is(equalTo(icmpv6Code))); |
| 877 | } |
| 878 | |
| 879 | /** |
| 880 | * Test the equals() method of the Icmpv6CodeCriterion class. |
| 881 | */ |
| 882 | @Test |
| 883 | public void testIcmpv6CodeCriterionEquals() { |
| 884 | new EqualsTester() |
| 885 | .addEqualityGroup(matchIcmpv6Code1, sameAsMatchIcmpv6Code1) |
| 886 | .addEqualityGroup(matchIcmpv6Code2) |
| 887 | .testEquals(); |
| 888 | } |
| 889 | |
| 890 | // IPv6NDTargetAddressCriterion class |
| 891 | |
| 892 | /** |
| 893 | * Test the matchIPv6NDTargetAddress method. |
| 894 | */ |
| 895 | @Test |
| 896 | public void testMatchIPv6NDTargetAddressMethod() { |
| 897 | Criterion matchTargetAddress = |
| 898 | Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 899 | IPv6NDTargetAddressCriterion targetAddressCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 900 | checkAndConvert(matchTargetAddress, |
| 901 | Criterion.Type.IPV6_ND_TARGET, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 902 | IPv6NDTargetAddressCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 903 | assertThat(targetAddressCriterion.targetAddress(), |
| 904 | is(ip6TargetAddress1)); |
| 905 | } |
| 906 | |
| 907 | /** |
| 908 | * Test the equals() method of the IPv6NDTargetAddressCriterion class. |
| 909 | */ |
| 910 | @Test |
| 911 | public void testIPv6NDTargetAddressCriterionEquals() { |
| 912 | new EqualsTester() |
| 913 | .addEqualityGroup(matchIpv6TargetAddr1, |
| 914 | sameAsMatchIpv6TargetAddr1) |
| 915 | .addEqualityGroup(matchIpv6TargetAddr2) |
| 916 | .testEquals(); |
| 917 | } |
| 918 | |
| 919 | // IPv6NDLinkLayerAddressCriterion class |
| 920 | |
| 921 | /** |
| 922 | * Test the matchIPv6NDSourceLinkLayerAddress method. |
| 923 | */ |
| 924 | @Test |
| 925 | public void testMatchIPv6NDSourceLinkLayerAddressMethod() { |
| 926 | Criterion matchSrcLlAddr = |
| 927 | Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 928 | IPv6NDLinkLayerAddressCriterion srcLlCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 929 | checkAndConvert(matchSrcLlAddr, |
| 930 | Criterion.Type.IPV6_ND_SLL, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 931 | IPv6NDLinkLayerAddressCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 932 | assertThat(srcLlCriterion.mac(), is(equalTo(llMac1))); |
| 933 | } |
| 934 | |
| 935 | /** |
| 936 | * Test the matchIPv6NDTargetLinkLayerAddress method. |
| 937 | */ |
| 938 | @Test |
| 939 | public void testMatchIPv6NDTargetLinkLayerAddressMethod() { |
| 940 | Criterion matchTargetLlAddr = |
| 941 | Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 942 | IPv6NDLinkLayerAddressCriterion targetLlCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 943 | checkAndConvert(matchTargetLlAddr, |
| 944 | Criterion.Type.IPV6_ND_TLL, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 945 | IPv6NDLinkLayerAddressCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 946 | assertThat(targetLlCriterion.mac(), is(equalTo(llMac1))); |
| 947 | } |
| 948 | |
| 949 | /** |
| 950 | * Test the equals() method of the IPv6NDLinkLayerAddressCriterion class. |
| 951 | */ |
| 952 | @Test |
| 953 | public void testIPv6NDLinkLayerAddressCriterionEquals() { |
| 954 | new EqualsTester() |
| 955 | .addEqualityGroup(matchSrcLlAddr1, sameAsMatchSrcLlAddr1) |
| 956 | .addEqualityGroup(matchSrcLlAddr2) |
| 957 | .testEquals(); |
| 958 | |
| 959 | new EqualsTester() |
| 960 | .addEqualityGroup(matchTargetLlAddr1, sameAsMatchTargetLlAddr1) |
| 961 | .addEqualityGroup(matchTargetLlAddr2) |
| 962 | .testEquals(); |
| 963 | } |
| 964 | |
| 965 | // MplsCriterion class |
| 966 | |
| 967 | /** |
| 968 | * Test the matchMplsLabel method. |
| 969 | */ |
| 970 | @Test |
| 971 | public void testMatchMplsLabelMethod() { |
| 972 | Criterion matchMplsLabel = Criteria.matchMplsLabel(mpls1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 973 | MplsCriterion mplsCriterion = |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 974 | checkAndConvert(matchMplsLabel, |
| 975 | Criterion.Type.MPLS_LABEL, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 976 | MplsCriterion.class); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 977 | assertThat(mplsCriterion.label(), is(equalTo(mpls1))); |
| 978 | } |
| 979 | |
| 980 | /** |
| 981 | * Test the equals() method of the MplsCriterion class. |
| 982 | */ |
| 983 | @Test |
| 984 | public void testMplsCriterionEquals() { |
| 985 | new EqualsTester() |
| 986 | .addEqualityGroup(matchMpls1, sameAsMatchMpls1) |
| 987 | .addEqualityGroup(matchMpls2) |
| 988 | .testEquals(); |
| 989 | } |
| 990 | |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 991 | // TunnelIdCriterion class |
| 992 | |
| 993 | /** |
| 994 | * Test the matchTunnelId method. |
| 995 | */ |
| 996 | @Test |
| 997 | public void testMatchTunnelIdMethod() { |
| 998 | Criterion matchTunnelId = Criteria.matchTunnelId(tunnelId1); |
| 999 | TunnelIdCriterion tunnelIdCriterion = |
| 1000 | checkAndConvert(matchTunnelId, |
| 1001 | Criterion.Type.TUNNEL_ID, |
| 1002 | TunnelIdCriterion.class); |
| 1003 | assertThat(tunnelIdCriterion.tunnelId(), is(equalTo(tunnelId1))); |
| 1004 | |
| 1005 | } |
| 1006 | |
| 1007 | /** |
| 1008 | * Test the equals() method of the TunnelIdCriterion class. |
| 1009 | */ |
| 1010 | @Test |
| 1011 | public void testTunnelIdCriterionEquals() { |
| 1012 | new EqualsTester() |
| 1013 | .addEqualityGroup(matchTunnelId1, sameAsMatchTunnelId1) |
| 1014 | .addEqualityGroup(matchTunnelId2) |
| 1015 | .testEquals(); |
| 1016 | } |
| 1017 | |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 1018 | // IPv6ExthdrFlagsCriterion class |
| 1019 | |
| 1020 | /** |
| 1021 | * Test the matchIPv6ExthdrFlags method. |
| 1022 | */ |
| 1023 | @Test |
| 1024 | public void testMatchIPv6ExthdrFlagsMethod() { |
| 1025 | Criterion matchExthdrFlags = |
| 1026 | Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 1027 | IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 1028 | checkAndConvert(matchExthdrFlags, |
| 1029 | Criterion.Type.IPV6_EXTHDR, |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 1030 | IPv6ExthdrFlagsCriterion.class); |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 1031 | assertThat(exthdrFlagsCriterion.exthdrFlags(), |
| 1032 | is(equalTo(ipv6ExthdrFlags1))); |
| 1033 | } |
| 1034 | |
| 1035 | /** |
| 1036 | * Test the equals() method of the IPv6ExthdrFlagsCriterion class. |
| 1037 | */ |
| 1038 | @Test |
| 1039 | public void testIPv6ExthdrFlagsCriterionEquals() { |
| 1040 | new EqualsTester() |
| 1041 | .addEqualityGroup(matchIpv6ExthdrFlags1, |
| 1042 | sameAsMatchIpv6ExthdrFlags1) |
| 1043 | .addEqualityGroup(matchIpv6ExthdrFlags2) |
| 1044 | .testEquals(); |
| 1045 | } |
| 1046 | |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 1047 | @Test |
Sho SHIMIZU | efc2e28 | 2015-05-04 15:26:23 -0700 | [diff] [blame] | 1048 | public void testIndexedLambdaCriterionEquals() { |
| 1049 | new EqualsTester() |
| 1050 | .addEqualityGroup(matchIndexedLambda1, sameAsMatchIndexedLambda1) |
| 1051 | .addEqualityGroup(matchIndexedLambda2) |
| 1052 | .testEquals(); |
| 1053 | } |
| 1054 | |
| 1055 | @Test |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 1056 | public void testOchSignalCriterionEquals() { |
| 1057 | new EqualsTester() |
| 1058 | .addEqualityGroup(matchOchSignal1, sameAsMatchOchSignal1) |
| 1059 | .addEqualityGroup(matchOchSignal2) |
| 1060 | .testEquals(); |
| 1061 | } |
| 1062 | |
Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -0700 | [diff] [blame] | 1063 | /** |
| 1064 | * Test the equals() method of the OchSignalTypeCriterion class. |
| 1065 | */ |
| 1066 | @Test |
| 1067 | public void testOchSignalTypeCriterionEquals() { |
| 1068 | new EqualsTester() |
| 1069 | .addEqualityGroup(matchOchSignalType1, sameAsMatchOchSignalType1) |
| 1070 | .addEqualityGroup(matchOchSignalType2) |
| 1071 | .testEquals(); |
| 1072 | } |
Ray Milkey | 33d9023 | 2014-11-04 10:49:00 -0800 | [diff] [blame] | 1073 | } |