cf50b62693cf56104ae4ccd93d73b531e9ff6e9f
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / core / connection / ChannelOutboundQueueTest.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.openflowjava.protocol.impl.core.connection;\r
10 \r
11 import io.netty.channel.Channel;\r
12 \r
13 import org.junit.Assert;\r
14 import org.junit.Test;\r
15 import org.mockito.Mock;\r
16 import org.mockito.MockitoAnnotations;\r
17 import org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue;\r
18 import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener;\r
19 \r
20 /**\r
21  * @author michal.polkorab\r
22  *\r
23  */\r
24 public class ChannelOutboundQueueTest {\r
25 \r
26     @Mock Channel channel;\r
27 \r
28     /**\r
29      * Initialize mocks\r
30      */\r
31     public ChannelOutboundQueueTest() {\r
32         MockitoAnnotations.initMocks(this);\r
33     }\r
34 \r
35     /**\r
36      * Test incorrect queue creation handling\r
37      */\r
38     @Test(expected=IllegalArgumentException.class)\r
39     public void testIncorrectQueueCreation() {\r
40         new ChannelOutboundQueue(channel, 0, null);\r
41     }\r
42 \r
43     /**\r
44      * Test correct enqueue handling\r
45      */\r
46     @Test\r
47     public void testEnqueue() {\r
48         ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1, null);\r
49         boolean enqueued;\r
50         enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT"));\r
51         Assert.assertTrue("Enqueue problem", enqueued);\r
52         enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT"));\r
53         Assert.assertFalse("Enqueue problem", enqueued);\r
54     }\r
55 }