mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
Improved test stability
This commit is contained in:
@@ -137,6 +137,15 @@ public class LocalPortForwarder {
|
|||||||
listen(Thread.currentThread());
|
listen(Thread.currentThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this listener is running (ie. whether a thread is attached to it).
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isRunning() {
|
||||||
|
return this.runningThread != null && !serverSocket.isClosed();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start listening for incoming connections and forward to remote host as a channel and ensure that the thread is registered.
|
* Start listening for incoming connections and forward to remote host as a channel and ensure that the thread is registered.
|
||||||
* This is useful if for instance {@link #close() is called from another thread}
|
* This is useful if for instance {@link #close() is called from another thread}
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ import com.hierynomus.sshj.test.SshFixture
|
|||||||
import net.schmizz.sshj.connection.channel.direct.LocalPortForwarder
|
import net.schmizz.sshj.connection.channel.direct.LocalPortForwarder
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import spock.lang.Specification
|
import spock.lang.Specification
|
||||||
|
import spock.util.concurrent.PollingConditions
|
||||||
|
|
||||||
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
class LocalPortForwarderSpec extends Specification {
|
class LocalPortForwarderSpec extends Specification {
|
||||||
@Rule
|
@Rule
|
||||||
@@ -44,6 +47,9 @@ class LocalPortForwarderSpec extends Specification {
|
|||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
then:
|
then:
|
||||||
|
new PollingConditions().eventually {
|
||||||
|
lpf.isRunning()
|
||||||
|
}
|
||||||
thread.isAlive()
|
thread.isAlive()
|
||||||
|
|
||||||
when:
|
when:
|
||||||
|
|||||||
Reference in New Issue
Block a user