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
05adf02a
Commit
05adf02a
authored
Apr 14, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include SQL init auto-config in JDBC-based test slices
Closes gh-25323
parent
e2252c78
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
13 deletions
+20
-13
TestDatabaseAutoConfiguration.java
...est/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java
+8
-4
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+4
-0
DataJdbcTestIntegrationTests.java
...autoconfigure/data/jdbc/DataJdbcTestIntegrationTests.java
+2
-2
JdbcTestIntegrationTests.java
...oot/test/autoconfigure/jdbc/JdbcTestIntegrationTests.java
+2
-2
JdbcTestWithIncludeFilterIntegrationTests.java
...igure/jdbc/JdbcTestWithIncludeFilterIntegrationTests.java
+2
-2
DataJpaTestSchemaCredentialsIntegrationTests.java
...orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java
+2
-3
No files found.
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java
View file @
05adf02a
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -16,7 +16,8 @@
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
jdbc
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.sql.DataSource
;
...
...
@@ -173,8 +174,11 @@ public class TestDatabaseAutoConfiguration {
EmbeddedDataSourceFactory
(
Environment
environment
)
{
this
.
environment
=
environment
;
if
(
environment
instanceof
ConfigurableEnvironment
)
{
((
ConfigurableEnvironment
)
environment
).
getPropertySources
().
addFirst
(
new
MapPropertySource
(
"testDatabase"
,
Collections
.
singletonMap
(
"spring.datasource.schema-username"
,
""
)));
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
"spring.datasource.schema-username"
,
""
);
source
.
put
(
"spring.sql.init.username"
,
""
);
((
ConfigurableEnvironment
)
environment
).
getPropertySources
()
.
addFirst
(
new
MapPropertySource
(
"testDatabase"
,
source
));
}
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
05adf02a
...
...
@@ -18,6 +18,7 @@ org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
# AutoConfigureDataJpa auto-configuration imports
...
...
@@ -29,6 +30,7 @@ org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConf
org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
# AutoConfigureDataLdap auto-configuration imports
...
...
@@ -79,6 +81,7 @@ org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
# AutoConfigureTestDatabase auto-configuration imports
...
...
@@ -93,6 +96,7 @@ org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration,\
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
# AutoConfigureJson auto-configuration imports
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestIntegrationTests.java
View file @
05adf02a
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
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.
...
...
@@ -39,7 +39,7 @@ import static org.springframework.boot.test.autoconfigure.AutoConfigurationImpor
*/
@DataJdbcTest
@TestPropertySource
(
properties
=
"spring.
datasource.schema
=classpath:org/springframework/boot/test/autoconfigure/data/jdbc/schema.sql"
)
properties
=
"spring.
sql.init.schemaLocations
=classpath:org/springframework/boot/test/autoconfigure/data/jdbc/schema.sql"
)
class
DataJdbcTestIntegrationTests
{
@Autowired
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestIntegrationTests.java
View file @
05adf02a
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
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.
...
...
@@ -41,7 +41,7 @@ import static org.springframework.boot.test.autoconfigure.AutoConfigurationImpor
*/
@JdbcTest
@TestPropertySource
(
properties
=
"spring.
datasource.schema
=classpath:org/springframework/boot/test/autoconfigure/jdbc/schema.sql"
)
properties
=
"spring.
sql.init.schemaLocations
=classpath:org/springframework/boot/test/autoconfigure/jdbc/schema.sql"
)
class
JdbcTestIntegrationTests
{
@Autowired
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithIncludeFilterIntegrationTests.java
View file @
05adf02a
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
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.
...
...
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@JdbcTest
(
includeFilters
=
@Filter
(
Repository
.
class
))
@TestPropertySource
(
properties
=
"spring.
datasource.schema
=classpath:org/springframework/boot/test/autoconfigure/jdbc/schema.sql"
)
properties
=
"spring.
sql.init.schemaLocations
=classpath:org/springframework/boot/test/autoconfigure/jdbc/schema.sql"
)
class
JdbcTestWithIncludeFilterIntegrationTests
{
@Autowired
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java
View file @
05adf02a
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -32,8 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson
*/
@DataJpaTest
@TestPropertySource
(
properties
=
{
"spring.datasource.schema-username=alice"
,
"spring.datasource.schema-password=secret"
})
@TestPropertySource
(
properties
=
{
"spring.sql.init.username=alice"
,
"spring.sql.init.password=secret"
})
class
DataJpaTestSchemaCredentialsIntegrationTests
{
@Autowired
...
...
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