External api proposal
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / NotificationQueueWrapperTest.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowplugin.openflow.md.core;\r
10 \r
11 import org.junit.Assert;\r
12 import org.junit.Test;\r
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
14 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;\r
16 \r
17 /**\r
18  * @author michal.polkorab\r
19  *\r
20  */\r
21 public class NotificationQueueWrapperTest {\r
22 \r
23     /**\r
24      * Test NotificationQueueWrapper creation\r
25      */\r
26     @Test(expected=IllegalArgumentException.class)\r
27     public void test() {\r
28         NotificationQueueWrapper queueWrapper = new NotificationQueueWrapper(null, null);\r
29     }\r
30 \r
31     /**\r
32      * Test NotificationQueueWrapper creation\r
33      */\r
34     @Test(expected=IllegalArgumentException.class)\r
35     public void test2() {\r
36         EchoRequestMessageBuilder echoBuilder = new EchoRequestMessageBuilder();\r
37         NotificationQueueWrapper queueWrapper = new NotificationQueueWrapper(echoBuilder.build(), null);\r
38     }\r
39 \r
40     /**\r
41      * Test NotificationQueueWrapper creation\r
42      */\r
43     @Test\r
44     public void test3() {\r
45         EchoRequestMessageBuilder echoBuilder = new EchoRequestMessageBuilder();\r
46         NotificationQueueWrapper queueWrapper = new NotificationQueueWrapper(echoBuilder.build(),\r
47                 (short) EncodeConstants.OF13_VERSION_ID);\r
48 \r
49         Assert.assertEquals("Wrong implemented interface", "org.opendaylight.openflowplugin.api.openflow.md"\r
50                 + ".core.NotificationQueueWrapper", queueWrapper.getImplementedInterface().getName());\r
51         Assert.assertEquals("Wrong version", 4, queueWrapper.getVersion().intValue());\r
52         Assert.assertEquals("Wrong notification", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol"\r
53                 + ".rev130731.EchoRequestMessage", queueWrapper.getNotification().getImplementedInterface().getName());\r
54         Assert.assertEquals("Wrong xid", -1, queueWrapper.getXid().longValue());\r
55         queueWrapper.setXid(12345L);\r
56         Assert.assertEquals("Wrong xid", 12345, queueWrapper.getXid().intValue());\r
57     }\r
58 }