Remove CloseableUtil
[netconf.git] / protocol / netconf-impl / src / test / java / org / opendaylight / netconf / impl / util / DeserializerExceptionHandlerTest.java
1 /*
2  * Copyright (c) 2014 Cisco 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 package org.opendaylight.netconf.impl.util;
9
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;
15
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;
22
23 public class DeserializerExceptionHandlerTest {
24
25     private DeserializerExceptionHandler handler;
26     private ChannelFuture channelFuture;
27     private ChannelHandlerContext context;
28     private Channel channel;
29
30     @Before
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());
39     }
40
41     @Test
42     public void testExceptionCaught() throws Exception {
43         handler.exceptionCaught(context, new Exception());
44         verify(context, times(1)).channel();
45     }
46 }