You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2015/06/09 15:53:18 UTC

[3/6] mina-sshd git commit: [SSHD-488] Implement (a naive) ssh-keyscan

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6432a7af/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ClientTest.java b/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
deleted file mode 100644
index 5f956b6..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
+++ /dev/null
@@ -1,958 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.net.SocketAddress;
-import java.security.KeyPair;
-import java.security.PublicKey;
-import java.util.Arrays;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.sshd.client.ClientFactoryManager;
-import org.apache.sshd.client.ServerKeyVerifier;
-import org.apache.sshd.client.SshClient;
-import org.apache.sshd.client.UserAuth;
-import org.apache.sshd.client.UserInteraction;
-import org.apache.sshd.client.auth.UserAuthKeyboardInteractive;
-import org.apache.sshd.client.auth.UserAuthPassword;
-import org.apache.sshd.client.auth.UserAuthPublicKey;
-import org.apache.sshd.client.channel.ChannelExec;
-import org.apache.sshd.client.channel.ChannelShell;
-import org.apache.sshd.client.channel.ClientChannel;
-import org.apache.sshd.client.future.AuthFuture;
-import org.apache.sshd.client.future.OpenFuture;
-import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.RuntimeSshException;
-import org.apache.sshd.common.Service;
-import org.apache.sshd.common.SshConstants;
-import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.channel.Channel;
-import org.apache.sshd.common.cipher.BuiltinCiphers;
-import org.apache.sshd.common.future.CloseFuture;
-import org.apache.sshd.common.future.SshFutureListener;
-import org.apache.sshd.common.io.IoReadFuture;
-import org.apache.sshd.common.io.IoSession;
-import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.io.mina.MinaSession;
-import org.apache.sshd.common.io.nio2.Nio2Session;
-import org.apache.sshd.common.keyprovider.KeyPairProvider;
-import org.apache.sshd.common.session.AbstractSession;
-import org.apache.sshd.common.session.ConnectionService;
-import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.sftp.SftpConstants;
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
-import org.apache.sshd.common.util.io.NoCloseOutputStream;
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.CommandFactory;
-import org.apache.sshd.server.PublickeyAuthenticator;
-import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.PublickeyAuthenticator.AcceptAllPublickeyAuthenticator;
-import org.apache.sshd.server.channel.ChannelSession;
-import org.apache.sshd.server.command.UnknownCommand;
-import org.apache.sshd.server.forward.TcpipServerChannel;
-import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
-import org.apache.sshd.server.session.ServerConnectionService;
-import org.apache.sshd.server.session.ServerSession;
-import org.apache.sshd.server.session.ServerUserAuthService;
-import org.apache.sshd.util.AsyncEchoShellFactory;
-import org.apache.sshd.util.BaseTestSupport;
-import org.apache.sshd.util.BogusPasswordAuthenticator;
-import org.apache.sshd.util.EchoShellFactory;
-import org.apache.sshd.util.TeeOutputStream;
-import org.apache.sshd.util.Utils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-/**
- * TODO Add javadoc
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class ClientTest extends BaseTestSupport {
-
-    private SshServer sshd;
-    private SshClient client;
-    private int port;
-    private CountDownLatch authLatch;
-    private CountDownLatch channelLatch;
-
-    public ClientTest() {
-        super();
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        authLatch = new CountDownLatch(0);
-        channelLatch = new CountDownLatch(0);
-
-        sshd = SshServer.setUpDefaultServer();
-        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
-        sshd.setShellFactory(new TestEchoShellFactory());
-        sshd.setCommandFactory(new CommandFactory() {
-            @Override
-            public Command createCommand(String command) {
-                return new UnknownCommand(command);
-            }
-        });
-        sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
-        sshd.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
-        sshd.setServiceFactories(Arrays.asList(
-                new ServerUserAuthService.Factory() {
-                    @Override
-                    public Service create(Session session) throws IOException {
-                        return new ServerUserAuthService(session) {
-                            @SuppressWarnings("synthetic-access")
-                            @Override
-                            public void process(byte cmd, Buffer buffer) throws Exception {
-                                authLatch.await();
-                                super.process(cmd, buffer);
-                            }
-                        };
-                    }
-                },
-                new ServerConnectionService.Factory()
-        ));
-        sshd.setChannelFactories(Arrays.<NamedFactory<Channel>>asList(
-                new ChannelSession.ChannelSessionFactory() {
-                    @Override
-                    public Channel create() {
-                        return new ChannelSession() {
-                            @SuppressWarnings("synthetic-access")
-                            @Override
-                            public OpenFuture open(int recipient, int rwsize, int rmpsize, Buffer buffer) {
-                                try {
-                                    channelLatch.await();
-                                } catch (InterruptedException e) {
-                                    throw new RuntimeSshException(e);
-                                }
-                                return super.open(recipient, rwsize, rmpsize, buffer);
-                            }
-
-                            @Override
-                            public String toString() {
-                                return "ChannelSession" + "[id=" + id + ", recipient=" + recipient + "]";
-                            }
-                        };
-                    }
-                },
-                TcpipServerChannel.DirectTcpipFactory.INSTANCE));
-        sshd.start();
-        port = sshd.getPort();
-
-        client = SshClient.setUpDefaultClient();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        if (sshd != null) {
-            sshd.stop(true);
-        }
-        if (client != null) {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testAsyncClient() throws Exception {
-        FactoryManagerUtils.updateProperty(sshd, FactoryManager.WINDOW_SIZE, 1024);
-        sshd.setShellFactory(new AsyncEchoShellFactory());
-
-        FactoryManagerUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 1024);
-        client.start();
-
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-
-            try(final ChannelShell channel = session.createShellChannel()) {
-                channel.setStreaming(ClientChannel.Streaming.Async);
-                channel.open().verify(5L, TimeUnit.SECONDS);
-        
-                final byte[] message = "0123456789\n".getBytes();
-                final int nbMessages = 1000;
-        
-                try(final ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
-                    final ByteArrayOutputStream baosErr = new ByteArrayOutputStream()) {
-                    final AtomicInteger writes = new AtomicInteger(nbMessages);
-            
-                    channel.getAsyncIn().write(new ByteArrayBuffer(message))
-                            .addListener(new SshFutureListener<IoWriteFuture>() {
-                                @Override
-                                public void operationComplete(IoWriteFuture future) {
-                                    try {
-                                        if (future.isWritten()) {
-                                            if (writes.decrementAndGet() > 0) {
-                                                channel.getAsyncIn().write(new ByteArrayBuffer(message)).addListener(this);
-                                            } else {
-                                                channel.getAsyncIn().close(false);
-                                            }
-                                        } else {
-                                            throw new SshException("Error writing", future.getException());
-                                        }
-                                    } catch (IOException e) {
-                                        if (!channel.isClosing()) {
-                                            e.printStackTrace();
-                                            channel.close(true);
-                                        }
-                                    }
-                                }
-                            });
-                    channel.getAsyncOut().read(new ByteArrayBuffer())
-                            .addListener(new SshFutureListener<IoReadFuture>() {
-                                @Override
-                                public void operationComplete(IoReadFuture future) {
-                                    try {
-                                        future.verify(5L, TimeUnit.SECONDS);
-                                        Buffer buffer = future.getBuffer();
-                                        baosOut.write(buffer.array(), buffer.rpos(), buffer.available());
-                                        buffer.rpos(buffer.rpos() + buffer.available());
-                                        buffer.compact();
-                                        channel.getAsyncOut().read(buffer).addListener(this);
-                                    } catch (IOException e) {
-                                        if (!channel.isClosing()) {
-                                            e.printStackTrace();
-                                            channel.close(true);
-                                        }
-                                    }
-                                }
-                            });
-                    channel.getAsyncErr().read(new ByteArrayBuffer())
-                            .addListener(new SshFutureListener<IoReadFuture>() {
-                                @Override
-                                public void operationComplete(IoReadFuture future) {
-                                    try {
-                                        future.verify(5L, TimeUnit.SECONDS);
-                                        Buffer buffer = future.getBuffer();
-                                        baosErr.write(buffer.array(), buffer.rpos(), buffer.available());
-                                        buffer.rpos(buffer.rpos() + buffer.available());
-                                        buffer.compact();
-                                        channel.getAsyncErr().read(buffer).addListener(this);
-                                    } catch (IOException e) {
-                                        if (!channel.isClosing()) {
-                                            e.printStackTrace();
-                                            channel.close(true);
-                                        }
-                                    }
-                                }
-                            });
-        
-                    channel.waitFor(ClientChannel.CLOSED, 0);
-        
-                    assertEquals(nbMessages * message.length, baosOut.size());
-                }
-            }    
-
-            client.close(true);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testCommandDeadlock() throws Exception {
-        client.start();
-
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-            
-            try(ChannelExec channel = session.createExecChannel("test");
-                OutputStream stdout = new NoCloseOutputStream(System.out);
-                OutputStream stderr = new NoCloseOutputStream(System.err)) {
-
-                channel.setOut(stdout);
-                channel.setErr(stderr);
-                channel.open().await();
-                Thread.sleep(100);
-                try {
-                    for (int i = 0; i < 100; i++) {
-                        channel.getInvertedIn().write("a".getBytes());
-                        channel.getInvertedIn().flush();
-                    }
-                } catch (SshException e) {
-                    // That's ok, the channel is being closed by the other side
-                }
-                assertEquals(ClientChannel.CLOSED, channel.waitFor(ClientChannel.CLOSED, 0) & ClientChannel.CLOSED);
-                session.close(false).await();
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testClient() throws Exception {
-        client.start();
-
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-            
-            try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-                ByteArrayOutputStream sent = new ByteArrayOutputStream();
-                PipedOutputStream pipedIn = new PipedOutputStream();
-                PipedInputStream pipedOut = new PipedInputStream(pipedIn)) {
-
-                channel.setIn(pipedOut);
-
-                try(OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
-                    ByteArrayOutputStream out = new ByteArrayOutputStream();
-                    ByteArrayOutputStream err = new ByteArrayOutputStream()) {
-
-                    channel.setOut(out);
-                    channel.setErr(err);
-                    channel.open();
-            
-                    teeOut.write("this is my command\n".getBytes());
-                    teeOut.flush();
-            
-                    StringBuilder sb = new StringBuilder();
-                    for (int i = 0; i < 1000; i++) {
-                        sb.append("0123456789");
-                    }
-                    sb.append("\n");
-                    teeOut.write(sb.toString().getBytes());
-            
-                    teeOut.write("exit\n".getBytes());
-                    teeOut.flush();
-            
-                    channel.waitFor(ClientChannel.CLOSED, 0);
-            
-                    channel.close(false);
-                    client.stop();
-            
-                    assertArrayEquals(sent.toByteArray(), out.toByteArray());
-                }
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testClientInverted() throws Exception {
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-            
-            try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-                ByteArrayOutputStream sent = new ByteArrayOutputStream();
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                ByteArrayOutputStream err = new ByteArrayOutputStream()) {
-
-                channel.setOut(out);
-                channel.setErr(err);
-                channel.open().await();
-        
-                try(OutputStream pipedIn = new TeeOutputStream(sent, channel.getInvertedIn())) {
-                    pipedIn.write("this is my command\n".getBytes());
-                    pipedIn.flush();
-            
-                    StringBuilder sb = new StringBuilder();
-                    for (int i = 0; i < 1000; i++) {
-                        sb.append("0123456789");
-                    }
-                    sb.append("\n");
-                    pipedIn.write(sb.toString().getBytes());
-            
-                    pipedIn.write("exit\n".getBytes());
-                    pipedIn.flush();
-                }
-        
-                channel.waitFor(ClientChannel.CLOSED, 0);
-        
-                channel.close(false);
-                client.stop();
-        
-                assertArrayEquals(sent.toByteArray(), out.toByteArray());
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testClientWithCustomChannel() throws Exception {
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-    
-            try(ChannelShell channel = new ChannelShell();
-                ByteArrayOutputStream sent = new ByteArrayOutputStream();
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                ByteArrayOutputStream err = new ByteArrayOutputStream()) {
-
-                session.getService(ConnectionService.class).registerChannel(channel);
-                channel.setOut(out);
-                channel.setErr(err);
-                channel.open().verify(5L, TimeUnit.SECONDS);
-                channel.close(false).await();
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testClientClosingStream() throws Exception {
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-    
-            try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-                ByteArrayOutputStream sent = new ByteArrayOutputStream();
-                PipedOutputStream pipedIn = new PipedOutputStream();
-                InputStream inPipe = new PipedInputStream(pipedIn);
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                ByteArrayOutputStream err = new ByteArrayOutputStream()) {
-
-                channel.setIn(inPipe);
-                channel.setOut(out);
-                channel.setErr(err);
-                channel.open();
-
-                try(OutputStream teeOut = new TeeOutputStream(sent, pipedIn)) {
-                    teeOut.write("this is my command\n".getBytes());
-                    teeOut.flush();
-        
-                    StringBuilder sb = new StringBuilder();
-                    for (int i = 0; i < 1000; i++) {
-                        sb.append("0123456789");
-                    }
-                    sb.append("\n");
-                    teeOut.write(sb.toString().getBytes());
-                }    
-    
-                channel.waitFor(ClientChannel.CLOSED, 0);
-        
-                channel.close(false);
-                client.stop();
-        
-                assertArrayEquals(sent.toByteArray(), out.toByteArray());
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testClientWithLengthyDialog() throws Exception {
-        // Reduce window size and packet size
-//        FactoryManagerUtils.updateProperty(client, SshClient.WINDOW_SIZE, 0x20000);
-//        FactoryManagerUtils.updateProperty(client, SshClient.MAX_PACKET_SIZE, 0x1000);
-//        FactoryManagerUtils.updateProperty(sshd, SshServer.WINDOW_SIZE, 0x20000);
-//        FactoryManagerUtils.updateProperty(sshd, SshServer.MAX_PACKET_SIZE, 0x1000);
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-
-            try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-                ByteArrayOutputStream sent = new ByteArrayOutputStream();
-                PipedOutputStream pipedIn = new PipedOutputStream();
-                InputStream inPipe = new PipedInputStream(pipedIn); 
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                ByteArrayOutputStream err = new ByteArrayOutputStream()) {
-
-                channel.setIn(inPipe);
-                channel.setOut(out);
-                channel.setErr(err);
-                channel.open().await();
-        
-        
-                int bytes = 0;
-                byte[] data = "01234567890123456789012345678901234567890123456789\n".getBytes();
-                long t0 = System.currentTimeMillis();
-                try(OutputStream teeOut = new TeeOutputStream(sent, pipedIn)) {
-                    for (int i = 0; i < 10000; i++) {
-                        teeOut.write(data);
-                        teeOut.flush();
-                        bytes += data.length;
-                        if ((bytes & 0xFFF00000) != ((bytes - data.length) & 0xFFF00000)) {
-                            System.out.println("Bytes written: " + bytes);
-                        }
-                    }
-                    teeOut.write("exit\n".getBytes());
-                    teeOut.flush();
-                }        
-                long t1 = System.currentTimeMillis();
-        
-                System.out.println("Sent " + (bytes / 1024) + " Kb in " + (t1 - t0) + " ms");
-        
-                System.out.println("Waiting for channel to be closed");
-        
-                channel.waitFor(ClientChannel.CLOSED, 0);
-        
-                channel.close(false);
-                client.stop();
-        
-                assertArrayEquals(sent.toByteArray(), out.toByteArray());
-                //assertArrayEquals(sent.toByteArray(), out.toByteArray());
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test(expected = SshException.class)
-    public void testOpenChannelOnClosedSession() throws Exception {
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-            
-            try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL)) {
-                session.close(false);
-        
-                try(PipedOutputStream pipedIn = new PipedOutputStream();
-                    InputStream inPipe = new PipedInputStream(pipedIn);
-                    ByteArrayOutputStream out = new ByteArrayOutputStream();
-                    ByteArrayOutputStream err = new ByteArrayOutputStream()) {
-
-                    channel.setIn(inPipe);
-                    channel.setOut(out);
-                    channel.setErr(err);
-                    channel.open();
-                }
-            }
-        }
-    }
-
-    @Test
-    public void testCloseBeforeAuthSucceed() throws Exception {
-        authLatch = new CountDownLatch(1);
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-
-            AuthFuture authFuture = session.auth();
-            CloseFuture closeFuture = session.close(false);
-            authLatch.countDown();
-            authFuture.await();
-            closeFuture.await();
-            assertNotNull("No authentication exception", authFuture.getException());
-            assertTrue("Future not closed", closeFuture.isClosed());
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testCloseCleanBeforeChannelOpened() throws Exception {
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-
-            try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-                InputStream inp = new ByteArrayInputStream(GenericUtils.EMPTY_BYTE_ARRAY);
-                OutputStream out = new ByteArrayOutputStream();
-                OutputStream err = new ByteArrayOutputStream()) { 
-
-                channel.setIn(inp);
-                channel.setOut(out);
-                channel.setErr(err);
-
-                OpenFuture openFuture = channel.open();
-                CloseFuture closeFuture = session.close(false);
-                openFuture.await();
-                closeFuture.await();
-                assertTrue("Not open", openFuture.isOpened());
-                assertTrue("Not closed", closeFuture.isClosed());
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testCloseImmediateBeforeChannelOpened() throws Exception {
-        channelLatch = new CountDownLatch(1);
-        client.start();
-
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-
-            try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-                InputStream inp = new ByteArrayInputStream(GenericUtils.EMPTY_BYTE_ARRAY);
-                OutputStream out = new ByteArrayOutputStream();
-                OutputStream err = new ByteArrayOutputStream()) { 
-
-                channel.setIn(inp);
-                channel.setOut(out);
-                channel.setErr(err);
-
-                OpenFuture openFuture = channel.open();
-                CloseFuture closeFuture = session.close(true);
-                channelLatch.countDown();
-                openFuture.await();
-                closeFuture.await();
-                assertNotNull("No open exception", openFuture.getException());
-                assertTrue("Not closed", closeFuture.isClosed());
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testPublicKeyAuth() throws Exception {
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            KeyPair pair = Utils.createTestHostKeyProvider().loadKey(KeyPairProvider.SSH_RSA);
-            session.addPublicKeyIdentity(pair);
-            session.auth().verify(5L, TimeUnit.SECONDS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testPublicKeyAuthNew() throws Exception {
-        client.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(UserAuthPublicKey.UserAuthPublicKeyFactory.INSTANCE));
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPublicKeyIdentity(Utils.createTestHostKeyProvider().loadKey(KeyPairProvider.SSH_RSA));
-            session.auth().verify(5L, TimeUnit.SECONDS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testPublicKeyAuthNewWithFailureOnFirstIdentity() throws Exception {
-        final KeyPair pair = Utils.createTestHostKeyProvider().loadKey(KeyPairProvider.SSH_RSA);
-        sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
-            @Override
-            public boolean authenticate(String username, PublicKey key, ServerSession session) {
-                return key.equals(pair.getPublic());
-            }
-        });
-        client.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(UserAuthPublicKey.UserAuthPublicKeyFactory.INSTANCE));
-        client.start();
-
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPublicKeyIdentity(new SimpleGeneratorHostKeyProvider(null, "RSA").loadKey(KeyPairProvider.SSH_RSA));
-            session.addPublicKeyIdentity(pair);
-            session.auth().verify(5L, TimeUnit.SECONDS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testPasswordAuthNew() throws Exception {
-        client.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(new UserAuthPassword.UserAuthPasswordFactory()));
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testPasswordAuthNewWithFailureOnFirstIdentity() throws Exception {
-        client.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(new UserAuthPassword.UserAuthPasswordFactory()));
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getClass().getSimpleName());
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testKeyboardInteractiveAuthNew() throws Exception {
-        client.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(UserAuthKeyboardInteractive.UserAuthKeyboardInteractiveFactory.INSTANCE));
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testKeyboardInteractiveAuthNewWithFailureOnFirstIdentity() throws Exception {
-        client.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(UserAuthKeyboardInteractive.UserAuthKeyboardInteractiveFactory.INSTANCE));
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getClass().getSimpleName());
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testKeyboardInteractiveWithFailures() throws Exception {
-        final AtomicInteger count = new AtomicInteger();
-        final int MAX_PROMPTS = 3;
-        FactoryManagerUtils.updateProperty(client, ClientFactoryManager.PASSWORD_PROMPTS, MAX_PROMPTS);
-
-        client.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(new UserAuthKeyboardInteractive.UserAuthKeyboardInteractiveFactory()));
-        client.setUserInteraction(new UserInteraction() {
-            @Override
-            public void welcome(String banner) {
-                // ignored
-            }
-            @Override
-            public String[] interactive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
-                count.incrementAndGet();
-                return new String[] { "bad" };
-            }
-        });
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            AuthFuture future = session.auth();
-            future.await();
-            assertTrue("Unexpected authentication success", future.isFailure());
-            assertEquals("Mismatched authentication retry count", MAX_PROMPTS, count.get());
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testKeyboardInteractiveInSessionUserInteractive() throws Exception {
-        final AtomicInteger count = new AtomicInteger();
-        final int MAX_PROMPTS = 3;
-        FactoryManagerUtils.updateProperty(client, ClientFactoryManager.PASSWORD_PROMPTS, MAX_PROMPTS);
-
-        client.setUserAuthFactories(Arrays
-                        .<NamedFactory<UserAuth>> asList(UserAuthKeyboardInteractive.UserAuthKeyboardInteractiveFactory.INSTANCE));
-        client.start();
-
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.setUserInteraction(new UserInteraction() {
-                    @Override
-                    public void welcome(String banner) {
-                        // ignored
-                    }
-        
-                    @Override
-                    public String[] interactive(String destination, String name, String instruction,
-                                                String[] prompt, boolean[] echo) {
-                        count.incrementAndGet();
-                        return new String[] { getCurrentTestName() };
-                    }
-                });
-            AuthFuture future = session.auth();
-            future.await();
-            assertTrue("Authentication not marked as success", future.isSuccess());
-            assertFalse("Authentication marked as failure", future.isFailure());
-            assertEquals("Mismatched authentication attempts count", 1, count.get());
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testKeyboardInteractiveInSessionUserInteractiveFailure() throws Exception {
-        final AtomicInteger count = new AtomicInteger();
-        final int MAX_PROMPTS = 3;
-        FactoryManagerUtils.updateProperty(client, ClientFactoryManager.PASSWORD_PROMPTS, MAX_PROMPTS);
-        client.setUserAuthFactories(Arrays
-                        .<NamedFactory<UserAuth>> asList(new UserAuthKeyboardInteractive.UserAuthKeyboardInteractiveFactory()));
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.setUserInteraction(new UserInteraction() {
-                @Override
-                public void welcome(String banner) {
-                    // ignored
-                }
-    
-                @Override
-                public String[] interactive(String destination, String name, String instruction,
-                                            String[] prompt, boolean[] echo) {
-                    count.incrementAndGet();
-                    return new String[] { "bad" };
-                }
-            });
-            AuthFuture future = session.auth();
-            future.await();
-            assertTrue("Authentication not, marked as failure", future.isFailure());
-            assertEquals("Mismatched authentication retry count", MAX_PROMPTS, count.get());
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testClientDisconnect() throws Exception {
-        TestEchoShellFactory.TestEchoShell.latch = new CountDownLatch(1);
-        try {
-            client.start();
-            
-            try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-                session.addPasswordIdentity(getCurrentTestName());
-                session.auth().verify(5L, TimeUnit.SECONDS);
-                
-                try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-                    PipedOutputStream pipedIn = new PipedOutputStream();
-                    InputStream inPipe = new PipedInputStream(pipedIn); 
-                    ByteArrayOutputStream out = new ByteArrayOutputStream();
-                    ByteArrayOutputStream err = new ByteArrayOutputStream()) {
-
-                    channel.setIn(inPipe);
-                    channel.setOut(out);
-                    channel.setErr(err);
-                    channel.open().await();
-        
-        //            ((AbstractSession) session).disconnect(SshConstants.SSH2_DISCONNECT_BY_APPLICATION, "Cancel");
-                    AbstractSession cs = (AbstractSession) session;
-                    Buffer buffer = cs.createBuffer(SshConstants.SSH_MSG_DISCONNECT);
-                    buffer.putInt(SshConstants.SSH2_DISCONNECT_BY_APPLICATION);
-                    buffer.putString("Cancel");
-                    buffer.putString("");
-                    IoWriteFuture f = cs.writePacket(buffer);
-                    f.await();
-                    suspend(cs.getIoSession());
-    
-                    TestEchoShellFactory.TestEchoShell.latch.await();
-                }
-            } finally {
-                client.stop();
-            }
-        } finally {
-            TestEchoShellFactory.TestEchoShell.latch = null;
-        }
-    }
-
-    @Test
-    public void testWaitAuth() throws Exception {
-        final AtomicBoolean ok = new AtomicBoolean();
-        client.setServerKeyVerifier(
-                new ServerKeyVerifier() {
-                    @Override
-                    public boolean verifyServerKey(
-                            ClientSession sshClientSession,
-                            SocketAddress remoteAddress,
-                            PublicKey serverKey
-                    ) {
-                        System.out.println(serverKey);
-                        ok.set(true);
-                        return true;
-                    }
-                }
-        );
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.waitFor(ClientSession.WAIT_AUTH, TimeUnit.SECONDS.toMillis(10L));
-            assertTrue(ok.get());
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testSwitchToNoneCipher() throws Exception {
-        sshd.getCipherFactories().add(BuiltinCiphers.none);
-        client.getCipherFactories().add(BuiltinCiphers.none);
-        client.start();
-        
-        try(ClientSession session = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            session.addPasswordIdentity(getCurrentTestName());
-            session.auth().verify(5L, TimeUnit.SECONDS);
-            session.switchToNoneCipher().await();
-    
-            try(ClientChannel channel = session.createSubsystemChannel(SftpConstants.SFTP_SUBSYSTEM_NAME)) {
-                channel.open().verify(5L, TimeUnit.SECONDS);
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    private void suspend(IoSession ioSession) {
-        if (ioSession instanceof MinaSession) {
-            ((MinaSession) ioSession).suspend();
-        } else {
-            ((Nio2Session) ioSession).suspend();
-        }
-    }
-
-    public static class TestEchoShellFactory extends EchoShellFactory {
-        @Override
-        public Command create() {
-            return new TestEchoShell();
-        }
-        public static class TestEchoShell extends EchoShell {
-
-            public static CountDownLatch latch = new CountDownLatch(1);
-
-            @Override
-            public void destroy() {
-                if (latch != null) {
-                    latch.countDown();
-                }
-                super.destroy();
-            }
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        SshClient.main(args);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6432a7af/sshd-core/src/test/java/org/apache/sshd/MacTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/MacTest.java b/sshd-core/src/test/java/org/apache/sshd/MacTest.java
deleted file mode 100644
index 6f3ea60..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/MacTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.cipher.BuiltinCiphers;
-import org.apache.sshd.common.cipher.Cipher;
-import org.apache.sshd.common.mac.BuiltinMacs;
-import org.apache.sshd.common.mac.Mac;
-import org.apache.sshd.common.random.BouncyCastleRandom;
-import org.apache.sshd.common.random.Random;
-import org.apache.sshd.server.SshServer;
-import org.apache.sshd.util.BaseTestSupport;
-import org.apache.sshd.util.BogusPasswordAuthenticator;
-import org.apache.sshd.util.EchoShellFactory;
-import org.apache.sshd.util.JSchLogger;
-import org.apache.sshd.util.SimpleUserInfo;
-import org.apache.sshd.util.Utils;
-import org.junit.After;
-import org.junit.FixMethodOrder;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-import com.jcraft.jsch.JSch;
-
-/**
- * Test Cipher algorithms.
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class MacTest extends BaseTestSupport {
-
-    private SshServer sshd;
-    private int port;
-
-    @Test
-    public void testHMACMD5() throws Exception {
-        setUp(BuiltinMacs.hmacmd5);
-        runTest();
-    }
-
-    @Test
-    public void testHMACMD596() throws Exception {
-        setUp(BuiltinMacs.hmacmd596);
-        runTest();
-    }
-
-    @Test
-    public void testHMACSHA1() throws Exception {
-        setUp(BuiltinMacs.hmacsha1);
-        runTest();
-    }
-
-    @Test
-    public void testHMACSHA196() throws Exception {
-        setUp(BuiltinMacs.hmacsha196);
-        runTest();
-    }
-
-    @Test
-    public void testHMACSHA256() throws Exception {
-        setUp(BuiltinMacs.hmacsha256);
-        runTest();
-    }
-
-    @Test
-    @Ignore("Lead to ArrayIndexOutOfBoundsException in JSch")
-    public void testHMACSHA512() throws Exception {
-        setUp(BuiltinMacs.hmacsha512);
-        runTest();
-    }
-
-    @Test
-    public void loadTest() throws Exception {
-        Random random = new BouncyCastleRandom();
-        loadTest(BuiltinCiphers.aes128cbc, random);
-        loadTest(BuiltinCiphers.blowfishcbc, random);
-        loadTest(BuiltinCiphers.tripledescbc, random);
-    }
-
-    protected void loadTest(NamedFactory<Cipher> factory, Random random) throws Exception {
-        Cipher cipher = factory.create();
-        byte[] key = new byte[cipher.getBlockSize()];
-        byte[] iv = new byte[cipher.getIVSize()];
-        random.fill(key, 0, key.length);
-        random.fill(iv, 0, iv.length);
-        cipher.init(Cipher.Mode.Encrypt, key, iv);
-
-        byte[] input = new byte[cipher.getBlockSize()];
-        random.fill(input, 0, input.length);
-        long t0 = System.currentTimeMillis();
-        for (int i = 0; i < 100000; i++) {
-            cipher.update(input, 0, input.length);
-        }
-        long t1 = System.currentTimeMillis();
-        System.err.println(factory.getName() + ": " + (t1 - t0) + " ms");
-    }
-
-
-    protected void setUp(NamedFactory<Mac> mac) throws Exception {
-        sshd = SshServer.setUpDefaultServer();
-        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
-        sshd.setMacFactories(Arrays.<NamedFactory<Mac>>asList(mac));
-        sshd.setShellFactory(new EchoShellFactory());
-        sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
-        sshd.start();
-        port  = sshd.getPort();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        if (sshd != null) {
-            sshd.stop(true);
-        }
-    }
-
-    protected void runTest() throws Exception {
-        JSchLogger.init();
-        JSch sch = new JSch();
-        JSch.setConfig("cipher.s2c", "aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,none");
-        JSch.setConfig("cipher.c2s", "aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,none");
-        JSch.setConfig("mac.s2c", "hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96,hmac-sha2-512");
-        JSch.setConfig("mac.c2s", "hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96,hmac-sha2-512");
-        JSch.setConfig("hmac-sha2-512",  "com.jcraft.jsch.jce.HMACSHA512");
-        com.jcraft.jsch.Session s = sch.getSession(getCurrentTestName(), "localhost", port);
-        try {
-            s.setUserInfo(new SimpleUserInfo(getCurrentTestName()));
-            s.connect();
-            com.jcraft.jsch.Channel c = s.openChannel("shell");
-            c.connect();
-
-            try(OutputStream os = c.getOutputStream();
-                InputStream is = c.getInputStream()) {
-
-                String  expected = "this is my command\n";
-                byte[] bytes = expected.getBytes();
-                byte[] data = new byte[bytes.length + Long.SIZE];
-                for (int i = 0; i < 10; i++) {
-                    os.write(bytes);
-                    os.flush();
-                    int len = is.read(data);
-                    String str = new String(data, 0, len);
-                    assertEquals("Mismatched data at iteration " + i, expected, str);
-                }
-            } finally {
-                c.disconnect();
-            }
-        } finally {
-            s.disconnect();
-        }
-    }
-
-    static boolean checkCipher(String cipher){
-        try{
-            Class<?> c=Class.forName(cipher);
-            com.jcraft.jsch.Cipher _c = (com.jcraft.jsch.Cipher)(c.newInstance());
-            _c.init(com.jcraft.jsch.Cipher.ENCRYPT_MODE,
-                    new byte[_c.getBlockSize()],
-                    new byte[_c.getIVSize()]);
-            return true;
-        }
-        catch(Exception e){
-            return false;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6432a7af/sshd-core/src/test/java/org/apache/sshd/RandomTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/RandomTest.java b/sshd-core/src/test/java/org/apache/sshd/RandomTest.java
deleted file mode 100644
index f35a265..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/RandomTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd;
-
-import org.apache.sshd.common.random.BouncyCastleRandom;
-import org.apache.sshd.common.random.JceRandom;
-import org.apache.sshd.common.random.Random;
-import org.apache.sshd.util.BaseTestSupport;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-/**
- * TODO Add javadoc
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class RandomTest extends BaseTestSupport {
-
-    @Test
-    public void testJce() {
-        long t = test(new JceRandom());
-        System.out.println("JCE: " + t + " micro");
-    }
-
-    @Test
-    public void testBc() {
-        long t = test(new BouncyCastleRandom());
-        System.out.println("BC:  " + t + " micro");
-    }
-
-    protected long test(Random random) {
-        byte[] bytes = new byte[32];
-        long l0 = System.nanoTime();
-        for (int i = 0; i < 1000; i++) {
-            random.fill(bytes, 8, 16);
-        }
-        long l1 = System.nanoTime();
-        return (l1 - l0) / 1000;
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6432a7af/sshd-core/src/test/java/org/apache/sshd/ServerMain.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ServerMain.java b/sshd-core/src/test/java/org/apache/sshd/ServerMain.java
deleted file mode 100644
index 2d9195f..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/ServerMain.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd;
-
-import org.apache.sshd.server.SshServer;
-
-
-/**
- * An activator for the {@link SshServer#main(String[])} - the reason it is
- * here is because the logging configuration is available only for test scope
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class ServerMain {
-    public static void main(String[] args) throws Throwable {
-        SshServer.main(args);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6432a7af/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
deleted file mode 100644
index 160b033..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.net.SocketAddress;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.sshd.client.SessionFactory;
-import org.apache.sshd.client.SshClient;
-import org.apache.sshd.client.channel.ChannelExec;
-import org.apache.sshd.client.channel.ChannelShell;
-import org.apache.sshd.client.future.AuthFuture;
-import org.apache.sshd.client.session.ClientConnectionService;
-import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.client.session.ClientSessionImpl;
-import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.SshConstants;
-import org.apache.sshd.common.channel.Channel;
-import org.apache.sshd.common.channel.WindowClosedException;
-import org.apache.sshd.common.io.IoSession;
-import org.apache.sshd.common.session.AbstractConnectionService;
-import org.apache.sshd.common.session.AbstractSession;
-import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.session.SessionListener;
-import org.apache.sshd.deprecated.ClientUserAuthServiceOld;
-import org.apache.sshd.deprecated.UserAuthPassword;
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.CommandFactory;
-import org.apache.sshd.server.Environment;
-import org.apache.sshd.server.ExitCallback;
-import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.command.ScpCommandFactory;
-import org.apache.sshd.server.sftp.SftpSubsystemFactory;
-import org.apache.sshd.util.BaseTestSupport;
-import org.apache.sshd.util.BogusPasswordAuthenticator;
-import org.apache.sshd.util.EchoShellFactory;
-import org.apache.sshd.util.Utils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * TODO Add javadoc
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class ServerTest extends BaseTestSupport {
-
-    private SshServer sshd;
-    private SshClient client;
-    private int port;
-
-    @Before
-    public void setUp() throws Exception {
-        sshd = SshServer.setUpDefaultServer();
-        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
-        sshd.setShellFactory(new TestEchoShellFactory());
-        sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
-        sshd.setSessionFactory(new org.apache.sshd.server.session.SessionFactory());
-        sshd.start();
-        port = sshd.getPort();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        if (sshd != null) {
-            sshd.stop(true);
-        }
-        if (client != null) {
-            client.stop();
-        }
-    }
-
-    /**
-     * Send bad password.  The server should disconnect after a few attempts
-     * @throws Exception
-     */
-    @Test
-    public void testFailAuthenticationWithWaitFor() throws Exception {
-        final int   MAX_AUTH_REQUESTS=10;
-        FactoryManagerUtils.updateProperty(sshd, ServerFactoryManager.MAX_AUTH_REQUESTS, MAX_AUTH_REQUESTS);
-
-        client = SshClient.setUpDefaultClient();
-        client.setServiceFactories(Arrays.asList(
-                new ClientUserAuthServiceOld.Factory(),
-                new ClientConnectionService.Factory()
-        ));
-        client.start();
-        
-        try(ClientSession s = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            int nbTrials = 0;
-            int res = 0;
-            while ((res & ClientSession.CLOSED) == 0) {
-                nbTrials ++;
-                s.getService(ClientUserAuthServiceOld.class)
-                        .auth(new UserAuthPassword((ClientSessionImpl) s, "ssh-connection", "buggy"));
-                res = s.waitFor(ClientSession.CLOSED | ClientSession.WAIT_AUTH, 5000);
-                if (res == ClientSession.TIMEOUT) {
-                    throw new TimeoutException();
-                }
-            }
-            assertTrue("Number trials (" + nbTrials + ") below min.=" + MAX_AUTH_REQUESTS, nbTrials > MAX_AUTH_REQUESTS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testFailAuthenticationWithFuture() throws Exception {
-        final int   MAX_AUTH_REQUESTS=10;
-        FactoryManagerUtils.updateProperty(sshd, ServerFactoryManager.MAX_AUTH_REQUESTS, MAX_AUTH_REQUESTS);
-
-        client = SshClient.setUpDefaultClient();
-        client.setServiceFactories(Arrays.asList(
-                new ClientUserAuthServiceOld.Factory(),
-                new ClientConnectionService.Factory()
-        ));
-        client.start();
-        try(ClientSession s = client.connect(getCurrentTestName(), "localhost", port).await().getSession()) {
-            int nbTrials = 0;
-            AuthFuture authFuture;
-            do {
-                nbTrials++;
-                assertTrue(nbTrials < 100);
-                authFuture = s.getService(ClientUserAuthServiceOld.class)
-                        .auth(new UserAuthPassword((ClientSessionImpl) s, "ssh-connection", "buggy"));
-                assertTrue("Authentication wait failed", authFuture.await(5000));
-                assertTrue("Authentication not done", authFuture.isDone());
-                assertFalse("Authentication unexpectedly successful", authFuture.isSuccess());
-            }
-            while (authFuture.isFailure());
-            assertNotNull("Missing auth future exception", authFuture.getException());
-            assertTrue("Number trials (" + nbTrials + ") below min.=" + MAX_AUTH_REQUESTS, nbTrials > MAX_AUTH_REQUESTS);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testAuthenticationTimeout() throws Exception {
-        final int   AUTH_TIMEOUT=5000;
-        FactoryManagerUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, AUTH_TIMEOUT);
-
-        client = SshClient.setUpDefaultClient();
-        client.start();
-        try(ClientSession s = client.connect("test", "localhost", port).await().getSession()) {
-            int res = s.waitFor(ClientSession.CLOSED, 2 * AUTH_TIMEOUT);
-            assertEquals("Session should be closed", ClientSession.CLOSED | ClientSession.WAIT_AUTH, res);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testIdleTimeout() throws Exception {
-        final CountDownLatch latch = new CountDownLatch(1);
-        TestEchoShellFactory.TestEchoShell.latch = new CountDownLatch(1);
-        final int   IDLE_TIMEOUT=2500;
-        FactoryManagerUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, IDLE_TIMEOUT);
-
-        sshd.getSessionFactory().addListener(new SessionListener() {
-            @Override
-            public void sessionCreated(Session session) {
-                System.out.println("Session created");
-            }
-            @Override
-            public void sessionEvent(Session session, Event event) {
-                System.out.println("Session event: " + event);
-            }
-            @Override
-            public void sessionClosed(Session session) {
-                System.out.println("Session closed");
-                latch.countDown();
-            }
-        });
-
-        client = SshClient.setUpDefaultClient();
-        client.start();
-        try(ClientSession s = client.connect("test", "localhost", port).await().getSession()) {
-            s.addPasswordIdentity("test");
-            s.auth().verify(5L, TimeUnit.SECONDS);
-
-            try(ChannelShell shell = s.createShellChannel();
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                ByteArrayOutputStream err = new ByteArrayOutputStream()) {
-                shell.setOut(out);
-                shell.setErr(err);
-                shell.open().await();
-                int res = s.waitFor(ClientSession.CLOSED, 2 * IDLE_TIMEOUT);
-                assertEquals("Session should be closed", ClientSession.CLOSED | ClientSession.AUTHED, res);
-            }
-        } finally {
-            client.stop();
-        }
-
-        assertTrue(latch.await(1, TimeUnit.SECONDS));
-        assertTrue(TestEchoShellFactory.TestEchoShell.latch.await(1, TimeUnit.SECONDS));
-    }
-
-    /**
-     * The scenario is the following:
-     *  - create a command that sends continuous data to the client
-     *  - the client does not read the data, filling the ssh window and the tcp socket
-     *  - the server session becomes idle, but the ssh disconnect message can't be written
-     *  - the server session is forcibly closed
-     */
-    @Test
-    public void testServerIdleTimeoutWithForce() throws Exception {
-        final CountDownLatch latch = new CountDownLatch(1);
-
-        sshd.setCommandFactory(new StreamCommand.Factory());
-        
-        FactoryManagerUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, 5000);
-        FactoryManagerUtils.updateProperty(sshd, FactoryManager.DISCONNECT_TIMEOUT, 2000);
-        sshd.getSessionFactory().addListener(new SessionListener() {
-            @Override
-            public void sessionCreated(Session session) {
-                System.out.println("Session created");
-            }
-
-            @Override
-            public void sessionEvent(Session session, Event event) {
-                System.out.println("Session event: " + event);
-            }
-
-            @Override
-            public void sessionClosed(Session session) {
-                System.out.println("Session closed");
-                latch.countDown();
-            }
-        });
-
-        client = SshClient.setUpDefaultClient();
-        client.start();
-
-        try(ClientSession s = client.connect("test", "localhost", port).await().getSession()) {
-            s.addPasswordIdentity("test");
-            s.auth().verify(5L, TimeUnit.SECONDS);
-
-            try(ChannelExec shell = s.createExecChannel("normal");
-                // Create a pipe that will block reading when the buffer is full
-                PipedInputStream pis = new PipedInputStream();
-                PipedOutputStream pos = new PipedOutputStream(pis)) {
-
-                shell.setOut(pos);
-                shell.open().verify(5L, TimeUnit.SECONDS);
-        
-                try(AbstractSession serverSession = sshd.getActiveSessions().iterator().next();
-                    Channel channel = serverSession.getService(AbstractConnectionService.class).getChannels().iterator().next()) {
-
-                    while (channel.getRemoteWindow().getSize() > 0) {
-                        Thread.sleep(1);
-                    }
-        
-                    LoggerFactory.getLogger(getClass()).info("Waiting for session idle timeouts");
-            
-                    long t0 = System.currentTimeMillis();
-                    latch.await(1, TimeUnit.MINUTES);
-                    long t1 = System.currentTimeMillis(), diff = t1 - t0;
-                    assertTrue("Wait time too low: " + diff, diff > 7000);
-                    assertTrue("Wait time too high: " + diff, diff < 10000);
-                }
-            }
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testLanguage() throws Exception {
-        client = SshClient.setUpDefaultClient();
-        client.setSessionFactory(new SessionFactory() {
-            @Override
-            protected AbstractSession createSession(IoSession ioSession) throws Exception {
-                return new ClientSessionImpl(client, ioSession) {
-                    @Override
-                    protected String[] createProposal(String hostKeyTypes) {
-                        String[] proposal = super.createProposal(hostKeyTypes);
-                        proposal[SshConstants.PROPOSAL_LANG_CTOS] = "en-US";
-                        proposal[SshConstants.PROPOSAL_LANG_STOC] = "en-US";
-                        return proposal;
-                    }
-                };
-            }
-        });
-        client.start();
-        try(ClientSession s = client.connect("test", "localhost", port).await().getSession()) {
-            s.close(false);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test
-    public void testKexCompletedEvent() throws Exception {
-    	final AtomicInteger	serverEventCount=new AtomicInteger(0);
-        sshd.getSessionFactory().addListener(new SessionListener() {
-	            @Override
-                public void sessionCreated(Session session) {
-	            	// ignored
-	            }
-	
-	            @Override
-                public void sessionEvent(Session session, Event event) {
-	            	if (event == Event.KexCompleted) {
-	            		serverEventCount.incrementAndGet();
-	            	}
-	            }
-	
-	            @Override
-                public void sessionClosed(Session session) {
-	            	// ignored
-	            }
-	        });
-
-        client = SshClient.setUpDefaultClient();
-        client.start();
-    	final AtomicInteger	clientEventCount=new AtomicInteger(0);
-        client.getSessionFactory().addListener(new SessionListener() {
-	            @Override
-                public void sessionCreated(Session session) {
-	            	// ignored
-	            }
-	
-	            @Override
-                public void sessionEvent(Session session, Event event) {
-	            	if (event == Event.KexCompleted) {
-	            		clientEventCount.incrementAndGet();
-	            	}
-	            }
-	
-	            @Override
-                public void sessionClosed(Session session) {
-	            	// ignored
-	            }
-	        });
-
-        try(ClientSession s = client.connect("test", "localhost", port).await().getSession()) {
-            s.addPasswordIdentity("test");
-            s.auth().verify(5L, TimeUnit.SECONDS);
-            assertEquals("Mismatched client events count", 1, clientEventCount.get());
-            assertEquals("Mismatched server events count", 1, serverEventCount.get());
-            s.close(false);
-        } finally {
-            client.stop();
-        }
-    }
-
-    @Test   // see https://issues.apache.org/jira/browse/SSHD-456
-    public void testServerStillListensIfSessionListenerThrowsException() throws InterruptedException {
-        final Map<String,SocketAddress> eventsMap = new TreeMap<String, SocketAddress>(String.CASE_INSENSITIVE_ORDER);
-        sshd.getSessionFactory().addListener(new SessionListener() {
-            private final Logger log=LoggerFactory.getLogger(getClass());
-            @Override
-            public void sessionCreated(Session session) {
-                throwException("SessionCreated", session);
-            }
-
-            @Override
-            public void sessionEvent(Session session, Event event) {
-                throwException("SessionEvent", session);
-            }
-
-            @Override
-            public void sessionClosed(Session session) {
-                throwException("SessionClosed", session);
-            }
-            
-            private void throwException(String phase, Session session) {
-                IoSession       ioSession = session.getIoSession();
-                SocketAddress   addr = ioSession.getRemoteAddress();
-                synchronized (eventsMap) {
-                    if (eventsMap.put(phase, addr) != null) {
-                        return; // already generated an event for this phase
-                    }
-                }
-                
-                RuntimeException e = new RuntimeException("Synthetic exception at phase=" + phase + ": " + addr);
-                log.info(e.getMessage());
-                throw e;
-            }
-        });
-        
-        client = SshClient.setUpDefaultClient();
-        client.start();
-        
-        int curCount=0;
-        for (int retryCount=0; retryCount < Byte.SIZE; retryCount++){
-            synchronized(eventsMap) {
-                if ((curCount=eventsMap.size()) >= 3) {
-                    return;
-                }
-            }
-            
-            try {
-                try(ClientSession s = client.connect("test", "localhost", port).await().getSession()) {
-                    s.addPasswordIdentity("test");
-                    s.auth().verify(5L, TimeUnit.SECONDS);
-                }
-                
-                synchronized(eventsMap) {
-                    assertTrue("Unexpected premature success: " + eventsMap, eventsMap.size() >= 3);
-                }
-            } catch(IOException e) {
-                // expected - ignored
-                synchronized(eventsMap) {
-                    int nextCount=eventsMap.size();
-                    assertTrue("No session event generated", nextCount > curCount);
-                }
-            }
-        }
-        
-        fail("No success to authenticate");
-    }
-
-    public static class TestEchoShellFactory extends EchoShellFactory {
-        @Override
-        public Command create() {
-            return new TestEchoShell();
-        }
-        public static class TestEchoShell extends EchoShell {
-
-            public static CountDownLatch latch = new CountDownLatch(1);
-
-            @Override
-            public void destroy() {
-                if (latch != null) {
-                    latch.countDown();
-                }
-                super.destroy();
-            }
-        }
-    }
-
-    public static class StreamCommand implements Command, Runnable {
-
-        public static class Factory implements CommandFactory {
-            @Override
-            public Command createCommand(String name) {
-                return new StreamCommand(name);
-            }
-        }
-
-        public static CountDownLatch latch;
-
-        private final String name;
-        private OutputStream out;
-
-        public StreamCommand(String name) {
-            this.name = name;
-        }
-
-        @Override
-        public void setInputStream(InputStream in) {
-            // ignored
-        }
-
-        @Override
-        public void setOutputStream(OutputStream out) {
-            this.out = out;
-        }
-
-        @Override
-        public void setErrorStream(OutputStream err) {
-            // ignored
-        }
-
-        @Override
-        public void setExitCallback(ExitCallback callback) {
-            // ignored
-        }
-
-        @Override
-        public void start(Environment env) throws IOException {
-            new Thread(this).start();
-        }
-
-        @Override
-        public void destroy() {
-            synchronized (name) {
-                if ("block".equals(name)) {
-                    try {
-                        name.wait();
-                    } catch (InterruptedException e) {
-                        e.printStackTrace();
-                    }
-                }
-            }
-        }
-
-        @Override
-        public void run() {
-            try {
-                Thread.sleep(5000);
-                while (true) {
-                    for (int i = 0; i < 100; i++) {
-                        out.write("0123456789\n".getBytes());
-                    }
-                    out.flush();
-                }
-            } catch (WindowClosedException e) {
-                // ok, do nothing
-            } catch (Throwable e) {
-                e.printStackTrace();
-            } finally {
-                if (latch != null) {
-                    latch.countDown();
-                }
-            }
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        SshServer sshd = SshServer.setUpDefaultServer();
-        FactoryManagerUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, TimeUnit.SECONDS.toMillis(10L));
-        sshd.setPort(8001);
-        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
-        sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory()));
-        sshd.setShellFactory(new EchoShellFactory());
-        sshd.setCommandFactory(new ScpCommandFactory());
-        sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
-        sshd.start();
-        Thread.sleep(100000);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6432a7af/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java b/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java
deleted file mode 100644
index 7f06812..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd;
-
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.sshd.common.BaseBuilder;
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.NamedResource;
-import org.apache.sshd.common.cipher.BuiltinCiphers;
-import org.apache.sshd.common.cipher.Cipher;
-import org.apache.sshd.common.kex.BuiltinDHFactories;
-import org.apache.sshd.common.mac.BuiltinMacs;
-import org.apache.sshd.common.signature.BuiltinSignatures;
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.BaseTestSupport;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class SshBuilderTest extends BaseTestSupport {
-    public SshBuilderTest() {
-        super();
-    }
-
-    /**
-     * Make sure that all values in {@link BuiltinCiphers} are
-     * listed in {@link BaseBuilder#DEFAULT_CIPHERS_PREFERENCE}
-     */
-    @Test
-    public void testAllBuiltinCiphersListed() {
-        Set<BuiltinCiphers> all=EnumSet.allOf(BuiltinCiphers.class);
-        // The 'none' cipher is not listed as preferred - it is implied
-        assertTrue("Missing " + BuiltinCiphers.Constants.NONE + " cipher in all values", all.remove(BuiltinCiphers.none));
-        testAllInstancesListed(all, BaseBuilder.DEFAULT_CIPHERS_PREFERENCE);
-    }
-
-    /**
-     * Make sure that all values in {@link BuiltinMacs} are
-     * listed in {@link BaseBuilder#DEFAULT_MAC_PREFERENCE}
-     */
-    @Test
-    public void testAllBuiltinMacsListed() {
-        testAllInstancesListed(BuiltinMacs.VALUES, BaseBuilder.DEFAULT_MAC_PREFERENCE);
-    }
-
-    /**
-     * Make sure that all values in {@link BuiltinSignatures} are
-     * listed in {@link BaseBuilder#DEFAULT_SIGNATURE_PREFERENCE}
-     */
-    @Test
-    public void testAllBuiltinSignaturesListed() {
-        testAllInstancesListed(BuiltinSignatures.VALUES, BaseBuilder.DEFAULT_SIGNATURE_PREFERENCE);
-    }
-
-    /**
-     * Make sure that all values in {@link BuiltinDHFactories} are
-     * listed in {@link BaseBuilder#DEFAULT_KEX_PREFERENCE}
-     */
-    @Test
-    public void testAllBuiltinDHFactoriesListed() {
-        testAllInstancesListed(BuiltinDHFactories.VALUES, BaseBuilder.DEFAULT_KEX_PREFERENCE);
-    }
-
-    private static <E extends Enum<E>> void testAllInstancesListed(Set<? extends E> expValues, Collection<? extends E> actValues) {
-        assertEquals("Mismatched actual values size", expValues.size(), actValues.size());
-        for (E expected : expValues) {
-            assertTrue(expected.name() + " not found in actual values", actValues.contains(expected));
-        }
-    }
-
-    /**
-     * Make sure that {@link BaseBuilder#setUpDefaultCiphers(boolean)} returns
-     * the correct result - i.e., according to the {@code ingoreUnsupported}
-     * parameter and in the defined preference order
-     */
-    @Test
-    public void testSetUpDefaultCiphers() {
-        for (boolean ignoreUnsupported : new boolean[] { true, false }) {
-            List<NamedFactory<Cipher>>  ciphers=BaseBuilder.setUpDefaultCiphers(ignoreUnsupported);
-            int                         numCiphers=GenericUtils.size(ciphers);
-            // make sure returned list size matches expected count
-            if (ignoreUnsupported) {
-                assertEquals("Incomplete full ciphers size", BaseBuilder.DEFAULT_CIPHERS_PREFERENCE.size(), numCiphers);
-            } else {
-                int expectedCount=0;
-                for (BuiltinCiphers c : BaseBuilder.DEFAULT_CIPHERS_PREFERENCE) {
-                    if (c.isSupported()) {
-                        expectedCount++;
-                    }
-                }
-                assertEquals("Incomplete supported ciphers size", expectedCount, numCiphers);
-            }
-            
-            // make sure order is according to the default preference list
-            List<String>    cipherNames=NamedResource.Utils.getNameList(ciphers);
-            int             nameIndex=0;
-            for (BuiltinCiphers c : BaseBuilder.DEFAULT_CIPHERS_PREFERENCE) {
-                if ((!c.isSupported()) && (!ignoreUnsupported)) {
-                    continue;
-                }
-                
-                String  expectedName=c.getName();
-                assertTrue("Out of actual ciphers for expected=" + expectedName, nameIndex < numCiphers);
-                
-                String  actualName=cipherNames.get(nameIndex);
-                assertEquals("Mismatched cipher at position " + nameIndex + " for ignoreUnsupported=" + ignoreUnsupported, expectedName, actualName);
-                nameIndex++;
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6432a7af/sshd-core/src/test/java/org/apache/sshd/SshServerMain.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SshServerMain.java b/sshd-core/src/test/java/org/apache/sshd/SshServerMain.java
deleted file mode 100644
index 72d662f..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/SshServerMain.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd;
-
-import org.apache.sshd.server.SshServer;
-
-/**
- * Just a test class used to invoke {@link SshServer#main(String[])} in
- * order to have logging - which is in {@code test} scope
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class SshServerMain {
-
-    public static void main(String[] args) throws Exception {
-        SshServer.main(args);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6432a7af/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java b/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java
deleted file mode 100644
index 674aba1..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.sshd.server.SshServer;
-import org.apache.sshd.util.BaseTestSupport;
-import org.apache.sshd.util.BogusPasswordAuthenticator;
-import org.apache.sshd.util.EchoShellFactory;
-import org.apache.sshd.util.Utils;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-/**
- * @author Kohsuke Kawaguchi
- * @author Michael Heemskerk
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class SshServerTest extends BaseTestSupport {
-
-    @Test
-    public void stopMethodShouldBeIdempotent() throws Exception {
-        try(SshServer sshd = new SshServer()) {
-            sshd.stop();
-            sshd.stop();
-            sshd.stop();
-        }
-    }
-
-    @Test
-    public void testExecutorShutdownFalse() throws Exception {
-        ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
-
-        try(SshServer sshd = createTestServer()) {
-            sshd.setScheduledExecutorService(executorService);
-    
-            sshd.start();
-            sshd.stop();
-    
-            assertFalse(executorService.isShutdown());
-            executorService.shutdownNow();
-        }
-    }
-
-    @Test
-    public void testExecutorShutdownTrue() throws Exception {
-        ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
-
-        try(SshServer sshd = createTestServer()) {
-            sshd.setScheduledExecutorService(executorService, true);
-    
-            sshd.start();
-            sshd.stop();
-    
-            assertTrue(executorService.isShutdown());
-        }
-    }
-
-    @Test
-    public void testDynamicPort() throws Exception {
-        try(SshServer sshd = createTestServer()) {
-            sshd.setHost("localhost");
-            sshd.start();
-    
-            assertNotEquals(0, sshd.getPort());
-    
-            sshd.stop();
-        }
-    }
-
-
-    private SshServer createTestServer() {
-        SshServer sshd = SshServer.setUpDefaultServer();
-        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
-        sshd.setShellFactory(new EchoShellFactory());
-        sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
-
-        return sshd;
-    }
-}