SshHelper { protected static boolean canEndTheSshConnection(int waitResultTimeoutInMs, com.trilead.ssh2.Session sess, int conditions) throws SshException { if (isChannelConditionEof(conditions)) { int newConditions = sess.waitForCondition(ChannelCondition.EXIT_STATUS, waitResultTimeoutInMs); throwSshExceptionIfConditionsTimeout(newConditions); if ((newConditions & ChannelCondition.EXIT_STATUS) != 0) { return true; } } return false; }  static Pair<Boolean, String> sshExecute(String host, int port, String user, File pemKeyFile, String password, String command); static void scpTo(String host, int port, String user, File pemKeyFile, String password, String remoteTargetDirectory, String localFile, String fileMode); static void scpTo(String host, int port, String user, File pemKeyFile, String password, String remoteTargetDirectory, byte[] data, String remoteFileName,
            String fileMode); static void scpTo(String host, int port, String user, File pemKeyFile, String password, String remoteTargetDirectory, String localFile, String fileMode,
            int connectTimeoutInMs, int kexTimeoutInMs); static void scpTo(String host, int port, String user, File pemKeyFile, String password, String remoteTargetDirectory, byte[] data, String remoteFileName,
            String fileMode, int connectTimeoutInMs, int kexTimeoutInMs); static Pair<Boolean, String> sshExecute(String host, int port, String user, File pemKeyFile, String password, String command, int connectTimeoutInMs,
            int kexTimeoutInMs,
            int waitResultTimeoutInMs);  }
@Test public void canEndTheSshConnectionTest() throws Exception { PowerMockito.spy(SshHelper.class); Session mockedSession = Mockito.mock(Session.class); PowerMockito.doReturn(true).when(SshHelper.class, "isChannelConditionEof", Mockito.anyInt()); Mockito.when(mockedSession.waitForCondition(ChannelCondition.EXIT_STATUS, 1l)).thenReturn(0); PowerMockito.doNothing().when(SshHelper.class, "throwSshExceptionIfConditionsTimeout", Mockito.anyInt()); SshHelper.canEndTheSshConnection(1, mockedSession, 0); PowerMockito.verifyStatic(); SshHelper.isChannelConditionEof(Mockito.anyInt()); SshHelper.throwSshExceptionIfConditionsTimeout(Mockito.anyInt()); Mockito.verify(mockedSession).waitForCondition(ChannelCondition.EXIT_STATUS, 1l); }