/*
* (c) 2015 Cable Television Laboratories, Inc. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.controller.packetcable.provider;
import static junit.framework.TestCase.assertEquals;
+
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.ServiceClassName;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.ServiceFlowDirection;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.TosByte;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.TpProtocol;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.ccap.attributes.AmId;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.ccap.attributes.Connection;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.ccaps.Ccap;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.classifier.attributes.Classifiers;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.classifier.attributes.classifiers.ClassifierContainer;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.classifier.attributes.classifiers.classifier.container.classifier.choice.QosClassifierChoice;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.pcmm.qos.classifier.Classifier;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.pcmm.qos.gate.spec.GateSpec;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.pcmm.qos.traffic.profile.TrafficProfile;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.ServiceClassName;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.ServiceFlowDirection;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.TosByte;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.TpProtocol;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.ccap.attributes.AmId;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.ccap.attributes.Connection;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.ccaps.Ccap;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.classifier.attributes.Classifiers;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.classifier.attributes.classifiers.ClassifierContainer;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.classifier.attributes.classifiers.classifier.container.classifier.choice.QosClassifierChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.classifier.Classifier;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.gate.spec.GateSpec;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.flow.spec.profile.FlowSpecProfile;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.traffic.profile.TrafficProfile;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.traffic.profile.TrafficProfileBuilder;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.traffic.profile.traffic.profile.TrafficProfileChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.FlowSpecChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.FlowSpecChoiceBuilder;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.ServiceClassNameChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.ServiceClassNameChoiceBuilder;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.serviceclass.name.profile.ServiceClassNameProfile;
import org.pcmm.PCMMPdpAgent;
-import org.pcmm.gates.IGateSpec.Direction;
import org.pcmm.gates.IPCMMGate;
import org.pcmm.rcd.IPCMMClient;
import org.pcmm.rcd.impl.CMTS;
+import org.pcmm.rcd.impl.CMTSConfig;
import org.umu.cops.stack.COPSClientSI;
import org.umu.cops.stack.COPSContext;
import org.umu.cops.stack.COPSContext.RType;
public void setup() throws IOException {
srcAddr = new Ipv4Address("10.10.10.0");
dstAddr = new Ipv4Address("10.32.99.99");
+ invalidCmAddrInet = InetAddress.getByAddress(new byte[] {99, 99, 99, 99});
if (realCmts) {
cmAddrInet = InetAddress.getByAddress(new byte[] {10, 32, 110, (byte)172});
- invalidCmAddrInet = InetAddress.getByAddress(new byte[] {99, 99, 99, 99});
+
// Use me when testing against a CMTS or emulator not running in the same JVM
cmtsAddr = new Ipv4Address("10.32.10.3");
ccap = makeCcapObj(PCMMPdpAgent.WELL_KNOWN_PDP_PORT, cmtsAddr, ccapId);
} else {
cmAddrInet = InetAddress.getByAddress(new byte[] {10, 32, 110, (byte)180});
- invalidCmAddrInet = InetAddress.getByAddress(new byte[] {99, 99, 99, 99});
// Use me for automated testing and the CMTS emulator running in the same JVM
cmtsAddr = new Ipv4Address("127.0.0.1");
- final Set<String> upGate = new HashSet<>();
- upGate.add("extrm_up");
- final Set<String> dnGate = new HashSet<>();
- dnGate.add("extrm_dn");
- final Map<Direction, Set<String>> gates = new HashMap<>();
- gates.put(Direction.UPSTREAM, upGate);
- gates.put(Direction.DOWNSTREAM, dnGate);
+ final Set<String> upSCN = new HashSet<>();
+ upSCN.add("extrm_up");
+ final Set<String> dnSCN = new HashSet<>();
+ dnSCN.add("extrm_dn");
final Map<String, Boolean> cmStatus = new HashMap<>();
cmStatus.put(cmAddrInet.getHostAddress(), true);
cmStatus.put(invalidCmAddrInet.getHostAddress(), false);
- icmts = new CMTS(gates, cmStatus);
+
+ CMTSConfig config = new CMTSConfig(0, (short)4, upSCN, dnSCN, cmStatus);
+
+ icmts = new CMTS(config);
icmts.startServer();
ccap = makeCcapObj(icmts.getPort(), cmtsAddr, ccapId);
public void testAddAndRemoveInvalidCmAddrUpGate() throws Exception {
// TODO - fix cmts emulator
final String expectedMsgStart = "404 Not Found - sendGateSet for " + ccapId + '/' + gatePath
- + " returned error - Error Code: 13 Error Subcode : 0 Invalid SubscriberID";
+ + " returned error - Error Code: 13 Subcode: 0 Invalid SubscriberID";
addInvalidGate(service, "extrm_up", srcAddr, dstAddr, ServiceFlowDirection.Us, invalidCmAddrInet, gatePath,
expectedMsgStart);
}
@Test
public void testAddInvalidScnUpGate() throws Exception {
final String expectedMsgStart = "404 Not Found - sendGateSet for " + ccapId + '/' + gatePath
- + " returned error - Error Code: 11 Error Subcode : 0 Undefined Service Class Name";
+ + " returned error - Error Code: 11 Subcode: 0 Undefined Service Class Name";
addInvalidGate(service, "extrm_up_invalid", srcAddr, dstAddr, ServiceFlowDirection.Us, cmAddrInet, gatePath,
expectedMsgStart);
}
@Test
public void testAddInvalidScnDownGate() throws Exception {
final String expectedMsgStart = "404 Not Found - sendGateSet for " + ccapId + '/' + gatePath
- + " returned error - Error Code: 11 Error Subcode : 0 Undefined Service Class Name";
+ + " returned error - Error Code: 11 Subcode: 0 Undefined Service Class Name";
addInvalidGate(service, "extrm_dn_invalid", srcAddr, dstAddr, ServiceFlowDirection.Ds, cmAddrInet, gatePath,
expectedMsgStart);
}
// Assert.assertNotNull(gateSetMsg);
// Assert.assertTrue(gateSetMsg, gateSetMsg.startsWith(expGateSetMsgStart));
- // TODO update this method for the new GateSetStatus object
- PCMMService.GateSetStatus status = service.sendGateSet(gatePath, cmAddrInet, gate, direction);
+ // TODO update this method for the new GateSendStatus object
+ PCMMService.GateSendStatus status = service.sendGateSet(gatePath, cmAddrInet, gate);
Assert.assertNotNull(status);
- Assert.assertTrue(status.getMessage().startsWith(expGateSetMsgStart));
+ assertThat(status.getMessage(), startsWith(expGateSetMsgStart));
+
// TODO - add validation to the PCMMGateReq contained within the map
if (status.didSucceed()) {
when(gateSpec.getDirection()).thenReturn(direction);
// TODO - make sure to write a test when this value is not null
when(gateSpec.getDscpTosOverwrite()).thenReturn(null);
+
+ // TODO - refactor to add flowspec profile testing as well
final TrafficProfile trafficProfile = mock(TrafficProfile.class);
- final ServiceClassName scn = mock(ServiceClassName.class);
- when(scn.getValue()).thenReturn(scnValue);
- when(trafficProfile.getServiceClassName()).thenReturn(scn);
+ final ServiceClassNameChoice serviceClassNameChoice = mock(ServiceClassNameChoice.class);
+ final ServiceClassNameProfile serviceClassNameProfile = mock(ServiceClassNameProfile.class);
+ final ServiceClassName serviceClassName = mock(ServiceClassName.class);
+ when(serviceClassName.getValue()).thenReturn(scnValue);
+ when(serviceClassNameProfile.getServiceClassName()).thenReturn(serviceClassName);
+ when(serviceClassNameChoice.getServiceClassNameProfile()).thenReturn(serviceClassNameProfile);
+ when(trafficProfile.getTrafficProfileChoice()).thenReturn(serviceClassNameChoice);
when(gate.getTrafficProfile()).thenReturn(trafficProfile);
// TODO - write tests when this is null and ExtClassifier or Ipv6Classifier objects are not null
gateBuilder.setAmId(ccap.getAmId());
gateBuilder.setSubscriberId(addrSubId);
// force gateSpec.Direction to align with SCN direction
- final ServiceClassName scn = gateReq.getTrafficProfile().getServiceClassName();
+ final ServiceClassName scn =
+ ((ServiceClassNameChoice)gateReq.getTrafficProfile().getTrafficProfileChoice()).getServiceClassNameProfile().getServiceClassName();
if (scn != null) {
gateBuilder.setGateSpec(gateReq.getGateSpec(), direction);
} else {