Skip to content

Commit 84a7e88

Browse files
committed
refactor: update imports for Spring Boot 4.0.0 compatibility
1 parent 5795d5f commit 84a7e88

File tree

10 files changed

+26
-13
lines changed

10 files changed

+26
-13
lines changed

example/acceptance-test/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
<artifactId>spring-boot-starter-test</artifactId>
3838
<scope>test</scope>
3939
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-resttestclient</artifactId>
43+
<scope>test</scope>
44+
</dependency>
4045
<dependency>
4146
<groupId>com.h2database</groupId>
4247
<artifactId>h2</artifactId>

example/acceptance-test/src/test/java/packagename/cucumber/ExampleStepDef.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.List;
1212
import java.util.Map;
1313
import java.util.stream.Collectors;
14-
import org.springframework.boot.test.web.client.TestRestTemplate;
14+
import org.springframework.boot.resttestclient.TestRestTemplate;
1515
import org.springframework.boot.test.web.server.LocalServerPort;
1616
import org.springframework.http.HttpStatus;
1717
import org.springframework.http.ResponseEntity;

example/acceptance-test/src/test/java/packagename/cucumber/SpringCucumberTestConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
44

55
import io.cucumber.spring.CucumberContextConfiguration;
6+
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
67
import org.springframework.boot.test.context.SpringBootTest;
78
import org.springframework.test.context.ActiveProfiles;
89
import packagename.boot.ExampleApplication;
910

1011
@SpringBootTest(classes = ExampleApplication.class, webEnvironment = RANDOM_PORT)
1112
@CucumberContextConfiguration
1213
@ActiveProfiles("test")
14+
@AutoConfigureTestRestTemplate
1315
public class SpringCucumberTestConfig {}

example/jpa-adapter/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
<artifactId>spring-boot-starter-data-jpa</artifactId>
2222
</dependency>
2323
<dependency>
24-
<groupId>org.liquibase</groupId>
25-
<artifactId>liquibase-core</artifactId>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-liquibase</artifactId>
2626
<exclusions>
2727
<exclusion>
28-
<artifactId>commons-text</artifactId>
2928
<groupId>org.apache.commons</groupId>
29+
<artifactId>commons-text</artifactId>
3030
</exclusion>
3131
</exclusions>
3232
</dependency>
@@ -53,6 +53,11 @@
5353
<artifactId>spring-boot-starter-test</artifactId>
5454
<scope>test</scope>
5555
</dependency>
56+
<dependency>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
59+
<scope>test</scope>
60+
</dependency>
5661
<dependency>
5762
<groupId>com.h2database</groupId>
5863
<artifactId>h2</artifactId>

example/jpa-adapter/src/main/java/packagename/repository/config/JpaAdapterConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package packagename.repository.config;
22

3-
import org.springframework.boot.autoconfigure.domain.EntityScan;
3+
import org.springframework.boot.persistence.autoconfigure.EntityScan;
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
66
import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;

example/jpa-adapter/src/main/resources/preliquibase/default.sql renamed to example/jpa-adapter/src/main/resources/preliquibase/h2.sql

File renamed without changes.

example/jpa-adapter/src/test/java/packagename/repository/ExampleJpaAdapterApplication.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package packagename.repository;
22

3-
import net.lbruun.springboot.preliquibase.PreLiquibaseAutoConfiguration;
43
import org.springframework.boot.SpringApplication;
5-
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
64
import org.springframework.boot.autoconfigure.SpringBootApplication;
75
import org.springframework.boot.test.context.TestConfiguration;
86
import org.springframework.context.annotation.Import;
@@ -17,6 +15,5 @@ public static void main(String[] args) {
1715

1816
@TestConfiguration
1917
@Import(JpaAdapterConfig.class)
20-
@ImportAutoConfiguration({PreLiquibaseAutoConfiguration.class})
2118
static class ExampleJpaTestConfig {}
2219
}

example/jpa-adapter/src/test/java/packagename/repository/ExampleJpaTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.junit.jupiter.api.Test;
77
import org.junit.jupiter.api.extension.ExtendWith;
88
import org.springframework.beans.factory.annotation.Autowired;
9-
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
9+
import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest;
1010
import org.springframework.test.context.ActiveProfiles;
1111
import org.springframework.test.context.jdbc.Sql;
1212
import org.springframework.test.context.junit.jupiter.SpringExtension;

example/rest-adapter/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
<artifactId>spring-boot-starter-test</artifactId>
3636
<scope>test</scope>
3737
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-resttestclient</artifactId>
41+
<scope>test</scope>
42+
</dependency>
3843
</dependencies>
3944
<build>
4045
<plugins>

example/rest-adapter/src/test/java/packagename/rest/ExampleResourceTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
import org.mockito.Mockito;
1414
import org.mockito.junit.jupiter.MockitoExtension;
1515
import org.springframework.beans.factory.annotation.Autowired;
16-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
17-
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
16+
import org.springframework.boot.resttestclient.TestRestTemplate;
17+
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
1818
import org.springframework.boot.test.context.SpringBootTest;
19-
import org.springframework.boot.test.web.client.TestRestTemplate;
2019
import org.springframework.boot.test.web.server.LocalServerPort;
2120
import org.springframework.http.HttpStatus;
2221
import org.springframework.test.context.bean.override.mockito.MockitoBean;
@@ -28,7 +27,7 @@
2827

2928
@ExtendWith(MockitoExtension.class)
3029
@SpringBootTest(classes = ExampleRestAdapterApplication.class, webEnvironment = RANDOM_PORT)
31-
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
30+
@AutoConfigureTestRestTemplate
3231
public class ExampleResourceTest {
3332

3433
private static final String LOCALHOST = "http://localhost:";

0 commit comments

Comments
 (0)