@Test
public void testWithTimeout() {

    try {
        // process finishes in 1 second
        when(process.exitValue()).thenThrow(new IllegalThreadStateException())
                .thenThrow(new IllegalThreadStateException())
                .thenReturn(0);
        int exitCode = ProcessHelper.runWithTimeout(10, process);
        assertEquals(0, exitCode);
        verify(process, never()).waitFor();
        verify(process, times(3)).exitValue();
        verify(process, never()).destroy();
    } catch (Exception e) {
        fail();
    }
}