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
4b138917
Commit
4b138917
authored
Oct 02, 2015
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to fix test failures caused by ordering issues
parent
e1070cce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
DataSourceHealthIndicatorTests.java
...k/boot/actuate/health/DataSourceHealthIndicatorTests.java
+13
-5
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DataSourceHealthIndicatorTests.java
View file @
4b138917
...
...
@@ -20,12 +20,12 @@ import java.sql.Connection;
import
javax.sql.DataSource
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.health.DataSourceHealthIndicator.Product
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.datasource.DriverManagerDataSource
;
import
org.springframework.jdbc.datasource.SingleConnectionDataSource
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
...
...
@@ -48,15 +48,23 @@ public class DataSourceHealthIndicatorTests {
private
final
DataSourceHealthIndicator
indicator
=
new
DataSourceHealthIndicator
();
private
DriverManager
DataSource
dataSource
;
private
SingleConnection
DataSource
dataSource
;
@Before
public
void
init
()
{
EmbeddedDatabaseConnection
db
=
EmbeddedDatabaseConnection
.
HSQL
;
this
.
dataSource
=
new
SingleConnectionDataSource
(
db
.
getUrl
(),
"sa"
,
""
,
false
);
this
.
dataSource
=
new
SingleConnectionDataSource
(
db
.
getUrl
()
+
";shutdown=true"
,
"sa"
,
""
,
false
);
this
.
dataSource
.
setDriverClassName
(
db
.
getDriverClassName
());
}
@After
public
void
close
()
{
if
(
this
.
dataSource
!=
null
)
{
this
.
dataSource
.
destroy
();
}
}
@Test
public
void
database
()
{
this
.
indicator
.
setDataSource
(
this
.
dataSource
);
...
...
@@ -91,8 +99,8 @@ public class DataSourceHealthIndicatorTests {
public
void
connectionClosed
()
throws
Exception
{
DataSource
dataSource
=
mock
(
DataSource
.
class
);
Connection
connection
=
mock
(
Connection
.
class
);
given
(
connection
.
getMetaData
())
.
willReturn
(
this
.
dataSource
.
getConnection
().
getMetaData
());
given
(
connection
.
getMetaData
())
.
willReturn
(
this
.
dataSource
.
getConnection
().
getMetaData
());
given
(
dataSource
.
getConnection
()).
willReturn
(
connection
);
this
.
indicator
.
setDataSource
(
dataSource
);
Health
health
=
this
.
indicator
.
health
();
...
...
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