@@ -48,7 +48,6 @@ class DatabaseStartupValidatorTests {
48
48
@ BeforeEach
49
49
void setUp () throws Exception {
50
50
given (dataSource .getConnection ()).willReturn (connection );
51
- validator .setDataSource (dataSource );
52
51
}
53
52
54
53
@ Test
@@ -60,6 +59,7 @@ void properSetupForDataSource() {
60
59
void shouldUseJdbc4IsValidByDefault () throws Exception {
61
60
given (connection .isValid (1 )).willReturn (true );
62
61
62
+ validator .setDataSource (dataSource );
63
63
validator .afterPropertiesSet ();
64
64
65
65
verify (connection , times (1 )).isValid (1 );
@@ -70,6 +70,7 @@ void shouldUseJdbc4IsValidByDefault() throws Exception {
70
70
void shouldCallValidatonTwiceWhenNotValid () throws Exception {
71
71
given (connection .isValid (1 )).willReturn (false , true );
72
72
73
+ validator .setDataSource (dataSource );
73
74
validator .afterPropertiesSet ();
74
75
75
76
verify (connection , times (2 )).isValid (1 );
@@ -80,6 +81,7 @@ void shouldCallValidatonTwiceWhenNotValid() throws Exception {
80
81
void shouldCallValidatonTwiceInCaseOfException () throws Exception {
81
82
given (connection .isValid (1 )).willThrow (new SQLException ("Test" )).willReturn (true );
82
83
84
+ validator .setDataSource (dataSource );
83
85
validator .afterPropertiesSet ();
84
86
85
87
verify (connection , times (2 )).isValid (1 );
@@ -94,6 +96,7 @@ void useValidationQueryInsteadOfIsValid() throws Exception {
94
96
given (connection .createStatement ()).willReturn (statement );
95
97
given (statement .execute (validationQuery )).willReturn (true );
96
98
99
+ validator .setDataSource (dataSource );
97
100
validator .setValidationQuery (validationQuery );
98
101
validator .afterPropertiesSet ();
99
102
@@ -113,6 +116,7 @@ void shouldExecuteValidatonTwiceOnError() throws Exception {
113
116
.willThrow (new SQLException ("Test" ))
114
117
.willReturn (true );
115
118
119
+ validator .setDataSource (dataSource );
116
120
validator .setValidationQuery (validationQuery );
117
121
validator .afterPropertiesSet ();
118
122
0 commit comments