X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fssh%2FSSHServerTest.java;h=54bc7bc4b686771279e5542bb7c29e4dabc0d8d2;hp=acad146b7737ff4c74478670b3439da07e12e551;hb=25ba6b145406b98f8521bcf510bb85bf0167ef72;hpb=d82b96055d2c0d471c85c2b2b3cb30e52fff1c69 diff --git a/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/ssh/SSHServerTest.java b/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/ssh/SSHServerTest.java index acad146b77..54bc7bc4b6 100644 --- a/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/ssh/SSHServerTest.java +++ b/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/ssh/SSHServerTest.java @@ -10,8 +10,9 @@ package org.opendaylight.controller.netconf.ssh; import ch.ethz.ssh2.Connection; import ch.ethz.ssh2.Session; import java.io.IOException; +import java.net.InetSocketAddress; import junit.framework.Assert; -import org.junit.Before; +import org.apache.commons.io.IOUtils; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,22 +23,15 @@ public class SSHServerTest { private static final String USER = "netconf"; private static final String PASSWORD = "netconf"; private static final String HOST = "127.0.0.1"; - private static final int PORT = 830; + private static final int PORT = 1830; + private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 8383); private static final Logger logger = LoggerFactory.getLogger(SSHServerTest.class); - private class TestSSHServer implements Runnable { - public void run() { - try { - NetconfSSHServer.start(); - } catch (Exception e) { - logger.info(e.getMessage()); - } - } - } - @Before +// @Before public void startSSHServer() throws Exception{ logger.info("Creating SSH server"); - Thread sshServerThread = new Thread(new TestSSHServer()); + NetconfSSHServer server = NetconfSSHServer.start(PORT,tcpAddress); + Thread sshServerThread = new Thread(server); sshServerThread.setDaemon(true); sshServerThread.start(); logger.info("SSH server on"); @@ -57,7 +51,8 @@ public class SSHServerTest { Session sess = conn.openSession(); logger.info("subsystem netconf"); sess.startSubSystem("netconf"); -// sess.requestPTY(""); + sess.getStdin().write("urn:ietf:params:netconf:base:1.1]]>]]>".getBytes()); + IOUtils.copy(sess.getStdout(), System.out); } catch (IOException e) { e.printStackTrace(); }