Merge "OPNFLWPLUG-929 : Remove deprecated guava library"
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / core / DelegatingInboundHandlerTest.java
1 /*
2  * Copyright (c) 2014 Brocade Communications Systems, Inc. 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;
10
11 import static org.mockito.Matchers.any;
12 import static org.mockito.Mockito.times;
13 import static org.mockito.Mockito.verify;
14
15 import io.netty.channel.ChannelHandlerContext;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.Mock;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;
21 import org.opendaylight.yangtools.yang.binding.DataObject;
22
23 /**
24  * Unit tests for DelegatingInboundHandler.
25  *
26  * @author jameshall
27  */
28 public class DelegatingInboundHandlerTest {
29
30     @Mock ChannelHandlerContext mockChHndlrCtx;
31     @Mock MessageConsumer mockMsgConsumer;
32     @Mock DataObject mockDataObject ;
33
34     DelegatingInboundHandler dih;
35
36     /**
37      * Sets up test environment.
38      */
39     @Before
40     public void setUp() {
41         MockitoAnnotations.initMocks(this);
42         dih = new DelegatingInboundHandler(mockMsgConsumer) ;
43     }
44
45     @Test
46     public void testChannelReadSuccess()   {
47         dih.channelRead(mockChHndlrCtx, mockDataObject) ;
48
49         // Verify that the message buf was released...
50         verify(mockMsgConsumer, times(1)).consume(mockDataObject);
51     }
52
53     @Test
54     public void testChannelInactive()   {
55         dih.channelInactive(mockChHndlrCtx);
56
57         verify(mockMsgConsumer, times(1)).consume(any(DataObject.class));
58     }
59
60     @Test
61     public void testChannelUnregistered()   {
62         dih.channelUnregistered(mockChHndlrCtx);
63
64         verify(mockMsgConsumer, times(1)).consume(any(DataObject.class));
65     }
66 }