【问题标题】:Why does my Oracle DataSource have a replay error only when unit testing?为什么我的 Oracle DataSource 只有在单元测试时才会出现重放错误?
【发布时间】:2019-04-22 08:21:43
【问题描述】:

我的 Spring Boot 1.5.17 (Spring 4.3.20) 服务器可以在 bootRun 或部署时正常工作。

但是,我的 Oracle 数据源仅在单元测试时失败

java.lang.AssertionError: 服务器正在发送一个非空的重播上下文 但是我们的 replayModes=[]

针对此错误的 Google 搜索没有确切的结果。

我能够使用不同的 Oracle 数据库进行单元测试。

我在完整的应用程序测试上下文中遇到错误

@RunWith(SpringRunner.class)
@SpringBootTest(
        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
        classes = { TestingUserConfiguration.class, Application.class }
)

以及单个 DataSource 配置和服务

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {
        MyDbConfig.class,
        MyService.class
})

oracle.jdbc.pool.OracleDataSourceoracle.jdbc.replay.OracleConnectionPoolDataSourceImpl 都有错误。 UCP 没有区别。

OracleConnectionPoolDataSourceImpl 有不同的错误:

java.sql.SQLException:不支持的功能

尝试从 OJDBC 12.2 升级到 2018.3,没有区别。

以前有人见过这个错误吗? 关于为什么它只出现在 Spring 单元测试中的任何想法?

【问题讨论】:

标签: oracle spring-boot jdbc


【解决方案1】:

经过一番摸索,我发现在测试套件中这样做:

static {
 ClassLoader.getSystemClassLoader().setPackageAssertionStatus("oracle.jdbc.driver", false);  
}

解决了我的问题,我确定这是 oracle.jdbc.driver.T4CTTIfun 类中的错误

【讨论】:

    【解决方案2】:

    您可以将“-da:oracle...”添加到您的 JAVA_TOOL_OPTIONS 以关闭 oracle 断言。为了解决这个问题。

    特伦特

    【讨论】:

    • 谢谢!它解决了我过去两天毒害我生活的问题:)
    猜你喜欢
    • 2022-01-19
    • 2020-08-17
    • 2020-09-10
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 2021-05-21
    相关资源
    最近更新 更多