Skip to content

Commit 0e83aaa

Browse files
committed
Fix hanging test
Partially reverts 1edc08f
1 parent 1edc08f commit 0e83aaa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-jdbc/src/test/java/org/springframework/jdbc/support/DatabaseStartupValidatorTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class DatabaseStartupValidatorTests {
4848
@BeforeEach
4949
void setUp() throws Exception {
5050
given(dataSource.getConnection()).willReturn(connection);
51-
validator.setDataSource(dataSource);
5251
}
5352

5453
@Test
@@ -60,6 +59,7 @@ void properSetupForDataSource() {
6059
void shouldUseJdbc4IsValidByDefault() throws Exception {
6160
given(connection.isValid(1)).willReturn(true);
6261

62+
validator.setDataSource(dataSource);
6363
validator.afterPropertiesSet();
6464

6565
verify(connection, times(1)).isValid(1);
@@ -70,6 +70,7 @@ void shouldUseJdbc4IsValidByDefault() throws Exception {
7070
void shouldCallValidatonTwiceWhenNotValid() throws Exception {
7171
given(connection.isValid(1)).willReturn(false, true);
7272

73+
validator.setDataSource(dataSource);
7374
validator.afterPropertiesSet();
7475

7576
verify(connection, times(2)).isValid(1);
@@ -80,6 +81,7 @@ void shouldCallValidatonTwiceWhenNotValid() throws Exception {
8081
void shouldCallValidatonTwiceInCaseOfException() throws Exception {
8182
given(connection.isValid(1)).willThrow(new SQLException("Test")).willReturn(true);
8283

84+
validator.setDataSource(dataSource);
8385
validator.afterPropertiesSet();
8486

8587
verify(connection, times(2)).isValid(1);
@@ -94,6 +96,7 @@ void useValidationQueryInsteadOfIsValid() throws Exception {
9496
given(connection.createStatement()).willReturn(statement);
9597
given(statement.execute(validationQuery)).willReturn(true);
9698

99+
validator.setDataSource(dataSource);
97100
validator.setValidationQuery(validationQuery);
98101
validator.afterPropertiesSet();
99102

@@ -113,6 +116,7 @@ void shouldExecuteValidatonTwiceOnError() throws Exception {
113116
.willThrow(new SQLException("Test"))
114117
.willReturn(true);
115118

119+
validator.setDataSource(dataSource);
116120
validator.setValidationQuery(validationQuery);
117121
validator.afterPropertiesSet();
118122

0 commit comments

Comments
 (0)