import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
+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;
/**
* Unit tests for FlowRemovedMessageFactory.
public void testSerialize() throws Exception {
FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
- builder.setCookie(BigInteger.valueOf(1234L));
- builder.setPriority(1234);
+ builder.setCookie(Uint64.valueOf(1234));
+ builder.setPriority(Uint16.valueOf(1234));
builder.setReason(FlowRemovedReason.forValue(2));
- builder.setTableId(new TableId(65L));
- builder.setDurationSec(1234L);
- builder.setDurationNsec(1234L);
- builder.setIdleTimeout(1234);
- builder.setHardTimeout(1234);
- builder.setPacketCount(BigInteger.valueOf(1234L));
- builder.setByteCount(BigInteger.valueOf(1234L));
+ builder.setTableId(new TableId(Uint32.valueOf(65)));
+ builder.setDurationSec(Uint32.valueOf(1234));
+ builder.setDurationNsec(Uint32.valueOf(1234));
+ builder.setIdleTimeout(Uint16.valueOf(1234));
+ builder.setHardTimeout(Uint16.valueOf(1234));
+ builder.setPacketCount(Uint64.valueOf(1234));
+ builder.setByteCount(Uint64.valueOf(1234));
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
entriesBuilder.setHasMask(false);
InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
- inPhyPortBuilder.setPortNumber(new PortNumber(42L));
+ inPhyPortBuilder.setPortNumber(new PortNumber(Uint32.valueOf(42)));
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder.setHasMask(false);
IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
- ipEcnBuilder.setEcn((short) 4);
+ ipEcnBuilder.setEcn(Uint8.valueOf(4));
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
entries.add(entriesBuilder.build());
Assert.assertEquals("Wrong Packet count", message.getPacketCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong Byte count", message.getByteCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong match type", 1, serializedBuffer.readUnsignedShort());
- serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ serializedBuffer.skipBytes(Short.BYTES);
Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort());
short fieldAndMask = serializedBuffer.readUnsignedByte();
Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
- serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+ serializedBuffer.skipBytes(Byte.BYTES);
Assert.assertEquals("Wrong oxm value", 42, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort());
fieldAndMask = serializedBuffer.readUnsignedByte();
Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
- serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+ serializedBuffer.skipBytes(Byte.BYTES);
Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(7);
}