Merge "BUG-692 Fix major issues reported by sonar for netconf subsystem"
authorTony Tkacik <ttkacik@cisco.com>
Thu, 18 Sep 2014 12:56:57 +0000 (12:56 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 18 Sep 2014 12:56:57 +0000 (12:56 +0000)
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtil.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractLastNetconfOperationTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperationTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractSingletonNetconfOperationTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessageAdditionalHeaderTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessageTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageHeaderTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageUtilTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/SendErrorExceptionUtilTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtilTest.java [new file with mode: 0644]

index 333fea3493172286fdba2c807eff105760741411..c77e0d7da25dc112e54489fbae42bf317a3f2b3f 100644 (file)
@@ -53,29 +53,6 @@ public final class NetconfConfigUtil {
         }
     }
 
-    /**
-     * Get extracted address or default.
-     *
-     * @throws java.lang.IllegalStateException if neither address is present.
-     */
-    private static InetSocketAddress getNetconfAddress(final InetSocketAddress defaultAddress, Optional<InetSocketAddress> extractedAddress, InfixProp infix) {
-        InetSocketAddress inetSocketAddress;
-
-        if (extractedAddress.isPresent() == false) {
-            logger.debug("Netconf {} address not found, falling back to default {}", infix, defaultAddress);
-
-            if (defaultAddress == null) {
-                logger.warn("Netconf {} address not found, default address not provided", infix);
-                throw new IllegalStateException("Netconf " + infix + " address not found, default address not provided");
-            }
-            inetSocketAddress = defaultAddress;
-        } else {
-            inetSocketAddress = extractedAddress.get();
-        }
-
-        return inetSocketAddress;
-    }
-
     public static String getPrivateKeyPath(final BundleContext context) {
         return getPropertyValue(context, getPrivateKeyKey());
     }
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractLastNetconfOperationTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractLastNetconfOperationTest.java
new file mode 100644 (file)
index 0000000..62633dd
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.mapping;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+public class AbstractLastNetconfOperationTest {
+    class LastNetconfOperationImplTest extends  AbstractLastNetconfOperation  {
+
+        boolean handleWithNoSubsequentOperationsRun;
+
+        protected LastNetconfOperationImplTest(String netconfSessionIdForReporting) {
+            super(netconfSessionIdForReporting);
+            handleWithNoSubsequentOperationsRun = false;
+        }
+
+        @Override
+        protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
+            handleWithNoSubsequentOperationsRun = true;
+            return null;
+        }
+
+        @Override
+        protected String getOperationName() {
+            return "";
+        }
+    }
+
+    LastNetconfOperationImplTest netconfOperation;
+
+    @Before
+    public void setUp() throws Exception {
+        netconfOperation = new LastNetconfOperationImplTest("");
+    }
+
+    @Test
+    public void testNetconfOperation() throws Exception {
+        netconfOperation.handleWithNoSubsequentOperations(null, null);
+        assertTrue(netconfOperation.handleWithNoSubsequentOperationsRun);
+        assertEquals(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY, netconfOperation.getHandlingPriority());
+    }
+
+    @Test(expected = NetconfDocumentedException.class)
+    public void testHandle() throws Exception {
+        NetconfOperationChainedExecution operation = mock(NetconfOperationChainedExecution.class);
+        doReturn("").when(operation).toString();
+
+        doReturn(false).when(operation).isExecutionTermination();
+        netconfOperation.handle(null, null, operation);
+    }
+}
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperationTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperationTest.java
new file mode 100644 (file)
index 0000000..ea4a6e6
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.mapping;
+
+import java.io.IOException;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public class AbstractNetconfOperationTest {
+
+    class NetconfOperationImpl extends AbstractNetconfOperation {
+
+        public boolean handleRun;
+
+        protected NetconfOperationImpl(String netconfSessionIdForReporting) {
+            super(netconfSessionIdForReporting);
+            this.handleRun = false;
+        }
+
+        @Override
+        protected String getOperationName() {
+            return null;
+        }
+
+        @Override
+        protected Element handle(Document document, XmlElement message, NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
+            this.handleRun = true;
+            try {
+                return XmlUtil.readXmlToElement("<element/>");
+            } catch (SAXException | IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+    private NetconfOperationImpl netconfOperation;
+    private NetconfOperationChainedExecution operation;
+
+    @Before
+    public void setUp() throws Exception {
+        netconfOperation = new NetconfOperationImpl("str");
+        operation = mock(NetconfOperationChainedExecution.class);
+    }
+
+    @Test
+    public void testAbstractNetconfOperation() throws Exception {
+        Document helloMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/edit_config.xml");
+        assertEquals(netconfOperation.getNetconfSessionIdForReporting(), "str");
+        assertNotNull(netconfOperation.canHandle(helloMessage));
+        assertEquals(netconfOperation.getHandlingPriority(), HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY);
+
+        netconfOperation.handle(helloMessage, operation);
+        assertTrue(netconfOperation.handleRun);
+    }
+}
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractSingletonNetconfOperationTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/mapping/AbstractSingletonNetconfOperationTest.java
new file mode 100644 (file)
index 0000000..d1310de
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.mapping;
+
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import static org.junit.Assert.assertEquals;
+
+public class AbstractSingletonNetconfOperationTest {
+    class SingletonNCOperationImpl extends AbstractSingletonNetconfOperation {
+
+        protected SingletonNCOperationImpl(String netconfSessionIdForReporting) {
+            super(netconfSessionIdForReporting);
+        }
+
+        @Override
+        protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
+            return null;
+        }
+
+        @Override
+        protected String getOperationName() {
+            return null;
+        }
+    }
+
+    @Test
+    public void testAbstractSingletonNetconfOperation() throws Exception {
+        SingletonNCOperationImpl operation = new SingletonNCOperationImpl("");
+        assertEquals(operation.getHandlingPriority(), HandlingPriority.HANDLE_WITH_MAX_PRIORITY);
+    }
+}
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessageAdditionalHeaderTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessageAdditionalHeaderTest.java
new file mode 100644 (file)
index 0000000..95c9124
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.messages;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class NetconfHelloMessageAdditionalHeaderTest {
+
+
+    private String customHeader = "[user;1.1.1.1:40;tcp;client;]";
+    private NetconfHelloMessageAdditionalHeader header;
+
+    @Before
+    public void setUp() throws Exception {
+        header = new NetconfHelloMessageAdditionalHeader("user", "1.1.1.1", "40", "tcp", "client");
+    }
+
+    @Test
+    public void testGetters() throws Exception {
+        assertEquals(header.getAddress(), "1.1.1.1");
+        assertEquals(header.getUserName(), "user");
+        assertEquals(header.getPort(), "40");
+        assertEquals(header.getTransport(), "tcp");
+        assertEquals(header.getSessionIdentifier(), "client");
+    }
+
+    @Test
+    public void testStaticConstructor() throws Exception {
+        NetconfHelloMessageAdditionalHeader h = NetconfHelloMessageAdditionalHeader.fromString(customHeader);
+        assertEquals(h.toString(), header.toString());
+        assertEquals(h.toFormattedString(), header.toFormattedString());
+    }
+}
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessageTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessageTest.java
new file mode 100644 (file)
index 0000000..c39ac8e
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.messages;
+
+
+import com.google.common.base.Optional;
+import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.internal.util.collections.Sets;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class NetconfHelloMessageTest {
+
+    Set<String> caps;
+
+    @Before
+    public void setUp() throws Exception {
+        caps = Sets.newSet("cap1");
+    }
+
+    @Test
+    public void testConstructor() throws Exception {
+        NetconfHelloMessageAdditionalHeader additionalHeader = new NetconfHelloMessageAdditionalHeader("name","host","1","transp","id");
+        NetconfHelloMessage message = NetconfHelloMessage.createClientHello(caps, Optional.of(additionalHeader));
+        assertTrue(message.isHelloMessage(message));
+        assertEquals(Optional.of(additionalHeader), message.getAdditionalHeader());
+
+        NetconfHelloMessage serverMessage = NetconfHelloMessage.createServerHello(caps, 100L);
+        assertTrue(serverMessage.isHelloMessage(serverMessage));
+    }
+}
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageHeaderTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageHeaderTest.java
new file mode 100644 (file)
index 0000000..cca89ae
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.messages;
+
+import com.google.common.base.Charsets;
+import java.util.Arrays;
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+public class NetconfMessageHeaderTest {
+    @Test
+    public void testGet() throws Exception {
+        NetconfMessageHeader header = new NetconfMessageHeader(10);
+        assertEquals(header.getLength(), 10);
+
+        byte[] expectedValue = "\n#10\n".getBytes(Charsets.US_ASCII);
+        assertArrayEquals(expectedValue, header.toBytes());
+    }
+}
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageUtilTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageUtilTest.java
new file mode 100644 (file)
index 0000000..2af34e9
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.messages;
+
+import java.util.Collection;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
+import org.w3c.dom.Document;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class NetconfMessageUtilTest {
+    @Test
+    public void testNetconfMessageUtil() throws Exception {
+        Document okMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/rpc-reply_ok.xml");
+        assertTrue(NetconfMessageUtil.isOKMessage(new NetconfMessage(okMessage)));
+        assertFalse(NetconfMessageUtil.isErrorMessage(new NetconfMessage(okMessage)));
+
+        Document errorMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/communicationError/testClientSendsRpcReply_expectedResponse.xml");
+        assertTrue(NetconfMessageUtil.isErrorMessage(new NetconfMessage(errorMessage)));
+        assertFalse(NetconfMessageUtil.isOKMessage(new NetconfMessage(errorMessage)));
+
+        Document helloMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/client_hello.xml");
+        Collection<String> caps = NetconfMessageUtil.extractCapabilitiesFromHello(new NetconfMessage(helloMessage).getDocument());
+        assertTrue(caps.contains("urn:ietf:params:netconf:base:1.0"));
+        assertTrue(caps.contains("urn:ietf:params:netconf:base:1.1"));
+    }
+}
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/SendErrorExceptionUtilTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/messages/SendErrorExceptionUtilTest.java
new file mode 100644 (file)
index 0000000..c8d562c
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.messages;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.util.concurrent.GenericFutureListener;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.api.NetconfSession;
+import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
+import org.w3c.dom.Document;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+public class SendErrorExceptionUtilTest {
+
+    NetconfSession netconfSession;
+    ChannelFuture channelFuture;
+    Channel channel;
+    private NetconfDocumentedException exception;
+
+    @Before
+    public void setUp() throws Exception {
+        netconfSession = mock(NetconfSession.class);
+        channelFuture = mock(ChannelFuture.class);
+        channel = mock(Channel.class);
+        doReturn(channelFuture).when(netconfSession).sendMessage(any(NetconfMessage.class));
+        doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
+        doReturn(channelFuture).when(channel).writeAndFlush(any(NetconfMessage.class));
+        exception = new NetconfDocumentedException("err");
+    }
+
+    @Test
+    public void testSendErrorMessage1() throws Exception {
+        SendErrorExceptionUtil.sendErrorMessage(netconfSession, exception);
+        verify(channelFuture, times(1)).addListener(any(GenericFutureListener.class));
+        verify(netconfSession, times(1)).sendMessage(any(NetconfMessage.class));
+    }
+
+    @Test
+    public void testSendErrorMessage2() throws Exception {
+        SendErrorExceptionUtil.sendErrorMessage(channel, exception);
+        verify(channelFuture, times(1)).addListener(any(GenericFutureListener.class));
+    }
+
+    @Test
+    public void testSendErrorMessage3() throws Exception {
+        Document helloMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/rpc.xml");
+        SendErrorExceptionUtil.sendErrorMessage(netconfSession, exception, new NetconfMessage(helloMessage));
+        verify(channelFuture, times(1)).addListener(any(GenericFutureListener.class));
+    }
+}
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtilTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtilTest.java
new file mode 100644 (file)
index 0000000..741d0d2
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.osgi;
+
+import com.google.common.base.Optional;
+import io.netty.channel.local.LocalAddress;
+import java.net.InetSocketAddress;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.util.NetconfUtil;
+import org.osgi.framework.BundleContext;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+public class NetconfConfigUtilTest {
+
+    private BundleContext bundleContext;
+
+    @Before
+    public void setUp() throws Exception {
+        bundleContext = mock(BundleContext.class);
+    }
+
+    @Test
+    public void testNetconfConfigUtil() throws Exception {
+        assertEquals(NetconfConfigUtil.getNetconfLocalAddress(), new LocalAddress("netconf"));
+
+        doReturn("").when(bundleContext).getProperty("netconf.connectionTimeoutMillis");
+        assertEquals(NetconfConfigUtil.extractTimeoutMillis(bundleContext), 5000);
+
+        doReturn("a").when(bundleContext).getProperty("netconf.connectionTimeoutMillis");
+        assertEquals(NetconfConfigUtil.extractTimeoutMillis(bundleContext), 5000);
+    }
+
+    @Test
+    public void testgetPrivateKeyKey() throws Exception {
+        assertEquals(NetconfConfigUtil.getPrivateKeyKey(), "netconf.ssh.pk.path");
+    }
+
+    @Test
+    public void testgetNetconfServerAddressKey() throws Exception {
+        NetconfConfigUtil.InfixProp prop = NetconfConfigUtil.InfixProp.tcp;
+        assertEquals(NetconfConfigUtil.getNetconfServerAddressKey(prop), "netconf.tcp.address");
+    }
+
+    @Test
+    public void testExtractNetconfServerAddress() throws Exception {
+        NetconfConfigUtil.InfixProp prop = NetconfConfigUtil.InfixProp.tcp;
+        doReturn("").when(bundleContext).getProperty(anyString());
+        assertEquals(NetconfConfigUtil.extractNetconfServerAddress(bundleContext, prop), Optional.absent());
+    }
+
+    @Test
+    public void testExtractNetconfServerAddress2() throws Exception {
+        NetconfConfigUtil.InfixProp prop = NetconfConfigUtil.InfixProp.tcp;
+        doReturn("1.1.1.1").when(bundleContext).getProperty("netconf.tcp.address");
+        doReturn("20").when(bundleContext).getProperty("netconf.tcp.port");
+        Optional<InetSocketAddress> inetSocketAddressOptional = NetconfConfigUtil.extractNetconfServerAddress(bundleContext, prop);
+        assertTrue(inetSocketAddressOptional.isPresent());
+        assertEquals(inetSocketAddressOptional.get(), new InetSocketAddress("1.1.1.1", 20));
+    }
+
+    @Test
+    public void testGetPrivateKeyPath() throws Exception {
+        doReturn("path").when(bundleContext).getProperty("netconf.ssh.pk.path");
+        assertEquals(NetconfConfigUtil.getPrivateKeyPath(bundleContext), "path");
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testGetPrivateKeyPath2() throws Exception {
+        doReturn(null).when(bundleContext).getProperty("netconf.ssh.pk.path");
+        assertEquals(NetconfConfigUtil.getPrivateKeyPath(bundleContext), "path");
+    }
+}