Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / core / connection / RpcResponseKeyTest.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.core.connection;
10
11 import org.junit.Assert;
12 import org.junit.Test;
13
14 /**
15  * Unit tests for RpcResponseKey.
16  *
17  * @author madamjak
18  */
19 public class RpcResponseKeyTest {
20
21     /**
22      * Test equals (xid is not tested).
23      */
24     @Test
25     public void testEquals() {
26
27         long xid1 = 12L;
28         long xid2 = 66L;
29         final String outputClazz1 = "Clazz01";
30         String outputClazz2 = "Clazz02";
31         RpcResponseKey key1 = new RpcResponseKey(xid1, null);
32         RpcResponseKey key2 = new RpcResponseKey(xid2, outputClazz2);
33
34         Assert.assertTrue("Wrong equal to same obejct.", key1.equals(key1));
35         Assert.assertFalse("Wrong equal to null.", key1.equals(null));
36         Assert.assertFalse("Wrong equal to different type.", key1.equals(new Object()));
37         Assert.assertFalse("Wrong equal by outputClazz.", key1.equals(key2));
38
39         key1 = new RpcResponseKey(xid1, outputClazz1);
40         Assert.assertFalse("Wrong equal by outputClazz.", key1.equals(key2));
41         key2 = new RpcResponseKey(xid2, outputClazz1);
42         Assert.assertFalse("Wrong equal.", key1.equals(key2));
43         key1 = new RpcResponseKey(xid2, outputClazz1);
44         Assert.assertTrue("Wrong equal.", key1.equals(key2));
45     }
46
47     /**
48      * Test getters.
49      */
50     @Test
51     public void testGetters() {
52
53         long xid1 = 12L;
54         String outputClazz1 = "Clazz01";
55         RpcResponseKey key1 = new RpcResponseKey(xid1, outputClazz1);
56
57         Assert.assertTrue("Wrong getXid",key1.getXid() == xid1);
58         Assert.assertTrue("Wrong getOutputClazz",key1.getOutputClazz() == outputClazz1);
59     }
60 }