|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
29 | 29 | import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
|
30 | 30 | import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
|
31 | 31 | import org.springframework.boot.test.autoconfigure.properties.SkipPropertyMapping;
|
| 32 | +import org.springframework.context.annotation.Primary; |
32 | 33 |
|
33 | 34 | /**
|
34 | 35 | * Annotation that can be applied to a test class to configure a test database to use
|
35 |
| - * instead of any application defined or auto-configured {@link DataSource}. |
| 36 | + * instead of the application-defined or auto-configured {@link DataSource}. In the case |
| 37 | + * of multiple {@code DataSource} beans, only the {@link Primary @Primary} |
| 38 | + * {@code DataSource} is considered. |
36 | 39 | *
|
37 | 40 | * @author Phillip Webb
|
38 | 41 | * @since 1.5.0
|
|
47 | 50 | public @interface AutoConfigureTestDatabase {
|
48 | 51 |
|
49 | 52 | /**
|
50 |
| - * Determines what type of existing DataSource beans can be replaced. |
| 53 | + * Determines what type of existing DataSource bean can be replaced. |
51 | 54 | * @return the type of existing DataSource to replace
|
52 | 55 | */
|
53 | 56 | @PropertyMapping(skip = SkipPropertyMapping.ON_DEFAULT_VALUE)
|
54 | 57 | Replace replace() default Replace.ANY;
|
55 | 58 |
|
56 | 59 | /**
|
57 |
| - * The type of connection to be established when {@link #replace() replacing} the data |
58 |
| - * source. By default will attempt to detect the connection based on the classpath. |
| 60 | + * The type of connection to be established when {@link #replace() replacing} the |
| 61 | + * DataSource. By default will attempt to detect the connection based on the |
| 62 | + * classpath. |
59 | 63 | * @return the type of connection to use
|
60 | 64 | */
|
61 | 65 | EmbeddedDatabaseConnection connection() default EmbeddedDatabaseConnection.NONE;
|
|
66 | 70 | enum Replace {
|
67 | 71 |
|
68 | 72 | /**
|
69 |
| - * Replace any DataSource bean (auto-configured or manually defined). |
| 73 | + * Replace the DataSource bean whether it was auto-configured or manually defined. |
70 | 74 | */
|
71 | 75 | ANY,
|
72 | 76 |
|
73 | 77 | /**
|
74 |
| - * Only replace auto-configured DataSource. |
| 78 | + * Only replace the DataSource if it was auto-configured. |
75 | 79 | */
|
76 | 80 | AUTO_CONFIGURED,
|
77 | 81 |
|
|
0 commit comments