Bug-915: Adding static document generation.
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / 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
9 package org.opendaylight.controller.netconf.impl.util;
10
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;
17
18 import static org.mockito.Mockito.*;
19
20 public class DeserializerExceptionHandlerTest {
21
22     private DeserializerExceptionHandler handler;
23     private ChannelFuture channelFuture;
24     private ChannelHandlerContext context;
25     private Channel channel;
26
27     @Before
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());
36     }
37
38     @Test
39     public void testExceptionCaught() throws Exception {
40         handler.exceptionCaught(context, new Exception());
41         verify(context, times(1)).channel();
42     }
43 }