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