Fix checkstyle warnings in netconf-impl.
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / mapping / operations / DefaultCloseSessionTest.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.mockito.Mockito.doNothing;
12 import static org.mockito.Mockito.doThrow;
13 import static org.mockito.Mockito.mock;
14
15 import org.junit.Test;
16 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
17 import org.opendaylight.controller.netconf.util.xml.XmlElement;
18 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
19 import org.w3c.dom.Document;
20
21 public class DefaultCloseSessionTest {
22     @Test
23     public void testDefaultCloseSession() throws Exception {
24         AutoCloseable res = mock(AutoCloseable.class);
25         doNothing().when(res).close();
26         DefaultCloseSession session = new DefaultCloseSession("", res);
27         Document doc = XmlUtil.newDocument();
28         XmlElement elem = XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"));
29         session.handleWithNoSubsequentOperations(doc, elem);
30     }
31
32     @Test(expected = NetconfDocumentedException.class)
33     public void testDefaultCloseSession2() throws Exception {
34         AutoCloseable res = mock(AutoCloseable.class);
35         doThrow(NetconfDocumentedException.class).when(res).close();
36         DefaultCloseSession session = new DefaultCloseSession("", res);
37         Document doc = XmlUtil.newDocument();
38         XmlElement elem = XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"));
39         session.handleWithNoSubsequentOperations(doc, elem);
40     }
41 }