use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class MultipartRequestTableFeaturesTest method testMultipartRequestTableFeaturesExperimenter.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestTableFeaturesExperimenter() throws Exception {
MultipartRequestInputFactory factory = new MultipartRequestInputFactory();
factory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(12));
builder.setFlags(new MultipartRequestFlags(true));
TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
tableFeaturesBuilder.setTableId((short) 8);
tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }));
tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }));
tableFeaturesBuilder.setConfig(new TableConfig(true));
tableFeaturesBuilder.setMaxEntries(65L);
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
List<TableFeatureProperties> properties = new ArrayList<>();
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
expBuilder.setExperimenter(new ExperimenterId(43L));
propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
properties.add(propBuilder.build());
tableFeaturesBuilder.setTableFeatureProperties(properties);
List<TableFeatures> tableFeaturesList = new ArrayList<>();
tableFeaturesList.add(tableFeaturesBuilder.build());
MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
featuresBuilder.setTableFeatures(tableFeaturesList);
MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 80);
Assert.assertEquals("Wrong type", 12, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort());
out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
Assert.assertEquals("Wrong length", 64, out.readUnsignedShort());
Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte());
out.skipBytes(5);
Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(out, 32));
byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
out.readBytes(metadataMatch);
Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatch);
byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
out.readBytes(metadataWrite);
Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWrite);
Assert.assertEquals("Wrong config", 8, out.readUnsignedInt());
Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt());
Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), Matchers.any(ByteBuf.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class VendorInputMessageFactoryTest method test.
/**
* Tests {@link VendorInputMessageFactory#serialize(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
* .protocol.rev130731.ExperimenterOfMessage, ByteBuf)}.
*/
@Test
public void test() {
Mockito.when(registry.getSerializer(Matchers.<MessageTypeKey<?>>any())).thenReturn(serializer);
VendorInputMessageFactory factory = new VendorInputMessageFactory();
factory.injectSerializerRegistry(registry);
final ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(12345L);
builder.setExperimenter(new ExperimenterId(42L));
builder.setExpType(84L);
builder.setExperimenterDataOfChoice(vendorData);
ExperimenterInput experimenterInput = builder.build();
Mockito.when(registry.getSerializer(Matchers.<ExperimenterIdSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(foundSerializer);
factory.serialize(experimenterInput, buffer);
Mockito.verify(foundSerializer, Mockito.times(1)).serialize(experimenterInput.getExperimenterDataOfChoice(), buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class OF13SetFieldActionSerializerTest method test.
/**
* Test identify ExperimenterClass serializer.
*/
@Test
public void test() {
OF13SetFieldActionSerializer ser = new OF13SetFieldActionSerializer();
ser.injectSerializerRegistry(registry);
final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder = new ActionBuilder();
long experimenterId = 12L;
ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder();
ExperimenterBuilder expBuilder = new ExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(experimenterId));
expCaseBuilder.setExperimenter(expBuilder.build());
MatchEntryBuilder meb = new MatchEntryBuilder();
meb.setOxmClass(ExperimenterClass.class);
meb.setOxmMatchField(OxmMatchFieldClass.class);
meb.setMatchEntryValue(expCaseBuilder.build());
List<MatchEntry> matchEntry = new ArrayList<>();
MatchEntry me = meb.build();
matchEntry.add(me);
SetFieldCaseBuilder caseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(matchEntry);
caseBuilder.setSetFieldAction(setFieldBuilder.build());
actionBuilder.setActionChoice(caseBuilder.build());
MatchEntrySerializerKey<?, ?> key = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, ExperimenterClass.class, OxmMatchFieldClass.class);
key.setExperimenterId(experimenterId);
registry.registerSerializer(key, serializerMock);
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ser.serialize(actionBuilder.build(), out);
Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntry) Mockito.anyObject(), (ByteBuf) Mockito.anyObject());
int lenght = out.readableBytes();
Assert.assertEquals("Wrong - bad field code", ActionConstants.SET_FIELD_CODE, out.readUnsignedShort());
Assert.assertEquals("Wrong - bad lenght", lenght, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class ExperimenterInputMessageFactoryTest method testV13.
/**
* Testing of {@link ExperimenterInputMessageFactory} for correct serializer
* lookup and serialization.
*/
@Test
public void testV13() throws Exception {
startUp(false);
ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setExperimenter(new ExperimenterId(42L));
builder.setExpType(21L);
builder.setExperimenterDataOfChoice(vendorData);
ExperimenterInput input = builder.build();
Mockito.when(registry.getSerializer((ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer);
expFactory.serialize(input, out);
Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class LearnCodecTest method createAction.
private Action createAction() {
ExperimenterId experimenterId = new ExperimenterId(NiciraConstants.NX_VENDOR_ID);
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setExperimenterId(experimenterId);
final ActionLearnBuilder actionLearnBuilder = new ActionLearnBuilder();
NxActionLearnBuilder nxActionLearnBuilder = new NxActionLearnBuilder();
nxActionLearnBuilder.setIdleTimeout(1);
nxActionLearnBuilder.setHardTimeout(2);
nxActionLearnBuilder.setPriority(3);
nxActionLearnBuilder.setCookie(BigInteger.valueOf(4));
nxActionLearnBuilder.setFlags(5);
nxActionLearnBuilder.setTableId((short) 6);
nxActionLearnBuilder.setFinIdleTimeout(7);
nxActionLearnBuilder.setFinHardTimeout(8);
nxActionLearnBuilder.setFlowMods(createFlowMods());
actionLearnBuilder.setNxActionLearn(nxActionLearnBuilder.build());
actionBuilder.setActionChoice(actionLearnBuilder.build());
return actionBuilder.build();
}
Aggregations