List of usage examples for io.netty.buffer ByteBuf readUnsignedByte
public abstract short readUnsignedByte();
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactoryTest.java
License:Open Source License
/** * Testing of {@link TableModInputMessageFactory} for correct translation from POJO * @throws Exception //w ww.ja v a 2 s . c om */ @Test public void testTableModInput() throws Exception { TableModInputBuilder builder = new TableModInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setTableId(new TableId(9L)); builder.setConfig(new TableConfig(true)); TableModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); TableModInputMessageFactory factory = TableModInputMessageFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16); Assert.assertEquals("Wrong TableID", message.getTableId().getValue().intValue(), out.readUnsignedByte()); out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE); Assert.assertEquals("Wrong TableConfig", 8, out.readUnsignedInt()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_OP, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SHA, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } else {/* ww w. j a v a 2s . c o m*/ assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SPA, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); } else {//from w w w . jav a 2 s .com assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); } }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpThaSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_THA, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } else {//ww w .ja v a2 s .c o m assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpTpaSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_TPA, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); } else {//w w w . ja v a 2 s. c om assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); } }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthDstSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_DST, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } else {/* w ww .j a va2 s .c om*/ assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthSrcSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_SRC, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } else {//from w w w . ja v a 2 s .c om assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthTypeSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_TYPE, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4CodeSerializerTest.java
License:Open Source License
/** * Test correct serialization/*from w w w.j a va 2 s.c o m*/ */ @Test public void testSerialize() { MatchEntryBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, false); assertEquals("Wrong value", 200, buffer.readUnsignedByte()); assertTrue("Unexpected data", buffer.readableBytes() == 0); }