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
7e21178f
Commit
7e21178f
authored
Jul 28, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Use configured schema in Liquibase endpoint"
Closes gh-9862
parent
3e13970f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
LiquibaseEndpoint.java
...ingframework/boot/actuate/endpoint/LiquibaseEndpoint.java
+2
-2
LiquibaseEndpointTests.java
...amework/boot/actuate/endpoint/LiquibaseEndpointTests.java
+8
-8
create-custom-schema.sql
...t-actuator/src/test/resources/db/create-custom-schema.sql
+1
-0
non-default-schema.sql
...oot-actuator/src/test/resources/db/non-default-schema.sql
+0
-1
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LiquibaseEndpoint.java
View file @
7e21178f
...
@@ -28,11 +28,11 @@ import liquibase.database.Database;
...
@@ -28,11 +28,11 @@ import liquibase.database.Database;
import
liquibase.database.DatabaseFactory
;
import
liquibase.database.DatabaseFactory
;
import
liquibase.database.jvm.JdbcConnection
;
import
liquibase.database.jvm.JdbcConnection
;
import
liquibase.integration.spring.SpringLiquibase
;
import
liquibase.integration.spring.SpringLiquibase
;
import
liquibase.util.StringUtils
;
import
org.springframework.boot.actuate.endpoint.LiquibaseEndpoint.LiquibaseReport
;
import
org.springframework.boot.actuate.endpoint.LiquibaseEndpoint.LiquibaseReport
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
/**
/**
* {@link Endpoint} to expose liquibase info.
* {@link Endpoint} to expose liquibase info.
...
@@ -69,7 +69,7 @@ public class LiquibaseEndpoint extends AbstractEndpoint<List<LiquibaseReport>> {
...
@@ -69,7 +69,7 @@ public class LiquibaseEndpoint extends AbstractEndpoint<List<LiquibaseReport>> {
Database
database
=
factory
Database
database
=
factory
.
findCorrectDatabaseImplementation
(
connection
);
.
findCorrectDatabaseImplementation
(
connection
);
String
defaultSchema
=
entry
.
getValue
().
getDefaultSchema
();
String
defaultSchema
=
entry
.
getValue
().
getDefaultSchema
();
if
(
StringUtils
.
trimToNull
(
defaultSchema
)
!=
null
)
{
if
(
StringUtils
.
hasText
(
defaultSchema
)
)
{
database
.
setDefaultSchemaName
(
defaultSchema
);
database
.
setDefaultSchemaName
(
defaultSchema
);
}
}
reports
.
add
(
new
LiquibaseReport
(
entry
.
getKey
(),
reports
.
add
(
new
LiquibaseReport
(
entry
.
getKey
(),
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/LiquibaseEndpointTests.java
View file @
7e21178f
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -18,9 +18,10 @@ package org.springframework.boot.actuate.endpoint;
...
@@ -18,9 +18,10 @@ package org.springframework.boot.actuate.endpoint;
import
liquibase.integration.spring.SpringLiquibase
;
import
liquibase.integration.spring.SpringLiquibase
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration
;
import
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration
;
import
org.springframework.boot.test.util.
TestPropertyValue
s
;
import
org.springframework.boot.test.util.
EnvironmentTestUtil
s
;
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
;
...
@@ -46,13 +47,12 @@ public class LiquibaseEndpointTests extends AbstractEndpointTests<LiquibaseEndpo
...
@@ -46,13 +47,12 @@ public class LiquibaseEndpointTests extends AbstractEndpointTests<LiquibaseEndpo
}
}
@Test
@Test
public
void
invoke
DifferentDefault
Schema
()
throws
Exception
{
public
void
invoke
WithCustom
Schema
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
TestPropertyValues
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
.
ofPair
(
"liquibase.defaultSchema"
,
"SOMESCHEMA"
)
"liquibase.default-schema=CUSTOMSCHEMA"
,
.
and
(
"spring.datasource.generate-unique-name"
,
"true"
)
"spring.datasource.generate-unique-name=true"
,
.
and
(
"spring.datasource.schema"
,
"classpath:/db/non-default-schema.sql"
)
"spring.datasource.schema=classpath:/db/create-custom-schema.sql"
);
.
applyTo
(
this
.
context
);
this
.
context
.
register
(
Config
.
class
);
this
.
context
.
register
(
Config
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertThat
(
getEndpointBean
().
invoke
()).
hasSize
(
1
);
assertThat
(
getEndpointBean
().
invoke
()).
hasSize
(
1
);
...
...
spring-boot-actuator/src/test/resources/db/create-custom-schema.sql
0 → 100644
View file @
7e21178f
CREATE
SCHEMA
CUSTOMSCHEMA
;
spring-boot-actuator/src/test/resources/db/non-default-schema.sql
deleted
100644 → 0
View file @
3e13970f
CREATE
SCHEMA
SOMESCHEMA
;
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