2 * Copyright (c) 2014 Cisco 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
8 package org.opendaylight.netconf.impl.util;
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.mock;
13 import static org.mockito.Mockito.times;
14 import static org.mockito.Mockito.verify;
16 import io.netty.channel.Channel;
17 import io.netty.channel.ChannelFuture;
18 import io.netty.channel.ChannelHandlerContext;
19 import io.netty.util.concurrent.GenericFutureListener;
20 import org.junit.Before;
21 import org.junit.Test;
23 public class DeserializerExceptionHandlerTest {
25 private DeserializerExceptionHandler handler;
26 private ChannelFuture channelFuture;
27 private ChannelHandlerContext context;
28 private Channel channel;
31 public void setUp() throws Exception {
32 handler = new DeserializerExceptionHandler();
33 context = mock(ChannelHandlerContext.class);
34 channel = mock(Channel.class);
35 doReturn(channel).when(context).channel();
36 channelFuture = mock(ChannelFuture.class);
37 doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
38 doReturn(channelFuture).when(channel).writeAndFlush(any());
42 public void testExceptionCaught() throws Exception {
43 handler.exceptionCaught(context, new Exception());
44 verify(context, times(1)).channel();