diff --git a/src/test/kotlin/com/atlassian/performance/tools/ssh/api/SshConnectionTest.kt b/src/test/kotlin/com/atlassian/performance/tools/ssh/api/SshConnectionTest.kt index f64cfad..9964bbb 100644 --- a/src/test/kotlin/com/atlassian/performance/tools/ssh/api/SshConnectionTest.kt +++ b/src/test/kotlin/com/atlassian/performance/tools/ssh/api/SshConnectionTest.kt @@ -1,7 +1,11 @@ package com.atlassian.performance.tools.ssh.api +import org.apache.logging.log4j.Level import org.junit.Assert import org.junit.Test +import java.lang.Exception +import java.time.Duration +import java.time.Instant class SshConnectionTest { @@ -14,4 +18,18 @@ class SshConnectionTest { Assert.assertEquals(sshResult.output, "test\n") } } + + @Test + fun shouldRespectTimeouts() { + SshContainer().useConnection { ssh: SshConnection -> + val start = Instant.now() + try { + ssh.execute("sleep 100", Duration.ofSeconds(1), Level.OFF, Level.OFF) + }catch (e : Exception){ + //ignore + } + val executeDuration = Duration.between( start, Instant.now()) + Assert.assertTrue(executeDuration < Duration.ofSeconds(10)) + } + } } \ No newline at end of file