* 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.openflowplugin.openflow.md.core.sal.convertor;
import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Assert;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.XidConvertorData;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Created by Jakub Toth jatoth@cisco.com on 9/23/14.
*/
-
public class PacketOutConvertorTest {
private ConvertorManager convertorManager;
}
/**
- * Test for {@link PacketOutConvertor} with null parameters.
+ * Test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor}
+ * with null parameters.
*/
@Test
public void toPacketOutInputAllParmNullTest() {
TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder();
- Long bufferId = null;
-
String nodeId = "0";
String port = "0";
NodeConnectorRef egressConfRef = new NodeConnectorRef(
createNodeConnRef(nodeId, nodeConnKey));
- transmitPacketInputBuilder.setBufferId(bufferId);
+ transmitPacketInputBuilder.setBufferId((Uint32) null);
transmitPacketInputBuilder.setConnectionCookie(null);
- transmitPacketInputBuilder.setAction(null);
transmitPacketInputBuilder.setNode(ref);
transmitPacketInputBuilder.setPayload(null);
transmitPacketInputBuilder.setEgress(egressConfRef);
Short version = (short) 0x04;
Long xid = null;
- PacketOutConvertorData data = new PacketOutConvertorData(version);
+ XidConvertorData data = new XidConvertorData(version);
PacketOutInput message = convert(transmitPacketInput, data);
//FIXME : this has to be fixed along with actions changed in openflowjava
Assert.assertEquals(buildActionForNullTransmitPacketInputAction(nodeConnKey, version), message.getAction());
Assert.assertEquals(OFConstants.OFP_NO_BUFFER, message.getBufferId());
- Assert.assertEquals(new PortNumber(0xfffffffdL), message.getInPort());
- Assert.assertEquals(version, message.getVersion());
+ Assert.assertEquals(new PortNumber(Uint32.valueOf(0xfffffffdL)), message.getInPort());
+ Assert.assertEquals(Uint8.valueOf(version), message.getVersion());
Assert.assertEquals(xid, message.getXid());
Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());
}
/**
- * Test for PacketOutConvertor.
+ * Test for XidConvertorData.
*/
@Test
public void toPacketOutInputAllParmTest() {
ab.setAction(new OutputActionCaseBuilder().setOutputAction(
output.build()).build());
ab.setOrder(0);
- ab.setKey(new ActionKey(0));
+ ab.withKey(new ActionKey(0));
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList =
new ArrayList<>();
actionList.add(ab.build());
- Long bufferId = 0xfL;
+ final Uint32 bufferId = Uint32.valueOf(0xf);
- Long valueForCookie = 0xeL;
+ final Uint32 valueForCookie = Uint32.valueOf(0xe);
ConnectionCookie connCook = new ConnectionCookie(valueForCookie);
String nodeId = "node:1";
for (int i = 0; i < datapathIdByte.length; i++) {
datapathIdByte[i] = 1;
}
- BigInteger datapathId = new BigInteger(1, datapathIdByte);
- Long xid = 0xfffffL;
+ Uint64 datapathId = Uint64.valueOf(new BigInteger(1, datapathIdByte));
+ Uint32 xid = Uint32.valueOf(0xfffffL);
- PacketOutConvertorData data = new PacketOutConvertorData(version);
+ XidConvertorData data = new XidConvertorData(version);
data.setXid(xid);
data.setDatapathId(datapathId);
PacketOutInput message = convert(transmitPacketInput, data);
Assert.assertEquals(transmitPacketInput.getBufferId(), message.getBufferId());
- Assert.assertEquals(Long.valueOf(inPort), message.getInPort().getValue());
- Assert.assertEquals(version, message.getVersion());
+ Assert.assertEquals(Uint32.valueOf(inPort), message.getInPort().getValue());
+ Assert.assertEquals(Uint8.valueOf(version), message.getVersion());
Assert.assertEquals(xid, message.getXid());
ActionConvertorData actionConvertorData = new ActionConvertorData(version);
Optional<List<Action>> actionsOptional = convertorManager.convert(actionList, actionConvertorData);
- List<Action> actions = actionsOptional.orElse(Collections.emptyList());
+ List<Action> actions = actionsOptional.orElse(null);
Assert.assertEquals(actions, message.getAction());
Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());
}
.action.choice.output.action._case.OutputActionBuilder();
outputActionBuilder.setPort(outPort);
- outputActionBuilder.setMaxLength(0xffff);
+ outputActionBuilder.setMaxLength(Uint16.MAX_VALUE);
outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(outputActionCaseBuilder.build());
}
private static PortNumber getPortNumber(final NodeConnectorKey nodeConKey, final Short ofVersion) {
- Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.get(ofVersion),
+ Uint32 port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.get(ofVersion),
nodeConKey.getId());
return new PortNumber(port);
}
private static NodeConnectorRef createNodeConnRef(final String nodeId, final NodeConnectorKey nodeConKey) {
InstanceIdentifier<NodeConnector> path = InstanceIdentifier
- .<Nodes>builder(Nodes.class)
- .<Node, NodeKey>child(Node.class,
+ .builder(Nodes.class)
+ .child(Node.class,
new NodeKey(new NodeId(nodeId)))
- .<NodeConnector, NodeConnectorKey>child(NodeConnector.class,
+ .child(NodeConnector.class,
nodeConKey).build();
return new NodeConnectorRef(path);
private static NodeRef createNodeRef(final String nodeId) {
NodeKey key = new NodeKey(new NodeId(nodeId));
InstanceIdentifier<Node> path = InstanceIdentifier
- .<Nodes>builder(Nodes.class)
- .<Node, NodeKey>child(Node.class, key).build();
+ .builder(Nodes.class)
+ .child(Node.class, key).build();
return new NodeRef(path);
}
- private PacketOutInput convert(TransmitPacketInput transmitPacketInput, PacketOutConvertorData data) {
+ private PacketOutInput convert(final TransmitPacketInput transmitPacketInput, final XidConvertorData data) {
Optional<PacketOutInput> messageOptional = convertorManager.convert(transmitPacketInput, data);
return messageOptional.orElse(PacketOutConvertor.defaultResult(data.getVersion()));
}