use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project openflowplugin by opendaylight.
the class BundleAddMessageFactoryTest method testSerialize.
private void testSerialize(final boolean withProperty, final BundleInnerMessage innerMessage) {
final BundleAddMessageOnfBuilder builder = new BundleAddMessageOnfBuilder();
final OnfAddMessageGroupingDataBuilder dataBuilder = new OnfAddMessageGroupingDataBuilder();
dataBuilder.setBundleId(new BundleId(1L));
dataBuilder.setFlags(new BundleFlags(true, false));
dataBuilder.setBundleInnerMessage(innerMessage);
if (withProperty) {
dataBuilder.setBundleProperty(new ArrayList<>(Collections.singleton(BundleTestUtils.createExperimenterProperty(propertyExperimenterData))));
Mockito.when(registry.getSerializer(Matchers.any())).thenReturn(caseSerializer).thenReturn(propertySerializer);
} else {
Mockito.when(registry.getSerializer(Matchers.any())).thenReturn(caseSerializer);
}
builder.setOnfAddMessageGroupingData(dataBuilder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
((SerializerRegistryInjector) factory).injectSerializerRegistry(registry);
factory.serialize(builder.build(), out);
Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt());
long padding = out.readUnsignedShort();
Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort());
Mockito.verify(caseSerializer).serialize(Mockito.any(), Mockito.any());
if (withProperty) {
Mockito.verify(propertySerializer).serialize(propertyExperimenterData, out);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project openflowplugin by opendaylight.
the class BundleControlFactoryTest method testDeserializeWithoutProperties.
@Test
public void testDeserializeWithoutProperties() {
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf(// bundle ID
"00 00 00 01 " + // type
"00 01 " + // flags
"00 03");
BundleControlOnf builtByFactory = factory.deserialize(buffer);
Assert.assertEquals(1, builtByFactory.getOnfControlGroupingData().getBundleId().getValue().intValue());
BundleFlags flags = new BundleFlags(true, true);
Assert.assertEquals("Wrong atomic flag", flags.isAtomic(), builtByFactory.getOnfControlGroupingData().getFlags().isAtomic());
Assert.assertEquals("Wrong ordered flag", flags.isOrdered(), builtByFactory.getOnfControlGroupingData().getFlags().isOrdered());
Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREPLY, builtByFactory.getOnfControlGroupingData().getType());
Assert.assertTrue("Properties not empty", builtByFactory.getOnfControlGroupingData().getBundleProperty().isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project openflowplugin by opendaylight.
the class FlowConvertorTest method test.
/**
* Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
*/
@Test
public void test() {
RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder();
flowBuilder.setBarrier(false);
flowBuilder.setCookie(new FlowCookie(new BigInteger("4")));
flowBuilder.setCookieMask(new FlowCookie(new BigInteger("5")));
flowBuilder.setTableId((short) 6);
flowBuilder.setStrict(true);
flowBuilder.setIdleTimeout(50);
flowBuilder.setHardTimeout(500);
flowBuilder.setPriority(40);
flowBuilder.setBufferId(18L);
flowBuilder.setOutPort(new BigInteger("65535"));
flowBuilder.setOutGroup(5000L);
flowBuilder.setFlags(null);
flowBuilder.setMatch(null);
RemoveFlowInput flow = flowBuilder.build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
data.setDatapathId(new BigInteger("42"));
List<FlowModInputBuilder> flowMod = convert(flow, data);
Assert.assertEquals("Wrong version", 4, flowMod.get(0).getVersion().intValue());
Assert.assertEquals("Wrong cookie", 4, flowMod.get(0).getCookie().intValue());
Assert.assertEquals("Wrong cookie mask", 5, flowMod.get(0).getCookieMask().intValue());
Assert.assertEquals("Wrong table id", 6, flowMod.get(0).getTableId().getValue().intValue());
Assert.assertEquals("Wrong command", FlowModCommand.OFPFCDELETESTRICT, flowMod.get(0).getCommand());
Assert.assertEquals("Wrong idle timeout", 50, flowMod.get(0).getIdleTimeout().intValue());
Assert.assertEquals("Wrong hard timeout", 500, flowMod.get(0).getHardTimeout().intValue());
Assert.assertEquals("Wrong priority", 40, flowMod.get(0).getPriority().intValue());
Assert.assertEquals("Wrong buffer id", 18, flowMod.get(0).getBufferId().intValue());
Assert.assertEquals("Wrong out port", 65535, flowMod.get(0).getOutPort().getValue().intValue());
Assert.assertEquals("Wrong out group", 5000, flowMod.get(0).getOutGroup().intValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowMod.get(0).getFlags());
Assert.assertEquals("Wrong match", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType", flowMod.get(0).getMatch().getType().getName());
Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project openflowplugin by opendaylight.
the class FlowCreatorUtil method equalsFlowModFlags.
/**
* Return {@code true} only if given two FLOW_MOD flags are identical.
*
* @param flags1 A value to be compared.
* @param flags2 A value to be compared.
* @return {@code true} only if {@code flags1} and {@code flags2} are identical.
*/
public static boolean equalsFlowModFlags(FlowModFlags flags1, FlowModFlags flags2) {
FlowModFlags f1;
FlowModFlags f2;
if (flags1 == null) {
if (flags2 == null) {
return true;
}
f1 = DEFAULT_FLOW_MOD_FLAGS;
f2 = flags2;
} else {
f1 = flags1;
f2 = (flags2 == null) ? DEFAULT_FLOW_MOD_FLAGS : flags2;
}
return equalsWithDefault(f1.isCHECKOVERLAP(), f2.isCHECKOVERLAP(), Boolean.FALSE) && equalsWithDefault(f1.isNOBYTCOUNTS(), f2.isNOBYTCOUNTS(), Boolean.FALSE) && equalsWithDefault(f1.isNOPKTCOUNTS(), f2.isNOPKTCOUNTS(), Boolean.FALSE) && equalsWithDefault(f1.isRESETCOUNTS(), f2.isRESETCOUNTS(), Boolean.FALSE) && equalsWithDefault(f1.isSENDFLOWREM(), f2.isSENDFLOWREM(), Boolean.FALSE);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyMeterConfigBodyMulti.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyMeterConfigBodyMulti() {
ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 " + // len
"00 28 " + // flags
"00 06 " + // meterId
"00 00 00 09 " + // meterBandDrop.type
"00 01 " + // meterBandDrop.len
"00 10 " + // meterBandDrop.rate
"00 00 00 11 " + // meterBandDrop.burstSize
"00 00 00 20 " + // meterBandDrop.pad
"00 00 00 00 " + // meterBandDscp.type
"00 02 " + // meterBandDscp.len
"00 10 " + // meterBandDscp.rate
"00 00 00 11 " + // meterBandDscp.burstSize
"00 00 00 20 " + // meterBandDscp.precLevel
"04 " + // meterBandDscp.pad
"00 00 00 " + // len01
"00 18 " + // flags01
"00 03 " + // meterId01
"00 00 00 07 " + // meterBandDscp01.type
"00 02 " + // meterBandDscp01.len
"00 10 " + // meterBandDscp01.rate
"00 00 00 11 " + // meterBandDscp01.burstSize
"00 00 00 20 " + // meterBandDscp01.precLevel
"04 " + // meterBandDscp01.pad
"00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), message.getMeterConfig().get(0).getFlags());
Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue());
MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
LOG.info(message.getMeterConfig().get(0).getFlags().toString());
Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false), message.getMeterConfig().get(1).getFlags());
Assert.assertEquals("Wrong meterId01", 7, message.getMeterConfig().get(1).getMeterId().getValue().intValue());
MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand();
MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark();
Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());
Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
}
Aggregations