org.testcontainers.containers.wait.strategy.WaitStrategyTarget Java Examples

The following examples show how to use org.testcontainers.containers.wait.strategy.WaitStrategyTarget. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
/**
 * @return the ports on which to check if the container is ready
 * @deprecated use {@link #getLivenessCheckPortNumbers()} instead
 */
@NotNull
@NonNull
@Deprecated
protected Set<Integer> getLivenessCheckPorts() {
    final Set<Integer> result = WaitStrategyTarget.super.getLivenessCheckPortNumbers();

    // for backwards compatibility
    if (this.getLivenessCheckPort() != null) {
        result.add(this.getLivenessCheckPort());
    }

    return result;
}
 
Example #2
Source File: ExternalPortListeningCheckTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    listeningSocket1 = new ServerSocket(0);
    listeningSocket2 = new ServerSocket(0);

    nonListeningSocket = new ServerSocket(0);
    nonListeningSocket.close();

    mockContainer = mock(WaitStrategyTarget.class);
    when(mockContainer.getHost()).thenReturn("127.0.0.1");
}
 
Example #3
Source File: CassandraWaitStrategy.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
public void waitUntilReady(WaitStrategyTarget waitStrategyTarget) {
    Unreliables.retryUntilTrue(Ints.checkedCast(timeout.getSeconds()), TimeUnit.SECONDS, () -> {
            try {
                return cassandraContainer
                    .execInContainer("cqlsh", "-u", "cassandra", "-p", "cassandra", "-e", "show host")
                    .getStdout()
                    .contains("Connected to Test Cluster");
            } catch (IOException | InterruptedException e) {
                return false;
            }
        }
    );
}
 
Example #4
Source File: SpamAssassinWaitStrategy.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
public void waitUntilReady(WaitStrategyTarget waitStrategyTarget) {
    Unreliables.retryUntilTrue(Ints.checkedCast(timeout.getSeconds()), TimeUnit.SECONDS, () -> {
            try {
                return spamAssassinContainer
                    .execInContainer("spamassassin", "-V")
                    .getStdout()
                    .contains("SpamAssassin version 3.4.2");
            } catch (IOException | InterruptedException e) {
                return false;
            }
        }
    );
}
 
Example #5
Source File: HollowTestcontainersConfigurationTest.java    From microshed-testing with Apache License 2.0 4 votes vote down vote up
@Override
public void waitUntilReady(WaitStrategyTarget waitStrategyTarget) {
    waitedForStartup = true;
}
 
Example #6
Source File: HollowTestcontainersConfigurationTest2.java    From microshed-testing with Apache License 2.0 4 votes vote down vote up
@Override
public void waitUntilReady(WaitStrategyTarget waitStrategyTarget) {
}
 
Example #7
Source File: RabbitMQWaitStrategy.java    From james-project with Apache License 2.0 4 votes vote down vote up
@Override
public void waitUntilReady(WaitStrategyTarget waitStrategyTarget) {
    int seconds = Ints.checkedCast(this.timeout.getSeconds());

    Unreliables.retryUntilTrue(seconds, TimeUnit.SECONDS, this::isConnected);
}