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.ArgumentMatchers.any;
12 import static org.mockito.Mockito.times;
13 import static org.mockito.Mockito.verify;
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;
24 * Unit tests for DelegatingInboundHandler.
28 public class DelegatingInboundHandlerTest {
30 @Mock ChannelHandlerContext mockChHndlrCtx;
31 @Mock MessageConsumer mockMsgConsumer;
32 @Mock DataObject mockDataObject ;
34 DelegatingInboundHandler dih;
37 * Sets up test environment.
41 MockitoAnnotations.initMocks(this);
42 dih = new DelegatingInboundHandler(mockMsgConsumer) ;
46 public void testChannelReadSuccess() {
47 dih.channelRead(mockChHndlrCtx, mockDataObject) ;
49 // Verify that the message buf was released...
50 verify(mockMsgConsumer, times(1)).consume(mockDataObject);
54 public void testChannelInactive() {
55 dih.channelInactive(mockChHndlrCtx);
57 verify(mockMsgConsumer, times(1)).consume(any(DataObject.class));
61 public void testChannelUnregistered() {
62 dih.channelUnregistered(mockChHndlrCtx);
64 verify(mockMsgConsumer, times(1)).consume(any(DataObject.class));