DATAJDBC-573 - Polishing.
Remove unused imports, reformat code. Tweak logging. Original pull request: #237.
This commit is contained in:
@@ -15,26 +15,26 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.testing;
|
||||
|
||||
import static org.awaitility.pollinterval.FibonacciPollInterval.*;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.awaitility.Awaitility;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.awaitility.pollinterval.FibonacciPollInterval.*;
|
||||
|
||||
/**
|
||||
* Basic configuration expecting subclasses to provide a {@link DataSource} via {@link #createDataSource()} to be
|
||||
* exposed to the {@link ApplicationContext}.
|
||||
@@ -47,7 +47,6 @@ abstract class DataSourceConfiguration {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DataSourceConfiguration.class);
|
||||
|
||||
|
||||
@Autowired Class<?> testClass;
|
||||
@Autowired Environment environment;
|
||||
|
||||
@@ -99,12 +98,15 @@ abstract class DataSourceConfiguration {
|
||||
.ignoreExceptions() //
|
||||
.until(() -> {
|
||||
|
||||
LOG.debug("connectivity verifying ...");
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Verifying connectivity to %s...", dataSource));
|
||||
}
|
||||
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
LOG.info("connectivity verified");
|
||||
LOG.info("Connectivity verified");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.testing;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.awaitility.Awaitility;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
@@ -32,8 +27,6 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
|
||||
import org.testcontainers.containers.Db2Container;
|
||||
|
||||
import static org.awaitility.pollinterval.FibonacciPollInterval.*;
|
||||
|
||||
/**
|
||||
* {@link DataSource} setup for DB2.
|
||||
*
|
||||
@@ -65,10 +58,8 @@ class Db2DataSourceConfiguration extends DataSourceConfiguration {
|
||||
DB_2_CONTAINER = container;
|
||||
}
|
||||
|
||||
DriverManagerDataSource dataSource = new DriverManagerDataSource(DB_2_CONTAINER.getJdbcUrl(),
|
||||
return new DriverManagerDataSource(DB_2_CONTAINER.getJdbcUrl(),
|
||||
DB_2_CONTAINER.getUsername(), DB_2_CONTAINER.getPassword());
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -62,10 +62,7 @@ public class OracleDataSourceConfiguration extends DataSourceConfiguration {
|
||||
|
||||
String jdbcUrl = ORACLE_CONTAINER.getJdbcUrl().replace(":xe", "/XEPDB1");
|
||||
|
||||
DataSource dataSource = new DriverManagerDataSource(jdbcUrl, ORACLE_CONTAINER.getUsername(),
|
||||
ORACLE_CONTAINER.getPassword());
|
||||
|
||||
return dataSource;
|
||||
return new DriverManagerDataSource(jdbcUrl, ORACLE_CONTAINER.getUsername(), ORACLE_CONTAINER.getPassword());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user