File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2 Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change 26
26
27
27
import org .junit .jupiter .api .Test ;
28
28
import org .junit .jupiter .api .extension .ExtendWith ;
29
- import org .mockito .invocation .InvocationOnMock ;
30
- import org .mockito .stubbing .Answer ;
31
29
32
30
import org .springframework .beans .factory .BeanCreationException ;
33
31
import org .springframework .boot .autoconfigure .AutoConfigurations ;
@@ -184,18 +182,13 @@ DataSource someDataSource() throws SQLException {
184
182
185
183
private DataSource mockDataSource (String url ) throws SQLException {
186
184
DataSource dataSource = mock (DataSource .class );
187
- given (dataSource .getConnection ()).will (new Answer <Connection >() {
188
-
189
- @ Override
190
- public Connection answer (InvocationOnMock invocation ) throws Throwable {
191
- assertThat (Thread .currentThread ().getContextClassLoader ()).isEqualTo (getClass ().getClassLoader ());
192
- Connection connection = mock (Connection .class );
193
- DatabaseMetaData metadata = mock (DatabaseMetaData .class );
194
- given (connection .getMetaData ()).willReturn (metadata );
195
- given (metadata .getURL ()).willReturn (url );
196
- return connection ;
197
- }
198
-
185
+ given (dataSource .getConnection ()).will ((invocation ) -> {
186
+ assertThat (Thread .currentThread ().getContextClassLoader ()).isEqualTo (getClass ().getClassLoader ());
187
+ Connection connection = mock (Connection .class );
188
+ DatabaseMetaData metadata = mock (DatabaseMetaData .class );
189
+ given (connection .getMetaData ()).willReturn (metadata );
190
+ given (metadata .getURL ()).willReturn (url );
191
+ return connection ;
199
192
});
200
193
201
194
return dataSource ;
You can’t perform that action at this time.
0 commit comments