diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests-context.xml index 4c32595f3da..aaaaf6f2548 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests-context.xml @@ -19,14 +19,13 @@ - - - - - - - - + + + + + + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests.java index 591de33fde7..1431b8bffca 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests.java @@ -28,7 +28,6 @@ import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -55,8 +54,7 @@ */ @SpringJUnitConfig @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) -@Disabled -public class MySqlJdbcMessageStoreMultipleChannelTests { +public class MySqlJdbcMessageStoreMultipleChannelTests implements MySqlContainerTest { private static final Log LOG = LogFactory.getLog(MySqlJdbcMessageStoreMultipleChannelTests.class); diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreTests.java index 1227f106687..e1072c06a35 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -545,8 +545,7 @@ PlatformTransactionManager transactionManager() { DataSourceInitializer dataSourceInitializer() { DataSourceInitializer dataSourceInitializer = new DataSourceInitializer(); dataSourceInitializer.setDataSource(dataSource()); - dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(this.createSchemaScript)); - dataSourceInitializer.setDatabaseCleaner(new ResourceDatabasePopulator(this.dropSchemaScript)); + dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(this.dropSchemaScript, this.createSchemaScript)); return dataSourceInitializer; } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlMetadataStoreTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlMetadataStoreTests.java index 978a4dbe1c5..4de7ad80a91 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlMetadataStoreTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlMetadataStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 the original author or authors. + * Copyright 2024-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,6 +75,9 @@ static class TestConfiguration { @Value("org/springframework/integration/jdbc/schema-mysql.sql") Resource createSchemaScript; + @Value("org/springframework/integration/jdbc/schema-drop-mysql.sql") + Resource dropSchemaScript; + @Bean DataSource dataSource() { return MySqlContainerTest.dataSource(); @@ -84,7 +87,7 @@ DataSource dataSource() { DataSourceInitializer dataSourceInitializer(DataSource dataSource) { DataSourceInitializer dataSourceInitializer = new DataSourceInitializer(); dataSourceInitializer.setDataSource(dataSource); - dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(this.createSchemaScript)); + dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(this.dropSchemaScript, this.createSchemaScript)); return dataSourceInitializer; } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/postgres/PostgresContainerTest.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/postgres/PostgresContainerTest.java index 71ef40d625c..1cc7747258d 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/postgres/PostgresContainerTest.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/postgres/PostgresContainerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2024 the original author or authors. + * Copyright 2022-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,9 @@ package org.springframework.integration.jdbc.postgres; +import javax.sql.DataSource; + +import org.apache.commons.dbcp2.BasicDataSource; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.junit.jupiter.Testcontainers; @@ -60,4 +63,13 @@ static String getPassword() { return POSTGRES_CONTAINER.getPassword(); } + static DataSource dataSource() { + BasicDataSource dataSource = new BasicDataSource(); + dataSource.setDriverClassName(POSTGRES_CONTAINER.getDriverClassName()); + dataSource.setUrl(POSTGRES_CONTAINER.getJdbcUrl()); + dataSource.setUsername(POSTGRES_CONTAINER.getUsername()); + dataSource.setPassword(POSTGRES_CONTAINER.getPassword()); + return dataSource; + } + } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/AbstractTxTimeoutMessageStoreTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/AbstractTxTimeoutMessageStoreTests.java index bf02c07386e..dda81ff7b3d 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/AbstractTxTimeoutMessageStoreTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/AbstractTxTimeoutMessageStoreTests.java @@ -63,7 +63,7 @@ @DirtiesContext // close at the end after class public abstract class AbstractTxTimeoutMessageStoreTests { - private static final Log log = LogFactory.getLog(AbstractTxTimeoutMessageStoreTests.class); + protected final Log log = LogFactory.getLog(this.getClass()); @Autowired protected DataSource dataSource; diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-oracle-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-oracle-context.xml index 950bc90dcc6..103b400e6f2 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-oracle-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-oracle-context.xml @@ -1,25 +1,13 @@ - - - - - - - - 3 - 20 - - - + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-postgres-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-postgres-context.xml index a81c22f67f6..a662f58b09b 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-postgres-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-postgres-context.xml @@ -2,21 +2,18 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/jdbc https://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> - - - - - - - + + + + + + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/HsqlTxTimeoutMessageStoreTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/HsqlTxTimeoutMessageStoreTests-context.xml index 88ae5b462ac..89b15f765ec 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/HsqlTxTimeoutMessageStoreTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/HsqlTxTimeoutMessageStoreTests-context.xml @@ -1,7 +1,14 @@ + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"> + + + 2000 + 1000 + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/HsqlTxTimeoutMessageStoreTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/HsqlTxTimeoutMessageStoreTests.java index e5760500c1e..f69177e8774 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/HsqlTxTimeoutMessageStoreTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/HsqlTxTimeoutMessageStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,7 @@ package org.springframework.integration.jdbc.store.channel; -import org.junit.Rule; - -import org.springframework.integration.test.support.LongRunningIntegrationTest; +import org.springframework.integration.test.condition.LongRunningTest; import org.springframework.test.context.ContextConfiguration; /** @@ -27,10 +25,8 @@ * @author Artem Bilan * */ +@LongRunningTest @ContextConfiguration public class HsqlTxTimeoutMessageStoreTests extends AbstractTxTimeoutMessageStoreTests { - @Rule - public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest(); - } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/MySqlTxTimeoutMessageStoreTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/MySqlTxTimeoutMessageStoreTests-context.xml index 579df76403a..d403a5c1085 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/MySqlTxTimeoutMessageStoreTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/MySqlTxTimeoutMessageStoreTests-context.xml @@ -1,11 +1,18 @@ + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"> + + 2000 + 1000 + + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/MySqlTxTimeoutMessageStoreTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/MySqlTxTimeoutMessageStoreTests.java index 69d1f963f54..b5e1593d85a 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/MySqlTxTimeoutMessageStoreTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/MySqlTxTimeoutMessageStoreTests.java @@ -16,8 +16,7 @@ package org.springframework.integration.jdbc.store.channel; -import org.junit.jupiter.api.Disabled; - +import org.springframework.integration.jdbc.mysql.MySqlContainerTest; import org.springframework.test.context.ContextConfiguration; /** @@ -26,8 +25,7 @@ * @author Artem Bilan * */ -@Disabled @ContextConfiguration -public class MySqlTxTimeoutMessageStoreTests extends AbstractTxTimeoutMessageStoreTests { +public class MySqlTxTimeoutMessageStoreTests extends AbstractTxTimeoutMessageStoreTests implements MySqlContainerTest { } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/OracleTxTimeoutMessageStoreTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/OracleTxTimeoutMessageStoreTests-context.xml index ddbc626eb1e..b4dcc1cacc1 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/OracleTxTimeoutMessageStoreTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/OracleTxTimeoutMessageStoreTests-context.xml @@ -1,11 +1,18 @@ + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"> + + 2000 + 1000 + + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/OracleTxTimeoutMessageStoreTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/OracleTxTimeoutMessageStoreTests.java index 4769e977dc2..e49f92a9b48 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/OracleTxTimeoutMessageStoreTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/OracleTxTimeoutMessageStoreTests.java @@ -16,9 +16,12 @@ package org.springframework.integration.jdbc.store.channel; -import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.AfterEach; +import org.springframework.integration.jdbc.oracle.OracleContainerTest; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.support.TransactionTemplate; /** * @@ -26,8 +29,18 @@ * @author Artem Bilan * */ -@Disabled @ContextConfiguration -public class OracleTxTimeoutMessageStoreTests extends AbstractTxTimeoutMessageStoreTests { +public class OracleTxTimeoutMessageStoreTests extends AbstractTxTimeoutMessageStoreTests implements OracleContainerTest { + + @AfterEach + public void cleanTable() { + final JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource); + new TransactionTemplate(this.transactionManager).execute(status -> { + final int deletedChannelMessageRows = jdbcTemplate.update("delete from INT_CHANNEL_MESSAGE"); + log.info(String.format("Cleaning Database - Deleted Channel Messages: %s ", + deletedChannelMessageRows)); + return null; + }); + } } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/PostgresTxTimeoutMessageStoreTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/PostgresTxTimeoutMessageStoreTests.java index 64930158980..7d6bba37e0f 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/PostgresTxTimeoutMessageStoreTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/PostgresTxTimeoutMessageStoreTests.java @@ -16,8 +16,7 @@ package org.springframework.integration.jdbc.store.channel; -import org.junit.jupiter.api.Disabled; - +import org.springframework.integration.jdbc.postgres.PostgresContainerTest; import org.springframework.test.context.ContextConfiguration; /** @@ -26,8 +25,7 @@ * @author Artem Bilan * */ -@Disabled @ContextConfiguration -public class PostgresTxTimeoutMessageStoreTests extends AbstractTxTimeoutMessageStoreTests { +public class PostgresTxTimeoutMessageStoreTests extends AbstractTxTimeoutMessageStoreTests implements PostgresContainerTest { } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/TxTimeoutMessageStoreTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/TxTimeoutMessageStoreTests-context.xml index 8be2407e0e1..1c2eb9b716b 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/TxTimeoutMessageStoreTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/TxTimeoutMessageStoreTests-context.xml @@ -3,9 +3,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task" xmlns:int="http://www.springframework.org/schema/integration" + xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/task https://www.springframework.org/schema/task/spring-task.xsd - http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> + http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"> + + + 200 + 100 + @@ -69,7 +76,7 @@ - + @@ -79,7 +86,7 @@ - +