parent
701bb6ee0a
commit
03667c7ddc
|
@ -51,11 +51,11 @@ public class CommonsDataSourceConfiguration extends AbstractDataSourceConfigurat
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
logger.info("Hint: using Commons DBCP BasicDataSource. It's going to work, "
|
logger.info("Hint: using Commons DBCP BasicDataSource. It's going to work, "
|
||||||
+ "but the Tomcat DataSource is more reliable.");
|
+ "but the Tomcat DataSource is more reliable.");
|
||||||
this.pool = createAndSetupPool();
|
this.pool = createAndConfigurePool();
|
||||||
return this.pool;
|
return this.pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BasicDataSource createAndSetupPool() {
|
private BasicDataSource createAndConfigurePool() {
|
||||||
BasicDataSource pool = new BasicDataSource();
|
BasicDataSource pool = new BasicDataSource();
|
||||||
pool.setDriverClassName(getDriverClassName());
|
pool.setDriverClassName(getDriverClassName());
|
||||||
pool.setUrl(getUrl());
|
pool.setUrl(getUrl());
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
|
||||||
List<ApplicationContextInitializer<?>> initializers = getInitializers(
|
List<ApplicationContextInitializer<?>> initializers = getInitializers(
|
||||||
mergedConfig, application);
|
mergedConfig, application);
|
||||||
if (mergedConfig instanceof WebMergedContextConfiguration) {
|
if (mergedConfig instanceof WebMergedContextConfiguration) {
|
||||||
new WebConfigurer().setup(mergedConfig, application, initializers);
|
new WebConfigurer().configure(mergedConfig, application, initializers);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
application.setWebEnvironment(false);
|
application.setWebEnvironment(false);
|
||||||
|
@ -168,20 +168,22 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class WebConfigurer {
|
private static class WebConfigurer {
|
||||||
void setup(MergedContextConfiguration mergedConfig,
|
|
||||||
|
void configure(MergedContextConfiguration configuration,
|
||||||
SpringApplication application,
|
SpringApplication application,
|
||||||
List<ApplicationContextInitializer<?>> initializers) {
|
List<ApplicationContextInitializer<?>> initializers) {
|
||||||
WebMergedContextConfiguration webConfig = (WebMergedContextConfiguration) mergedConfig;
|
WebMergedContextConfiguration webConfiguration = (WebMergedContextConfiguration) configuration;
|
||||||
if (AnnotationUtils.findAnnotation(webConfig.getTestClass(),
|
if (AnnotationUtils.findAnnotation(webConfiguration.getTestClass(),
|
||||||
IntegrationTest.class) == null) {
|
IntegrationTest.class) == null) {
|
||||||
MockServletContext servletContext = new MockServletContext(
|
MockServletContext servletContext = new MockServletContext(
|
||||||
webConfig.getResourceBasePath());
|
webConfiguration.getResourceBasePath());
|
||||||
initializers.add(0, new ServletContextApplicationContextInitializer(
|
initializers.add(0, new ServletContextApplicationContextInitializer(
|
||||||
servletContext));
|
servletContext));
|
||||||
application
|
application
|
||||||
.setApplicationContextClass(GenericWebApplicationContext.class);
|
.setApplicationContextClass(GenericWebApplicationContext.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue