Merge "Fix checkstyle warnings"
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / mapping / operations / DefaultStopExiTest.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.mapping.operations;
10
11 import io.netty.channel.Channel;
12 import io.netty.channel.ChannelHandler;
13 import io.netty.channel.ChannelPipeline;
14 import org.junit.Test;
15 import org.opendaylight.controller.netconf.impl.NetconfServerSession;
16 import org.opendaylight.controller.netconf.util.xml.XmlElement;
17 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
18 import org.w3c.dom.Document;
19
20 import static org.junit.Assert.assertNotNull;
21 import static org.mockito.Mockito.*;
22
23 public class DefaultStopExiTest {
24     @Test
25     public void testHandleWithNoSubsequentOperations() throws Exception {
26         DefaultStopExi exi = new DefaultStopExi("");
27         Document doc = XmlUtil.newDocument();
28         Channel channel = mock(Channel.class);
29         ChannelPipeline pipeline = mock(ChannelPipeline.class);
30         doReturn(pipeline).when(channel).pipeline();
31         ChannelHandler channelHandler = mock(ChannelHandler.class);
32         doReturn(channelHandler).when(pipeline).replace(anyString(), anyString(), any(ChannelHandler.class));
33
34         NetconfServerSession serverSession = new NetconfServerSession(null, channel, 2L, null);
35         exi.setNetconfSession(serverSession);
36
37         assertNotNull(exi.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"))));
38         verify(pipeline, times(1)).replace(anyString(), anyString(), any(ChannelHandler.class));
39     }
40 }