Skip to content

Commit ce95fd6

Browse files
committed
Polish "Use @DynamicPropertySource for Neo4J and Redis data tests"
See gh-20676
1 parent d84422a commit ce95fd6

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,11 +45,6 @@ class DataNeo4jTestIntegrationTests {
4545
@Container
4646
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>().withoutAuthentication();
4747

48-
@DynamicPropertySource
49-
static void neo4jProperties(DynamicPropertyRegistry registry) {
50-
registry.add("spring.data.neo4j.uri", neo4j::getBoltUrl);
51-
}
52-
5348
@Autowired
5449
private Session session;
5550

@@ -59,6 +54,11 @@ static void neo4jProperties(DynamicPropertyRegistry registry) {
5954
@Autowired
6055
private ApplicationContext applicationContext;
6156

57+
@DynamicPropertySource
58+
static void neo4jProperties(DynamicPropertyRegistry registry) {
59+
registry.add("spring.data.neo4j.uri", neo4j::getBoltUrl);
60+
}
61+
6262
@Test
6363
void testRepository() {
6464
ExampleGraph exampleGraph = new ExampleGraph();

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,14 +41,14 @@ class DataNeo4jTestPropertiesIntegrationTests {
4141
@Container
4242
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>().withoutAuthentication();
4343

44+
@Autowired
45+
private Environment environment;
46+
4447
@DynamicPropertySource
4548
static void neo4jProperties(DynamicPropertyRegistry registry) {
4649
registry.add("spring.data.neo4j.uri", neo4j::getBoltUrl);
4750
}
4851

49-
@Autowired
50-
private Environment environment;
51-
5252
@Test
5353
void environmentWithNewProfile() {
5454
assertThat(this.environment.getActiveProfiles()).containsExactly("test");

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,14 +42,14 @@ class DataNeo4jTestWithIncludeFilterIntegrationTests {
4242
@Container
4343
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>().withoutAuthentication();
4444

45+
@Autowired
46+
private ExampleService service;
47+
4548
@DynamicPropertySource
4649
static void neo4jProperties(DynamicPropertyRegistry registry) {
4750
registry.add("spring.data.neo4j.uri", neo4j::getBoltUrl);
4851
}
4952

50-
@Autowired
51-
private ExampleService service;
52-
5353
@Test
5454
void testService() {
5555
assertThat(this.service.hasNode(ExampleGraph.class)).isFalse();

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ class DataRedisTestIntegrationTests {
4949
@Container
5050
static RedisContainer redis = new RedisContainer();
5151

52-
@DynamicPropertySource
53-
static void redisProperties(DynamicPropertyRegistry registry) {
54-
registry.add("spring.redis.port", redis::getFirstMappedPort);
55-
}
56-
5752
@Autowired
5853
private RedisOperations<Object, Object> operations;
5954

@@ -63,6 +58,11 @@ static void redisProperties(DynamicPropertyRegistry registry) {
6358
@Autowired
6459
private ApplicationContext applicationContext;
6560

61+
@DynamicPropertySource
62+
static void redisProperties(DynamicPropertyRegistry registry) {
63+
registry.add("spring.redis.port", redis::getFirstMappedPort);
64+
}
65+
6666
@Test
6767
void testRepository() {
6868
PersonHash personHash = new PersonHash();

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ class DataRedisTestPropertiesIntegrationTests {
4141
@Container
4242
static final RedisContainer redis = new RedisContainer();
4343

44+
@Autowired
45+
private Environment environment;
46+
4447
@DynamicPropertySource
4548
static void redisProperties(DynamicPropertyRegistry registry) {
4649
registry.add("spring.redis.port", redis::getFirstMappedPort);
4750
}
4851

49-
@Autowired
50-
private Environment environment;
51-
5252
@Test
5353
void environmentWithNewProfile() {
5454
assertThat(this.environment.getActiveProfiles()).containsExactly("test");

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ class DataRedisTestWithIncludeFilterIntegrationTests {
4141
@Container
4242
static final RedisContainer redis = new RedisContainer();
4343

44-
@DynamicPropertySource
45-
static void redisProperties(DynamicPropertyRegistry registry) {
46-
registry.add("spring.redis.port", redis::getFirstMappedPort);
47-
}
48-
4944
@Autowired
5045
private ExampleRepository exampleRepository;
5146

5247
@Autowired
5348
private ExampleService service;
5449

50+
@DynamicPropertySource
51+
static void redisProperties(DynamicPropertyRegistry registry) {
52+
registry.add("spring.redis.port", redis::getFirstMappedPort);
53+
}
54+
5555
@Test
5656
void testService() {
5757
PersonHash personHash = new PersonHash();

0 commit comments

Comments
 (0)