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
9 package org.opendaylight.controller.netconf.impl.util;
11 import io.netty.channel.Channel;
12 import io.netty.channel.ChannelFuture;
13 import io.netty.channel.ChannelHandlerContext;
14 import io.netty.util.concurrent.GenericFutureListener;
15 import org.junit.Before;
16 import org.junit.Test;
18 import static org.mockito.Mockito.*;
20 public class DeserializerExceptionHandlerTest {
22 private DeserializerExceptionHandler handler;
23 private ChannelFuture channelFuture;
24 private ChannelHandlerContext context;
25 private Channel channel;
28 public void setUp() throws Exception {
29 handler = new DeserializerExceptionHandler();
30 context = mock(ChannelHandlerContext.class);
31 channel = mock(Channel.class);
32 doReturn(channel).when(context).channel();
33 channelFuture = mock(ChannelFuture.class);
34 doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
35 doReturn(channelFuture).when(channel).writeAndFlush(anyObject());
39 public void testExceptionCaught() throws Exception {
40 handler.exceptionCaught(context, new Exception());
41 verify(context, times(1)).channel();