FossologySshConnector { protected void waitCompletion(Channel channel, long timeout) throws SW360Exception { long startTime = currentTimeMillis(); while (!channel.isClosed() && (currentTimeMillis() - startTime < timeout)) { try { Thread.sleep(200); } catch (InterruptedException e) { throw fail(e, "interrupted connection to Fossology"); } } if (!channel.isClosed()) { throw fail("timeout while waiting for completion of connection to Fossology"); } } @Autowired  FossologySshConnector(JSchSessionProvider jSchSessionProvider, FossologySettings fossologySettings); int runInFossologyViaSsh(String command); int runInFossologyViaSsh(String command, InputStream stdin); int runInFossologyViaSsh(String command, OutputStream stdout); int runInFossologyViaSsh(String command, InputStream stdin, OutputStream stdout);  }
@Test public void testWaitCompletion() throws SW360Exception { executionTimeout = 100; doCallRealMethod().when(fossologySshConnector).waitCompletion(channel, executionTimeout); when(channel.isClosed()).thenReturn(true); fossologySshConnector.waitCompletion(channel, executionTimeout); }
@Test public void testWaitCompletionThrowsOnTimeout() throws SW360Exception { executionTimeout = 100; doCallRealMethod().when(fossologySshConnector).waitCompletion(channel, executionTimeout); expectedException.expect(SW360Exception.class); when(channel.isClosed()).thenReturn(false); fossologySshConnector.waitCompletion(channel, executionTimeout); }