Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
96d01d67
Commit
96d01d67
authored
Apr 19, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.3.x'
parents
0ea6fb32
a19eeaf9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
326 additions
and
12 deletions
+326
-12
pom.xml
spring-boot-devtools/pom.xml
+11
-0
DevToolsDataSourceAutoConfiguration.java
...ls/autoconfigure/DevToolsDataSourceAutoConfiguration.java
+36
-12
AbstractDevToolsDataSourceAutoConfigurationTests.java
...ure/AbstractDevToolsDataSourceAutoConfigurationTests.java
+161
-0
DevToolsEmbeddedDataSourceAutoConfigurationTests.java
...ure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java
+55
-0
DevToolsPooledDataSourceAutoConfigurationTests.java
...igure/DevToolsPooledDataSourceAutoConfigurationTests.java
+63
-0
No files found.
spring-boot-devtools/pom.xml
View file @
96d01d67
...
@@ -86,6 +86,12 @@
...
@@ -86,6 +86,12 @@
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<!-- Test -->
<!-- Test -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot
</artifactId>
<type>
test-jar
</type>
<scope>
test
</scope>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-test
</artifactId>
<artifactId>
spring-boot-test
</artifactId>
...
@@ -141,5 +147,10 @@
...
@@ -141,5 +147,10 @@
<artifactId>
thymeleaf-layout-dialect
</artifactId>
<artifactId>
thymeleaf-layout-dialect
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.tomcat
</groupId>
<artifactId>
tomcat-jdbc
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java
View file @
96d01d67
...
@@ -23,18 +23,24 @@ import java.util.Set;
...
@@ -23,18 +23,24 @@ import java.util.Set;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.annotation.AnnotatedBeanDefinition
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.
AllNestedConditions
;
import
org.springframework.boot.autoconfigure.condition.
ConditionOutcome
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.SpringBootCondition
;
import
org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDependsOnPostProcessor
;
import
org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDependsOnPostProcessor
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
;
import
org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration.DevToolsDataSourceCondition
;
import
org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration.DevToolsDataSourceCondition
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ConditionContext
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.ConfigurationCondition
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
org.springframework.jdbc.datasource.embedded.EmbeddedDatabase
;
import
org.springframework.jdbc.datasource.embedded.EmbeddedDatabase
;
import
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean
;
import
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean
;
import
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
;
import
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
;
...
@@ -109,20 +115,38 @@ public class DevToolsDataSourceAutoConfiguration {
...
@@ -109,20 +115,38 @@ public class DevToolsDataSourceAutoConfiguration {
}
}
static
class
DevToolsDataSourceCondition
extends
AllNestedConditions
{
static
class
DevToolsDataSourceCondition
extends
SpringBootCondition
implements
ConfigurationCondition
{
DevToolsDataSourceCondition
()
{
super
(
ConfigurationPhase
.
REGISTER_BEAN
);
}
@ConditionalOnBean
(
DataSource
.
class
)
static
final
class
DataSourceBean
{
@Override
public
ConfigurationPhase
getConfigurationPhase
()
{
return
ConfigurationPhase
.
REGISTER_BEAN
;
}
}
@ConditionalOnBean
(
DataSourceProperties
.
class
)
@Override
static
final
class
DataSourcePropertiesBean
{
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
String
[]
dataSourceBeanNames
=
context
.
getBeanFactory
()
.
getBeanNamesForType
(
DataSource
.
class
);
if
(
dataSourceBeanNames
.
length
!=
1
)
{
return
ConditionOutcome
.
noMatch
(
"A single DataSource bean was not found in the context"
);
}
if
(
context
.
getBeanFactory
()
.
getBeanNamesForType
(
DataSourceProperties
.
class
).
length
!=
1
)
{
return
ConditionOutcome
.
noMatch
(
"A single DataSourceProperties bean was not found in the context"
);
}
BeanDefinition
dataSourceDefinition
=
context
.
getRegistry
()
.
getBeanDefinition
(
dataSourceBeanNames
[
0
]);
if
(
dataSourceDefinition
instanceof
AnnotatedBeanDefinition
&&
((
AnnotatedBeanDefinition
)
dataSourceDefinition
)
.
getFactoryMethodMetadata
().
getDeclaringClassName
()
.
startsWith
(
DataSourceAutoConfiguration
.
class
.
getPackage
()
.
getName
()
+
".DataSourceConfiguration$"
))
{
return
ConditionOutcome
.
match
(
"Found auto-configured DataSource"
);
}
return
ConditionOutcome
.
noMatch
(
"DataSource was not auto-configured"
);
}
}
}
}
...
...
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfigurationTests.java
→
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/
Abstract
DevToolsDataSourceAutoConfigurationTests.java
View file @
96d01d67
...
@@ -19,13 +19,14 @@ package org.springframework.boot.devtools.autoconfigure;
...
@@ -19,13 +19,14 @@ package org.springframework.boot.devtools.autoconfigure;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.Collection
;
import
javax.persistence.EntityManagerFactory
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.mockito.InOrder
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
...
@@ -33,127 +34,72 @@ import org.springframework.context.ConfigurableApplicationContext;
...
@@ -33,127 +34,72 @@ import org.springframework.context.ConfigurableApplicationContext;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.datasource.embedded.EmbeddedDatabase
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
inOrder
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
/**
*
T
ests for {@link DevToolsDataSourceAutoConfiguration}.
*
Base class for t
ests for {@link DevToolsDataSourceAutoConfiguration}.
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
*/
*/
public
class
DevToolsDataSourceAutoConfigurationTests
{
public
class
Abstract
DevToolsDataSourceAutoConfigurationTests
{
@Test
@Test
public
void
embeddedDatabaseIsNotShutDown
()
throws
SQLException
{
public
void
singleManuallyConfiguredDataSourceIsNotClosed
()
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContextWithDriver
(
"org.h2.Driver"
,
ConfigurableApplicationContext
context
=
createContext
(
EmbeddedDatabaseConfiguration
.
class
);
DataSourcePropertiesConfiguration
.
class
,
SingleDataSourceConfiguration
.
class
);
DataSource
dataSource
=
context
.
getBean
(
DataSource
.
class
);
DataSource
dataSource
=
context
.
getBean
(
DataSource
.
class
);
context
.
close
(
);
Statement
statement
=
configureDataSourceBehaviour
(
dataSource
);
verify
(
dataSource
,
times
(
0
)).
getConnection
(
);
verify
(
statement
,
times
(
0
)).
execute
(
"SHUTDOWN"
);
}
}
@Test
@Test
public
void
externalDatabaseIsNotShutDown
()
throws
SQLException
{
public
void
multipleDataSourcesAreIgnored
()
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContextWithDriver
(
ConfigurableApplicationContext
context
=
createContext
(
"org.postgresql.Driver"
,
DataSourceConfiguration
.
class
);
DataSourcePropertiesConfiguration
.
class
,
DataSource
dataSource
=
context
.
getBean
(
DataSource
.
class
);
MultipleDataSourcesConfiguration
.
class
);
context
.
close
();
Collection
<
DataSource
>
dataSources
=
context
.
getBeansOfType
(
DataSource
.
class
)
verify
(
dataSource
,
times
(
0
)).
getConnection
();
.
values
();
}
for
(
DataSource
dataSource
:
dataSources
)
{
Statement
statement
=
configureDataSourceBehaviour
(
dataSource
);
@Test
verify
(
statement
,
times
(
0
)).
execute
(
"SHUTDOWN"
);
public
void
nonEmbeddedInMemoryDatabaseConfiguredWithDriverIsShutDown
()
}
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContextWithDriver
(
"org.h2.Driver"
,
DataSourceConfiguration
.
class
);
DataSource
dataSource
=
context
.
getBean
(
DataSource
.
class
);
Connection
connection
=
mock
(
Connection
.
class
);
given
(
dataSource
.
getConnection
()).
willReturn
(
connection
);
Statement
statement
=
mock
(
Statement
.
class
);
given
(
connection
.
createStatement
()).
willReturn
(
statement
);
context
.
close
();
verify
(
statement
).
execute
(
"SHUTDOWN"
);
}
@Test
public
void
nonEmbeddedInMemoryDatabaseConfiguredWithUrlIsShutDown
()
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContextWithUrl
(
"jdbc:h2:mem:test"
,
DataSourceConfiguration
.
class
);
DataSource
dataSource
=
context
.
getBean
(
DataSource
.
class
);
Connection
connection
=
mock
(
Connection
.
class
);
given
(
dataSource
.
getConnection
()).
willReturn
(
connection
);
Statement
statement
=
mock
(
Statement
.
class
);
given
(
connection
.
createStatement
()).
willReturn
(
statement
);
context
.
close
();
verify
(
statement
).
execute
(
"SHUTDOWN"
);
}
@Test
public
void
configurationBacksOffWithoutDataSourceProperties
()
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContext
(
"org.h2.Driver"
,
NoDataSourcePropertiesConfiguration
.
class
);
assertThat
(
context
.
getBeansOfType
(
DevToolsDataSourceAutoConfiguration
.
class
))
.
isEmpty
();
}
}
@Test
protected
final
Statement
configureDataSourceBehaviour
(
DataSource
dataSource
)
public
void
entityManagerFactoryIsClosedBeforeDatabaseIsShutDown
()
throws
SQLException
{
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContextWithUrl
(
"jdbc:h2:mem:test"
,
DataSourceConfiguration
.
class
,
EntityManagerFactoryConfiguration
.
class
);
DataSource
dataSource
=
context
.
getBean
(
DataSource
.
class
);
Connection
connection
=
mock
(
Connection
.
class
);
Connection
connection
=
mock
(
Connection
.
class
);
given
(
dataSource
.
getConnection
()).
willReturn
(
connection
);
Statement
statement
=
mock
(
Statement
.
class
);
Statement
statement
=
mock
(
Statement
.
class
);
doReturn
(
connection
).
when
(
dataSource
).
getConnection
();
given
(
connection
.
createStatement
()).
willReturn
(
statement
);
given
(
connection
.
createStatement
()).
willReturn
(
statement
);
EntityManagerFactory
entityManagerFactory
=
context
return
statement
;
.
getBean
(
EntityManagerFactory
.
class
);
context
.
close
();
InOrder
inOrder
=
inOrder
(
statement
,
entityManagerFactory
);
inOrder
.
verify
(
statement
).
execute
(
"SHUTDOWN"
);
inOrder
.
verify
(
entityManagerFactory
).
close
();
}
private
ConfigurableApplicationContext
createContextWithDriver
(
String
driver
,
Class
<?>...
classes
)
{
return
createContext
(
"spring.datasource.driver-class-name:"
+
driver
,
classes
);
}
}
private
ConfigurableApplicationContext
createContextWithUrl
(
String
url
,
protected
final
ConfigurableApplicationContext
createContext
(
String
driverClassName
,
Class
<?>...
classes
)
{
return
createContext
(
"spring.datasource.url:"
+
url
,
classes
);
}
private
ConfigurableApplicationContext
createContext
(
String
property
,
Class
<?>...
classes
)
{
Class
<?>...
classes
)
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
context
.
register
(
classes
);
context
.
register
(
classes
);
context
.
register
(
DevToolsDataSourceAutoConfiguration
.
class
);
context
.
register
(
DevToolsDataSourceAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
context
,
property
);
if
(
driverClassName
!=
null
)
{
EnvironmentTestUtils
.
addEnvironment
(
context
,
"spring.datasource.driver-class-name:"
+
driverClassName
);
}
context
.
refresh
();
context
.
refresh
();
return
context
;
return
context
;
}
}
@Configuration
protected
final
ConfigurableApplicationContext
createContext
(
Class
<?>...
classes
)
{
@EnableConfigurationProperties
(
DataSourceProperties
.
class
)
return
this
.
createContext
(
null
,
classes
);
static
class
EmbeddedDatabaseConfiguration
{
@Bean
public
EmbeddedDatabase
embeddedDatabase
()
{
return
mock
(
EmbeddedDatabase
.
class
);
}
}
}
@Configuration
@Configuration
@EnableConfigurationProperties
(
DataSourceProperties
.
class
)
static
class
SingleDataSourceConfiguration
{
static
class
DataSourceConfiguration
{
@Bean
@Bean
public
DataSource
dataSource
()
{
public
DataSource
dataSource
()
{
...
@@ -163,21 +109,51 @@ public class DevToolsDataSourceAutoConfigurationTests {
...
@@ -163,21 +109,51 @@ public class DevToolsDataSourceAutoConfigurationTests {
}
}
@Configuration
@Configuration
static
class
NoDataSourceProperti
esConfiguration
{
static
class
MultipleDataSourc
esConfiguration
{
@Bean
@Bean
public
DataSource
dataSource
()
{
public
DataSource
dataSourceOne
()
{
return
mock
(
DataSource
.
class
);
}
@Bean
public
DataSource
dataSourceTwo
()
{
return
mock
(
DataSource
.
class
);
return
mock
(
DataSource
.
class
);
}
}
}
}
@Configuration
@Configuration
static
class
EntityManagerFactoryConfiguration
{
@EnableConfigurationProperties
(
DataSourceProperties
.
class
)
static
class
DataSourcePropertiesConfiguration
{
}
@Configuration
static
class
DataSourceSpyConfiguration
{
@Bean
@Bean
public
EntityManagerFactory
entityManagerFactory
()
{
public
DataSourceSpyBeanPostProcessor
dataSourceSpyBeanPostProcessor
()
{
return
mock
(
EntityManagerFactory
.
class
);
return
new
DataSourceSpyBeanPostProcessor
();
}
}
private
static
class
DataSourceSpyBeanPostProcessor
implements
BeanPostProcessor
{
@Override
public
Object
postProcessBeforeInitialization
(
Object
bean
,
String
beanName
)
throws
BeansException
{
if
(
bean
instanceof
DataSource
)
{
bean
=
spy
(
bean
);
}
return
bean
;
}
@Override
public
Object
postProcessAfterInitialization
(
Object
bean
,
String
beanName
)
throws
BeansException
{
return
bean
;
}
}
}
}
...
...
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java
0 → 100644
View file @
96d01d67
/*
* Copyright 2012-2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
devtools
.
autoconfigure
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
javax.sql.DataSource
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.testutil.ClassPathExclusions
;
import
org.springframework.boot.testutil.FilteredClassPathRunner
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
* Tests for {@link DevToolsDataSourceAutoConfiguration} with an embedded data source.
*
* @author Andy Wilkinson
*/
@RunWith
(
FilteredClassPathRunner
.
class
)
@ClassPathExclusions
(
"tomcat-jdbc-*.jar"
)
public
class
DevToolsEmbeddedDataSourceAutoConfigurationTests
extends
AbstractDevToolsDataSourceAutoConfigurationTests
{
@Test
public
void
autoConfiguredDataSourceIsNotShutdown
()
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContext
(
DataSourceAutoConfiguration
.
class
,
DataSourceSpyConfiguration
.
class
);
Statement
statement
=
configureDataSourceBehaviour
(
context
.
getBean
(
DataSource
.
class
));
context
.
close
();
verify
(
statement
,
times
(
0
)).
execute
(
"SHUTDOWN"
);
}
}
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java
0 → 100644
View file @
96d01d67
/*
* Copyright 2012-2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
devtools
.
autoconfigure
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
javax.sql.DataSource
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.testutil.FilteredClassPathRunner
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
* Tests for {@link DevToolsDataSourceAutoConfiguration} with a pooled data source.
*
* @author Andy Wilkinson
*/
@RunWith
(
FilteredClassPathRunner
.
class
)
public
class
DevToolsPooledDataSourceAutoConfigurationTests
extends
AbstractDevToolsDataSourceAutoConfigurationTests
{
@Test
public
void
autoConfiguredInMemoryDataSourceIsShutdown
()
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContext
(
DataSourceAutoConfiguration
.
class
,
DataSourceSpyConfiguration
.
class
);
Statement
statement
=
configureDataSourceBehaviour
(
context
.
getBean
(
DataSource
.
class
));
context
.
close
();
verify
(
statement
).
execute
(
"SHUTDOWN"
);
}
@Test
public
void
autoConfiguredExternalDataSourceIsNotShutdown
()
throws
SQLException
{
ConfigurableApplicationContext
context
=
createContext
(
"org.postgresql.Driver"
,
DataSourceAutoConfiguration
.
class
,
DataSourceSpyConfiguration
.
class
);
Statement
statement
=
configureDataSourceBehaviour
(
context
.
getBean
(
DataSource
.
class
));
context
.
close
();
verify
(
statement
,
times
(
0
)).
execute
(
"SHUTDOWN"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment