blob: eb8d3b2452cbeedea260c6da7c368b2be65396c3 [file] [log] [blame]
Ray Milkey33d90232014-11-04 10:49:00 -08001/*
2 * Copyright 2014 Open Networking Laboratory
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow.criteria;
Ray Milkey33d90232014-11-04 10:49:00 -080017
18import org.junit.Test;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.net.PortNumber;
Ray Milkey33d90232014-11-04 10:49:00 -080020import org.onlab.packet.IpPrefix;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080021import org.onlab.packet.Ip6Address;
Ray Milkey33d90232014-11-04 10:49:00 -080022import org.onlab.packet.MacAddress;
Michele Santuari4b6019e2014-12-19 11:31:45 +010023import org.onlab.packet.MplsLabel;
Ray Milkey33d90232014-11-04 10:49:00 -080024import org.onlab.packet.VlanId;
25
Ray Milkeyfff20b52014-11-06 14:45:10 -080026import com.google.common.testing.EqualsTester;
27
Ray Milkey33d90232014-11-04 10:49:00 -080028import static org.hamcrest.MatcherAssert.assertThat;
Ray Milkey33d90232014-11-04 10:49:00 -080029import static org.hamcrest.Matchers.equalTo;
30import static org.hamcrest.Matchers.instanceOf;
31import static org.hamcrest.Matchers.is;
Ray Milkey33d90232014-11-04 10:49:00 -080032import static org.hamcrest.Matchers.notNullValue;
33import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
34import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
Brian O'Connorabafb502014-12-02 22:26:20 -080035import static org.onosproject.net.PortNumber.portNumber;
Ray Milkey33d90232014-11-04 10:49:00 -080036
37/**
38 * Unit tests for the Criteria class and its subclasses.
39 */
40public class CriteriaTest {
41
42 final PortNumber port1 = portNumber(1);
43 final PortNumber port2 = portNumber(2);
44
45 Criterion matchInPort1 = Criteria.matchInPort(port1);
46 Criterion sameAsMatchInPort1 = Criteria.matchInPort(port1);
47 Criterion matchInPort2 = Criteria.matchInPort(port2);
48
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080049 Criterion matchInPhyPort1 = Criteria.matchInPhyPort(port1);
50 Criterion sameAsMatchInPhyPort1 = Criteria.matchInPhyPort(port1);
51 Criterion matchInPhyPort2 = Criteria.matchInPhyPort(port2);
52
53 long metadata1 = 1;
54 long metadata2 = 2;
55 Criterion matchMetadata1 = Criteria.matchMetadata(metadata1);
56 Criterion sameAsMatchMetadata1 = Criteria.matchMetadata(metadata1);
57 Criterion matchMetadata2 = Criteria.matchMetadata(metadata2);
58
Ray Milkey33d90232014-11-04 10:49:00 -080059 private static final String MAC1 = "00:00:00:00:00:01";
60 private static final String MAC2 = "00:00:00:00:00:02";
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080061 private MacAddress mac1 = MacAddress.valueOf(MAC1);
62 private MacAddress mac2 = MacAddress.valueOf(MAC2);
Ray Milkey33d90232014-11-04 10:49:00 -080063 Criterion matchEth1 = Criteria.matchEthSrc(mac1);
64 Criterion sameAsMatchEth1 = Criteria.matchEthSrc(mac1);
65 Criterion matchEth2 = Criteria.matchEthDst(mac2);
66
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -080067 int ethType1 = 1;
68 int ethType2 = 2;
Ray Milkey33d90232014-11-04 10:49:00 -080069 Criterion matchEthType1 = Criteria.matchEthType(ethType1);
70 Criterion sameAsMatchEthType1 = Criteria.matchEthType(ethType1);
71 Criterion matchEthType2 = Criteria.matchEthType(ethType2);
72
73 short vlan1 = 1;
74 short vlan2 = 2;
75 VlanId vlanId1 = VlanId.vlanId(vlan1);
76 VlanId vlanId2 = VlanId.vlanId(vlan2);
77 Criterion matchVlanId1 = Criteria.matchVlanId(vlanId1);
78 Criterion sameAsMatchVlanId1 = Criteria.matchVlanId(vlanId1);
79 Criterion matchVlanId2 = Criteria.matchVlanId(vlanId2);
80
81 byte vlanPcp1 = 1;
82 byte vlanPcp2 = 2;
83 Criterion matchVlanPcp1 = Criteria.matchVlanPcp(vlanPcp1);
84 Criterion sameAsMatchVlanPcp1 = Criteria.matchVlanPcp(vlanPcp1);
85 Criterion matchVlanPcp2 = Criteria.matchVlanPcp(vlanPcp2);
86
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080087 byte ipDscp1 = 1;
88 byte ipDscp2 = 2;
89 Criterion matchIpDscp1 = Criteria.matchIPDscp(ipDscp1);
90 Criterion sameAsMatchIpDscp1 = Criteria.matchIPDscp(ipDscp1);
91 Criterion matchIpDscp2 = Criteria.matchIPDscp(ipDscp2);
92
93 byte ipEcn1 = 1;
94 byte ipEcn2 = 2;
95 Criterion matchIpEcn1 = Criteria.matchIPEcn(ipEcn1);
96 Criterion sameAsMatchIpEcn1 = Criteria.matchIPEcn(ipEcn1);
97 Criterion matchIpEcn2 = Criteria.matchIPEcn(ipEcn2);
98
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -080099 short protocol1 = 1;
100 short protocol2 = 2;
Ray Milkey33d90232014-11-04 10:49:00 -0800101 Criterion matchIpProtocol1 = Criteria.matchIPProtocol(protocol1);
102 Criterion sameAsMatchIpProtocol1 = Criteria.matchIPProtocol(protocol1);
103 Criterion matchIpProtocol2 = Criteria.matchIPProtocol(protocol2);
104
105 private static final String IP1 = "1.2.3.4/24";
106 private static final String IP2 = "5.6.7.8/24";
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800107 private static final String IPV61 = "fe80::1/64";
108 private static final String IPV62 = "fc80::2/64";
Ray Milkey33d90232014-11-04 10:49:00 -0800109 private IpPrefix ip1 = IpPrefix.valueOf(IP1);
110 private IpPrefix ip2 = IpPrefix.valueOf(IP2);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800111 private IpPrefix ipv61 = IpPrefix.valueOf(IPV61);
112 private IpPrefix ipv62 = IpPrefix.valueOf(IPV62);
Ray Milkey33d90232014-11-04 10:49:00 -0800113 Criterion matchIp1 = Criteria.matchIPSrc(ip1);
114 Criterion sameAsMatchIp1 = Criteria.matchIPSrc(ip1);
115 Criterion matchIp2 = Criteria.matchIPSrc(ip2);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800116 Criterion matchIpv61 = Criteria.matchIPSrc(ipv61);
117 Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61);
118 Criterion matchIpv62 = Criteria.matchIPSrc(ipv62);
Ray Milkey33d90232014-11-04 10:49:00 -0800119
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800120 Criterion matchTcpPort1 = Criteria.matchTcpSrc(1);
121 Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(1);
122 Criterion matchTcpPort2 = Criteria.matchTcpDst(2);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800123
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800124 Criterion matchUdpPort1 = Criteria.matchUdpSrc(1);
125 Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(1);
126 Criterion matchUdpPort2 = Criteria.matchUdpDst(2);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800127
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800128 Criterion matchSctpPort1 = Criteria.matchSctpSrc(1);
129 Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(1);
130 Criterion matchSctpPort2 = Criteria.matchSctpDst(2);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800131
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800132 short icmpType1 = 1;
133 short icmpType2 = 2;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800134 Criterion matchIcmpType1 = Criteria.matchIcmpType(icmpType1);
135 Criterion sameAsMatchIcmpType1 = Criteria.matchIcmpType(icmpType1);
136 Criterion matchIcmpType2 = Criteria.matchIcmpType(icmpType2);
137
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800138 short icmpCode1 = 1;
139 short icmpCode2 = 2;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800140 Criterion matchIcmpCode1 = Criteria.matchIcmpCode(icmpCode1);
141 Criterion sameAsMatchIcmpCode1 = Criteria.matchIcmpCode(icmpCode1);
142 Criterion matchIcmpCode2 = Criteria.matchIcmpCode(icmpCode2);
143
144 int flowLabel1 = 1;
145 int flowLabel2 = 2;
146 Criterion matchFlowLabel1 = Criteria.matchIPv6FlowLabel(flowLabel1);
147 Criterion sameAsMatchFlowLabel1 = Criteria.matchIPv6FlowLabel(flowLabel1);
148 Criterion matchFlowLabel2 = Criteria.matchIPv6FlowLabel(flowLabel2);
149
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800150 short icmpv6Type1 = 1;
151 short icmpv6Type2 = 2;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800152 Criterion matchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1);
153 Criterion sameAsMatchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1);
154 Criterion matchIcmpv6Type2 = Criteria.matchIcmpv6Type(icmpv6Type2);
155
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800156 short icmpv6Code1 = 1;
157 short icmpv6Code2 = 2;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800158 Criterion matchIcmpv6Code1 = Criteria.matchIcmpv6Code(icmpv6Code1);
159 Criterion sameAsMatchIcmpv6Code1 = Criteria.matchIcmpv6Code(icmpv6Code1);
160 Criterion matchIcmpv6Code2 = Criteria.matchIcmpv6Code(icmpv6Code2);
161
162 private static final String IPV6_ADDR1 = "fe80::1";
163 private static final String IPV6_ADDR2 = "fe80::2";
164 private Ip6Address ip6TargetAddress1 = Ip6Address.valueOf(IPV6_ADDR1);
165 private Ip6Address ip6TargetAddress2 = Ip6Address.valueOf(IPV6_ADDR2);
166 Criterion matchIpv6TargetAddr1 =
167 Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
168 Criterion sameAsMatchIpv6TargetAddr1 =
169 Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
170 Criterion matchIpv6TargetAddr2 =
171 Criteria.matchIPv6NDTargetAddress(ip6TargetAddress2);
172
173 private static final String LL_MAC1 = "00:00:00:00:00:01";
174 private static final String LL_MAC2 = "00:00:00:00:00:02";
175 private MacAddress llMac1 = MacAddress.valueOf(LL_MAC1);
176 private MacAddress llMac2 = MacAddress.valueOf(LL_MAC2);
177 Criterion matchSrcLlAddr1 =
178 Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
179 Criterion sameAsMatchSrcLlAddr1 =
180 Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
181 Criterion matchSrcLlAddr2 =
182 Criteria.matchIPv6NDSourceLinkLayerAddress(llMac2);
183 Criterion matchTargetLlAddr1 =
184 Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
185 Criterion sameAsMatchTargetLlAddr1 =
186 Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
187 Criterion matchTargetLlAddr2 =
188 Criteria.matchIPv6NDTargetLinkLayerAddress(llMac2);
189
Michele Santuari4b6019e2014-12-19 11:31:45 +0100190 MplsLabel mpls1 = MplsLabel.mplsLabel(1);
191 MplsLabel mpls2 = MplsLabel.mplsLabel(2);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800192 Criterion matchMpls1 = Criteria.matchMplsLabel(mpls1);
193 Criterion sameAsMatchMpls1 = Criteria.matchMplsLabel(mpls1);
194 Criterion matchMpls2 = Criteria.matchMplsLabel(mpls2);
195
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800196 int ipv6ExthdrFlags1 =
197 Criterion.IPv6ExthdrFlags.NONEXT.getValue() |
198 Criterion.IPv6ExthdrFlags.ESP.getValue() |
199 Criterion.IPv6ExthdrFlags.AUTH.getValue() |
200 Criterion.IPv6ExthdrFlags.DEST.getValue() |
201 Criterion.IPv6ExthdrFlags.FRAG.getValue() |
202 Criterion.IPv6ExthdrFlags.ROUTER.getValue() |
203 Criterion.IPv6ExthdrFlags.HOP.getValue() |
204 Criterion.IPv6ExthdrFlags.UNREP.getValue();
205 int ipv6ExthdrFlags2 = ipv6ExthdrFlags1 |
206 Criterion.IPv6ExthdrFlags.UNSEQ.getValue();
207 Criterion matchIpv6ExthdrFlags1 =
208 Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
209 Criterion sameAsMatchIpv6ExthdrFlags1 =
210 Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
211 Criterion matchIpv6ExthdrFlags2 =
212 Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags2);
213
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800214 int lambda1 = 1;
215 int lambda2 = 2;
Ray Milkey33d90232014-11-04 10:49:00 -0800216 Criterion matchLambda1 = Criteria.matchLambda(lambda1);
217 Criterion sameAsMatchLambda1 = Criteria.matchLambda(lambda1);
218 Criterion matchLambda2 = Criteria.matchLambda(lambda2);
219
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800220 short signalLambda1 = 1;
221 short signalLambda2 = 2;
Ray Milkey33d90232014-11-04 10:49:00 -0800222 Criterion matchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1);
223 Criterion sameAsMatchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1);
224 Criterion matchSignalLambda2 = Criteria.matchOpticalSignalType(signalLambda2);
225
226 /**
227 * Checks that a Criterion object has the proper type, and then converts
228 * it to the proper type.
229 *
230 * @param criterion Criterion object to convert
231 * @param type Enumerated type value for the Criterion class
232 * @param clazz Desired Criterion class
233 * @param <T> The type the caller wants returned
234 * @return converted object
235 */
236 @SuppressWarnings("unchecked")
237 private <T> T checkAndConvert(Criterion criterion, Criterion.Type type, Class clazz) {
238 assertThat(criterion, is(notNullValue()));
239 assertThat(criterion.type(), is(equalTo(type)));
Ray Milkey78081052014-11-05 10:38:12 -0800240 assertThat(criterion, instanceOf(clazz));
Ray Milkey33d90232014-11-04 10:49:00 -0800241 return (T) criterion;
242 }
243
244 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800245 * Check that the Criteria class is a valid utility class.
246 */
247 @Test
248 public void testCriteriaUtility() {
249 assertThatClassIsUtility(Criteria.class);
250 }
251
252 /**
253 * Check that the Criteria implementations are immutable.
254 */
255 @Test
256 public void testCriteriaImmutability() {
257 assertThatClassIsImmutable(Criteria.PortCriterion.class);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800258 assertThatClassIsImmutable(Criteria.MetadataCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800259 assertThatClassIsImmutable(Criteria.EthCriterion.class);
260 assertThatClassIsImmutable(Criteria.EthTypeCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800261 assertThatClassIsImmutable(Criteria.VlanIdCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800262 assertThatClassIsImmutable(Criteria.VlanPcpCriterion.class);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800263 assertThatClassIsImmutable(Criteria.IPDscpCriterion.class);
264 assertThatClassIsImmutable(Criteria.IPEcnCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800265 assertThatClassIsImmutable(Criteria.IPProtocolCriterion.class);
266 assertThatClassIsImmutable(Criteria.IPCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800267 assertThatClassIsImmutable(Criteria.TcpPortCriterion.class);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800268 assertThatClassIsImmutable(Criteria.UdpPortCriterion.class);
269 assertThatClassIsImmutable(Criteria.SctpPortCriterion.class);
270 assertThatClassIsImmutable(Criteria.IcmpTypeCriterion.class);
271 assertThatClassIsImmutable(Criteria.IcmpCodeCriterion.class);
272 assertThatClassIsImmutable(Criteria.IPv6FlowLabelCriterion.class);
273 assertThatClassIsImmutable(Criteria.Icmpv6TypeCriterion.class);
274 assertThatClassIsImmutable(Criteria.Icmpv6CodeCriterion.class);
275 assertThatClassIsImmutable(Criteria.IPv6NDTargetAddressCriterion.class);
276 assertThatClassIsImmutable(Criteria.IPv6NDLinkLayerAddressCriterion.class);
277 assertThatClassIsImmutable(Criteria.MplsCriterion.class);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800278 assertThatClassIsImmutable(Criteria.IPv6ExthdrFlagsCriterion.class);
Ray Milkey33d90232014-11-04 10:49:00 -0800279 assertThatClassIsImmutable(Criteria.LambdaCriterion.class);
280 assertThatClassIsImmutable(Criteria.OpticalSignalTypeCriterion.class);
281 }
282
283 // PortCriterion class
284
285 /**
286 * Test the matchInPort method.
287 */
288 @Test
289 public void testMatchInPortMethod() {
290 PortNumber p1 = portNumber(1);
291 Criterion matchInPort = Criteria.matchInPort(p1);
292 Criteria.PortCriterion portCriterion =
293 checkAndConvert(matchInPort,
294 Criterion.Type.IN_PORT,
295 Criteria.PortCriterion.class);
296 assertThat(portCriterion.port(), is(equalTo(p1)));
297 }
298
299 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800300 * Test the matchInPhyPort method.
301 */
302 @Test
303 public void testMatchInPhyPortMethod() {
304 PortNumber p1 = portNumber(1);
305 Criterion matchInPhyPort = Criteria.matchInPhyPort(p1);
306 Criteria.PortCriterion portCriterion =
307 checkAndConvert(matchInPhyPort,
308 Criterion.Type.IN_PHY_PORT,
309 Criteria.PortCriterion.class);
310 assertThat(portCriterion.port(), is(equalTo(p1)));
311 }
312
313 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800314 * Test the equals() method of the PortCriterion class.
315 */
316 @Test
317 public void testPortCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800318 new EqualsTester()
319 .addEqualityGroup(matchInPort1, sameAsMatchInPort1)
320 .addEqualityGroup(matchInPort2)
321 .testEquals();
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800322
323 new EqualsTester()
324 .addEqualityGroup(matchInPhyPort1, sameAsMatchInPhyPort1)
325 .addEqualityGroup(matchInPhyPort2)
326 .testEquals();
327 }
328
329 // MetadataCriterion class
330
331 /**
332 * Test the matchMetadata method.
333 */
334 @Test
335 public void testMatchMetadataMethod() {
336 Long metadata = 12L;
337 Criterion matchMetadata = Criteria.matchMetadata(metadata);
338 Criteria.MetadataCriterion metadataCriterion =
339 checkAndConvert(matchMetadata,
340 Criterion.Type.METADATA,
341 Criteria.MetadataCriterion.class);
342 assertThat(metadataCriterion.metadata(), is(equalTo(metadata)));
343 }
344
345 /**
346 * Test the equals() method of the MetadataCriterion class.
347 */
348 @Test
349 public void testMetadataCriterionEquals() {
350 new EqualsTester()
351 .addEqualityGroup(matchMetadata1, sameAsMatchMetadata1)
352 .addEqualityGroup(matchMetadata2)
353 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800354 }
355
356 // EthCriterion class
357
358 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800359 * Test the matchEthDst method.
360 */
361 @Test
362 public void testMatchEthDstMethod() {
363 Criterion matchEthDst = Criteria.matchEthDst(mac1);
364 Criteria.EthCriterion ethCriterion =
365 checkAndConvert(matchEthDst,
366 Criterion.Type.ETH_DST,
367 Criteria.EthCriterion.class);
368 assertThat(ethCriterion.mac(), is(equalTo(mac1)));
369 }
370
371 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800372 * Test the matchEthSrc method.
373 */
374 @Test
375 public void testMatchEthSrcMethod() {
376 Criterion matchEthSrc = Criteria.matchEthSrc(mac1);
377 Criteria.EthCriterion ethCriterion =
378 checkAndConvert(matchEthSrc,
379 Criterion.Type.ETH_SRC,
380 Criteria.EthCriterion.class);
381 assertThat(ethCriterion.mac(), is(mac1));
382 }
383
384 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800385 * Test the equals() method of the EthCriterion class.
386 */
387 @Test
388 public void testEthCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800389 new EqualsTester()
390 .addEqualityGroup(matchEth1, sameAsMatchEth1)
391 .addEqualityGroup(matchEth2)
392 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800393 }
394
Ray Milkey33d90232014-11-04 10:49:00 -0800395 // EthTypeCriterion class
396
397 /**
398 * Test the matchEthType method.
399 */
400 @Test
401 public void testMatchEthTypeMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800402 int ethType = 12;
Ray Milkey33d90232014-11-04 10:49:00 -0800403 Criterion matchEthType = Criteria.matchEthType(ethType);
404 Criteria.EthTypeCriterion ethTypeCriterion =
405 checkAndConvert(matchEthType,
406 Criterion.Type.ETH_TYPE,
407 Criteria.EthTypeCriterion.class);
408 assertThat(ethTypeCriterion.ethType(), is(equalTo(ethType)));
409 }
410
411 /**
412 * Test the equals() method of the EthTypeCriterion class.
413 */
414 @Test
415 public void testEthTypeCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800416 new EqualsTester()
417 .addEqualityGroup(matchEthType1, sameAsMatchEthType1)
418 .addEqualityGroup(matchEthType2)
419 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800420 }
421
Ray Milkey33d90232014-11-04 10:49:00 -0800422 // VlanIdCriterion class
423
424 /**
425 * Test the matchVlanId method.
426 */
427 @Test
428 public void testMatchVlanIdMethod() {
429 Criterion matchVlanId = Criteria.matchVlanId(vlanId1);
430 Criteria.VlanIdCriterion vlanIdCriterion =
431 checkAndConvert(matchVlanId,
432 Criterion.Type.VLAN_VID,
433 Criteria.VlanIdCriterion.class);
434 assertThat(vlanIdCriterion.vlanId(), is(equalTo(vlanId1)));
435 }
436
437 /**
438 * Test the equals() method of the VlanIdCriterion class.
439 */
440 @Test
441 public void testVlanIdCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800442 new EqualsTester()
443 .addEqualityGroup(matchVlanId1, sameAsMatchVlanId1)
444 .addEqualityGroup(matchVlanId2)
445 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800446 }
447
448 // VlanPcpCriterion class
449
450 /**
451 * Test the matchVlanPcp method.
452 */
453 @Test
454 public void testMatchVlanPcpMethod() {
455 Criterion matchVlanPcp = Criteria.matchVlanPcp(vlanPcp1);
456 Criteria.VlanPcpCriterion vlanPcpCriterion =
457 checkAndConvert(matchVlanPcp,
458 Criterion.Type.VLAN_PCP,
459 Criteria.VlanPcpCriterion.class);
460 assertThat(vlanPcpCriterion.priority(), is(equalTo(vlanPcp1)));
461 }
462
463 /**
464 * Test the equals() method of the VlanPcpCriterion class.
465 */
466 @Test
467 public void testVlanPcpCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800468 new EqualsTester()
469 .addEqualityGroup(matchVlanPcp1, sameAsMatchVlanPcp1)
470 .addEqualityGroup(matchVlanPcp2)
471 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800472 }
473
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800474 // IPDscpCriterion class
475
476 /**
477 * Test the matchIPDscp method.
478 */
479 @Test
480 public void testMatchIPDscpMethod() {
481 Criterion matchIPDscp = Criteria.matchIPDscp(ipDscp1);
482 Criteria.IPDscpCriterion ipDscpCriterion =
483 checkAndConvert(matchIPDscp,
484 Criterion.Type.IP_DSCP,
485 Criteria.IPDscpCriterion.class);
486 assertThat(ipDscpCriterion.ipDscp(), is(equalTo(ipDscp1)));
487 }
488
489 /**
490 * Test the equals() method of the IPDscpCriterion class.
491 */
492 @Test
493 public void testIPDscpCriterionEquals() {
494 new EqualsTester()
495 .addEqualityGroup(matchIpDscp1, sameAsMatchIpDscp1)
496 .addEqualityGroup(matchIpDscp2)
497 .testEquals();
498 }
499
500 // IPEcnCriterion class
501
502 /**
503 * Test the matchIPEcn method.
504 */
505 @Test
506 public void testMatchIPEcnMethod() {
507 Criterion matchIPEcn = Criteria.matchIPEcn(ipEcn1);
508 Criteria.IPEcnCriterion ipEcnCriterion =
509 checkAndConvert(matchIPEcn,
510 Criterion.Type.IP_ECN,
511 Criteria.IPEcnCriterion.class);
512 assertThat(ipEcnCriterion.ipEcn(), is(equalTo(ipEcn1)));
513 }
514
515 /**
516 * Test the equals() method of the IPEcnCriterion class.
517 */
518 @Test
519 public void testIPEcnCriterionEquals() {
520 new EqualsTester()
521 .addEqualityGroup(matchIpEcn1, sameAsMatchIpEcn1)
522 .addEqualityGroup(matchIpEcn2)
523 .testEquals();
524 }
525
Ray Milkey33d90232014-11-04 10:49:00 -0800526 // IpProtocolCriterion class
527
528 /**
529 * Test the matchIpProtocol method.
530 */
531 @Test
532 public void testMatchIpProtocolMethod() {
533 Criterion matchIPProtocol = Criteria.matchIPProtocol(protocol1);
534 Criteria.IPProtocolCriterion ipProtocolCriterion =
535 checkAndConvert(matchIPProtocol,
536 Criterion.Type.IP_PROTO,
537 Criteria.IPProtocolCriterion.class);
538 assertThat(ipProtocolCriterion.protocol(), is(equalTo(protocol1)));
539 }
540
541 /**
542 * Test the equals() method of the IpProtocolCriterion class.
543 */
544 @Test
545 public void testIpProtocolCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800546 new EqualsTester()
547 .addEqualityGroup(matchIpProtocol1, sameAsMatchIpProtocol1)
548 .addEqualityGroup(matchIpProtocol2)
549 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800550 }
551
552 // IPCriterion class
553
554 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800555 * Test the matchIPSrc method: IPv4.
Ray Milkey33d90232014-11-04 10:49:00 -0800556 */
557 @Test
558 public void testMatchIPSrcMethod() {
559 Criterion matchIpSrc = Criteria.matchIPSrc(ip1);
560 Criteria.IPCriterion ipCriterion =
561 checkAndConvert(matchIpSrc,
562 Criterion.Type.IPV4_SRC,
563 Criteria.IPCriterion.class);
564 assertThat(ipCriterion.ip(), is(ip1));
565 }
566
567 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800568 * Test the matchIPDst method: IPv4.
Ray Milkey33d90232014-11-04 10:49:00 -0800569 */
570 @Test
571 public void testMatchIPDstMethod() {
572 Criterion matchIPDst = Criteria.matchIPDst(ip1);
573 Criteria.IPCriterion ipCriterion =
574 checkAndConvert(matchIPDst,
575 Criterion.Type.IPV4_DST,
576 Criteria.IPCriterion.class);
577 assertThat(ipCriterion.ip(), is(equalTo(ip1)));
578 }
579
580 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800581 * Test the matchIPSrc method: IPv6.
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800582 */
583 @Test
584 public void testMatchIPv6SrcMethod() {
585 Criterion matchIpv6Src = Criteria.matchIPv6Src(ipv61);
586 Criteria.IPCriterion ipCriterion =
587 checkAndConvert(matchIpv6Src,
588 Criterion.Type.IPV6_SRC,
589 Criteria.IPCriterion.class);
590 assertThat(ipCriterion.ip(), is(ipv61));
591 }
592
593 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800594 * Test the matchIPDst method: IPv6.
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800595 */
596 @Test
597 public void testMatchIPv6DstMethod() {
598 Criterion matchIPv6Dst = Criteria.matchIPv6Dst(ipv61);
599 Criteria.IPCriterion ipCriterion =
600 checkAndConvert(matchIPv6Dst,
601 Criterion.Type.IPV6_DST,
602 Criteria.IPCriterion.class);
603 assertThat(ipCriterion.ip(), is(equalTo(ipv61)));
604 }
605
606 /**
Ray Milkey33d90232014-11-04 10:49:00 -0800607 * Test the equals() method of the IpCriterion class.
608 */
609 @Test
610 public void testIPCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -0800611 new EqualsTester()
612 .addEqualityGroup(matchIp1, sameAsMatchIp1)
613 .addEqualityGroup(matchIp2)
614 .testEquals();
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800615
616 new EqualsTester()
617 .addEqualityGroup(matchIpv61, sameAsMatchIpv61)
618 .addEqualityGroup(matchIpv62)
619 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -0800620 }
621
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800622 // TcpPortCriterion class
623
624 /**
625 * Test the matchTcpSrc method.
626 */
627 @Test
628 public void testMatchTcpSrcMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800629 Criterion matchTcpSrc = Criteria.matchTcpSrc(1);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800630 Criteria.TcpPortCriterion tcpPortCriterion =
631 checkAndConvert(matchTcpSrc,
632 Criterion.Type.TCP_SRC,
633 Criteria.TcpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800634 assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800635 }
636
637 /**
638 * Test the matchTcpDst method.
639 */
640 @Test
641 public void testMatchTcpDstMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800642 Criterion matchTcpDst = Criteria.matchTcpDst(1);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800643 Criteria.TcpPortCriterion tcpPortCriterion =
644 checkAndConvert(matchTcpDst,
645 Criterion.Type.TCP_DST,
646 Criteria.TcpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800647 assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800648 }
649
650 /**
651 * Test the equals() method of the TcpPortCriterion class.
652 */
653 @Test
654 public void testTcpPortCriterionEquals() {
655 new EqualsTester()
656 .addEqualityGroup(matchTcpPort1, sameAsMatchTcpPort1)
657 .addEqualityGroup(matchTcpPort2)
658 .testEquals();
659 }
660
661 // UdpPortCriterion class
662
663 /**
664 * Test the matchUdpSrc method.
665 */
666 @Test
667 public void testMatchUdpSrcMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800668 Criterion matchUdpSrc = Criteria.matchUdpSrc(1);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800669 Criteria.UdpPortCriterion udpPortCriterion =
670 checkAndConvert(matchUdpSrc,
671 Criterion.Type.UDP_SRC,
672 Criteria.UdpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800673 assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800674 }
675
676 /**
677 * Test the matchUdpDst method.
678 */
679 @Test
680 public void testMatchUdpDstMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800681 Criterion matchUdpDst = Criteria.matchUdpDst(1);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800682 Criteria.UdpPortCriterion udpPortCriterion =
683 checkAndConvert(matchUdpDst,
684 Criterion.Type.UDP_DST,
685 Criteria.UdpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800686 assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800687 }
688
689 /**
690 * Test the equals() method of the UdpPortCriterion class.
691 */
692 @Test
693 public void testUdpPortCriterionEquals() {
694 new EqualsTester()
695 .addEqualityGroup(matchUdpPort1, sameAsMatchUdpPort1)
696 .addEqualityGroup(matchUdpPort2)
697 .testEquals();
698 }
699
700 // SctpPortCriterion class
701
702 /**
703 * Test the matchSctpSrc method.
704 */
705 @Test
706 public void testMatchSctpSrcMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800707 Criterion matchSctpSrc = Criteria.matchSctpSrc(1);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800708 Criteria.SctpPortCriterion sctpPortCriterion =
709 checkAndConvert(matchSctpSrc,
710 Criterion.Type.SCTP_SRC,
711 Criteria.SctpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800712 assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800713 }
714
715 /**
716 * Test the matchSctpDst method.
717 */
718 @Test
719 public void testMatchSctpDstMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800720 Criterion matchSctpDst = Criteria.matchSctpDst(1);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800721 Criteria.SctpPortCriterion sctpPortCriterion =
722 checkAndConvert(matchSctpDst,
723 Criterion.Type.SCTP_DST,
724 Criteria.SctpPortCriterion.class);
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800725 assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800726 }
727
728 /**
729 * Test the equals() method of the SctpPortCriterion class.
730 */
731 @Test
732 public void testSctpPortCriterionEquals() {
733 new EqualsTester()
734 .addEqualityGroup(matchSctpPort1, sameAsMatchSctpPort1)
735 .addEqualityGroup(matchSctpPort2)
736 .testEquals();
737 }
738
739 // IcmpTypeCriterion class
740
741 /**
742 * Test the matchIcmpType method.
743 */
744 @Test
745 public void testMatchIcmpTypeMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800746 short icmpType = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800747 Criterion matchIcmpType = Criteria.matchIcmpType(icmpType);
748 Criteria.IcmpTypeCriterion icmpTypeCriterion =
749 checkAndConvert(matchIcmpType,
750 Criterion.Type.ICMPV4_TYPE,
751 Criteria.IcmpTypeCriterion.class);
752 assertThat(icmpTypeCriterion.icmpType(), is(equalTo(icmpType)));
753 }
754
755 /**
756 * Test the equals() method of the IcmpTypeCriterion class.
757 */
758 @Test
759 public void testIcmpTypeCriterionEquals() {
760 new EqualsTester()
761 .addEqualityGroup(matchIcmpType1, sameAsMatchIcmpType1)
762 .addEqualityGroup(matchIcmpType2)
763 .testEquals();
764 }
765
766 // IcmpCodeCriterion class
767
768 /**
769 * Test the matchIcmpCode method.
770 */
771 @Test
772 public void testMatchIcmpCodeMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800773 short icmpCode = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800774 Criterion matchIcmpCode = Criteria.matchIcmpCode(icmpCode);
775 Criteria.IcmpCodeCriterion icmpCodeCriterion =
776 checkAndConvert(matchIcmpCode,
777 Criterion.Type.ICMPV4_CODE,
778 Criteria.IcmpCodeCriterion.class);
779 assertThat(icmpCodeCriterion.icmpCode(), is(equalTo(icmpCode)));
780 }
781
782 /**
783 * Test the equals() method of the IcmpCodeCriterion class.
784 */
785 @Test
786 public void testIcmpCodeCriterionEquals() {
787 new EqualsTester()
788 .addEqualityGroup(matchIcmpCode1, sameAsMatchIcmpCode1)
789 .addEqualityGroup(matchIcmpCode2)
790 .testEquals();
791 }
792
793 // IPv6FlowLabelCriterion class
794
795 /**
796 * Test the matchIPv6FlowLabel method.
797 */
798 @Test
799 public void testMatchIPv6FlowLabelMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800800 int flowLabel = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800801 Criterion matchFlowLabel = Criteria.matchIPv6FlowLabel(flowLabel);
802 Criteria.IPv6FlowLabelCriterion flowLabelCriterion =
803 checkAndConvert(matchFlowLabel,
804 Criterion.Type.IPV6_FLABEL,
805 Criteria.IPv6FlowLabelCriterion.class);
806 assertThat(flowLabelCriterion.flowLabel(), is(equalTo(flowLabel)));
807 }
808
809 /**
810 * Test the equals() method of the IPv6FlowLabelCriterion class.
811 */
812 @Test
813 public void testIPv6FlowLabelCriterionEquals() {
814 new EqualsTester()
815 .addEqualityGroup(matchFlowLabel1, sameAsMatchFlowLabel1)
816 .addEqualityGroup(matchFlowLabel2)
817 .testEquals();
818 }
819
820 // Icmpv6TypeCriterion class
821
822 /**
823 * Test the matchIcmpv6Type method.
824 */
825 @Test
826 public void testMatchIcmpv6TypeMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800827 short icmpv6Type = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800828 Criterion matchIcmpv6Type = Criteria.matchIcmpv6Type(icmpv6Type);
829 Criteria.Icmpv6TypeCriterion icmpv6TypeCriterion =
830 checkAndConvert(matchIcmpv6Type,
831 Criterion.Type.ICMPV6_TYPE,
832 Criteria.Icmpv6TypeCriterion.class);
833 assertThat(icmpv6TypeCriterion.icmpv6Type(), is(equalTo(icmpv6Type)));
834 }
835
836 /**
837 * Test the equals() method of the Icmpv6TypeCriterion class.
838 */
839 @Test
840 public void testIcmpv6TypeCriterionEquals() {
841 new EqualsTester()
842 .addEqualityGroup(matchIcmpv6Type1, sameAsMatchIcmpv6Type1)
843 .addEqualityGroup(matchIcmpv6Type2)
844 .testEquals();
845 }
846
847 // Icmpv6CodeCriterion class
848
849 /**
850 * Test the matchIcmpv6Code method.
851 */
852 @Test
853 public void testMatchIcmpv6CodeMethod() {
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800854 short icmpv6Code = 12;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800855 Criterion matchIcmpv6Code = Criteria.matchIcmpv6Code(icmpv6Code);
856 Criteria.Icmpv6CodeCriterion icmpv6CodeCriterion =
857 checkAndConvert(matchIcmpv6Code,
858 Criterion.Type.ICMPV6_CODE,
859 Criteria.Icmpv6CodeCriterion.class);
860 assertThat(icmpv6CodeCriterion.icmpv6Code(), is(equalTo(icmpv6Code)));
861 }
862
863 /**
864 * Test the equals() method of the Icmpv6CodeCriterion class.
865 */
866 @Test
867 public void testIcmpv6CodeCriterionEquals() {
868 new EqualsTester()
869 .addEqualityGroup(matchIcmpv6Code1, sameAsMatchIcmpv6Code1)
870 .addEqualityGroup(matchIcmpv6Code2)
871 .testEquals();
872 }
873
874 // IPv6NDTargetAddressCriterion class
875
876 /**
877 * Test the matchIPv6NDTargetAddress method.
878 */
879 @Test
880 public void testMatchIPv6NDTargetAddressMethod() {
881 Criterion matchTargetAddress =
882 Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1);
883 Criteria.IPv6NDTargetAddressCriterion targetAddressCriterion =
884 checkAndConvert(matchTargetAddress,
885 Criterion.Type.IPV6_ND_TARGET,
886 Criteria.IPv6NDTargetAddressCriterion.class);
887 assertThat(targetAddressCriterion.targetAddress(),
888 is(ip6TargetAddress1));
889 }
890
891 /**
892 * Test the equals() method of the IPv6NDTargetAddressCriterion class.
893 */
894 @Test
895 public void testIPv6NDTargetAddressCriterionEquals() {
896 new EqualsTester()
897 .addEqualityGroup(matchIpv6TargetAddr1,
898 sameAsMatchIpv6TargetAddr1)
899 .addEqualityGroup(matchIpv6TargetAddr2)
900 .testEquals();
901 }
902
903 // IPv6NDLinkLayerAddressCriterion class
904
905 /**
906 * Test the matchIPv6NDSourceLinkLayerAddress method.
907 */
908 @Test
909 public void testMatchIPv6NDSourceLinkLayerAddressMethod() {
910 Criterion matchSrcLlAddr =
911 Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1);
912 Criteria.IPv6NDLinkLayerAddressCriterion srcLlCriterion =
913 checkAndConvert(matchSrcLlAddr,
914 Criterion.Type.IPV6_ND_SLL,
915 Criteria.IPv6NDLinkLayerAddressCriterion.class);
916 assertThat(srcLlCriterion.mac(), is(equalTo(llMac1)));
917 }
918
919 /**
920 * Test the matchIPv6NDTargetLinkLayerAddress method.
921 */
922 @Test
923 public void testMatchIPv6NDTargetLinkLayerAddressMethod() {
924 Criterion matchTargetLlAddr =
925 Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1);
926 Criteria.IPv6NDLinkLayerAddressCriterion targetLlCriterion =
927 checkAndConvert(matchTargetLlAddr,
928 Criterion.Type.IPV6_ND_TLL,
929 Criteria.IPv6NDLinkLayerAddressCriterion.class);
930 assertThat(targetLlCriterion.mac(), is(equalTo(llMac1)));
931 }
932
933 /**
934 * Test the equals() method of the IPv6NDLinkLayerAddressCriterion class.
935 */
936 @Test
937 public void testIPv6NDLinkLayerAddressCriterionEquals() {
938 new EqualsTester()
939 .addEqualityGroup(matchSrcLlAddr1, sameAsMatchSrcLlAddr1)
940 .addEqualityGroup(matchSrcLlAddr2)
941 .testEquals();
942
943 new EqualsTester()
944 .addEqualityGroup(matchTargetLlAddr1, sameAsMatchTargetLlAddr1)
945 .addEqualityGroup(matchTargetLlAddr2)
946 .testEquals();
947 }
948
949 // MplsCriterion class
950
951 /**
952 * Test the matchMplsLabel method.
953 */
954 @Test
955 public void testMatchMplsLabelMethod() {
956 Criterion matchMplsLabel = Criteria.matchMplsLabel(mpls1);
957 Criteria.MplsCriterion mplsCriterion =
958 checkAndConvert(matchMplsLabel,
959 Criterion.Type.MPLS_LABEL,
960 Criteria.MplsCriterion.class);
961 assertThat(mplsCriterion.label(), is(equalTo(mpls1)));
962 }
963
964 /**
965 * Test the equals() method of the MplsCriterion class.
966 */
967 @Test
968 public void testMplsCriterionEquals() {
969 new EqualsTester()
970 .addEqualityGroup(matchMpls1, sameAsMatchMpls1)
971 .addEqualityGroup(matchMpls2)
972 .testEquals();
973 }
974
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800975 // IPv6ExthdrFlagsCriterion class
976
977 /**
978 * Test the matchIPv6ExthdrFlags method.
979 */
980 @Test
981 public void testMatchIPv6ExthdrFlagsMethod() {
982 Criterion matchExthdrFlags =
983 Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1);
984 Criteria.IPv6ExthdrFlagsCriterion exthdrFlagsCriterion =
985 checkAndConvert(matchExthdrFlags,
986 Criterion.Type.IPV6_EXTHDR,
987 Criteria.IPv6ExthdrFlagsCriterion.class);
988 assertThat(exthdrFlagsCriterion.exthdrFlags(),
989 is(equalTo(ipv6ExthdrFlags1)));
990 }
991
992 /**
993 * Test the equals() method of the IPv6ExthdrFlagsCriterion class.
994 */
995 @Test
996 public void testIPv6ExthdrFlagsCriterionEquals() {
997 new EqualsTester()
998 .addEqualityGroup(matchIpv6ExthdrFlags1,
999 sameAsMatchIpv6ExthdrFlags1)
1000 .addEqualityGroup(matchIpv6ExthdrFlags2)
1001 .testEquals();
1002 }
1003
Ray Milkey33d90232014-11-04 10:49:00 -08001004 // LambdaCriterion class
1005
1006 /**
1007 * Test the matchLambda method.
1008 */
1009 @Test
1010 public void testMatchLambdaMethod() {
1011 Criterion matchLambda = Criteria.matchLambda(lambda1);
1012 Criteria.LambdaCriterion lambdaCriterion =
1013 checkAndConvert(matchLambda,
1014 Criterion.Type.OCH_SIGID,
1015 Criteria.LambdaCriterion.class);
1016 assertThat(lambdaCriterion.lambda(), is(equalTo(lambda1)));
1017 }
1018
1019 /**
1020 * Test the equals() method of the LambdaCriterion class.
1021 */
1022 @Test
1023 public void testLambdaCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -08001024 new EqualsTester()
1025 .addEqualityGroup(matchLambda1, sameAsMatchLambda1)
1026 .addEqualityGroup(matchLambda2)
1027 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -08001028 }
1029
1030 // OpticalSignalTypeCriterion class
1031
1032 /**
1033 * Test the matchOpticalSignalType method.
1034 */
1035 @Test
1036 public void testMatchOpticalSignalTypeMethod() {
1037 Criterion matchLambda = Criteria.matchOpticalSignalType(signalLambda1);
1038 Criteria.OpticalSignalTypeCriterion opticalSignalTypeCriterion =
1039 checkAndConvert(matchLambda,
1040 Criterion.Type.OCH_SIGTYPE,
1041 Criteria.OpticalSignalTypeCriterion.class);
1042 assertThat(opticalSignalTypeCriterion.signalType(), is(equalTo(signalLambda1)));
1043 }
1044
1045 /**
1046 * Test the equals() method of the OpticalSignalTypeCriterion class.
1047 */
1048 @Test
1049 public void testOpticalSignalTypeCriterionEquals() {
Ray Milkeyfff20b52014-11-06 14:45:10 -08001050 new EqualsTester()
1051 .addEqualityGroup(matchSignalLambda1, sameAsMatchSignalLambda1)
1052 .addEqualityGroup(matchSignalLambda2)
1053 .testEquals();
Ray Milkey33d90232014-11-04 10:49:00 -08001054 }
Ray Milkey33d90232014-11-04 10:49:00 -08001055}