blob: bad60a00dd780af17f7f1cdcc81b0fdce739f16d [file] [log] [blame]
Ray Milkey33d90232014-11-04 10:49:00 -08001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Ray Milkey33d90232014-11-04 10:49:00 -08003 *
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow.criteria;
Ray Milkey33d90232014-11-04 10:49:00 -080017
18import org.junit.Test;
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -070019import org.onosproject.net.ChannelSpacing;
20import org.onosproject.net.GridType;
21import org.onosproject.net.Lambda;
Brian O'Connorabafb502014-12-02 22:26:20 -080022import org.onosproject.net.PortNumber;
Ray Milkey33d90232014-11-04 10:49:00 -080023import org.onlab.packet.IpPrefix;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080024import org.onlab.packet.Ip6Address;
Ray Milkey33d90232014-11-04 10:49:00 -080025import org.onlab.packet.MacAddress;
Michele Santuari4b6019e2014-12-19 11:31:45 +010026import org.onlab.packet.MplsLabel;
Ray Milkey33d90232014-11-04 10:49:00 -080027import org.onlab.packet.VlanId;
28
Ray Milkeyfff20b52014-11-06 14:45:10 -080029import com.google.common.testing.EqualsTester;
Sho SHIMIZU585bed92015-05-13 11:08:45 -070030import org.onosproject.net.OchSignalType;
Ray Milkeyfff20b52014-11-06 14:45:10 -080031
Ray Milkey33d90232014-11-04 10:49:00 -080032import static org.hamcrest.MatcherAssert.assertThat;
Ray Milkey33d90232014-11-04 10:49:00 -080033import static org.hamcrest.Matchers.equalTo;
34import static org.hamcrest.Matchers.instanceOf;
35import static org.hamcrest.Matchers.is;
Ray Milkey33d90232014-11-04 10:49:00 -080036import static org.hamcrest.Matchers.notNullValue;
37import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
38import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
Brian O'Connorabafb502014-12-02 22:26:20 -080039import static org.onosproject.net.PortNumber.portNumber;
Ray Milkey33d90232014-11-04 10:49:00 -080040
41/**
42 * Unit tests for the Criteria class and its subclasses.
43 */
44public 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 Radoslavovd0fd8412015-02-04 13:57:00 -080053 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 Milkey33d90232014-11-04 10:49:00 -080063 private static final String MAC1 = "00:00:00:00:00:01";
64 private static final String MAC2 = "00:00:00:00:00:02";
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080065 private MacAddress mac1 = MacAddress.valueOf(MAC1);
66 private MacAddress mac2 = MacAddress.valueOf(MAC2);
Ray Milkey33d90232014-11-04 10:49:00 -080067 Criterion matchEth1 = Criteria.matchEthSrc(mac1);
68 Criterion sameAsMatchEth1 = Criteria.matchEthSrc(mac1);
69 Criterion matchEth2 = Criteria.matchEthDst(mac2);
70
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -080071 int ethType1 = 1;
72 int ethType2 = 2;
Ray Milkey33d90232014-11-04 10:49:00 -080073 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 Radoslavovd0fd8412015-02-04 13:57:00 -080091 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 Radoslavovf3b69332015-02-06 15:47:05 -0800103 short protocol1 = 1;
104 short protocol2 = 2;
Ray Milkey33d90232014-11-04 10:49:00 -0800105 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. Chan52fae7d2015-01-17 00:35:53 +0800111 private static final String IPV61 = "fe80::1/64";
112 private static final String IPV62 = "fc80::2/64";
Ray Milkey33d90232014-11-04 10:49:00 -0800113 private IpPrefix ip1 = IpPrefix.valueOf(IP1);
114 private IpPrefix ip2 = IpPrefix.valueOf(IP2);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800115 private IpPrefix ipv61 = IpPrefix.valueOf(IPV61);
116 private IpPrefix ipv62 = IpPrefix.valueOf(IPV62);
Ray Milkey33d90232014-11-04 10:49:00 -0800117 Criterion matchIp1 = Criteria.matchIPSrc(ip1);
118 Criterion sameAsMatchIp1 = Criteria.matchIPSrc(ip1);
119 Criterion matchIp2 = Criteria.matchIPSrc(ip2);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800120 Criterion matchIpv61 = Criteria.matchIPSrc(ipv61);
121 Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61);
122 Criterion matchIpv62 = Criteria.matchIPSrc(ipv62);
Ray Milkey33d90232014-11-04 10:49:00 -0800123
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800124 Criterion matchTcpPort1 = Criteria.matchTcpSrc(1);
125 Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(1);
126 Criterion matchTcpPort2 = Criteria.matchTcpDst(2);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800127
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800128 Criterion matchUdpPort1 = Criteria.matchUdpSrc(1);
129 Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(1);
130 Criterion matchUdpPort2 = Criteria.matchUdpDst(2);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800131
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800132 Criterion matchSctpPort1 = Criteria.matchSctpSrc(1);
133 Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(1);
134 Criterion matchSctpPort2 = Criteria.matchSctpDst(2);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800135
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800136 short icmpType1 = 1;
137 short icmpType2 = 2;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800138 Criterion matchIcmpType1 = Criteria.matchIcmpType(icmpType1);
139 Criterion sameAsMatchIcmpType1 = Criteria.matchIcmpType(icmpType1);
140 Criterion matchIcmpType2 = Criteria.matchIcmpType(icmpType2);
141
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800142 short icmpCode1 = 1;
143 short icmpCode2 = 2;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800144 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 Radoslavovf3b69332015-02-06 15:47:05 -0800154 short icmpv6Type1 = 1;
155 short icmpv6Type2 = 2;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800156 Criterion matchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1);
157 Criterion sameAsMatchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1);
158 Criterion matchIcmpv6Type2 = Criteria.matchIcmpv6Type(icmpv6Type2);
159
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800160 short icmpv6Code1 = 1;
161 short icmpv6Code2 = 2;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800162 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 Santuari4b6019e2014-12-19 11:31:45 +0100194 MplsLabel mpls1 = MplsLabel.mplsLabel(1);
195 MplsLabel mpls2 = MplsLabel.mplsLabel(2);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800196 Criterion matchMpls1 = Criteria.matchMplsLabel(mpls1);
197 Criterion sameAsMatchMpls1 = Criteria.matchMplsLabel(mpls1);
198 Criterion matchMpls2 = Criteria.matchMplsLabel(mpls2);
199
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800200 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 Radoslavovf3b69332015-02-06 15:47:05 -0800218 int lambda1 = 1;
219 int lambda2 = 2;
Ray Milkey33d90232014-11-04 10:49:00 -0800220 Criterion matchLambda1 = Criteria.matchLambda(lambda1);
221 Criterion sameAsMatchLambda1 = Criteria.matchLambda(lambda1);
222 Criterion matchLambda2 = Criteria.matchLambda(lambda2);
223
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700224 Criterion matchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID);
225 Criterion sameAsMatchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID);
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700226 Criterion matchOchSignalType2 = Criteria.matchOchSignalType(OchSignalType.FLEX_GRID);
227
Sho SHIMIZUefc2e282015-05-04 15:26:23 -0700228 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 Radoslavov5e4f7542015-02-06 18:18:21 -0800232 short signalLambda1 = 1;
233 short signalLambda2 = 2;
Ray Milkey33d90232014-11-04 10:49:00 -0800234 Criterion matchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1);
235 Criterion sameAsMatchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1);
236 Criterion matchSignalLambda2 = Criteria.matchOpticalSignalType(signalLambda2);
237
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700238 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 Milkey33d90232014-11-04 10:49:00 -0800245 /**
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 Milkey78081052014-11-05 10:38:12 -0800259 assertThat(criterion, instanceOf(clazz));
Ray Milkey33d90232014-11-04 10:49:00 -0800260 return (T) criterion;
261 }
262
263 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800264 * 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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700276 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 Milkey33d90232014-11-04 10:49:00 -0800300 }
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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700311 PortCriterion portCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -0800312 checkAndConvert(matchInPort,
313 Criterion.Type.IN_PORT,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700314 PortCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800315 assertThat(portCriterion.port(), is(equalTo(p1)));
316 }
317
318 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800319 * Test the matchInPhyPort method.
320 */
321 @Test
322 public void testMatchInPhyPortMethod() {
323 PortNumber p1 = portNumber(1);
324 Criterion matchInPhyPort = Criteria.matchInPhyPort(p1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700325 PortCriterion portCriterion =
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800326 checkAndConvert(matchInPhyPort,
327 Criterion.Type.IN_PHY_PORT,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700328 PortCriterion.class);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800329 assertThat(portCriterion.port(), is(equalTo(p1)));
330 }
331
332 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800333 * Test the equals() method of the PortCriterion class.
334 */
335 @Test
336 public void testPortCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800337 new EqualsTester()
338 .addEqualityGroup(matchInPort1, sameAsMatchInPort1)
339 .addEqualityGroup(matchInPort2)
340 .testEquals();
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800341
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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700357 MetadataCriterion metadataCriterion =
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800358 checkAndConvert(matchMetadata,
359 Criterion.Type.METADATA,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700360 MetadataCriterion.class);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800361 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 Milkey33d90232014-11-04 10:49:00 -0800373 }
374
375 // EthCriterion class
376
377 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800378 * Test the matchEthDst method.
379 */
380 @Test
381 public void testMatchEthDstMethod() {
382 Criterion matchEthDst = Criteria.matchEthDst(mac1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700383 EthCriterion ethCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800384 checkAndConvert(matchEthDst,
385 Criterion.Type.ETH_DST,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700386 EthCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800387 assertThat(ethCriterion.mac(), is(equalTo(mac1)));
388 }
389
390 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800391 * Test the matchEthSrc method.
392 */
393 @Test
394 public void testMatchEthSrcMethod() {
395 Criterion matchEthSrc = Criteria.matchEthSrc(mac1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700396 EthCriterion ethCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -0800397 checkAndConvert(matchEthSrc,
398 Criterion.Type.ETH_SRC,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700399 EthCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800400 assertThat(ethCriterion.mac(), is(mac1));
401 }
402
403 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800404 * Test the equals() method of the EthCriterion class.
405 */
406 @Test
407 public void testEthCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800408 new EqualsTester()
409 .addEqualityGroup(matchEth1, sameAsMatchEth1)
410 .addEqualityGroup(matchEth2)
411 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800412 }
413
Ray Milkey33d90232014-11-04 10:49:00 -0800414 // EthTypeCriterion class
415
416 /**
417 * Test the matchEthType method.
418 */
419 @Test
420 public void testMatchEthTypeMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800421 int ethType = 12;
Ray Milkey33d90232014-11-04 10:49:00 -0800422 Criterion matchEthType = Criteria.matchEthType(ethType);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700423 EthTypeCriterion ethTypeCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -0800424 checkAndConvert(matchEthType,
425 Criterion.Type.ETH_TYPE,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700426 EthTypeCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800427 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 Milkeyfff20b52014-11-06 14:45:10 -0800435 new EqualsTester()
436 .addEqualityGroup(matchEthType1, sameAsMatchEthType1)
437 .addEqualityGroup(matchEthType2)
438 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800439 }
440
Ray Milkey33d90232014-11-04 10:49:00 -0800441 // VlanIdCriterion class
442
443 /**
444 * Test the matchVlanId method.
445 */
446 @Test
447 public void testMatchVlanIdMethod() {
448 Criterion matchVlanId = Criteria.matchVlanId(vlanId1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700449 VlanIdCriterion vlanIdCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -0800450 checkAndConvert(matchVlanId,
451 Criterion.Type.VLAN_VID,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700452 VlanIdCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800453 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 Milkeyfff20b52014-11-06 14:45:10 -0800461 new EqualsTester()
462 .addEqualityGroup(matchVlanId1, sameAsMatchVlanId1)
463 .addEqualityGroup(matchVlanId2)
464 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800465 }
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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700475 VlanPcpCriterion vlanPcpCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -0800476 checkAndConvert(matchVlanPcp,
477 Criterion.Type.VLAN_PCP,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700478 VlanPcpCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800479 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 Milkeyfff20b52014-11-06 14:45:10 -0800487 new EqualsTester()
488 .addEqualityGroup(matchVlanPcp1, sameAsMatchVlanPcp1)
489 .addEqualityGroup(matchVlanPcp2)
490 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800491 }
492
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800493 // IPDscpCriterion class
494
495 /**
496 * Test the matchIPDscp method.
497 */
498 @Test
499 public void testMatchIPDscpMethod() {
500 Criterion matchIPDscp = Criteria.matchIPDscp(ipDscp1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700501 IPDscpCriterion ipDscpCriterion =
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800502 checkAndConvert(matchIPDscp,
503 Criterion.Type.IP_DSCP,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700504 IPDscpCriterion.class);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800505 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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700527 IPEcnCriterion ipEcnCriterion =
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800528 checkAndConvert(matchIPEcn,
529 Criterion.Type.IP_ECN,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700530 IPEcnCriterion.class);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800531 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 Milkey33d90232014-11-04 10:49:00 -0800545 // IpProtocolCriterion class
546
547 /**
548 * Test the matchIpProtocol method.
549 */
550 @Test
551 public void testMatchIpProtocolMethod() {
552 Criterion matchIPProtocol = Criteria.matchIPProtocol(protocol1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700553 IPProtocolCriterion ipProtocolCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -0800554 checkAndConvert(matchIPProtocol,
555 Criterion.Type.IP_PROTO,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700556 IPProtocolCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800557 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 Milkeyfff20b52014-11-06 14:45:10 -0800565 new EqualsTester()
566 .addEqualityGroup(matchIpProtocol1, sameAsMatchIpProtocol1)
567 .addEqualityGroup(matchIpProtocol2)
568 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800569 }
570
571 // IPCriterion class
572
573 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800574 * Test the matchIPSrc method: IPv4.
Ray Milkey33d90232014-11-04 10:49:00 -0800575 */
576 @Test
577 public void testMatchIPSrcMethod() {
578 Criterion matchIpSrc = Criteria.matchIPSrc(ip1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700579 IPCriterion ipCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -0800580 checkAndConvert(matchIpSrc,
581 Criterion.Type.IPV4_SRC,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700582 IPCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800583 assertThat(ipCriterion.ip(), is(ip1));
584 }
585
586 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800587 * Test the matchIPDst method: IPv4.
Ray Milkey33d90232014-11-04 10:49:00 -0800588 */
589 @Test
590 public void testMatchIPDstMethod() {
591 Criterion matchIPDst = Criteria.matchIPDst(ip1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700592 IPCriterion ipCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -0800593 checkAndConvert(matchIPDst,
594 Criterion.Type.IPV4_DST,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700595 IPCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800596 assertThat(ipCriterion.ip(), is(equalTo(ip1)));
597 }
598
599 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800600 * Test the matchIPSrc method: IPv6.
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800601 */
602 @Test
603 public void testMatchIPv6SrcMethod() {
604 Criterion matchIpv6Src = Criteria.matchIPv6Src(ipv61);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700605 IPCriterion ipCriterion =
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800606 checkAndConvert(matchIpv6Src,
607 Criterion.Type.IPV6_SRC,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700608 IPCriterion.class);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800609 assertThat(ipCriterion.ip(), is(ipv61));
610 }
611
612 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800613 * Test the matchIPDst method: IPv6.
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800614 */
615 @Test
616 public void testMatchIPv6DstMethod() {
617 Criterion matchIPv6Dst = Criteria.matchIPv6Dst(ipv61);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700618 IPCriterion ipCriterion =
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800619 checkAndConvert(matchIPv6Dst,
620 Criterion.Type.IPV6_DST,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700621 IPCriterion.class);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800622 assertThat(ipCriterion.ip(), is(equalTo(ipv61)));
623 }
624
625 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800626 * Test the equals() method of the IpCriterion class.
627 */
628 @Test
629 public void testIPCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800630 new EqualsTester()
631 .addEqualityGroup(matchIp1, sameAsMatchIp1)
632 .addEqualityGroup(matchIp2)
633 .testEquals();
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800634
635 new EqualsTester()
636 .addEqualityGroup(matchIpv61, sameAsMatchIpv61)
637 .addEqualityGroup(matchIpv62)
638 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800639 }
640
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800641 // TcpPortCriterion class
642
643 /**
644 * Test the matchTcpSrc method.
645 */
646 @Test
647 public void testMatchTcpSrcMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800648 Criterion matchTcpSrc = Criteria.matchTcpSrc(1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700649 TcpPortCriterion tcpPortCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800650 checkAndConvert(matchTcpSrc,
651 Criterion.Type.TCP_SRC,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700652 TcpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800653 assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800654 }
655
656 /**
657 * Test the matchTcpDst method.
658 */
659 @Test
660 public void testMatchTcpDstMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800661 Criterion matchTcpDst = Criteria.matchTcpDst(1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700662 TcpPortCriterion tcpPortCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800663 checkAndConvert(matchTcpDst,
664 Criterion.Type.TCP_DST,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700665 TcpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800666 assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800667 }
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 Radoslavovf3b69332015-02-06 15:47:05 -0800687 Criterion matchUdpSrc = Criteria.matchUdpSrc(1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700688 UdpPortCriterion udpPortCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800689 checkAndConvert(matchUdpSrc,
690 Criterion.Type.UDP_SRC,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700691 UdpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800692 assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800693 }
694
695 /**
696 * Test the matchUdpDst method.
697 */
698 @Test
699 public void testMatchUdpDstMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800700 Criterion matchUdpDst = Criteria.matchUdpDst(1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700701 UdpPortCriterion udpPortCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800702 checkAndConvert(matchUdpDst,
703 Criterion.Type.UDP_DST,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700704 UdpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800705 assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800706 }
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 Radoslavovf3b69332015-02-06 15:47:05 -0800726 Criterion matchSctpSrc = Criteria.matchSctpSrc(1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700727 SctpPortCriterion sctpPortCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800728 checkAndConvert(matchSctpSrc,
729 Criterion.Type.SCTP_SRC,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700730 SctpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800731 assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800732 }
733
734 /**
735 * Test the matchSctpDst method.
736 */
737 @Test
738 public void testMatchSctpDstMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800739 Criterion matchSctpDst = Criteria.matchSctpDst(1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700740 SctpPortCriterion sctpPortCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800741 checkAndConvert(matchSctpDst,
742 Criterion.Type.SCTP_DST,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700743 SctpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800744 assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800745 }
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 Radoslavovf3b69332015-02-06 15:47:05 -0800765 short icmpType = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800766 Criterion matchIcmpType = Criteria.matchIcmpType(icmpType);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700767 IcmpTypeCriterion icmpTypeCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800768 checkAndConvert(matchIcmpType,
769 Criterion.Type.ICMPV4_TYPE,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700770 IcmpTypeCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800771 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 Radoslavovf3b69332015-02-06 15:47:05 -0800792 short icmpCode = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800793 Criterion matchIcmpCode = Criteria.matchIcmpCode(icmpCode);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700794 IcmpCodeCriterion icmpCodeCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800795 checkAndConvert(matchIcmpCode,
796 Criterion.Type.ICMPV4_CODE,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700797 IcmpCodeCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800798 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 Radoslavovf3b69332015-02-06 15:47:05 -0800819 int flowLabel = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800820 Criterion matchFlowLabel = Criteria.matchIPv6FlowLabel(flowLabel);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700821 IPv6FlowLabelCriterion flowLabelCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800822 checkAndConvert(matchFlowLabel,
823 Criterion.Type.IPV6_FLABEL,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700824 IPv6FlowLabelCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800825 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 Radoslavovf3b69332015-02-06 15:47:05 -0800846 short icmpv6Type = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800847 Criterion matchIcmpv6Type = Criteria.matchIcmpv6Type(icmpv6Type);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700848 Icmpv6TypeCriterion icmpv6TypeCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800849 checkAndConvert(matchIcmpv6Type,
850 Criterion.Type.ICMPV6_TYPE,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700851 Icmpv6TypeCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800852 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 Radoslavovf3b69332015-02-06 15:47:05 -0800873 short icmpv6Code = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800874 Criterion matchIcmpv6Code = Criteria.matchIcmpv6Code(icmpv6Code);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700875 Icmpv6CodeCriterion icmpv6CodeCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800876 checkAndConvert(matchIcmpv6Code,
877 Criterion.Type.ICMPV6_CODE,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700878 Icmpv6CodeCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800879 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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700902 IPv6NDTargetAddressCriterion targetAddressCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800903 checkAndConvert(matchTargetAddress,
904 Criterion.Type.IPV6_ND_TARGET,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700905 IPv6NDTargetAddressCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800906 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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700931 IPv6NDLinkLayerAddressCriterion srcLlCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800932 checkAndConvert(matchSrcLlAddr,
933 Criterion.Type.IPV6_ND_SLL,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700934 IPv6NDLinkLayerAddressCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800935 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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700945 IPv6NDLinkLayerAddressCriterion targetLlCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800946 checkAndConvert(matchTargetLlAddr,
947 Criterion.Type.IPV6_ND_TLL,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700948 IPv6NDLinkLayerAddressCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800949 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 SHIMIZUfbc80e52015-04-28 10:41:58 -0700976 MplsCriterion mplsCriterion =
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800977 checkAndConvert(matchMplsLabel,
978 Criterion.Type.MPLS_LABEL,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -0700979 MplsCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800980 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 Radoslavov5e4f7542015-02-06 18:18:21 -0800994 // IPv6ExthdrFlagsCriterion class
995
996 /**
997 * Test the matchIPv6ExthdrFlags method.
998 */
999 @Test
1000 public void testMatchIPv6ExthdrFlagsMethod() {
1001 Criterion matchExthdrFlags =
1002 Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -07001003 IPv6ExthdrFlagsCriterion exthdrFlagsCriterion =
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -08001004 checkAndConvert(matchExthdrFlags,
1005 Criterion.Type.IPV6_EXTHDR,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -07001006 IPv6ExthdrFlagsCriterion.class);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -08001007 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 Milkey33d90232014-11-04 10:49:00 -08001023 // LambdaCriterion class
1024
1025 /**
1026 * Test the matchLambda method.
1027 */
1028 @Test
1029 public void testMatchLambdaMethod() {
1030 Criterion matchLambda = Criteria.matchLambda(lambda1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -07001031 LambdaCriterion lambdaCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -08001032 checkAndConvert(matchLambda,
1033 Criterion.Type.OCH_SIGID,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -07001034 LambdaCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -08001035 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 Milkeyfff20b52014-11-06 14:45:10 -08001043 new EqualsTester()
1044 .addEqualityGroup(matchLambda1, sameAsMatchLambda1)
1045 .addEqualityGroup(matchLambda2)
1046 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -08001047 }
1048
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -07001049 @Test
Sho SHIMIZUefc2e282015-05-04 15:26:23 -07001050 public void testIndexedLambdaCriterionEquals() {
1051 new EqualsTester()
1052 .addEqualityGroup(matchIndexedLambda1, sameAsMatchIndexedLambda1)
1053 .addEqualityGroup(matchIndexedLambda2)
1054 .testEquals();
1055 }
1056
1057 @Test
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -07001058 public void testOchSignalCriterionEquals() {
1059 new EqualsTester()
1060 .addEqualityGroup(matchOchSignal1, sameAsMatchOchSignal1)
1061 .addEqualityGroup(matchOchSignal2)
1062 .testEquals();
1063 }
1064
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -07001065 /**
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 Milkey33d90232014-11-04 10:49:00 -08001076 // OpticalSignalTypeCriterion class
1077
1078 /**
1079 * Test the matchOpticalSignalType method.
1080 */
1081 @Test
1082 public void testMatchOpticalSignalTypeMethod() {
1083 Criterion matchLambda = Criteria.matchOpticalSignalType(signalLambda1);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -07001084 OpticalSignalTypeCriterion opticalSignalTypeCriterion =
Ray Milkey33d90232014-11-04 10:49:00 -08001085 checkAndConvert(matchLambda,
1086 Criterion.Type.OCH_SIGTYPE,
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -07001087 OpticalSignalTypeCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -08001088 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 Milkeyfff20b52014-11-06 14:45:10 -08001096 new EqualsTester()
1097 .addEqualityGroup(matchSignalLambda1, sameAsMatchSignalLambda1)
1098 .addEqualityGroup(matchSignalLambda2)
1099 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -08001100 }
Ray Milkey33d90232014-11-04 10:49:00 -08001101}