本文整理了Java中org.testcontainers.containers.wait.strategy.Wait.forListeningPort()
方法的一些代码示例,展示了Wait.forListeningPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wait.forListeningPort()
方法的具体详情如下:
包路径:org.testcontainers.containers.wait.strategy.Wait
类名称:Wait
方法名:forListeningPort
[英]Convenience method to return a WaitStrategy for an exposed or mapped port.
[中]为公开或映射的端口返回WaitStrategy的便捷方法。
代码示例来源:origin: testcontainers/testcontainers-java
/**
* Convenience method to return the default WaitStrategy.
*
* @return a WaitStrategy
*/
public static WaitStrategy defaultWaitStrategy() {
return forListeningPort();
}
代码示例来源:origin: testcontainers/testcontainers-java
public InfluxDBContainer(final String version) {
super(IMAGE_NAME + ":" + version);
waitStrategy = new WaitAllStrategy()
.withStrategy(Wait.forHttp("/ping").withBasicCredentials(username, password).forStatusCode(204))
.withStrategy(Wait.forListeningPort());
}
代码示例来源:origin: testcontainers/testcontainers-java
@Test
public void testWaitOnListeningPort() {
final DockerComposeContainer environment = new DockerComposeContainer(new File("src/test/resources/compose-test.yml"))
.withExposedService("redis_1", REDIS_PORT, Wait.forListeningPort());
try {
environment.starting(Description.createTestDescription(Object.class, "name"));
VisibleAssertions.pass("Docker compose should start after waiting for listening port");
} catch (RuntimeException e) {
VisibleAssertions.fail("Docker compose should start after waiting for listening port with failed with: " + e);
}
}
代码示例来源:origin: testcontainers/testcontainers-java
@Test
public void testWaitOnOneOfMultipleStrategiesFailing() {
final DockerComposeContainer environment = new DockerComposeContainer(new File("src/test/resources/compose-test.yml"))
.withExposedService("redis_1", REDIS_PORT, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(10)))
.waitingFor("db_1", Wait.forLogMessage(".*test test test.*\\s", 1).withStartupTimeout(Duration.ofSeconds(10)))
.withTailChildContainers(true);
VisibleAssertions.assertThrows("waiting on one failing strategy to time out",
RuntimeException.class,
() -> environment.starting(Description.createTestDescription(Object.class, "name")));
}
代码示例来源:origin: testcontainers/testcontainers-java
@Test
public void testWaitOnMultipleStrategiesPassing() {
final DockerComposeContainer environment = new DockerComposeContainer(new File("src/test/resources/compose-test.yml"))
.withExposedService("redis_1", REDIS_PORT, Wait.forListeningPort())
.withExposedService("db_1", 3306, Wait.forLogMessage(".*ready for connections.*\\s", 1))
.withTailChildContainers(true);
try {
environment.starting(Description.createTestDescription(Object.class, "name"));
VisibleAssertions.pass("Docker compose should start after waiting for listening port");
} catch (RuntimeException e) {
VisibleAssertions.fail("Docker compose should start after waiting for listening port with failed with: " + e);
}
}
代码示例来源:origin: org.testcontainers/testcontainers
/**
* Convenience method to return the default WaitStrategy.
*
* @return a WaitStrategy
*/
public static WaitStrategy defaultWaitStrategy() {
return forListeningPort();
}
代码示例来源:origin: org.testcontainers/influxdb
public InfluxDBContainer(final String version) {
super(IMAGE_NAME + ":" + version);
waitStrategy = new WaitAllStrategy()
.withStrategy(Wait.forHttp("/ping").withBasicCredentials(username, password).forStatusCode(204))
.withStrategy(Wait.forListeningPort());
}
内容来源于网络,如有侵权,请联系作者删除!