Bug 1254 - Added unit tests for FlowConvertor, NotificationQueueWrapper and OpenflowP...
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / NotificationQueueWrapperTest.java
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/NotificationQueueWrapperTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/NotificationQueueWrapperTest.java
new file mode 100644 (file)
index 0000000..d39711e
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowplugin.openflow.md.core;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class NotificationQueueWrapperTest {\r
+\r
+    /**\r
+     * Test NotificationQueueWrapper creation\r
+     */\r
+    @Test(expected=IllegalArgumentException.class)\r
+    public void test() {\r
+        NotificationQueueWrapper queueWrapper = new NotificationQueueWrapper(null, null);\r
+    }\r
+\r
+    /**\r
+     * Test NotificationQueueWrapper creation\r
+     */\r
+    @Test(expected=IllegalArgumentException.class)\r
+    public void test2() {\r
+        EchoRequestMessageBuilder echoBuilder = new EchoRequestMessageBuilder();\r
+        NotificationQueueWrapper queueWrapper = new NotificationQueueWrapper(echoBuilder.build(), null);\r
+    }\r
+\r
+    /**\r
+     * Test NotificationQueueWrapper creation\r
+     */\r
+    @Test\r
+    public void test3() {\r
+        EchoRequestMessageBuilder echoBuilder = new EchoRequestMessageBuilder();\r
+        NotificationQueueWrapper queueWrapper = new NotificationQueueWrapper(echoBuilder.build(),\r
+                (short) EncodeConstants.OF13_VERSION_ID);\r
+\r
+        Assert.assertEquals("Wrong implemented interface", "org.opendaylight.openflowplugin.openflow.md"\r
+                + ".core.NotificationQueueWrapper", queueWrapper.getImplementedInterface().getName());\r
+        Assert.assertEquals("Wrong version", 4, queueWrapper.getVersion().intValue());\r
+        Assert.assertEquals("Wrong notification", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol"\r
+                + ".rev130731.EchoRequestMessage", queueWrapper.getNotification().getImplementedInterface().getName());\r
+        Assert.assertEquals("Wrong xid", -1, queueWrapper.getXid().longValue());\r
+        queueWrapper.setXid(12345L);\r
+        Assert.assertEquals("Wrong xid", 12345, queueWrapper.getXid().intValue());\r
+    }\r
+}
\ No newline at end of file