client.stop();
@Override public void closeConnection() { if (sftp != null) { client.stop(); sftp = null; } } }
@Override protected void doStop() throws Exception { super.doStop(); if (client != null) { client.stop(); client = null; } }
@Override protected void doStop() throws Exception { super.doStop(); if (client != null) { client.stop(); client = null; } }
private void disconnect(Throwable reason) { try { if (session != null) { session.close(); session = null; } } catch (IOException e) { if (reason != null) { reason.addSuppressed(e); } else { LOG.error(SshdText.get().sessionCloseFailed, e); } } finally { client.stop(); client = null; } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (client != null) { client.stop(); } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (client != null) { client.stop(); } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (client != null) { client.stop(); } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (client != null) { client.stop(); } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (client != null) { client.stop(); } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (client != null) { client.stop(); } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (acceptor != null) { acceptor.dispose(true); } if (client != null) { client.stop(); } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (acceptor != null) { acceptor.dispose(true); } if (client != null) { client.stop(); } }
@After public void tearDown() throws Exception { if (sshd != null) { sshd.stop(true); } if (acceptor != null) { acceptor.dispose(true); } if (client != null) { client.stop(); } }
@Test public void testAuthenticationTimeout() throws Exception { final long testAuthTimeout = TimeUnit.SECONDS.toMillis(5L); PropertyResolverUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, testAuthTimeout); sshd.start(); client.start(); try (ClientSession s = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) { Collection<ClientSession.ClientSessionEvent> res = s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testAuthTimeout); assertTrue("Session should be closed: " + res, res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.WAIT_AUTH))); } finally { client.stop(); } }
@Test public void testAuthenticationTimeout() throws Exception { final long testAuthTimeout = TimeUnit.SECONDS.toMillis(5L); PropertyResolverUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, testAuthTimeout); sshd.start(); client.start(); try (ClientSession s = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) { Collection<ClientSession.ClientSessionEvent> res = s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testAuthTimeout); assertTrue("Session should be closed: " + res, res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.WAIT_AUTH))); } finally { client.stop(); } }
@Test public void testAuthenticationTimeout() throws Exception { final long testAuthTimeout = TimeUnit.SECONDS.toMillis(5L); PropertyResolverUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, testAuthTimeout); sshd.start(); client.start(); try (ClientSession s = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) { Collection<ClientSession.ClientSessionEvent> res = s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testAuthTimeout); assertTrue("Session should be closed: " + res, res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.WAIT_AUTH))); } finally { client.stop(); } }
@Test public void testIdleClient() throws Exception { SshClient client = setupTestClient(); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll(EnumSet.of(ClientChannelEvent.CLOSED))); } } finally { client.stop(); } }
@Test public void testIdleClient() throws Exception { SshClient client = setupTestClient(); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll(EnumSet.of(ClientChannelEvent.CLOSED))); } } finally { client.stop(); } }
@Test public void testIdleClient() throws Exception { SshClient client = setupTestClient(); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll(EnumSet.of(ClientChannelEvent.CLOSED))); } } finally { client.stop(); } }