Merge branch '1.4.x' into 1.5.x
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,8 +95,17 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
return statement;
|
||||
}
|
||||
|
||||
protected final ConfigurableApplicationContext createContext(Class<?>... classes) {
|
||||
return this.createContext(null, classes);
|
||||
}
|
||||
|
||||
protected final ConfigurableApplicationContext createContext(String driverClassName,
|
||||
Class<?>... classes) {
|
||||
return this.createContext(driverClassName, null, classes);
|
||||
}
|
||||
|
||||
protected final ConfigurableApplicationContext createContext(String driverClassName,
|
||||
String url, Class<?>... classes) {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(classes);
|
||||
context.register(DevToolsDataSourceAutoConfiguration.class);
|
||||
@@ -104,14 +113,13 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(context,
|
||||
"spring.datasource.driver-class-name:" + driverClassName);
|
||||
}
|
||||
if (url != null) {
|
||||
EnvironmentTestUtils.addEnvironment(context, "spring.datasource.url:" + url);
|
||||
}
|
||||
context.refresh();
|
||||
return context;
|
||||
}
|
||||
|
||||
protected final ConfigurableApplicationContext createContext(Class<?>... classes) {
|
||||
return this.createContext(null, classes);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class SingleDataSourceConfiguration {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,4 +57,70 @@ public class DevToolsPooledDataSourceAutoConfigurationTests
|
||||
verify(statement, times(0)).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void h2ServerIsNotShutdown() throws SQLException {
|
||||
ConfigurableApplicationContext context = createContext("org.h2.Driver",
|
||||
"jdbc:h2:hsql://localhost", DataSourceAutoConfiguration.class,
|
||||
DataSourceSpyConfiguration.class);
|
||||
Statement statement = configureDataSourceBehaviour(
|
||||
context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, times(0)).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void inMemoryh2IsShutdown() throws SQLException {
|
||||
ConfigurableApplicationContext context = createContext("org.h2.Driver",
|
||||
"jdbc:h2:mem:test", DataSourceAutoConfiguration.class,
|
||||
DataSourceSpyConfiguration.class);
|
||||
Statement statement = configureDataSourceBehaviour(
|
||||
context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, times(1)).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hsqlServerIsNotShutdown() throws SQLException {
|
||||
ConfigurableApplicationContext context = createContext("org.hsqldb.jdbcDriver",
|
||||
"jdbc:hsqldb:hsql://localhost", DataSourceAutoConfiguration.class,
|
||||
DataSourceSpyConfiguration.class);
|
||||
Statement statement = configureDataSourceBehaviour(
|
||||
context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, times(0)).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void inMemoryHsqlIsShutdown() throws SQLException {
|
||||
ConfigurableApplicationContext context = createContext("org.hsqldb.jdbcDriver",
|
||||
"jdbc:hsqldb:mem:test", DataSourceAutoConfiguration.class,
|
||||
DataSourceSpyConfiguration.class);
|
||||
Statement statement = configureDataSourceBehaviour(
|
||||
context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, times(1)).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void derbyClientIsNotShutdown() throws SQLException {
|
||||
ConfigurableApplicationContext context = createContext(
|
||||
"org.apache.derby.jdbc.ClientDriver", "jdbc:derby://localhost",
|
||||
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class);
|
||||
Statement statement = configureDataSourceBehaviour(
|
||||
context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, times(0)).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void inMemoryDerbyIsShutdown() throws SQLException {
|
||||
ConfigurableApplicationContext context = createContext(
|
||||
"org.apache.derby.jdbc.EmbeddedDriver", "jdbc:derby:memory:test",
|
||||
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class);
|
||||
Statement statement = configureDataSourceBehaviour(
|
||||
context.getBean(DataSource.class));
|
||||
context.close();
|
||||
verify(statement, times(1)).execute("SHUTDOWN");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user