BUG-4283: experimenter msg support - serialization part 12/28812/3
authorMichal Rehak <mirehak@cisco.com>
Thu, 22 Oct 2015 12:59:51 +0000 (14:59 +0200)
committerMichal Rehak <mirehak@cisco.com>
Wed, 28 Oct 2015 12:45:01 +0000 (13:45 +0100)
 - added serialization support for symmetric and multipart
   experimenter message
 - comments worked in

Change-Id: I8fc4d00e6afc058b335034e8298f9b846d24d8bc
Signed-off-by: Michal Rehak <mirehak@cisco.com>
23 files changed:
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdSerializerKey.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeSerializerKey.java [new file with mode: 0644]
openflow-protocol-api/src/main/yang/openflow-augments.yang
openflow-protocol-api/src/main/yang/openflow-protocol.yang
openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java
openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeSerializerKeyTest.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java
openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java
openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java

index a49d84c3a588cd58a319daf842cf7199a8bca18f..06c54f9dc47ae622cf447f4d4e3ea0ca2898c675 100644 (file)
@@ -9,8 +9,7 @@
 package org.opendaylight.openflowjava.protocol.api.extensibility;
 
 import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 /**
  * Uniform interface for deserializing factories
@@ -18,7 +17,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  * @author timotej.kubas
  * @param <E> message code type
  */
-public interface OFDeserializer<E extends DataObject> extends OFGeneralDeserializer {
+public interface OFDeserializer<E extends DataContainer> extends OFGeneralDeserializer {
 
     /**
      * Transforms byte message into POJO/DTO (of type E).
index 6b2ef47314d74d356ea18cf6e773f8df49fffb64..ec63be53d2784bee65d9686fe24c295167ced7fb 100644 (file)
@@ -8,9 +8,8 @@
 
 package org.opendaylight.openflowjava.protocol.api.extensibility;
 
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 /**
  * Uniform interface for serializers
@@ -18,7 +17,7 @@ import io.netty.buffer.ByteBuf;
  * @author timotej.kubas
  * @param <T> message type
  */
-public interface OFSerializer <T extends DataObject> extends OFGeneralSerializer {
+public interface OFSerializer<T extends DataContainer> extends OFGeneralSerializer {
 
     /**
      * Transforms POJO/DTO into byte message (ByteBuf).
index ebccdad87719fe9dbe994ab1bb13e56fa48ab92a..13162491f92135d238d62df2795d8fa6173011ff 100644 (file)
@@ -15,9 +15,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
 
 
@@ -73,16 +72,16 @@ public interface SerializerExtensionProvider {
      * @param key used for serializer lookup
      * @param serializer serializer implementation
      */
-    void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey<ExperimenterInput> key,
-            OFSerializer<ExperimenterInput> serializer);
+    void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey<? extends ExperimenterDataOfChoice> key,
+                                               OFSerializer<? extends ExperimenterDataOfChoice> serializer);
 
     /**
      * Registers multipart-request (stats-request) serializer
      * @param key used for serializer lookup
      * @param serializer serializer implementation
      */
-    void registerMultipartRequestSerializer(ExperimenterIdSerializerKey<MultipartRequestExperimenterCase> key,
-            OFSerializer<MultipartRequestExperimenterCase> serializer);
+    void registerMultipartRequestSerializer(ExperimenterIdSerializerKey<? extends ExperimenterDataOfChoice> key,
+                                            OFSerializer<? extends ExperimenterDataOfChoice> serializer);
 
     /**
      * Registers multipart-request table-features serializer
index 89525282c3412f372ad5839614afed011b66d434..8a900e346e02686eaf686908823ff6ef5bfcd507 100644 (file)
@@ -8,16 +8,16 @@
 
 package org.opendaylight.openflowjava.protocol.api.keys;
 
-import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 /**
  * @author michal.polkorab
  * @param <T> class of object to be serialized
  */
-public class ExperimenterIdSerializerKey<T extends DataObject> extends MessageTypeKey<T>
+public class ExperimenterIdSerializerKey<T extends DataContainer> extends MessageTypeKey<T>
         implements ExperimenterSerializerKey {
 
-    private Long experimenterId;
+    private long experimenterId;
 
     /**
      * @param msgVersion protocol wire version
@@ -25,7 +25,7 @@ public class ExperimenterIdSerializerKey<T extends DataObject> extends MessageTy
      * @param objectClass class of object to be serialized
      */
     public ExperimenterIdSerializerKey(short msgVersion,
-            Long experimenterId, Class<T> objectClass) {
+                                       long experimenterId, Class<T> objectClass) {
         super(msgVersion, objectClass);
         this.experimenterId = experimenterId;
     }
@@ -34,10 +34,14 @@ public class ExperimenterIdSerializerKey<T extends DataObject> extends MessageTy
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode());
+        result = prime * result + hashCodeOfLong(experimenterId);
         return result;
     }
 
+    protected int hashCodeOfLong(long longValue) {
+        return (int) (longValue ^ (longValue >>> 32));
+    }
+
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
@@ -50,11 +54,7 @@ public class ExperimenterIdSerializerKey<T extends DataObject> extends MessageTy
             return false;
         }
         ExperimenterIdSerializerKey<?> other = (ExperimenterIdSerializerKey<?>) obj;
-        if (experimenterId == null) {
-            if (other.experimenterId != null) {
-                return false;
-            }
-        } else if (!experimenterId.equals(other.experimenterId)) {
+        if (experimenterId != other.experimenterId) {
             return false;
         }
         return true;
diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeSerializerKey.java
new file mode 100644 (file)
index 0000000..b8f6ac9
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014 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.api.keys;
+
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+/**
+ * @param <T> class of object to be serialized
+ * @author michal.polkorab
+ */
+public class ExperimenterIdTypeSerializerKey<T extends DataContainer> extends ExperimenterIdSerializerKey<T> {
+
+    private long type;
+
+    /**
+     * @param msgVersion     protocol wire version
+     * @param experimenterId experimenter / vendor ID
+     * @param type           data type according to vendor implementation
+     * @param objectClass    class of object to be serialized
+     */
+    public ExperimenterIdTypeSerializerKey(short msgVersion,
+                                           long experimenterId, long type, Class<T> objectClass) {
+        super(msgVersion, experimenterId, objectClass);
+        this.type = type;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + hashCodeOfLong(type);
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof ExperimenterIdTypeSerializerKey)) {
+            return false;
+        }
+        ExperimenterIdTypeSerializerKey<?> other = (ExperimenterIdTypeSerializerKey<?>) obj;
+        if (type != other.type) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + "; type: " + type;
+    }
+}
\ No newline at end of file
index f0f96369a403facdb4d872f04de89d95944bd526..e5be7e566af13870df05e8cc85463a8c88135528 100644 (file)
          }
      }
 
-// OFP_MULTIPART AUGMENTS
-     augment "/ofproto:multipart-request/ofproto:input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" {
-         ext:augment-identifier "experimenter-id-multipart-request";
-         leaf experimenter {
-             type oft:experimenter-id;
-         }
-         leaf exp-type {
-             type uint32;
-         }
-     }
-     augment "/ofproto:multipart-reply-message/ofproto:multipart-reply-body/ofproto:multipart-reply-experimenter-case/ofproto:multipart-reply-experimenter" {
-         ext:augment-identifier "experimenter-id-multipart-reply";
-         leaf experimenter {
-             type oft:experimenter-id;
-         }
-         leaf exp-type {
-             type uint32;
-         }
-     }
-
 // OFP_METER_BAND AUGMENTS
      augment "/ofproto:meter-band-container/ofproto:meter-band/ofproto:meter-band-experimenter-case/ofproto:meter-band-experimenter" {
          ext:augment-identifier "experimenter-id-meter-band";
index 3d9f1d6c25247f120cafa215cc10d6f73583ee4e..84e78a5839f4090984ad8f6ffc8c3cf46d553161 100644 (file)
                     type uint32;
                 }
             }
+            grouping experimenter-core {
+                description "General experimenter message content suitable for symmetric and multipart message";
+                leaf experimenter {
+                    type oft:experimenter-id;
+                }
+                leaf exp_type {
+                    type uint32;
+                }
+                choice experimenter-data-of-choice {
+                    // to be augmented by vendors
+                }
+             }
+            grouping experimenter-of-message {
+                reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec";
+                /* Symmetric message */
+                uses ofHeader;
+                uses experimenter-core;
+            }
+
         /* Switch configuration messages. */
             grouping features-request {
                 reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec";
                     }
                     case multipart-request-experimenter-case {
                         container multipart-request-experimenter {
-                            // empty body - used for experimenter augmentation
+                            uses experimenter-core;
                         }
                     }
                 }
             }
 
             rpc experimenter {
+                description "Send experimenter message to device, reply is not solicitated.";
                 input {
-                    uses experimenter;
+                    uses experimenter-of-message;
                 }
             }
 
index aa5d127517e20ac23e7e76d1800e4224b27b1b81..a3bf78913832530d34bec6fdd34b040dc4501c19 100644 (file)
@@ -26,7 +26,7 @@ public class ExperimenterIdSerializerKeyTest {
      * Test ExperimenterIdSerializerKey equals and hashCode
      */
     @Test
-    public void test() {
+    public void testHashCodeAndEquals() {
         ExperimenterIdSerializerKey<?> key1 =
                 new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class);
         ExperimenterIdSerializerKey<?> key2 =
@@ -36,9 +36,6 @@ public class ExperimenterIdSerializerKeyTest {
         key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
-        key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class);
-        Assert.assertFalse("Wrong equals", key1.equals(key2));
-        Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
         key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
@@ -56,7 +53,7 @@ public class ExperimenterIdSerializerKeyTest {
     @Test
     public void testEquals() {
         ExperimenterIdSerializerKey<?> key1 =
-                new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class);
+                new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 41L, ExperimenterMessage.class);
         Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
         MessageTypeKey<?>mk = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID,ExperimenterMessage.class);
         Assert.assertFalse("Wrong equal to different class.", key1.equals(mk));
diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeSerializerKeyTest.java
new file mode 100644 (file)
index 0000000..a613d0d
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2014 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.api.keys.experimenter;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
+
+/**
+ * @author michal.polkorab
+ */
+public class ExperimenterIdTypeSerializerKeyTest {
+
+    /**
+     * Test ExperimenterIdTypeSerializerKey equals and hashCode
+     */
+    @Test
+    public void testHashCodeAndEquals() {
+        ExperimenterIdTypeSerializerKey<?> key1 =
+                new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class);
+        ExperimenterIdTypeSerializerKey<?> key2 =
+                new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class);
+        Assert.assertTrue("Wrong equals", key1.equals(key2));
+        Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode());
+        key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, 1L, ExperimenterMessage.class);
+        Assert.assertFalse("Wrong equals", key1.equals(key2));
+        Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
+        key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, 1L, ExperimenterMessage.class);
+        Assert.assertFalse("Wrong equals", key1.equals(key2));
+        Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
+        key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, 1L, null);
+        Assert.assertFalse("Wrong equals", key1.equals(key2));
+        Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
+        key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, 1L, ErrorMessage.class);
+        Assert.assertFalse("Wrong equals", key1.equals(key2));
+        Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
+
+        key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, 2L, ExperimenterMessage.class);
+        Assert.assertFalse("Wrong equals", key1.equals(key2));
+        Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
+    }
+
+    /**
+     * Test ExperimenterIdTypeSerializerKey equals - additional test
+     */
+    @Test
+    public void testEquals() {
+        ExperimenterIdTypeSerializerKey<?> key1 =
+                new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 41L, 1L, ExperimenterMessage.class);
+        Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
+        ExperimenterIdSerializerKey<?> mk = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class);
+        Assert.assertFalse("Wrong equal to different class.", key1.equals(mk));
+        ExperimenterIdTypeSerializerKey<?> key2 =
+                new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class);
+        Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2));
+
+        ExperimenterIdTypeSerializerKey<?> key3 =
+                new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 41L, 2L, ExperimenterMessage.class);
+        Assert.assertFalse("Wrong equal by type.", key1.equals(key3));
+    }
+
+}
\ No newline at end of file
index c2b4890dfab34f0acaa6c41ef8b6844b97f4a9c8..5d6d26c2e306e5b46d663be8a77c07b3632c74b9 100644 (file)
@@ -9,8 +9,9 @@
 
 package org.opendaylight.openflowjava.protocol.impl.core;
 
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.channel.nio.NioEventLoopGroup;
-
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
@@ -43,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
@@ -50,9 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
  * Exposed class for server handling<br>
  * C - {@link MatchEntrySerializerKey} parameter representing oxm_class (see specification)<br>
@@ -253,14 +252,14 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
     }
 
     @Override
-    public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey<ExperimenterInput> key,
-            OFSerializer<ExperimenterInput> serializer) {
+    public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey<? extends ExperimenterDataOfChoice> key,
+                                                      OFSerializer<? extends ExperimenterDataOfChoice> serializer) {
         serializerRegistry.registerSerializer(key, serializer);
     }
 
     @Override
-    public void registerMultipartRequestSerializer(ExperimenterIdSerializerKey<MultipartRequestExperimenterCase> key,
-            OFSerializer<MultipartRequestExperimenterCase> serializer) {
+    public void registerMultipartRequestSerializer(ExperimenterIdSerializerKey<? extends ExperimenterDataOfChoice> key,
+                                                   OFSerializer<? extends ExperimenterDataOfChoice> serializer) {
         serializerRegistry.registerSerializer(key, serializer);
     }
 
index c3610c13fef5188889ac9a39eda51d572a935704..953034091988c8b11f790e4310c9dda8490a3ede 100644 (file)
@@ -35,6 +35,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleR
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetAsyncInputMessageFactory;
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory;
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.VendorInputMessageFactory;
 import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
@@ -77,7 +78,7 @@ public final class MessageFactoryInitializer {
         registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory());
         registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory());
         registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory());
-        registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory());
+        registryHelper.registerSerializer(ExperimenterInput.class, new VendorInputMessageFactory());
         registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory());
         registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory());
         registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory());
index 6dd5f663cbff4c938c875d99c0a08fa7d2bbc8a2..b544a8ffd1ad2795e92ea3a39d521066402aa00c 100644 (file)
@@ -9,30 +9,41 @@
 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
-
 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.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterOfMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 
 /**
- * Translates Experimenter messages
+ * Translates Experimenter messages (both: symmetric request and single reply)
  * @author michal.polkorab
  */
-public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterInput>,
+public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterOfMessage>,
         SerializerRegistryInjector {
 
     private SerializerRegistry registry;
 
+    /** Code type of symmetric Experimenter message */
+    private static final byte MESSAGE_TYPE = 4;
+
     @Override
-    public void serialize(ExperimenterInput message, ByteBuf outBuffer) {
+    public void serialize(ExperimenterOfMessage message, ByteBuf outBuffer) {
         long expId = message.getExperimenter().getValue();
-        OFSerializer<ExperimenterInput> serializer = registry.getSerializer(
+        OFSerializer<ExperimenterDataOfChoice> serializer = registry.getSerializer(
                 ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey(
-                        EncodeConstants.OF10_VERSION_ID, expId));
-        serializer.serialize(message, outBuffer);
+                        EncodeConstants.OF13_VERSION_ID, expId, message.getExpType().longValue()));
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+
+        // write experimenterId and type
+        outBuffer.writeInt(message.getExperimenter().getValue().intValue());
+        outBuffer.writeInt(message.getExpType().intValue());
+
+        serializer.serialize(message.getExperimenterDataOfChoice(), outBuffer);
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
     }
 
     @Override
index 7afb253b4bc50d524d9faa4b59427d34c5f5cd96..2287a64abf2534cc69c9e7067266b796bf63e371 100644 (file)
@@ -9,9 +9,7 @@
 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
-
 import java.util.List;
-
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
@@ -23,7 +21,6 @@ import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
@@ -37,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase;
@@ -144,11 +142,18 @@ public class MultipartRequestInputFactory implements OFSerializer<MultipartReque
         MultipartRequestExperimenterCase expCase =
                 (MultipartRequestExperimenterCase) message.getMultipartRequestBody();
         MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter();
-        long expId = experimenter.getAugmentation(ExperimenterIdMultipartRequest.class).getExperimenter().getValue();
-        OFSerializer<MultipartRequestExperimenterCase> serializer = registry.getSerializer(
+        final long expId = experimenter.getExperimenter().getValue().longValue();
+        final long expType = experimenter.getExpType().longValue();
+
+        // write experimenterId and type
+        outBuffer.writeInt((int) expId);
+        outBuffer.writeInt((int) expType);
+
+        // serialize experimenter data
+        OFSerializer<ExperimenterDataOfChoice> serializer = registry.getSerializer(
                 ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(
-                        EncodeConstants.OF13_VERSION_ID, expId));
-        serializer.serialize(expCase, outBuffer);
+                        EncodeConstants.OF13_VERSION_ID, expId, expType));
+        serializer.serialize(experimenter.getExperimenterDataOfChoice(), outBuffer);
     }
 
     private static int createMultipartRequestFlagsBitmask(final MultipartRequestFlags flags) {
index ca81ef13986ba7637897cb4aacc88ad871aab5f4..fa01f6d8fc3784c87ae9e56a40386baea018c4b8 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
@@ -17,10 +16,10 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase;
@@ -132,11 +131,16 @@ public class OF10StatsRequestInputFactory implements OFSerializer<MultipartReque
     private void serializeExperimenterBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) {
         MultipartRequestExperimenterCase expCase = (MultipartRequestExperimenterCase) multipartRequestBody;
         MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter();
-        long expId = experimenter.getAugmentation(ExperimenterIdMultipartRequest.class).getExperimenter().getValue();
-        OFSerializer<MultipartRequestExperimenterCase> serializer = registry.getSerializer(
+        final long expId = experimenter.getExperimenter().getValue().longValue();
+
+        // write experimenterId
+        output.writeInt((int) expId);
+
+        OFSerializer<ExperimenterDataOfChoice> serializer = registry.getSerializer(
                 ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(
-                        EncodeConstants.OF10_VERSION_ID, expId));
-        serializer.serialize(expCase, output);
+                        EncodeConstants.OF10_VERSION_ID, expId,
+                        -1 /* in order not to collide with OF >= 1.3 codecs*/));
+        serializer.serialize(experimenter.getExperimenterDataOfChoice(), output);
     }
 
     @Override
index 1cf2adc39ca8c51bcd15a0a1c4b5c8b1fff3dfe6..2cc7148e944c3bf5279517d09d8ba65b87cda21f 100644 (file)
@@ -9,30 +9,34 @@
 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
-
 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.util.EncodeConstants;
 import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterOfMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 
 /**
- * Translates Vendor messages
+ * Translates Vendor messages (OF-1.0 limited version - skipping experimenter type)
  * @author michal.polkorab
  */
-public class VendorInputMessageFactory implements OFSerializer<ExperimenterInput>,
+public class VendorInputMessageFactory implements OFSerializer<ExperimenterOfMessage>,
         SerializerRegistryInjector {
 
     private SerializerRegistry registry;
 
     @Override
-    public void serialize(ExperimenterInput message, ByteBuf outBuffer) {
+    public void serialize(ExperimenterOfMessage message, ByteBuf outBuffer) {
         long expId = message.getExperimenter().getValue();
-        OFSerializer<ExperimenterInput> serializer = registry.getSerializer(
+        OFSerializer<ExperimenterDataOfChoice> serializer = registry.getSerializer(
                 ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey(
-                        EncodeConstants.OF10_VERSION_ID, expId));
-        serializer.serialize(message, outBuffer);
+                        EncodeConstants.OF10_VERSION_ID, expId, message.getExpType().longValue()));
+
+        // write experimenterId
+        outBuffer.writeInt(message.getExperimenter().getValue().intValue());
+
+        serializer.serialize(message.getExperimenterDataOfChoice(), outBuffer);
     }
 
     @Override
index a770e853e554c222c1d63597c400696b9b92f1c2..862de53db0b0f96a11a56790bfe79ffca180fd34 100644 (file)
@@ -8,15 +8,18 @@
 package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
 import static org.mockito.Mockito.when;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.RemovalListener;
+import com.google.common.cache.RemovalNotification;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelOutboundHandlerAdapter;
 import io.netty.channel.ChannelPipeline;
 import io.netty.channel.embedded.EmbeddedChannel;
 import io.netty.channel.socket.SocketChannel;
-
 import java.net.InetSocketAddress;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -57,11 +60,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
-
 /**
  * Test counters in ConnectionAdapter (at least DS_ENTERED_OFJAVA, DS_FLOW_MODS_ENTERED and US_MESSAGE_PASS counters have to be enabled)
  * @author madamjak
index c83e60c5383f7334e8cc4ad53352fc1eb22c8566..f70962f640f41bd2626c6c09f908a8a84b73fc69 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -43,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
@@ -63,8 +64,8 @@ public class SwitchConnectionProviderImpl02Test {
     @Mock OFDeserializer<MultipartReplyMessage> deserializerMultipartRplMsg;
     @Mock OFDeserializer<QueueProperty> deserializerQueueProperty;
     @Mock OFDeserializer<MeterBandExperimenterCase> deserializerMeterBandExpCase;
-    @Mock OFSerializer<ExperimenterInput> serializerExperimenterInput;
-    @Mock OFSerializer<MultipartRequestExperimenterCase> serializerMultipartRequestExpCase;
+    @Mock OFSerializer<ExperimenterDataOfChoice> serializerExperimenterInput;
+    @Mock OFSerializer<ExperimenterDataOfChoice> serializerMultipartRequestExpCase;
     @Mock OFSerializer<MeterBandExperimenterCase> serializerMeterBandExpCase;
     private static final int SWITCH_IDLE_TIMEOUT = 2000;
     private InetAddress startupAddress;
@@ -211,14 +212,14 @@ public class SwitchConnectionProviderImpl02Test {
         Assert.assertTrue("Wrong -- unregister MeterBandDeserializer", provider.unregisterDeserializer(key11));
         Assert.assertFalse("Wrong -- unregister MeterBandDeserializer by not existing key", provider.unregisterDeserializer(key11));
         // -- registerExperimenterMessageSerializer
-        ExperimenterIdSerializerKey<ExperimenterInput> key12
-            = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,ExperimenterInput.class);
+        ExperimenterIdSerializerKey<ExperimenterDataOfChoice> key12
+                = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterDataOfChoice.class);
         provider.registerExperimenterMessageSerializer(key12, serializerExperimenterInput);
         Assert.assertTrue("Wrong -- unregister ExperimenterMessageSerializer", provider.unregisterSerializer(key12));
         Assert.assertFalse("Wrong -- unregister ExperimenterMessageSerializer by not existing key", provider.unregisterSerializer(key12));
         //registerMultipartRequestSerializer
-        ExperimenterIdSerializerKey<MultipartRequestExperimenterCase> key13
-            = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,MultipartRequestExperimenterCase.class);
+        ExperimenterIdSerializerKey<ExperimenterDataOfChoice> key13
+                = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterDataOfChoice.class);
         provider.registerMultipartRequestSerializer(key13, serializerMultipartRequestExpCase);
         Assert.assertTrue("Wrong -- unregister MultipartRequestSerializer", provider.unregisterSerializer(key13));
         Assert.assertFalse("Wrong -- unregister MultipartRequestSerializer by not existing key", provider.unregisterSerializer(key13));
index 89e0f958fb9bc45122ff6908b0bee85e13e8f326..9b6720e4935fea48e76845c191e462294d631a17 100644 (file)
@@ -9,8 +9,6 @@
 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
-import io.netty.buffer.UnpooledByteBufAllocator;
-
 import org.junit.Test;
 import org.mockito.Matchers;
 import org.mockito.Mock;
@@ -26,6 +24,8 @@ import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterOfMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 
 /**
  * @author michal.polkorab
@@ -34,8 +34,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class ExperimenterInputMessageFactoryTest {
 
     @Mock SerializerRegistry registry;
-    @Mock OFSerializer<ExperimenterInput> serializer;
-    private OFSerializer<ExperimenterInput> expFactory;
+    @Mock
+    private OFSerializer<ExperimenterDataOfChoice> serializer;
+    private OFSerializer<ExperimenterOfMessage> expFactory;
+    @Mock
+    private ExperimenterDataOfChoice vendorData;
+    @Mock
+    private ByteBuf out;
 
     /**
      * Sets up ExperimenterInputMessageFactory
@@ -64,9 +69,10 @@ public class ExperimenterInputMessageFactoryTest {
         ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
         BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
         builder.setExperimenter(new ExperimenterId(42L));
+        builder.setExpType(21L);
+        builder.setExperimenterDataOfChoice(vendorData);
         ExperimenterInput input = builder.build();
 
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         expFactory.serialize(input, out);
     }
 
@@ -81,9 +87,10 @@ public class ExperimenterInputMessageFactoryTest {
         ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
         BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
         builder.setExperimenter(new ExperimenterId(42L));
+        builder.setExpType(22L);
+        builder.setExperimenterDataOfChoice(vendorData);
         ExperimenterInput input = builder.build();
 
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         expFactory.serialize(input, out);
     }
 
@@ -98,13 +105,15 @@ public class ExperimenterInputMessageFactoryTest {
         ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
         BufferHelper.setupHeader(builder, EncodeConstants.OF10_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);
 
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         expFactory.serialize(input, out);
+        Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out);
     }
 
     /**
@@ -118,12 +127,14 @@ public class ExperimenterInputMessageFactoryTest {
         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);
 
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         expFactory.serialize(input, out);
+        Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out);
     }
 }
\ No newline at end of file
index 15496598fd9bfb582e519c867a3174df53ee7ee5..f299e818e9e9f6a1832a220007231e95cba7b86d 100644 (file)
@@ -10,19 +10,21 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.PooledByteBufAllocator;
-
 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.keys.ExperimenterIdSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 
 /**
  * @author michal.polkorab
@@ -32,14 +34,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class VendorInputMessageFactoryTest {
 
     @Mock SerializerRegistry registry;
-    @Mock ExperimenterInputMessageFactory serializer;
+    @Mock OFSerializer<ExperimenterDataOfChoice> foundSerializer;
+    @Mock ExperimenterDataOfChoice vendorData;
+    VendorInputMessageFactory serializer;
 
     /**
-     * Tests {@link VendorInputMessageFactory#serialize(ExperimenterInput, ByteBuf)}
+     * Tests {@link VendorInputMessageFactory#serialize(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterOfMessage, ByteBuf)}
      */
     @Test
     public void test() {
-        Mockito.when(registry.getSerializer((MessageTypeKey<?>) Matchers.any(MessageTypeKey.class)))
+        Mockito.when(registry.getSerializer(Matchers.<MessageTypeKey<?>>any()))
             .thenReturn(serializer);
         VendorInputMessageFactory factory = new VendorInputMessageFactory();
         factory.injectSerializerRegistry(registry);
@@ -49,9 +53,12 @@ public class VendorInputMessageFactoryTest {
         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(serializer, Mockito.times(1)).serialize(experimenterInput, buffer);
+        Mockito.verify(foundSerializer, Mockito.times(1)).serialize(experimenterInput.getExperimenterDataOfChoice(), buffer);
     }
 }
\ No newline at end of file
index c4d58dc94c1c1dd5a7e20e9f62e720804c09f369..ce94f426a606be54d566844e1c58afbc56caae6f 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories.mult
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.UnpooledByteBufAllocator;
-
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -20,18 +19,16 @@ 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.keys.ExperimenterIdSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequestBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder;
 
@@ -43,7 +40,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class MultipartRequestExperimenterTest {
 
     @Mock SerializerRegistry mockRegistry;
-    @Mock OFSerializer<MultipartRequestExperimenterCase> serializer;
+    @Mock OFSerializer<ExperimenterDataOfChoice> serializer;
+
+    @Mock ExperimenterDataOfChoice vendorData;
 
     /**
      * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization
@@ -51,7 +50,7 @@ public class MultipartRequestExperimenterTest {
      */
     @Test
     public void testExperimenter() throws Exception {
-        Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class)))
+        Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any()))
             .thenReturn(serializer);
         MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory();
         multipartFactory.injectSerializerRegistry(mockRegistry);
@@ -61,9 +60,9 @@ public class MultipartRequestExperimenterTest {
         builder.setFlags(new MultipartRequestFlags(false));
         MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
         MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
-        ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder();
-        expIdBuilder.setExperimenter(new ExperimenterId(42L));
-        expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build());
+        expBuilder.setExperimenter(new ExperimenterId(42L));
+        expBuilder.setExpType(21L);
+        expBuilder.setExperimenterDataOfChoice(vendorData);
         caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
         builder.setMultipartRequestBody(caseBuilder.build());
         MultipartRequestInput message = builder.build();
@@ -71,9 +70,9 @@ public class MultipartRequestExperimenterTest {
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         multipartFactory.serialize(message, out);
 
-        BufferHelper.checkHeaderV13(out, (byte) 18, 16);
+        BufferHelper.checkHeaderV13(out, (byte) 18, 24);
         Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
         Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
-        Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class));
+        Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
     }
 }
\ No newline at end of file
index 0fcacef140d2fddf40fe5942c11ac053c0f0cfee..15430aa6db14b5714d21c1b761a7b6e81d3a056e 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories.mult
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.UnpooledByteBufAllocator;
-
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -20,18 +19,16 @@ 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.keys.ExperimenterIdSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequestBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder;
 
@@ -43,7 +40,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class OF10StatsRequestExperimenterTest {
 
     @Mock SerializerRegistry mockRegistry;
-    @Mock OFSerializer<MultipartRequestExperimenterCase> serializer;
+    @Mock OFSerializer<ExperimenterDataOfChoice> serializer;
+    @Mock
+    private ExperimenterDataOfChoice vendorData;
 
     /**
      * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization
@@ -51,7 +50,7 @@ public class OF10StatsRequestExperimenterTest {
      */
     @Test
     public void testExperimenter() throws Exception {
-        Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class)))
+        Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any()))
             .thenReturn(serializer);
         OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory();
         multipartFactory.injectSerializerRegistry(mockRegistry);
@@ -61,9 +60,9 @@ public class OF10StatsRequestExperimenterTest {
         builder.setFlags(new MultipartRequestFlags(false));
         MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
         MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
-        ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder();
-        expIdBuilder.setExperimenter(new ExperimenterId(42L));
-        expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build());
+        expBuilder.setExperimenter(new ExperimenterId(42L));
+        expBuilder.setExpType(21L);
+        expBuilder.setExperimenterDataOfChoice(vendorData);
         caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
         builder.setMultipartRequestBody(caseBuilder.build());
         MultipartRequestInput message = builder.build();
@@ -71,9 +70,9 @@ public class OF10StatsRequestExperimenterTest {
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         multipartFactory.serialize(message, out);
 
-        BufferHelper.checkHeaderV10(out, (byte) 16, 12);
+        BufferHelper.checkHeaderV10(out, (byte) 16, 16);
         Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
         Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
-        Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class));
+        Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
     }
 }
\ No newline at end of file
index 36033d07b05aa1e67efca0f7c09f9736599afa0a..edc6f25ea5be312689e9c7e433bca0a635d93866 100644 (file)
@@ -9,9 +9,9 @@
 package org.opendaylight.openflowjava.util;
 
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
 
 /**
@@ -23,21 +23,23 @@ public abstract class ExperimenterSerializerKeyFactory {
     /**
      * @param msgVersion openflow wire version
      * @param experimenterId experimenter / vendor ID
+     * @param type experimenter type according to vendor implementation
      * @return key instance
      */
-    public static ExperimenterIdSerializerKey<ExperimenterInput> createExperimenterMessageSerializerKey(
-            short msgVersion, Long experimenterId) {
-        return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, ExperimenterInput.class);
+    public static ExperimenterIdSerializerKey<ExperimenterDataOfChoice> createExperimenterMessageSerializerKey(
+            short msgVersion, long experimenterId, long type) {
+        return new ExperimenterIdTypeSerializerKey<>(msgVersion, experimenterId, type, ExperimenterDataOfChoice.class);
     }
 
     /**
      * @param msgVersion openflow wire version
      * @param experimenterId experimenter / vendor ID
+     * @param type experimenter type according to vendor implementation
      * @return key instance
      */
-    public static ExperimenterIdSerializerKey<MultipartRequestExperimenterCase> createMultipartRequestSerializerKey(
-            short msgVersion, Long experimenterId) {
-        return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MultipartRequestExperimenterCase.class);
+    public static ExperimenterIdSerializerKey<ExperimenterDataOfChoice> createMultipartRequestSerializerKey(
+            short msgVersion, long experimenterId, long type) {
+        return new ExperimenterIdTypeSerializerKey<>(msgVersion, experimenterId, type, ExperimenterDataOfChoice.class);
     }
 
     /**
@@ -46,7 +48,7 @@ public abstract class ExperimenterSerializerKeyFactory {
      * @return key instance
      */
     public static ExperimenterIdSerializerKey<TableFeatureProperties> createMultipartRequestTFSerializerKey(
-            short msgVersion, Long experimenterId) {
+            short msgVersion, long experimenterId) {
         return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, TableFeatureProperties.class);
     }
 
@@ -56,7 +58,7 @@ public abstract class ExperimenterSerializerKeyFactory {
      * @return key instance
      */
     public static ExperimenterIdSerializerKey<MeterBandExperimenterCase> createMeterBandSerializerKey(
-            short msgVersion, Long experimenterId) {
+            short msgVersion, long experimenterId) {
         return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class);
     }
 }
\ No newline at end of file
index 91435929d28b54e3bde9eab03400e0fbb19c1405..211186d75c964d655149eafdd9e0e248dd47a183 100644 (file)
@@ -11,62 +11,64 @@ package org.opendaylight.openflowjava.util;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
 
 /**
+ * Test ExperimenterSerializerKeyFactory key creation
  * @author michal.polkorab
  *
  */
 public class ExperimenterSerializerKeyFactoryTest {
 
-    /**
-     * Test ExperimenterSerializerKeyFactory key creation
-     */
     @Test
-    public void test() {
-        ExperimenterIdSerializerKey<?> createdKey = ExperimenterSerializerKeyFactory
-                .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L);
-        ExperimenterIdSerializerKey<?> comparationKey =
-                new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterInput.class);
-        Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
-        comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
-                null, ExperimenterInput.class);
-        Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(
-                EncodeConstants.OF10_VERSION_ID, 43L);
-        comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
-                43L, MeterBandExperimenterCase.class);
-        Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
-        comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
-                null, MeterBandExperimenterCase.class);
-        Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(
-                EncodeConstants.OF10_VERSION_ID, 44L);
-        comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
-                44L, MultipartRequestExperimenterCase.class);
+    public void testCreateExperimenterMessageSerializerKey() throws Exception {
+        ExperimenterIdSerializerKey<?> createdKey;
+        ExperimenterIdSerializerKey<?> comparationKey;
+
+        createdKey = ExperimenterSerializerKeyFactory
+                .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L);
+        comparationKey = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
+                42L, 1L, ExperimenterDataOfChoice.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
+    }
+
+    @Test
+    public void testCreateMultipartRequestSerializerKey() throws Exception {
+        ExperimenterIdSerializerKey<?> createdKey;
+        ExperimenterIdSerializerKey<?> comparationKey;
+
         createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
+                EncodeConstants.OF10_VERSION_ID, 44L, 1L);
         comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
-                null, MultipartRequestExperimenterCase.class);
+                44L, ExperimenterDataOfChoice.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
+    }
+
+    @Test
+    public void testCreateMultipartRequestTFSerializerKey() throws Exception {
+        ExperimenterIdSerializerKey<?> createdKey;
+        ExperimenterIdSerializerKey<?> comparationKey;
+
         createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey(
                 EncodeConstants.OF10_VERSION_ID, 45L);
         comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
                 45L, TableFeatureProperties.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
+    }
+
+    @Test
+    public void testCreateMeterBandSerializerKey() throws Exception {
+        ExperimenterIdSerializerKey<?> createdKey;
+        ExperimenterIdSerializerKey<?> comparationKey;
+
+        createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(
+                EncodeConstants.OF10_VERSION_ID, 43L);
         comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
-                null, TableFeatureProperties.class);
+                43L, MeterBandExperimenterCase.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
     }
 }
\ No newline at end of file