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