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
622606d8
Commit
622606d8
authored
Nov 03, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it clearer that only the main DataSource bean may be replaced
Closes gh-23808
parent
d32d65b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
AutoConfigureTestDatabase.java
...ot/test/autoconfigure/jdbc/AutoConfigureTestDatabase.java
+11
-7
No files found.
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabase.java
View file @
622606d8
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
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.
...
...
@@ -29,10 +29,13 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import
org.springframework.boot.jdbc.EmbeddedDatabaseConnection
;
import
org.springframework.boot.test.autoconfigure.properties.PropertyMapping
;
import
org.springframework.boot.test.autoconfigure.properties.SkipPropertyMapping
;
import
org.springframework.context.annotation.Primary
;
/**
* Annotation that can be applied to a test class to configure a test database to use
* instead of any application defined or auto-configured {@link DataSource}.
* instead of the application-defined or auto-configured {@link DataSource}. In the case
* of multiple {@code DataSource} beans, only the {@link Primary @Primary}
* {@code DataSource} is considered.
*
* @author Phillip Webb
* @since 1.5.0
...
...
@@ -47,15 +50,16 @@ import org.springframework.boot.test.autoconfigure.properties.SkipPropertyMappin
public
@interface
AutoConfigureTestDatabase
{
/**
* Determines what type of existing DataSource bean
s
can be replaced.
* Determines what type of existing DataSource bean can be replaced.
* @return the type of existing DataSource to replace
*/
@PropertyMapping
(
skip
=
SkipPropertyMapping
.
ON_DEFAULT_VALUE
)
Replace
replace
()
default
Replace
.
ANY
;
/**
* The type of connection to be established when {@link #replace() replacing} the data
* source. By default will attempt to detect the connection based on the classpath.
* The type of connection to be established when {@link #replace() replacing} the
* DataSource. By default will attempt to detect the connection based on the
* classpath.
* @return the type of connection to use
*/
EmbeddedDatabaseConnection
connection
()
default
EmbeddedDatabaseConnection
.
NONE
;
...
...
@@ -66,12 +70,12 @@ public @interface AutoConfigureTestDatabase {
enum
Replace
{
/**
* Replace
any DataSource bean (auto-configured or manually defined)
.
* Replace
the DataSource bean whether it was auto-configured or manually defined
.
*/
ANY
,
/**
* Only replace
auto-configured DataSource
.
* Only replace
the DataSource if it was auto-configured
.
*/
AUTO_CONFIGURED
,
...
...
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