|
|
|
@ -16,6 +16,8 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.jdbc;
|
|
|
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
|
|
|
|
|
import com.zaxxer.hikari.HikariDataSource;
|
|
|
|
@ -27,6 +29,9 @@ import org.springframework.jdbc.datasource.DelegatingDataSource;
|
|
|
|
|
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tests for {@link DataSourceUnwrapper}.
|
|
|
|
@ -91,6 +96,17 @@ public class DataSourceUnwrapperTests {
|
|
|
|
|
.isSameAs(dataSource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void unwrappingIsNotAttemptedWhenDataSourceIsNotWrapperForTarget()
|
|
|
|
|
throws SQLException {
|
|
|
|
|
DataSource dataSource = mock(DataSource.class);
|
|
|
|
|
DataSource actual = DataSourceUnwrapper.unwrap(dataSource,
|
|
|
|
|
HikariDataSource.class);
|
|
|
|
|
assertThat(actual).isNull();
|
|
|
|
|
verify(dataSource).isWrapperFor(HikariDataSource.class);
|
|
|
|
|
verifyNoMoreInteractions(dataSource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DataSource wrapInProxy(DataSource dataSource) {
|
|
|
|
|
return (DataSource) new ProxyFactory(dataSource).getProxy();
|
|
|
|
|
}
|
|
|
|
|