2 * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowjava.protocol.impl.core;
11 import static org.mockito.Matchers.any;
12 import static org.mockito.Mockito.times;
13 import static org.mockito.Mockito.verify;
14 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;
26 public class DelegatingInboundHandlerTest {
28 @Mock ChannelHandlerContext mockChHndlrCtx ;
29 @Mock MessageConsumer mockMsgConsumer ;
30 @Mock DataObject mockDataObject ;
32 DelegatingInboundHandler dih ;
35 * Sets up test environment
39 MockitoAnnotations.initMocks(this);
40 dih = new DelegatingInboundHandler(mockMsgConsumer) ;
47 public void testChannelReadSuccess() {
48 dih.channelRead(mockChHndlrCtx, mockDataObject) ;
50 // Verify that the message buf was released...
51 verify( mockMsgConsumer, times(1)).consume(mockDataObject);
57 public void testChannelInactive() {
58 dih.channelInactive(mockChHndlrCtx);
60 verify( mockMsgConsumer, times(1)).consume(any(DataObject.class));
67 public void testChannelUnregistered() {
68 dih.channelUnregistered(mockChHndlrCtx);
70 verify( mockMsgConsumer, times(1)).consume(any(DataObject.class));