channel.setIn(new NoCloseInputStream(System.in)); channel.setOut(new NoCloseOutputStream(System.out)); channel.setErr(new NoCloseOutputStream(System.err)); WaitableFuture wf = channel.open(); wf.await();
final ByteArrayOutputStream serr = new ByteArrayOutputStream(); channel.setOut( AnsiConsole.wrapOutputStream(sout)); channel.setErr( AnsiConsole.wrapOutputStream(serr)); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
final ByteArrayOutputStream serr = new ByteArrayOutputStream(); channel.setOut( AnsiConsole.wrapOutputStream(sout)); channel.setErr( AnsiConsole.wrapOutputStream(serr)); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
final ByteArrayOutputStream serr = new ByteArrayOutputStream(); channel.setOut( AnsiConsole.wrapOutputStream(sout)); channel.setErr( AnsiConsole.wrapOutputStream(serr)); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
final ByteArrayOutputStream serr = new ByteArrayOutputStream(); channel.setOut( AnsiConsole.wrapOutputStream(sout)); channel.setErr( AnsiConsole.wrapOutputStream(serr)); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
channel.setIn(iin); channel.setOut(iout); channel.setErr(ierr); channel.open();
channel.setErr(err); OpenFuture openFuture = channel.open(); openFuture.await(configuration.getTimeout());
ClientChannel channel = createExecChannel(command)) { channel.setOut(channelOut); channel.setErr(channelErr);
ClientChannel channel = createExecChannel(command)) { channel.setOut(channelOut); channel.setErr(channelErr);
channel.setIn(new ByteArrayInputStream(new byte[0])); channel.setOut(new NoCloseOutputStream(stdout)); channel.setErr(new NoCloseOutputStream(stderr)); channel.open().verify(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
channel.setIn(new ByteArrayInputStream(new byte[0])); channel.setOut(new NoCloseOutputStream(stdout)); channel.setErr(new NoCloseOutputStream(stderr)); channel.open().verify(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
@Test public void testShellClosedOnClientTimeout() throws Exception { TestEchoShell.latch = new CountDownLatch(1); 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); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream()) { channel.setOut(out); channel.setErr(err); channel.open().verify(9L, TimeUnit.SECONDS); assertTrue("Latch time out", TestEchoShell.latch.await(10L, TimeUnit.SECONDS)); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll( EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.OPENED))); } } finally { TestEchoShell.latch = null; client.stop(); } }
ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { channel.setOut(out); channel.setErr(err);
ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { channel.setOut(out); channel.setErr(err);
ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { channel.setOut(out); channel.setErr(err);
@Test public void testShellClosedOnClientTimeout() throws Exception { TestEchoShell.latch = new CountDownLatch(1); 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); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream()) { channel.setOut(out); channel.setErr(err); channel.open().verify(9L, TimeUnit.SECONDS); assertTrue("Latch time out", TestEchoShell.latch.await(10L, TimeUnit.SECONDS)); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll( EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.OPENED))); } } finally { TestEchoShell.latch = null; client.stop(); } }
@Test public void testShellClosedOnClientTimeout() throws Exception { TestEchoShell.latch = new CountDownLatch(1); 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); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream()) { channel.setOut(out); channel.setErr(err); channel.open().verify(9L, TimeUnit.SECONDS); assertTrue("Latch time out", TestEchoShell.latch.await(10L, TimeUnit.SECONDS)); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll( EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.OPENED))); } } finally { TestEchoShell.latch = null; client.stop(); } }
@Test(timeout = 6L * 60L * 1000L) public void testTrafficHeavyLoad() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (final ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); try (final ClientChannel channel = session.createShellChannel()) { channel.setOut(new VerifyingOutputStream(channel, END_FILE)); channel.setErr(new NoCloseOutputStream(System.err)); channel.open().verify(15L, TimeUnit.SECONDS); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.MINUTES.toMillis(2L)); assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } } finally { client.stop(); } } }
@Test(timeout = 6L * 60L * 1000L) public void testTrafficHeavyLoad() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (final ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); try (final ClientChannel channel = session.createShellChannel()) { channel.setOut(new VerifyingOutputStream(channel, END_FILE)); channel.setErr(new NoCloseOutputStream(System.err)); channel.open().verify(15L, TimeUnit.SECONDS); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.MINUTES.toMillis(2L)); assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } } finally { client.stop(); } } }
@Test(timeout = 6L * 60L * 1000L) public void testTrafficHeavyLoad() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (final ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); try (final ClientChannel channel = session.createShellChannel()) { channel.setOut(new VerifyingOutputStream(channel, END_FILE)); channel.setErr(new NoCloseOutputStream(System.err)); channel.open().verify(15L, TimeUnit.SECONDS); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.MINUTES.toMillis(2L)); assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } } finally { client.stop(); } } }