Added test
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / MessageTypeCodeKeyTest.java
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java
new file mode 100644 (file)
index 0000000..d63a792
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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.impl.deserialization;
+
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+/**
+ * 
+ * @author madamjak
+ *
+ */
+public class MessageTypeCodeKeyTest {
+
+    @Test
+    public void testEquals(){
+        short msgType1 = 12;
+        short msgVersion1 = 34;
+        short msgType2 = 21;
+        short msgVersion2 = 43;
+        
+        MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion1, msgType1);
+        
+        Assert.assertTrue("Wrong - equals to same obejct",key1.equals(key1));
+        Assert.assertFalse("Wrong - equals to null",key1.equals(null));
+        Assert.assertFalse("Wrong - equals to different class",key1.equals(new Object()));
+        
+        MessageTypeCodeKey key2 = new MessageTypeCodeKey(msgVersion2, msgType2);
+        Assert.assertFalse("Wrong - equals by msgType",key1.equals(key2));
+        
+        key2 = new MessageTypeCodeKey(msgVersion2, msgType1);
+        Assert.assertFalse("Wrong - equals by msgVersion",key1.equals(key2));
+    }
+
+    @Test
+    public void testGetter(){
+        
+        short msgType = 12;
+        short msgVersion = 34;
+
+        MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion, msgType);
+
+        Assert.assertEquals(msgType, key1.getMsgType());
+        Assert.assertEquals(msgVersion, key1.getMsgVersion());
+
+    }
+
+}