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