Skip to content

Commit e9b9cbd

Browse files
authored
Merge pull request #19104 from eugenp/upgrade-client-4
update client project to Boot 4
2 parents 3698884 + 7c8335d commit e9b9cbd

5 files changed

Lines changed: 33 additions & 85 deletions

File tree

spring-boot-modules/spring-boot-client/pom.xml

Lines changed: 25 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,47 @@
1010
<description>This is simple boot client application for Spring boot actuator test</description>
1111

1212
<parent>
13-
<groupId>com.baeldung.spring-boot-modules</groupId>
14-
<artifactId>spring-boot-modules</artifactId>
15-
<version>1.0.0-SNAPSHOT</version>
13+
<groupId>com.baeldung</groupId>
14+
<artifactId>parent-boot-4</artifactId>
15+
<version>0.0.1-SNAPSHOT</version>
16+
<relativePath>../../parent-boot-4</relativePath>
1617
</parent>
1718

1819
<dependencies>
1920
<dependency>
2021
<groupId>org.springframework.boot</groupId>
2122
<artifactId>spring-boot-starter-web</artifactId>
2223
</dependency>
24+
<dependency>
25+
<groupId>org.springframework.boot</groupId>
26+
<artifactId>spring-boot-starter-restclient</artifactId>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-webclient</artifactId>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.junit.vintage</groupId>
35+
<artifactId>junit-vintage-engine</artifactId>
36+
<scope>provided</scope>
37+
</dependency>
38+
2339
<dependency>
2440
<groupId>org.springframework.boot</groupId>
2541
<artifactId>spring-boot-starter-test</artifactId>
2642
<scope>test</scope>
43+
<exclusions>
44+
<exclusion>
45+
<groupId>org.junit.vintage</groupId>
46+
<artifactId>junit-vintage-engine</artifactId>
47+
</exclusion>
48+
</exclusions>
2749
</dependency>
2850
<dependency>
2951
<groupId>com.h2database</groupId>
3052
<artifactId>h2</artifactId>
3153
</dependency>
32-
<dependency>
33-
<groupId>org.springframework.boot</groupId>
34-
<artifactId>spring-boot-starter</artifactId>
35-
</dependency>
3654

3755
<dependency>
3856
<groupId>org.springframework</groupId>
@@ -44,67 +62,4 @@
4462
</dependency>
4563
</dependencies>
4664

47-
<build>
48-
<finalName>spring-boot-client</finalName>
49-
<resources>
50-
<resource>
51-
<directory>src/main/resources</directory>
52-
<filtering>true</filtering>
53-
</resource>
54-
</resources>
55-
<plugins>
56-
<plugin>
57-
<groupId>org.apache.maven.plugins</groupId>
58-
<artifactId>maven-war-plugin</artifactId>
59-
</plugin>
60-
<plugin>
61-
<groupId>pl.project13.maven</groupId>
62-
<artifactId>git-commit-id-plugin</artifactId>
63-
<version>${git-commit-id-plugin.version}</version>
64-
</plugin>
65-
</plugins>
66-
</build>
67-
68-
<profiles>
69-
<profile>
70-
<id>autoconfiguration</id>
71-
<build>
72-
<plugins>
73-
<plugin>
74-
<groupId>org.apache.maven.plugins</groupId>
75-
<artifactId>maven-surefire-plugin</artifactId>
76-
<version>${maven-surefire-plugin.version}</version>
77-
<executions>
78-
<execution>
79-
<phase>integration-test</phase>
80-
<goals>
81-
<goal>test</goal>
82-
</goals>
83-
<configuration>
84-
<excludes>
85-
<exclude>**/*LiveTest.java</exclude>
86-
<exclude>**/*IntegrationTest.java</exclude>
87-
<exclude>**/*IntTest.java</exclude>
88-
</excludes>
89-
<includes>
90-
<include>**/AutoconfigurationTest.java</include>
91-
</includes>
92-
</configuration>
93-
</execution>
94-
</executions>
95-
<configuration>
96-
<systemPropertyVariables>
97-
<test.mime>json</test.mime>
98-
</systemPropertyVariables>
99-
</configuration>
100-
</plugin>
101-
</plugins>
102-
</build>
103-
</profile>
104-
</profiles>
105-
106-
<properties>
107-
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
108-
</properties>
109-
11065
</project>

spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/DetailsServiceClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.baeldung.boot.client;
22

3-
import org.springframework.boot.web.client.RestTemplateBuilder;
3+
import org.springframework.boot.restclient.RestTemplateBuilder;
44
import org.springframework.stereotype.Service;
55
import org.springframework.web.client.RestTemplate;
66

spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/StompClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static void main(String[] args) {
2323
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
2424

2525
StompSessionHandler sessionHandler = new MyStompSessionHandler();
26-
stompClient.connect(URL, sessionHandler);
26+
stompClient.connectAsync(URL, sessionHandler);
2727

2828
new Scanner(System.in).nextLine(); // Don't close immediately.
2929
}

spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/SpringContextTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package com.baeldung;
22

33
import com.baeldung.boot.Application;
4-
import org.junit.Test;
5-
import org.junit.runner.RunWith;
4+
import org.junit.jupiter.api.Test;
65
import org.springframework.boot.test.context.SpringBootTest;
7-
import org.springframework.test.context.junit4.SpringRunner;
86

9-
@RunWith(SpringRunner.class)
107
@SpringBootTest(classes = Application.class)
118
public class SpringContextTest {
129

spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/boot/client/DetailsServiceClientIntegrationTest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@
55
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
66

77
import com.baeldung.boot.Application;
8-
import com.baeldung.boot.client.Details;
9-
import com.baeldung.boot.client.DetailsServiceClient;
10-
import org.junit.Before;
11-
import org.junit.Test;
12-
import org.junit.runner.RunWith;
8+
9+
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.BeforeEach;
1311
import org.springframework.beans.factory.annotation.Autowired;
1412
import org.springframework.boot.test.autoconfigure.web.client.RestClientTest;
1513
import org.springframework.http.MediaType;
16-
import org.springframework.test.context.junit4.SpringRunner;
1714
import org.springframework.test.web.client.MockRestServiceServer;
1815

19-
import com.fasterxml.jackson.databind.ObjectMapper;
16+
import tools.jackson.databind.ObjectMapper;
2017

21-
@RunWith(SpringRunner.class)
2218
@RestClientTest({ DetailsServiceClient.class, Application.class })
2319
public class DetailsServiceClientIntegrationTest {
2420

@@ -31,7 +27,7 @@ public class DetailsServiceClientIntegrationTest {
3127
@Autowired
3228
private ObjectMapper objectMapper;
3329

34-
@Before
30+
@BeforeEach
3531
public void setUp() throws Exception {
3632
String detailsString = objectMapper.writeValueAsString(new Details("John Smith", "john"));
3733
this.server.expect(requestTo("/john/details"))

0 commit comments

Comments
 (0)