Fix fileEncoding violations for checkstyle
[groupbasedpolicy.git] / renderers / ofoverlay / src / test / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / sf / L4ClassifierTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNull;
12 import static org.junit.Assert.assertSame;
13 import static org.junit.Assert.assertTrue;
14
15 import java.util.ArrayList;
16 import java.util.HashMap;
17 import java.util.HashSet;
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Set;
21
22 import com.google.common.collect.ImmutableMap;
23 import org.apache.commons.lang3.tuple.Pair;
24 import org.junit.Rule;
25 import org.junit.Test;
26 import org.junit.rules.ExpectedException;
27 import org.opendaylight.groupbasedpolicy.api.sf.IpProtoClassifierDefinition;
28 import org.opendaylight.groupbasedpolicy.api.sf.L4ClassifierDefinition;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValueBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
38
39 public class L4ClassifierTest {
40
41     private static final long LESSER_RANGE_START = 79L;
42     private static final long LESSER_RANGE_END = 81L;
43     private static final long GREATER_RANGE_START = 8079L;
44     private static final long GREATER_RANGE_END = 8081L;
45     private static final long SINGLE_PORT = 80L;
46     private static final int SINGLE_PORT_INT = 80;
47
48     @Rule
49     public ExpectedException thrown = ExpectedException.none();
50
51     @Test
52     public void testUpdate_TcpSrcPort() {
53         List<MatchBuilder> matches = new ArrayList<>();
54         Map<String, ParameterValue> params = new HashMap<>();
55         matches.add(new MatchBuilder()
56             .setEthernetMatch(
57                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
58         Long sPort = SINGLE_PORT;
59         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
60                 ClassifierTestUtils.TCP));
61         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, sPort));
62
63         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
64
65         assertEquals(1, updated.size());
66         MatchBuilder first = updated.get(0);
67         assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, first.getEthernetMatch().getEthernetType());
68         TcpMatch match = new TcpMatchBuilder((TcpMatch) first.getLayer4Match()).build();
69         assertSame(sPort, match.getTcpSourcePort().getValue().longValue());
70         assertNull(match.getTcpDestinationPort());
71     }
72
73     @Test
74     public void testUpdate_TcpDstPort() {
75         List<MatchBuilder> matches = new ArrayList<>();
76         Map<String, ParameterValue> params = new HashMap<>();
77         Long dPort = SINGLE_PORT;
78         matches.add(new MatchBuilder()
79             .setEthernetMatch(
80                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)));
81         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
82                 ClassifierTestUtils.TCP));
83         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.DST_PORT_PARAM, dPort));
84
85         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
86
87         assertEquals(1, updated.size());
88         MatchBuilder first = updated.get(0);
89         assertEquals(ClassifierTestUtils.IPV6_ETH_TYPE, first.getEthernetMatch().getEthernetType());
90         TcpMatch match = new TcpMatchBuilder((TcpMatch) first.getLayer4Match()).build();
91         assertSame(dPort, match.getTcpDestinationPort().getValue().longValue());
92         assertNull(match.getTcpSourcePort());
93     }
94
95     @Test
96     public void testUpdate_TcpSrcPort_DstPortRange() {
97         List<MatchBuilder> matches = new ArrayList<>();
98         Map<String, ParameterValue> params = new HashMap<>();
99         matches.add(new MatchBuilder()
100             .setEthernetMatch(
101                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
102         Long dstRangeStart = GREATER_RANGE_START;
103         Long dstRangeEnd = GREATER_RANGE_END;
104         Long srcPort = SINGLE_PORT;
105         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
106                 ClassifierTestUtils.TCP));
107         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, srcPort));
108         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
109                 dstRangeStart, dstRangeEnd));
110         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
111
112         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
113
114         Set<Long> dstPorts = new HashSet<>();
115         for (MatchBuilder match : updated) {
116             assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, match.getEthernetMatch().getEthernetType());
117             assertEquals(srcPort,
118                     Long.valueOf(new TcpMatchBuilder((TcpMatch) match.getLayer4Match()).getTcpSourcePort().getValue()));
119             dstPorts.add(new TcpMatchBuilder((TcpMatch) match.getLayer4Match()).getTcpDestinationPort()
120                 .getValue()
121                 .longValue());
122         }
123         for (Long port = dstRangeStart; port <= dstRangeEnd; port++) {
124             assertTrue(dstPorts.contains((port)));
125         }
126     }
127
128     @Test
129     public void testUpdate_OverrideDstPortWithTheSameValue() {
130         List<MatchBuilder> matches = new ArrayList<>();
131         Map<String, ParameterValue> params = new HashMap<>();
132         Long dPort = SINGLE_PORT;
133         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createUdpDstPort(SINGLE_PORT_INT))
134             .setEthernetMatch(
135                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)));
136         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
137                 ClassifierTestUtils.UDP));
138         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.DST_PORT_PARAM, dPort));
139
140         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
141
142         assertEquals(1, updated.size());
143         MatchBuilder first = updated.get(0);
144         assertEquals(ClassifierTestUtils.IPV6_ETH_TYPE, first.getEthernetMatch().getEthernetType());
145         UdpMatch match = new UdpMatchBuilder((UdpMatch) first.getLayer4Match()).build();
146         assertSame(dPort, match.getUdpDestinationPort().getValue().longValue());
147         assertNull(match.getUdpSourcePort());
148     }
149
150     @Test
151     public void testUpdate_AddUdpSrcPortRange() {
152         List<MatchBuilder> matches = new ArrayList<>();
153         Map<String, ParameterValue> params = new HashMap<>();
154         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createUdpDstPort(SINGLE_PORT_INT))
155             .setEthernetMatch(
156                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
157         Long srcRangeStart = GREATER_RANGE_START;
158         Long srcRangeEnd = GREATER_RANGE_END;
159         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
160                 ClassifierTestUtils.UDP));
161         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
162                 srcRangeStart, srcRangeEnd));
163
164         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
165
166         assertEquals(3, updated.size());
167         Set<Long> srcPorts = new HashSet<>();
168         for (MatchBuilder match : updated) {
169             assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, match.getEthernetMatch().getEthernetType());
170             assertSame(SINGLE_PORT_INT,
171                     new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpDestinationPort().getValue());
172             assertEquals(SINGLE_PORT_INT, new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpDestinationPort()
173                 .getValue()
174                 .longValue());
175             srcPorts
176                 .add(new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpSourcePort()
177                         .getValue()
178                         .longValue());
179         }
180         for (Long port = srcRangeStart; port <= srcRangeEnd; port++) {
181             assertTrue(srcPorts.contains((port)));
182         }
183     }
184
185     @Test
186     public void testUpdate_UdpSrcPortRange_DstPort() {
187         List<MatchBuilder> matches = new ArrayList<>();
188         Map<String, ParameterValue> params = new HashMap<>();
189         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createUdpDstPort(SINGLE_PORT_INT))
190             .setEthernetMatch(
191                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)));
192         Long dPort = SINGLE_PORT;
193         Long srcRangeStart = GREATER_RANGE_START;
194         Long srcRangeEnd = GREATER_RANGE_END;
195         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
196                 ClassifierTestUtils.UDP));
197         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.DST_PORT_PARAM, dPort));
198         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
199                 srcRangeStart, srcRangeEnd));
200         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
201
202         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
203
204         assertEquals(3, updated.size());
205         Set<Long> srcPorts = new HashSet<>();
206         for (MatchBuilder match : updated) {
207             assertEquals(ClassifierTestUtils.IPV6_ETH_TYPE, match.getEthernetMatch().getEthernetType());
208             assertSame(dPort, new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpDestinationPort()
209                 .getValue()
210                 .longValue());
211             srcPorts
212                 .add(new UdpMatchBuilder((UdpMatch) match.getLayer4Match()).getUdpSourcePort()
213                         .getValue()
214                         .longValue());
215         }
216         for (Long port = srcRangeStart; port <= srcRangeEnd; port++) {
217             assertTrue(srcPorts.contains((port)));
218         }
219     }
220
221     @Test
222     public void testUpdate_OverrideSrcPortWithTheSameValue() {
223         List<MatchBuilder> matches = new ArrayList<>();
224         Map<String, ParameterValue> params = new HashMap<>();
225         Long sPort = SINGLE_PORT;
226         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createSctpSrcPort(sPort.intValue()))
227             .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
228         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
229                 ClassifierTestUtils.SCTP));
230         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, sPort));
231
232         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
233
234         assertEquals(1, updated.size());
235         MatchBuilder first = updated.get(0);
236         assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, first.getEthernetMatch().getEthernetType());
237         SctpMatch match = new SctpMatchBuilder((SctpMatch) first.getLayer4Match()).build();
238         assertSame(sPort, match.getSctpSourcePort().getValue().longValue());
239         assertNull(match.getSctpDestinationPort());
240     }
241
242     @Test
243     public void testUpdate_AddSctpDstPortRange() {
244         List<MatchBuilder> matches = new ArrayList<>();
245         Map<String, ParameterValue> params = new HashMap<>();
246         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createSctpSrcPort(SINGLE_PORT_INT))
247             .setEthernetMatch(
248                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
249         Long dstRangeStart = GREATER_RANGE_START;
250         Long dstRangeEnd = GREATER_RANGE_END;
251         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
252                 ClassifierTestUtils.SCTP));
253         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
254                 dstRangeStart, dstRangeEnd));
255
256         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
257
258         assertEquals(3, updated.size());
259         Set<Long> dstPorts = new HashSet<>();
260         for (MatchBuilder match : updated) {
261             assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, match.getEthernetMatch().getEthernetType());
262             assertSame(SINGLE_PORT_INT,
263                     new SctpMatchBuilder((SctpMatch) match.getLayer4Match()).getSctpSourcePort().getValue());
264             dstPorts.add(new SctpMatchBuilder((SctpMatch) match.getLayer4Match()).getSctpDestinationPort()
265                 .getValue()
266                 .longValue());
267         }
268         for (Long port = dstRangeStart; port <= dstRangeEnd; port++) {
269             assertTrue(dstPorts.contains((port)));
270         }
271     }
272
273     @Test
274     public void testUpdate_Sctp_SrcPortRange_DstPortRange() {
275         List<MatchBuilder> matches = new ArrayList<>();
276         Map<String, ParameterValue> params = new HashMap<>();
277         matches.add(new MatchBuilder()
278             .setEthernetMatch(
279                     ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)));
280         Long srcRangeStart = LESSER_RANGE_START;
281         Long srcRangeEnd = LESSER_RANGE_END;
282         Long dstRangeStart = GREATER_RANGE_START;
283         Long dstRangeEnd = GREATER_RANGE_END;
284         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
285                 ClassifierTestUtils.SCTP));
286         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
287                 srcRangeStart, srcRangeEnd));
288         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
289                 dstRangeStart, dstRangeEnd));
290         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
291
292         List<MatchBuilder> updated = Classifier.L4_CL.update(matches, params);
293
294         assertEquals(9, updated.size());
295         Set<Pair<Long, Long>> set = new HashSet<>();
296         for (MatchBuilder match : updated) {
297             Long srcPort =
298                     new SctpMatchBuilder((SctpMatch) match.getLayer4Match()).getSctpSourcePort().getValue().longValue();
299             Long dstPort = new SctpMatchBuilder((SctpMatch) match.getLayer4Match()).getSctpDestinationPort()
300                 .getValue()
301                 .longValue();
302             set.add(Pair.of(srcPort, dstPort));
303         }
304         for (Long sPort = srcRangeStart; sPort <= srcRangeEnd; sPort++) {
305             for (Long dPort = dstRangeStart; dPort <= dstRangeEnd; dPort++) {
306                 assertTrue(set.contains(Pair.of(sPort, dPort)));
307             }
308         }
309     }
310
311     @Test
312     public void testCheckPresenceOfRequiredParams_SrcPort_SrtPortRange_MutualExclusion() {
313         Map<String, ParameterValue> params = new HashMap<>();
314         Long srcRangeStart = GREATER_RANGE_START;
315         Long srcRangeEnd = GREATER_RANGE_END;
316         Long srcPort = SINGLE_PORT;
317         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
318                 ClassifierTestUtils.SCTP));
319         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, srcPort));
320         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
321                 srcRangeStart, srcRangeEnd));
322
323         thrown.expect(IllegalArgumentException.class);
324         thrown.expectMessage(Classifier.MSG_MUTUALLY_EXCLUSIVE);
325         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
326     }
327
328     @Test
329     public void testCheckPresenceOfRequiredParams_DstPort_DstPortRange_MutualExclusion() {
330         Map<String, ParameterValue> params = new HashMap<>();
331         Long dstRangeStart = GREATER_RANGE_START;
332         Long dstRangeEnd = GREATER_RANGE_END;
333         Long dstPort = SINGLE_PORT;
334         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
335                 ClassifierTestUtils.UDP));
336         params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.DST_PORT_PARAM, dstPort));
337         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
338                 dstRangeStart, dstRangeEnd));
339
340         thrown.expect(IllegalArgumentException.class);
341         thrown.expectMessage(Classifier.MSG_MUTUALLY_EXCLUSIVE);
342         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
343     }
344
345     @Test
346     public void testCheckPresenceOfRequiredParams_RangeValueMismatch() {
347         Map<String, ParameterValue> params = new HashMap<>();
348         Long dstRangeStart = GREATER_RANGE_END;
349         Long dstRangeEnd = GREATER_RANGE_START;
350         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
351                 ClassifierTestUtils.TCP));
352         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
353                 dstRangeStart, dstRangeEnd));
354
355         thrown.expect(IllegalArgumentException.class);
356         thrown.expectMessage(Classifier.MSG_RANGE_VALUE_MISMATCH);
357         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
358     }
359
360     @Test
361     public void testUpdate_UnsupportedProtocol() {
362         List<MatchBuilder> matches = new ArrayList<>();
363         Map<String, ParameterValue> params = new HashMap<>();
364         matches.add(new MatchBuilder());
365         Long dstRangeStart = GREATER_RANGE_START;
366         Long dstRangeEnd = GREATER_RANGE_END;
367         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM, 136));
368         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
369                 dstRangeStart, dstRangeEnd));
370
371         thrown.expect(IllegalArgumentException.class);
372         thrown.expectMessage(Classifier.MSG_NOT_SUPPORTED);
373         Classifier.L4_CL.update(matches, params);
374     }
375
376     @Test
377     public void testUpdate_ClassificationConflict() {
378         List<MatchBuilder> matches = new ArrayList<>();
379         Map<String, ParameterValue> params = new HashMap<>();
380         matches.add(new MatchBuilder().setLayer4Match(ClassifierTestUtils.createSctpDstPort(SINGLE_PORT_INT)));
381         Long dstRangeStart = GREATER_RANGE_START;
382         Long dstRangeEnd = GREATER_RANGE_END;
383         params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM,
384                 ClassifierTestUtils.UDP));
385         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
386                 dstRangeStart, dstRangeEnd));
387
388         thrown.expect(IllegalArgumentException.class);
389         thrown.expectMessage(Classifier.MSG_CLASSIFICATION_CONFLICT_DETECTED);
390         Classifier.L4_CL.update(matches, params);
391     }
392
393     @Test
394     public void testUpdate_NoProto() {
395         List<MatchBuilder> matches = new ArrayList<>();
396         Map<String, ParameterValue> params = new HashMap<>();
397         matches.add(new MatchBuilder());
398         Long dstRangeStart = GREATER_RANGE_START;
399         Long dstRangeEnd = GREATER_RANGE_END;
400         params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
401                 dstRangeStart, dstRangeEnd));
402
403         thrown.expect(IllegalArgumentException.class);
404         thrown.expectMessage(Classifier.MSG_IS_MISSING);
405         Classifier.L4_CL.update(matches, params);
406     }
407
408     @Test
409     public void testCheckPresenceOfRequiredParameters_SrcPortNotSet() {
410         Map<String, ParameterValue> params = new HashMap<>();
411         params.putAll(ImmutableMap.of(L4ClassifierDefinition.SRC_PORT_PARAM, new ParameterValueBuilder().build()));
412
413         thrown.expect(IllegalArgumentException.class);
414         thrown.expectMessage(Classifier.MSG_NOT_SPECIFIED);
415         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
416     }
417
418     @Test
419     public void testCheckPresenceOfRequiredParameters_DstPortNotSet() {
420         Map<String, ParameterValue> params = new HashMap<>();
421         params.putAll(ImmutableMap.of(L4ClassifierDefinition.DST_PORT_PARAM, new ParameterValueBuilder().build()));
422
423         thrown.expect(IllegalArgumentException.class);
424         thrown.expectMessage(Classifier.MSG_NOT_SPECIFIED);
425         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
426     }
427
428     @Test
429     public void testCheckPresenceOfRequiredParameters_SrcRangeNotSet() {
430         Map<String, ParameterValue> params = new HashMap<>();
431         params.putAll(ImmutableMap.of(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM,
432                 new ParameterValueBuilder().build()));
433
434         thrown.expect(IllegalArgumentException.class);
435         thrown.expectMessage(Classifier.MSG_NOT_PRESENT);
436         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
437     }
438
439     @Test
440     public void testCheckPresenceOfRequiredParameters_DstRangeNotSet() {
441         Map<String, ParameterValue> params = new HashMap<>();
442         params.putAll(ImmutableMap.of(L4ClassifierDefinition.DST_PORT_RANGE_PARAM,
443                 new ParameterValueBuilder().build()));
444
445         thrown.expect(IllegalArgumentException.class);
446         thrown.expectMessage(Classifier.MSG_NOT_PRESENT);
447         Classifier.L4_CL.checkPresenceOfRequiredParams(params);
448     }
449 }