2 * Copyright (c) 2015 CableLabs and others. All rights reserved.
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
9 package org.opendaylight.controller.packetcable.provider.validation.impl.validators.qos.classifier;
11 import org.junit.Rule;
12 import org.junit.Test;
13 import org.opendaylight.controller.packetcable.provider.test.rules.Params;
14 import org.opendaylight.controller.packetcable.provider.validation.ValidationException;
15 import org.opendaylight.controller.packetcable.provider.validation.Validator;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
18 import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.TosByte;
19 import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.TpProtocol;
20 import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.pcmm.qos.classifier.Classifier;
21 import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.pcmm.qos.classifier.ClassifierBuilder;
26 @Params.AlwaysUseParams
27 public class ClassifierValidatorTest {
30 public Params<Validator.Extent> extentParams = Params.of(Validator.Extent.class);
32 private final ClassifierValidator validator= new ClassifierValidator();
34 @Test(expected = ValidationException.class)
35 public void nullClassifier() throws ValidationException {
36 validator.validate(null, extentParams.getCurrentParam());
39 @Params.DoNotUseParams
40 @Test(expected = NullPointerException.class)
41 public void nullExtent() throws ValidationException {
42 validator.validate(buildValidClassifierTree(), null);
46 public void nullSrcIp() throws ValidationException {
47 Classifier classifier = new ClassifierBuilder(buildValidClassifierTree())
51 validator.validate(classifier, extentParams.getCurrentParam());
55 public void nullSrcPort() throws ValidationException {
56 Classifier classifier = new ClassifierBuilder(buildValidClassifierTree())
60 validator.validate(classifier, extentParams.getCurrentParam());
64 public void nullDstIp() throws ValidationException {
65 Classifier classifier = new ClassifierBuilder(buildValidClassifierTree())
69 validator.validate(classifier, extentParams.getCurrentParam());
73 public void nullDstPort() throws ValidationException {
74 Classifier classifier = new ClassifierBuilder(buildValidClassifierTree())
78 validator.validate(classifier, extentParams.getCurrentParam());
82 public void nullProtocol() throws ValidationException {
83 Classifier classifier = new ClassifierBuilder(buildValidClassifierTree())
87 validator.validate(classifier, extentParams.getCurrentParam());
91 public void nullTosByte() throws ValidationException {
92 Classifier classifier = new ClassifierBuilder(buildValidClassifierTree())
96 validator.validate(classifier, extentParams.getCurrentParam());
100 public void nullTosMask() throws ValidationException {
101 Classifier classifier = new ClassifierBuilder(buildValidClassifierTree())
105 validator.validate(classifier, extentParams.getCurrentParam());
109 public void valid() throws ValidationException {
110 Classifier classifier = buildValidClassifierTree();
111 validator.validate(classifier, extentParams.getCurrentParam());
114 public static Classifier buildValidClassifierTree() {
115 return new ClassifierBuilder()
116 .setSrcIp(new Ipv4Address("10.0.0.100"))
117 .setSrcPort(new PortNumber(7000))
118 .setDstIp(new Ipv4Address("10.0.0.200"))
119 .setDstPort(new PortNumber(8000))
120 .setProtocol(new TpProtocol(127))
121 .setTosByte(new TosByte((short)0x10))
122 .setTosMask(new TosByte((short)0xf0))