Fix deprecation warnings
* Remove `forkEvery = 1000` since where the build fails there is no way find the reason * Rework affected test classes to use JUnit 5 API * Use Java text block for JSON snippets in the test
This commit is contained in:
@@ -345,8 +345,6 @@ configure(javaProjects) { subproject ->
|
||||
reports.junitXml.required = false
|
||||
|
||||
enableAssertions = false
|
||||
|
||||
forkEvery = 1000
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
* Copyright 2019-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -132,8 +133,7 @@ class FluxAggregatorMessageHandlerTests {
|
||||
|
||||
Object payload = result.getPayload();
|
||||
assertThat(payload)
|
||||
.isInstanceOf(List.class)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.containsExactly(
|
||||
IntStream.iterate(0, i -> i + 2)
|
||||
.limit(10)
|
||||
@@ -145,8 +145,7 @@ class FluxAggregatorMessageHandlerTests {
|
||||
|
||||
payload = result.getPayload();
|
||||
assertThat(payload)
|
||||
.isInstanceOf(List.class)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.containsExactly(
|
||||
IntStream.iterate(1, i -> i + 2)
|
||||
.limit(10)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.integration.aggregator.integration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -56,8 +56,8 @@ public class DefaultMessageAggregatorIntegrationTests {
|
||||
this.input.send(prepareSequenceMessage(i, 5, 1));
|
||||
}
|
||||
Object payload = this.output.receive(20_000).getPayload();
|
||||
assertThat(payload).isInstanceOf(List.class)
|
||||
.asList()
|
||||
assertThat(payload)
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.containsAll(Arrays.asList(0, 1, 2, 3, 4));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023 the original author or authors.
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -133,7 +134,7 @@ public class PartitionedChannelTests {
|
||||
|
||||
assertThat(receive).isNotNull()
|
||||
.extracting(Message::getPayload)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.hasSize(5);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2023 the original author or authors.
|
||||
* Copyright 2016-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,8 +25,8 @@ import java.util.stream.IntStream;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.TextNode;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -53,16 +53,17 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class CorrelationHandlerTests {
|
||||
|
||||
@@ -167,7 +168,7 @@ public class CorrelationHandlerTests {
|
||||
.isInstanceOf(ArrayNode.class)
|
||||
.extracting(new String[] {"_children"})
|
||||
.element(0)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.hasSize(0);
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ public class CorrelationHandlerTests {
|
||||
public static class ContextConfiguration {
|
||||
|
||||
@Bean
|
||||
public TestSplitterPojo testSplitterData() {
|
||||
TestSplitterPojo testSplitterData() {
|
||||
List<String> first = new ArrayList<>();
|
||||
first.add("1,2,3");
|
||||
first.add("4,5,6");
|
||||
@@ -324,26 +325,7 @@ public class CorrelationHandlerTests {
|
||||
|
||||
}
|
||||
|
||||
private static final class TestSplitterPojo {
|
||||
|
||||
final List<String> first;
|
||||
|
||||
final List<String> second;
|
||||
|
||||
TestSplitterPojo(List<String> first, List<String> second) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public List<String> getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public List<String> getSecond() {
|
||||
return second;
|
||||
}
|
||||
record TestSplitterPojo(List<String> first, List<String> second) {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public List<List<String>> buildList() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
@@ -49,13 +50,24 @@ public class JsonToObjectTransformerTests {
|
||||
// Since DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES is disabled by default
|
||||
// (see Jackson2JsonObjectMapper)
|
||||
// the extra "foo" property is ignored.
|
||||
String jsonString = "[{\"firstName\":\"John\",\"lastName\":\"Doe\",\"age\":42," +
|
||||
"\"address\":{\"number\":123,\"street\":\"Main Street\"}, \"foo\":\"bar\"}]";
|
||||
// language=JSON
|
||||
String jsonString = """
|
||||
[
|
||||
{
|
||||
"firstName": "John",
|
||||
"lastName": "Doe",
|
||||
"age": 42,
|
||||
"address": {
|
||||
"number": 123,
|
||||
"street": "Main Street"
|
||||
},
|
||||
"foo": "bar"
|
||||
}
|
||||
]""";
|
||||
Message<?> message = transformer.transform(new GenericMessage<>(jsonString));
|
||||
assertThat(message)
|
||||
.extracting(Message::getPayload)
|
||||
.isInstanceOf(List.class)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.hasSize(1)
|
||||
.element(0)
|
||||
.isInstanceOf(TestPerson.class)
|
||||
@@ -75,7 +87,17 @@ public class JsonToObjectTransformerTests {
|
||||
customMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, Boolean.TRUE);
|
||||
JsonToObjectTransformer transformer = new JsonToObjectTransformer(new Jackson2JsonObjectMapper(customMapper));
|
||||
transformer.setValueTypeExpression(new ValueExpression<>(ResolvableType.forClass(TestPerson.class)));
|
||||
String jsonString = "{firstName:'John', lastName:'Doe', age:42, address:{number:123, street:'Main Street'}}";
|
||||
// language=JSON
|
||||
String jsonString = """
|
||||
{
|
||||
"firstName": "John",
|
||||
"lastName": "Doe",
|
||||
"age": 42,
|
||||
"address": {
|
||||
"number": 123,
|
||||
"street": "Main Street"
|
||||
}
|
||||
}""";
|
||||
Message<?> message = transformer.transform(new GenericMessage<>(jsonString));
|
||||
TestPerson person = (TestPerson) message.getPayload();
|
||||
assertThat(person.getFirstName()).isEqualTo("John");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2022 the original author or authors.
|
||||
* Copyright 2014-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package org.springframework.integration.scattergather.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.gateway.RequestReplyExchanger;
|
||||
@@ -28,8 +26,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -39,8 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class ScatterGatherTests {
|
||||
|
||||
@@ -66,8 +62,7 @@ public class ScatterGatherTests {
|
||||
assertThat(bestQuoteMessage)
|
||||
.isNotNull()
|
||||
.extracting(Message::getPayload)
|
||||
.isInstanceOf(List.class)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.hasSizeGreaterThanOrEqualTo(1);
|
||||
}
|
||||
|
||||
@@ -78,8 +73,7 @@ public class ScatterGatherTests {
|
||||
assertThat(bestQuoteMessage)
|
||||
.isNotNull()
|
||||
.extracting(Message::getPayload)
|
||||
.isInstanceOf(List.class)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.hasSizeGreaterThanOrEqualTo(1);
|
||||
}
|
||||
|
||||
@@ -89,16 +83,14 @@ public class ScatterGatherTests {
|
||||
assertThat(bestQuoteMessage)
|
||||
.isNotNull()
|
||||
.extracting(Message::getPayload)
|
||||
.isInstanceOf(List.class)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.hasSizeGreaterThanOrEqualTo(1);
|
||||
|
||||
bestQuoteMessage = this.gateway.exchange(new GenericMessage<>("bar"));
|
||||
assertThat(bestQuoteMessage)
|
||||
.isNotNull()
|
||||
.extracting(Message::getPayload)
|
||||
.isInstanceOf(List.class)
|
||||
.asList()
|
||||
.asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.hasSizeGreaterThanOrEqualTo(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user