Skip to content

Commit 46f11c1

Browse files
committed
Update all samples to remove Jackson2
Now use Jackson 3`
1 parent 28e4dfd commit 46f11c1

File tree

7 files changed

+26
-39
lines changed

7 files changed

+26
-39
lines changed

spring-cloud-task-integration-tests/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@
115115
<artifactId>spring-integration-test</artifactId>
116116
<scope>test</scope>
117117
</dependency>
118-
<dependency>
119-
<groupId>com.fasterxml.jackson.datatype</groupId>
120-
<artifactId>jackson-datatype-jsr310</artifactId>
121-
<scope>test</scope>
122-
<optional>true</optional>
123-
</dependency>
124118
<dependency>
125119
<groupId>org.testcontainers</groupId>
126120
<artifactId>mariadb</artifactId>

spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/BatchExecutionEventTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
import java.util.List;
2121
import java.util.UUID;
2222

23-
import com.fasterxml.jackson.databind.DeserializationFeature;
24-
import com.fasterxml.jackson.databind.ObjectMapper;
25-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
2623
import configuration.JobConfiguration;
2724
import configuration.JobSkipConfiguration;
2825
import org.assertj.core.api.Assertions;
2926
import org.junit.jupiter.api.AfterEach;
3027
import org.junit.jupiter.api.BeforeEach;
3128
import org.junit.jupiter.api.Test;
29+
import tools.jackson.databind.DeserializationFeature;
30+
import tools.jackson.databind.ObjectMapper;
31+
import tools.jackson.databind.json.JsonMapper;
3232

3333
import org.springframework.boot.WebApplicationType;
3434
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -51,14 +51,13 @@ public class BatchExecutionEventTests {
5151

5252
private static final String TASK_NAME = "taskEventTest";
5353

54-
private final ObjectMapper objectMapper = new ObjectMapper();
54+
private ObjectMapper objectMapper;
5555

5656
private ConfigurableApplicationContext applicationContext;
5757

5858
@BeforeEach
5959
public void setup() {
60-
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
61-
objectMapper.registerModule(new JavaTimeModule());
60+
objectMapper = JsonMapper.builder().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build();
6261
}
6362

6463
@AfterEach

spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import java.util.List;
2121
import java.util.UUID;
2222

23-
import com.fasterxml.jackson.databind.ObjectMapper;
24-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
2523
import org.assertj.core.api.Assertions;
2624
import org.junit.jupiter.api.AfterEach;
2725
import org.junit.jupiter.api.BeforeEach;
2826
import org.junit.jupiter.api.Test;
27+
import tools.jackson.databind.DeserializationFeature;
28+
import tools.jackson.databind.ObjectMapper;
29+
import tools.jackson.databind.json.JsonMapper;
2930

3031
import org.springframework.boot.WebApplicationType;
3132
import org.springframework.boot.builder.SpringApplicationBuilder;
@@ -45,13 +46,13 @@ public class TaskEventTests {
4546

4647
private static final String TASK_NAME = "taskEventTest";
4748

48-
private final ObjectMapper objectMapper = new ObjectMapper();
49+
private ObjectMapper objectMapper;
4950

5051
private ConfigurableApplicationContext applicationContext;
5152

5253
@BeforeEach
5354
public void setup() {
54-
this.objectMapper.registerModule(new JavaTimeModule());
55+
objectMapper = JsonMapper.builder().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build();
5556
}
5657

5758
@AfterEach

spring-cloud-task-samples/batch-events/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@
7878
<groupId>com.h2database</groupId>
7979
<artifactId>h2</artifactId>
8080
</dependency>
81-
<dependency>
82-
<groupId>com.fasterxml.jackson.datatype</groupId>
83-
<artifactId>jackson-datatype-jsr310</artifactId>
84-
</dependency>
8581
<dependency>
8682
<groupId>org.springframework.cloud</groupId>
8783
<artifactId>spring-cloud-stream-test-binder</artifactId>

spring-cloud-task-samples/batch-events/src/test/java/io/spring/cloud/BatchEventsApplicationTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
import java.util.List;
2121
import java.util.UUID;
2222

23-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
2423
import org.junit.jupiter.api.Tag;
25-
import com.fasterxml.jackson.databind.DeserializationFeature;
26-
import com.fasterxml.jackson.databind.ObjectMapper;
2724
import org.junit.jupiter.api.AfterEach;
2825
import org.junit.jupiter.api.BeforeEach;
2926
import org.junit.jupiter.api.Test;
27+
import tools.jackson.databind.DeserializationFeature;
28+
import tools.jackson.databind.ObjectMapper;
29+
import tools.jackson.databind.json.JsonMapper;
3030

3131
import org.springframework.boot.WebApplicationType;
3232
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -48,14 +48,13 @@ public class BatchEventsApplicationTests {
4848

4949
private ConfigurableApplicationContext applicationContext;
5050

51-
private final ObjectMapper objectMapper = new ObjectMapper();
51+
private ObjectMapper objectMapper;
5252

5353
private final TaskEventProperties taskEventProperties = new TaskEventProperties();
5454

5555
@BeforeEach
5656
public void setup() {
57-
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
58-
objectMapper.registerModule(new JavaTimeModule());
57+
objectMapper = JsonMapper.builder().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build();
5958
}
6059

6160
@AfterEach

spring-cloud-task-stream/pom.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
<groupId>org.springframework.cloud</groupId>
3434
<artifactId>spring-cloud-task-core</artifactId>
3535
</dependency>
36-
36+
<dependency>
37+
<groupId>tools.jackson.core</groupId>
38+
<artifactId>jackson-databind</artifactId>
39+
<scope>test</scope>
40+
<optional>true</optional>
41+
</dependency>
3742
<dependency>
3843
<groupId>org.springframework.boot</groupId>
3944
<artifactId>spring-boot-starter-test</artifactId>
@@ -80,11 +85,5 @@
8085
<artifactId>assertj-core</artifactId>
8186
<scope>test</scope>
8287
</dependency>
83-
<dependency>
84-
<groupId>com.fasterxml.jackson.datatype</groupId>
85-
<artifactId>jackson-datatype-jsr310</artifactId>
86-
<scope>test</scope>
87-
<optional>true</optional>
88-
</dependency>
8988
</dependencies>
9089
</project>

spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/EventListenerTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import java.util.List;
2222
import java.util.UUID;
2323

24-
import com.fasterxml.jackson.databind.DeserializationFeature;
25-
import com.fasterxml.jackson.databind.ObjectMapper;
26-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
2724
import org.junit.jupiter.api.AfterEach;
2825
import org.junit.jupiter.api.BeforeEach;
2926
import org.junit.jupiter.api.Test;
27+
import tools.jackson.databind.DeserializationFeature;
28+
import tools.jackson.databind.ObjectMapper;
29+
import tools.jackson.databind.json.JsonMapper;
3030

3131
import org.springframework.batch.core.job.JobExecution;
3232
import org.springframework.batch.core.job.JobInstance;
@@ -75,11 +75,11 @@ public class EventListenerTests {
7575

7676
private final TaskEventProperties taskEventProperties = new TaskEventProperties();
7777

78-
private final ObjectMapper objectMapper = new ObjectMapper();
78+
private ObjectMapper objectMapper = new ObjectMapper();
7979

8080
@BeforeEach
8181
public void beforeTests() {
82-
objectMapper.registerModule(new JavaTimeModule());
82+
objectMapper = JsonMapper.builder().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build();
8383

8484
this.applicationContext = new SpringApplicationBuilder()
8585
.sources(TestChannelBinderConfiguration.getCompleteConfiguration(BatchEventsApplication.class))
@@ -88,7 +88,6 @@ public void beforeTests() {
8888
.run();
8989
StreamBridge streamBridge = this.applicationContext.getBean(StreamBridge.class);
9090
MessagePublisher messagePublisher = new MessagePublisher(streamBridge);
91-
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
9291

9392
this.eventEmittingSkipListener = new EventEmittingSkipListener(messagePublisher, this.taskEventProperties);
9493
this.eventEmittingItemProcessListener = new EventEmittingItemProcessListener(messagePublisher,

0 commit comments

Comments
 (0)