Search in sources :

Example 1 with DeserializerRegistryInjector

use of org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector in project openflowplugin by opendaylight.

the class BundleControlFactoryTest method testDeserializeWithProperties.

@Test
public void testDeserializeWithProperties() {
    ByteBuf buffer = ByteBufUtils.hexStringToByteBuf(// bundle ID
    "00 00 00 01 " + // type
    "00 05 " + // flags
    "00 02 " + // type 1
    "ff ff " + // length 1
    "00 0c " + // experimenter ID 1
    "00 00 00 01 " + // experimenter type 1
    "00 00 00 02 " + // experimenter data 1
    "00 00 00 00 " + // type 2
    "00 00 " + // length 2
    "00 04 " + // data 2
    "00 00 00 00");
    Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(experimenterPropertyDeserializer);
    ((DeserializerRegistryInjector) factory).injectDeserializerRegistry(registry);
    BundleControlOnf builtByFactory = factory.deserialize(buffer);
    Assert.assertEquals(1, builtByFactory.getOnfControlGroupingData().getBundleId().getValue().intValue());
    BundleFlags flags = new BundleFlags(false, 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.ONFBCTCOMMITREPLY, builtByFactory.getOnfControlGroupingData().getType());
    BundleProperty property = builtByFactory.getOnfControlGroupingData().getBundleProperty().get(0);
    Assert.assertEquals("Wrong bundle property type", BundlePropertyType.ONFETBPTEXPERIMENTER, property.getType());
    BundlePropertyExperimenter experimenterProperty = (BundlePropertyExperimenter) property.getBundlePropertyEntry();
    Assert.assertEquals("Wrong experimenter ID", 1, experimenterProperty.getExperimenter().getValue().intValue());
    Assert.assertEquals("Wrong experimenter type", 2, experimenterProperty.getExpType().longValue());
    Mockito.verify(experimenterPropertyDeserializer, Mockito.times(1)).deserialize(buffer);
}
Also used : DeserializerRegistryInjector(org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) BundleControlOnf(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf) BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundlePropertyExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter) ByteBuf(io.netty.buffer.ByteBuf) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 DeserializerRegistryInjector (org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector)1 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)1 BundleFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)1 BundleProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty)1 BundlePropertyExperimenter (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter)1 BundleControlOnf (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf)1