X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fserialization%2Fexperimenter%2FBundleControlFactoryTest.java;fp=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fserialization%2Fexperimenter%2FBundleControlFactoryTest.java;h=0000000000000000000000000000000000000000;hb=ce9898d3e25c7cecae6a21290be1eb3c74061737;hp=180d915a0e91a6aa309ea3c84ce636ae4d665c5f;hpb=4231959d8488d0e5e50199703c5619d50428a962;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java deleted file mode 100644 index 180d915a..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleControlType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControlBuilder; - -/** - * Test for {@link org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleControlFactory}. - */ -@RunWith(MockitoJUnitRunner.class) -public class BundleControlFactoryTest { - - private OFSerializer factory; - @Mock - SerializerRegistry registry; - @Mock - OFSerializer serializer; - - @Before - public void setUp() throws Exception { - SerializerRegistry registry = new SerializerRegistryImpl(); - registry.init(); - factory = registry.getSerializer(ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( - EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID, EncodeConstants.ONF_ET_BUNDLE_CONTROL)); - } - - @Test - public void testSerializeWithoutProperties() { - BundleControlBuilder builder = new BundleControlBuilder(); - builder.setBundleId(new BundleId(1L)); - builder.setType(BundleControlType.ONFBCTOPENREQUEST); - builder.setFlags(new BundleFlags(true, true)); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - factory.serialize(builder.build(), out); - - Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt()); - Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREQUEST.getIntValue(), out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort()); - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } - - @Test - public void testSerializeWithExperimenterProperty() { - BundleControlBuilder builder = new BundleControlBuilder(); - builder.setBundleId(new BundleId(3L)); - builder.setType(BundleControlType.ONFBCTCOMMITREQUEST); - builder.setFlags(new BundleFlags(false, true)); - - BundleExperimenterPropertyData data = AbstractBundleMessageFactoryTest.createBundleExperimenterPropertyData(); - builder.setBundleProperty(AbstractBundleMessageFactoryTest.createListWithBundleExperimenterProperty(data)); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - Mockito.when(registry.getSerializer(Matchers.any(MessageTypeKey.class))).thenReturn(serializer); - ((SerializerRegistryInjector) factory).injectSerializerRegistry(registry); - factory.serialize(builder.build(), out); - - Assert.assertEquals("Wrong bundle ID", 3L, out.readUnsignedInt()); - Assert.assertEquals("Wrong type", BundleControlType.ONFBCTCOMMITREQUEST.getIntValue(), out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong property type", BundlePropertyType.ONFETBPTEXPERIMENTER.getIntValue(), out.readUnsignedShort()); - int length = out.readUnsignedShort(); - Assert.assertEquals("Wrong experimenter ID", 1, out.readUnsignedInt()); - Assert.assertEquals("Wrong experimenter type", 2, out.readUnsignedInt()); - Mockito.verify(serializer, Mockito.times(1)).serialize(data, out); - } - -} \ No newline at end of file