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