Skip to content

Commit ec02b56

Browse files
committed
Merge pull request #13453 from izeye:spring-boot-test-properties
* pr/13453: Use @SpringBootTest.properties in tests and samples
2 parents 01da6ea + 870d7fe commit ec02b56

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JolokiaEndpointAutoConfigurationIntegrationTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.springframework.http.HttpStatus;
4949
import org.springframework.http.ResponseEntity;
5050
import org.springframework.test.annotation.DirtiesContext;
51-
import org.springframework.test.context.TestPropertySource;
5251
import org.springframework.test.context.junit4.SpringRunner;
5352

5453
import static org.assertj.core.api.Assertions.assertThat;
@@ -59,9 +58,8 @@
5958
* @author Stephane Nicoll
6059
*/
6160
@RunWith(SpringRunner.class)
62-
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
61+
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "management.endpoints.web.exposure.include=jolokia")
6362
@DirtiesContext
64-
@TestPropertySource(properties = "management.endpoints.web.exposure.include=jolokia")
6563
public class JolokiaEndpointAutoConfigurationIntegrationTests {
6664

6765
@Autowired

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/test/MetricsIntegrationTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import org.springframework.context.annotation.Primary;
6262
import org.springframework.http.HttpMethod;
6363
import org.springframework.http.MediaType;
64-
import org.springframework.test.context.TestPropertySource;
6564
import org.springframework.test.context.junit4.SpringRunner;
6665
import org.springframework.test.util.ReflectionTestUtils;
6766
import org.springframework.test.web.client.MockRestServiceServer;
@@ -81,8 +80,7 @@
8180
* @author Jon Schneider
8281
*/
8382
@RunWith(SpringRunner.class)
84-
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = MetricsIntegrationTests.MetricsApp.class)
85-
@TestPropertySource(properties = "management.metrics.use-global-registry=false")
83+
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = MetricsIntegrationTests.MetricsApp.class, properties = "management.metrics.use-global-registry=false")
8684
public class MetricsIntegrationTests {
8785

8886
@Autowired

spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.beans.factory.annotation.Autowired;
2828
import org.springframework.boot.test.context.SpringBootTest;
2929
import org.springframework.test.context.ActiveProfiles;
30-
import org.springframework.test.context.TestPropertySource;
3130
import org.springframework.test.context.junit4.SpringRunner;
3231
import org.springframework.test.web.servlet.MockMvc;
3332
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -45,9 +44,8 @@
4544
* @author Dave Syer
4645
*/
4746
@RunWith(SpringRunner.class)
48-
@SpringBootTest
4947
// Enable JMX so we can test the MBeans (you can't do this in a properties file)
50-
@TestPropertySource(properties = { "spring.jmx.enabled:true",
48+
@SpringBootTest(properties = { "spring.jmx.enabled:true",
5149
"spring.datasource.jmx-enabled:true" })
5250
@ActiveProfiles("scratch")
5351
// Separate profile for web tests to avoid clashing databases

spring-boot-samples/spring-boot-sample-kafka/src/test/java/sample/kafka/SampleKafkaApplicationTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.boot.test.rule.OutputCapture;
2828
import org.springframework.context.annotation.Bean;
2929
import org.springframework.kafka.test.context.EmbeddedKafka;
30-
import org.springframework.test.context.TestPropertySource;
3130
import org.springframework.test.context.junit4.SpringRunner;
3231

3332
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,8 +39,7 @@
4039
* @author Stephane Nicoll
4140
*/
4241
@RunWith(SpringRunner.class)
43-
@SpringBootTest
44-
@TestPropertySource(properties = "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}")
42+
@SpringBootTest(properties = "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}")
4543
@EmbeddedKafka
4644
public class SampleKafkaApplicationTests {
4745

0 commit comments

Comments
 (0)