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
c0f158df
Commit
c0f158df
authored
Oct 02, 2020
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Do not fail if h2Console bean cannot connect to db"
See gh-23566
parent
2d76de29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
H2ConsoleAutoConfiguration.java
...ork/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java
+0
-1
H2ConsoleAutoConfigurationTests.java
...oot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java
+9
-10
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java
View file @
c0f158df
...
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
h2
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
javax.sql.DataSource
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java
View file @
c0f158df
...
...
@@ -23,7 +23,6 @@ import javax.sql.DataSource;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.mockito.BDDMockito
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.BeanCreationException
;
...
...
@@ -37,6 +36,7 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
...
...
@@ -45,6 +45,7 @@ import static org.mockito.Mockito.mock;
* @author Andy Wilkinson
* @author Marten Deinum
* @author Stephane Nicoll
* @author Shraddha Yeole
*/
class
H2ConsoleAutoConfigurationTests
{
...
...
@@ -123,24 +124,22 @@ class H2ConsoleAutoConfigurationTests {
}
@Test
void
testDataSource
()
{
this
.
contextRunner
.
withUserConfiguration
(
DataSourceAvailable
.
class
)
.
withPropertyValues
(
"spring.h2.console.enabled=true"
).
run
((
context
)
->
{
assertThat
(
context
.
isRunning
()).
isTrue
();
});
void
h2ConsoleShouldNotFailIfDatabaseConnectionFails
()
{
this
.
contextRunner
.
withUserConfiguration
(
CustomDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.h2.console.enabled=true"
)
.
run
((
context
)
->
assertThat
(
context
.
isRunning
()).
isTrue
());
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
DataSourceAvailable
{
static
class
CustomDataSourceConfiguration
{
@Bean
public
DataSource
dataSource
()
throws
SQLException
{
DataSource
dataSource
()
throws
SQLException
{
DataSource
dataSource
=
mock
(
DataSource
.
class
);
BDDMockito
.
when
(
dataSource
.
getConnection
()).
then
Throw
(
IllegalStateException
.
class
);
given
(
dataSource
.
getConnection
()).
will
Throw
(
IllegalStateException
.
class
);
return
dataSource
;
}
}
}
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