gpt4 book ai didi

java - TestContainers Oracle 超时异常

转载 作者:行者123 更新时间:2023-12-02 12:02:55 31 4
gpt4 key购买 nike

我尝试使用 testcontainers用于与 Oracle 集成测试的库。这是简单的测试:

public class SimpleTest {

@Rule
public OracleContainer oracle = new OracleContainer();

@Test
public void simpleTest() throws SQLException {
HikariDataSource ds = buildHikariDataSource();
Statement statement = ds.getConnection().createStatement();
statement.execute("SELECT 1 FROM dual");
ResultSet resultSet = statement.getResultSet();

resultSet.next();
int resultSetInt = resultSet.getInt(1);
assertEquals("A basic SELECT query succeeds", 1, resultSetInt);
}

private HikariDataSource buildHikariDataSource() {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(oracle.getJdbcUrl());
hikariConfig.setUsername(oracle.getUsername());
hikariConfig.setPassword(oracle.getPassword());
return new HikariDataSource(hikariConfig);
}
}

But it fails with TimeoutException:

Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:256)
at org.testcontainers.containers.GenericContainer.lambda$start$0(GenericContainer.java:184)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
... 18 more
Caused by: org.rnorth.ducttape.TimeoutException: org.rnorth.ducttape.TimeoutException: java.util.concurrent.TimeoutException
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:53)
at org.testcontainers.containers.JdbcDatabaseContainer.waitUntilContainerStarted(JdbcDatabaseContainer.java:81)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:235)
... 20 more

我的 Docker 安装适用于 testcontainers-oracle-xe,操作系统是 macOS Sierra 10.12.6。

如何解决这个问题?

附注Full console output

最佳答案

总而言之,我创建了一个 issue在 testcontainers-java-module-oracle-xe 存储库中。

解决方案是在系统偏好设置中将位置更改为美国,将语言更改为英语。

testcontainers工程师的回答:

My colleague have faced the same problem. We have debugged and understood that problem with oracle TNS (ORA-12514). In order to resolve it, there is a need to change language to English and location to US.

关于java - TestContainers Oracle 超时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47115371/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com