Merge "Fix improper cleanup of operational data in sal-netconf-connector's disconnect"
[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 static org.junit.Assert.assertNotNull;
12 import static org.mockito.Mockito.any;
13 import static org.mockito.Mockito.anyString;
14 import static org.mockito.Mockito.doReturn;
15 import static org.mockito.Mockito.mock;
16 import static org.mockito.Mockito.times;
17 import static org.mockito.Mockito.verify;
18
19 import io.netty.channel.Channel;
20 import io.netty.channel.ChannelHandler;
21 import io.netty.channel.ChannelPipeline;
22 import org.junit.Test;
23 import org.opendaylight.controller.netconf.impl.NetconfServerSession;
24 import org.opendaylight.controller.netconf.util.xml.XmlElement;
25 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
26 import org.w3c.dom.Document;
27
28 public class DefaultStopExiTest {
29     @Test
30     public void testHandleWithNoSubsequentOperations() throws Exception {
31         DefaultStopExi exi = new DefaultStopExi("");
32         Document doc = XmlUtil.newDocument();
33         Channel channel = mock(Channel.class);
34         doReturn("mockChannel").when(channel).toString();
35         ChannelPipeline pipeline = mock(ChannelPipeline.class);
36         doReturn(pipeline).when(channel).pipeline();
37         ChannelHandler channelHandler = mock(ChannelHandler.class);
38         doReturn(channelHandler).when(pipeline).replace(anyString(), anyString(), any(ChannelHandler.class));
39
40         NetconfServerSession serverSession = new NetconfServerSession(null, channel, 2L, null);
41         exi.setNetconfSession(serverSession);
42
43         assertNotNull(exi.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"))));
44         verify(pipeline, times(1)).replace(anyString(), anyString(), any(ChannelHandler.class));
45     }
46 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.