Tabnine Logo
org.testcontainers.containers.wait
Code IndexAdd Tabnine to your IDE (free)

How to use org.testcontainers.containers.wait

Best Java code snippets using org.testcontainers.containers.wait (Showing top 20 results out of 315)

origin: testcontainers/testcontainers-java

/**
 * Convenience method to return a WaitStrategy for an HTTPS endpoint.
 *
 * @param path the path to check
 * @return the WaitStrategy
 * @see HttpWaitStrategy
 */
public static HttpWaitStrategy forHttps(String path) {
  return forHttp(path)
      .usingTls();
}
origin: testcontainers/testcontainers-java

/**
 * Wait until the container has started.
 *
 * @param container the container for which to wait
 */
default void waitUntilReady(GenericContainer container) {
  this.waitUntilReady((WaitStrategyTarget)container);
}
origin: testcontainers/testcontainers-java

/**
 * Convenience method to return a WaitStrategy for an HTTP endpoint.
 *
 * @param path the path to check
 * @return the WaitStrategy
 * @see HttpWaitStrategy
 */
public static HttpWaitStrategy forHttp(String path) {
  return new HttpWaitStrategy()
      .forPath(path);
}
origin: testcontainers/testcontainers-java

/**
 */
public BrowserWebDriverContainer() {
  final WaitStrategy logWaitStrategy = new LogMessageWaitStrategy()
      .withRegEx(".*(RemoteWebDriver instances should connect to|Selenium Server is up and running).*\n")
      .withStartupTimeout(Duration.of(15, SECONDS));
  this.waitStrategy = new WaitAllStrategy()
      .withStrategy(logWaitStrategy)
      .withStrategy(new HostPortWaitStrategy())
      .withStartupTimeout(Duration.of(15, SECONDS));
  this.withRecordingFileFactory(new DefaultRecordingFileFactory());
}
origin: testcontainers/testcontainers-java

public PostgreSQLContainer(final String dockerImageName) {
  super(dockerImageName);
  this.waitStrategy = new LogMessageWaitStrategy()
      .withRegEx(".*database system is ready to accept connections.*\\s")
      .withTimes(2)
      .withStartupTimeout(Duration.of(60, SECONDS));
}
origin: testcontainers/testcontainers-java

  /**
   * Convenience method to return a WaitStrategy for log messages.
   *
   * @param regex the regex pattern to check for
   * @param times the number of times the pattern is expected
   * @return LogMessageWaitStrategy
   */
  public static LogMessageWaitStrategy forLogMessage(String regex, int times) {
    return new LogMessageWaitStrategy().withRegEx(regex).withTimes(times);
  }
}
origin: testcontainers/testcontainers-java

@Override
protected void configure() {
  withExposedPorts(HTTP_PORT, NATIVE_PORT);
  waitingFor(
    new HttpWaitStrategy()
      .forStatusCode(200)
      .forResponsePredicate(responseBody -> "Ok.".equals(responseBody))
      .withStartupTimeout(Duration.ofMinutes(1))
  );
}
origin: testcontainers/testcontainers-java

  @Test
  public void appliesOuterTimeout() {

    final WaitStrategy underTest = new WaitAllStrategy()
        .withStrategy(strategy1)
        .withStartupTimeout(Duration.ofMillis(10));

    doAnswer(invocation -> {
      Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
      return null;
    }).when(strategy1).waitUntilReady(eq(container));

    assertThrows("The outer strategy timeout applies", TimeoutException.class, () -> {
      underTest.waitUntilReady(container);
    });
  }
}
origin: testcontainers/testcontainers-java

@Test
public void simpleTest() {
  final WaitStrategy underTest = new WaitAllStrategy()
      .withStrategy(strategy1)
      .withStrategy(strategy2);
  doNothing().when(strategy1).waitUntilReady(eq(container));
  doNothing().when(strategy2).waitUntilReady(eq(container));
  underTest.waitUntilReady(container);
  InOrder inOrder = inOrder(strategy1, strategy2);
  inOrder.verify(strategy1).waitUntilReady(any());
  inOrder.verify(strategy2).waitUntilReady(any());
}
origin: testcontainers/testcontainers-java

/**
 * Convenience method to return a WaitStrategy for an exposed or mapped port.
 *
 * @return the WaitStrategy
 * @see HostPortWaitStrategy
 */
public static HostPortWaitStrategy forListeningPort() {
  return new HostPortWaitStrategy();
}
origin: testcontainers/testcontainers-java

/**
 * Convenience method to return the default WaitStrategy.
 *
 * @return a WaitStrategy
 */
public static WaitStrategy defaultWaitStrategy() {
  return forListeningPort();
}
origin: testcontainers/testcontainers-java

@Override
protected void waitUntilReady() {
  // execute select version query until success or timeout
  try {
    retryUntilSuccess((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> {
      getRateLimiter().doWhenReady(() -> {
        try (DatabaseDelegate databaseDelegate = getDatabaseDelegate()) {
          databaseDelegate.execute(SELECT_VERSION_QUERY, "", 1, false, false);
        }
      });
      return true;
    });
  } catch (TimeoutException e) {
    throw new ContainerLaunchException(TIMEOUT_ERROR);
  }
}
origin: testcontainers/testcontainers-java

@Test
public void testCassandraQueryWaitStrategy() {
  try (
    CassandraContainer cassandraContainer = new CassandraContainer<>()
      .waitingFor(new CassandraQueryWaitStrategy())
  ) {
    cassandraContainer.start();
    ResultSet resultSet = performQuery(cassandraContainer, "SELECT release_version FROM system.local");
    assertTrue("Query was not applied", resultSet.wasApplied());
  }
}
origin: org.testcontainers/testcontainers

  /**
   * Convenience method to return a WaitStrategy for log messages.
   *
   * @param regex the regex pattern to check for
   * @param times the number of times the pattern is expected
   * @return LogMessageWaitStrategy
   */
  public static LogMessageWaitStrategy forLogMessage(String regex, int times) {
    return new LogMessageWaitStrategy().withRegEx(regex).withTimes(times);
  }
}
origin: org.testcontainers/testcontainers

/**
 * Convenience method to return a WaitStrategy for an HTTP endpoint.
 *
 * @param path the path to check
 * @return the WaitStrategy
 * @see HttpWaitStrategy
 */
public static HttpWaitStrategy forHttp(String path) {
  return new HttpWaitStrategy()
      .forPath(path);
}
origin: org.testcontainers/testcontainers

/**
 * Convenience method to return a WaitStrategy for an HTTPS endpoint.
 *
 * @param path the path to check
 * @return the WaitStrategy
 * @see HttpWaitStrategy
 */
public static HttpWaitStrategy forHttps(String path) {
  return forHttp(path)
      .usingTls();
}
origin: org.testcontainers/testcontainers

/**
 * Convenience method to return a WaitStrategy for an exposed or mapped port.
 *
 * @return the WaitStrategy
 * @see HostPortWaitStrategy
 */
public static HostPortWaitStrategy forListeningPort() {
  return new HostPortWaitStrategy();
}
origin: testcontainers/testcontainers-java

@Override
public void waitUntilReady(GenericContainer container) {
  Timeouts.doWithTimeout((int) timeout.toMillis(), TimeUnit.MILLISECONDS, () -> {
    for (WaitStrategy strategy : strategies) {
      strategy.waitUntilReady(container);
    }
  });
}
origin: org.testcontainers/testcontainers

/**
 * Convenience method to return the default WaitStrategy.
 *
 * @return a WaitStrategy
 */
public static WaitStrategy defaultWaitStrategy() {
  return forListeningPort();
}
origin: org.testcontainers/testcontainers

/**
 * Wait until the container has started.
 *
 * @param container the container for which to wait
 */
default void waitUntilReady(GenericContainer container) {
  this.waitUntilReady((WaitStrategyTarget)container);
}
org.testcontainers.containers.wait

Most used classes

  • HttpWaitStrategy
  • Wait
    Convenience class with logic for building common WaitStrategy instances.
  • WaitAllStrategy
  • HostPortWaitStrategy
    Waits until a socket connection can be established on a port exposed or mapped by the container.
  • WaitStrategyTarget
  • WaitStrategy,
  • HttpWaitStrategy,
  • LogMessageWaitStrategy,
  • HostPortWaitStrategy,
  • Wait,
  • WaitAllStrategy,
  • WaitStrategy,
  • ExternalPortListeningCheck,
  • InternalCommandPortListeningCheck,
  • DockerHealthcheckWaitStrategy,
  • CassandraQueryWaitStrategy,
  • AbstractWaitStrategy
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now