From 6aa522b3c1d74f1ce3c07f030b576ad0be07f581 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 25 Sep 2020 14:25:16 +0200 Subject: [PATCH] Apply LONG_RUNNING test group properly See gh-24830 --- .../DataSourceTransactionManagerTests.java | 16 +++++----------- .../support/JdbcTransactionManagerTests.java | 16 +++++----------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java index 050bb5f0ef8..b4c12bf32ce 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java @@ -28,6 +28,8 @@ import javax.sql.DataSource; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.InOrder; import org.springframework.core.testfixture.EnabledForTestGroups; @@ -963,18 +965,10 @@ public class DataSourceTransactionManagerTests { ordered.verify(con).close(); } - @Test - public void testTransactionWithLongTimeout() throws Exception { - doTestTransactionWithTimeout(10); - } - - @Test - public void testTransactionWithShortTimeout() throws Exception { - doTestTransactionWithTimeout(1); - } - + @ParameterizedTest(name = "transaction with {0} second timeout") + @ValueSource(ints = {1, 10}) @EnabledForTestGroups(LONG_RUNNING) - private void doTestTransactionWithTimeout(int timeout) throws Exception { + public void transactionWithTimeout(int timeout) throws Exception { PreparedStatement ps = mock(PreparedStatement.class); given(con.getAutoCommit()).willReturn(true); given(con.prepareStatement("some SQL statement")).willReturn(ps); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/JdbcTransactionManagerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/JdbcTransactionManagerTests.java index 8da9d158bce..7890fc7ec98 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/JdbcTransactionManagerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/JdbcTransactionManagerTests.java @@ -28,6 +28,8 @@ import javax.sql.DataSource; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.InOrder; import org.springframework.core.testfixture.EnabledForTestGroups; @@ -969,18 +971,10 @@ public class JdbcTransactionManagerTests { ordered.verify(con).close(); } - @Test - public void testTransactionWithLongTimeout() throws Exception { - doTestTransactionWithTimeout(10); - } - - @Test - public void testTransactionWithShortTimeout() throws Exception { - doTestTransactionWithTimeout(1); - } - + @ParameterizedTest(name = "transaction with {0} second timeout") + @ValueSource(ints = {1, 10}) @EnabledForTestGroups(LONG_RUNNING) - private void doTestTransactionWithTimeout(int timeout) throws Exception { + public void transactionWithTimeout(int timeout) throws Exception { PreparedStatement ps = mock(PreparedStatement.class); given(con.getAutoCommit()).willReturn(true); given(con.prepareStatement("some SQL statement")).willReturn(ps);