Added test
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / MessageTypeCodeKeyTest.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowjava.protocol.impl.deserialization;
10
11 import org.junit.Test;
12
13 import junit.framework.Assert;
14
15 /**
16  * 
17  * @author madamjak
18  *
19  */
20 public class MessageTypeCodeKeyTest {
21
22     @Test
23     public void testEquals(){
24         short msgType1 = 12;
25         short msgVersion1 = 34;
26         short msgType2 = 21;
27         short msgVersion2 = 43;
28         
29         MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion1, msgType1);
30         
31         Assert.assertTrue("Wrong - equals to same obejct",key1.equals(key1));
32         Assert.assertFalse("Wrong - equals to null",key1.equals(null));
33         Assert.assertFalse("Wrong - equals to different class",key1.equals(new Object()));
34         
35         MessageTypeCodeKey key2 = new MessageTypeCodeKey(msgVersion2, msgType2);
36         Assert.assertFalse("Wrong - equals by msgType",key1.equals(key2));
37         
38         key2 = new MessageTypeCodeKey(msgVersion2, msgType1);
39         Assert.assertFalse("Wrong - equals by msgVersion",key1.equals(key2));
40     }
41
42     @Test
43     public void testGetter(){
44         
45         short msgType = 12;
46         short msgVersion = 34;
47
48         MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion, msgType);
49
50         Assert.assertEquals(msgType, key1.getMsgType());
51         Assert.assertEquals(msgVersion, key1.getMsgVersion());
52
53     }
54
55 }