use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class DefaultDeserializerFactoryTest method testHeaderVersions.
/**
* Test correct version after deserialization for all supported OF versions.
* @param versions supported OF versions
* @param buffer byte buffer to deserialze
*/
protected void testHeaderVersions(final List<Byte> versions, final ByteBuf buffer) {
for (short version : versions) {
ByteBuf bb = buffer.copy();
OFDeserializer<T> serializer = registry.getDeserializer(new MessageCodeKey(version, messageCodeKey.getMsgType(), messageCodeKey.getClazz()));
T builtByFactory = BufferHelper.deserialize(serializer, bb);
BufferHelper.checkHeader((OfHeader) builtByFactory, version);
}
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class ExperimenterIdDeserializerKeyTest method testEquals.
/**
* Test ExperimenterIdDeserializerKey equals - additional test.
*/
@Test
public void testEquals() {
ExperimenterIdDeserializerKey key1 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0L, ExperimenterMessage.class);
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class);
Assert.assertFalse("Wrong equal to different class.", key1.equals(mk));
ExperimenterIdDeserializerKey key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class);
Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2));
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class MessageCodeKeyTest method testToString.
/**
* Test MessageCodeKey toString().
*/
@Test
public void testToString() {
MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class);
Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + ".opendaylight.openflow.protocol.rev130731.BarrierInput msgType: 4", key1.toString());
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class MessageCodeKeyTest method testEquals.
/**
* Test MessageCodeKey equals - additional test.
*/
@Test
public void testEquals() {
MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class);
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
Assert.assertFalse("Wrong equal to null.", key1.equals(null));
Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null);
MessageCodeKey key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class);
Assert.assertFalse("Wrong equal by clazz.", key1.equals(key2));
key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null);
Assert.assertTrue("Wrong equal by clazz.", key1.equals(key2));
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class MultipartRequestInputMessageFactory method setFlow.
private MultipartRequestFlowCase setFlow(ByteBuf input) {
final MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
flowBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(FLOW_PADDING_1);
flowBuilder.setOutPort(input.readUnsignedInt());
flowBuilder.setOutGroup(input.readUnsignedInt());
input.skipBytes(FLOW_PADDING_2);
byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(cookie);
flowBuilder.setCookie(new BigInteger(1, cookie));
final byte[] cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(cookieMask);
flowBuilder.setCookieMask(new BigInteger(1, cookieMask));
OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
flowBuilder.setMatch(matchDeserializer.deserialize(input));
caseBuilder.setMultipartRequestFlow(flowBuilder.build());
return caseBuilder.build();
}
Aggregations