Skip to content

Commit 2022c40

Browse files
committed
Fix compatibility with the latest SF
* Upgrade Spring dependencies to the latest SNAPSHOTs * Fix tests to verify against stack traces: the message of the `NestedRuntimeException` does not include the nested exception information. Related to spring-projects/spring-framework#25162 * Fix `JdbcMessageStore` and `DefaultLockRepository` to rely on the `DataIntegrityViolationException` instead of only its `DuplicateKeyException` extension. This is the current behavior of the SQL errors translation * Disable `WebFluxDslTests.testValidation()` - doesn't subscribe to the reply somehow... * Refine `SimplePool.PoolSemaphore.reducePermits()`
1 parent 979b841 commit 2022c40

File tree

39 files changed

+278
-354
lines changed

39 files changed

+278
-354
lines changed

Diff for: build.gradle

+8-8
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ ext {
6767
hazelcastVersion = '5.1.1'
6868
hibernateVersion = '5.6.8.Final'
6969
hsqldbVersion = '2.6.1'
70-
h2Version = '2.1.210'
70+
h2Version = '2.1.212'
7171
jacksonVersion = '2.13.3'
7272
jaxbVersion = '3.0.2'
7373
jcifsVersion = '2.1.29'
@@ -91,21 +91,21 @@ ext {
9191
pahoMqttClientVersion = '1.2.5'
9292
postgresVersion = '42.3.3'
9393
r2dbch2Version = '0.9.1.RELEASE'
94-
reactorVersion = '2020.0.18'
94+
reactorVersion = '2022.0.0-M2'
9595
resilience4jVersion = '1.7.1'
9696
romeToolsVersion = '1.18.0'
9797
rsocketVersion = '1.1.2'
9898
saajVersion = '2.0.1'
9999
servletApiVersion = '5.0.0'
100100
smackVersion = '4.4.5'
101-
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '3.0.0-M3'
102-
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2022.0.0-M4'
101+
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '3.0.0-SNAPSHOT'
102+
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2022.0.0-SNAPSHOT'
103103
springGraphqlVersion = '1.0.0'
104-
springKafkaVersion = '3.0.0-M4'
104+
springKafkaVersion = '3.0.0-SNAPSHOT'
105105
springRetryVersion = '1.3.3'
106-
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '6.0.0-M5'
107-
springVersion = project.hasProperty('springVersion') ? project.springVersion : '6.0.0-M4'
108-
springWsVersion = '4.0.0-M2'
106+
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '6.0.0-SNAPSHOT'
107+
springVersion = project.hasProperty('springVersion') ? project.springVersion : '6.0.0-SNAPSHOT'
108+
springWsVersion = '4.0.0-SNAPSHOT'
109109
testcontainersVersion = '1.17.1'
110110
tomcatVersion = '10.0.21'
111111
xmlUnitVersion = '2.9.0'

Diff for: spring-integration-amqp/src/test/java/org/springframework/integration/amqp/channel/DispatcherHasNoSubscribersTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -77,7 +77,7 @@ public void testPtP() throws Exception {
7777
amqpChannel.setBeanFactory(mock(BeanFactory.class));
7878
amqpChannel.afterPropertiesSet();
7979

80-
MessageListener listener = (MessageListener) container.getMessageListener();
80+
MessageListener listener = container.getMessageListener();
8181

8282
assertThatExceptionOfType(MessageDeliveryException.class)
8383
.isThrownBy(() -> listener.onMessage(new Message("Hello world!".getBytes())))
@@ -101,7 +101,7 @@ public void testPubSub() {
101101
amqpChannel.afterPropertiesSet();
102102

103103
List<String> logList = insertMockLoggerInListener(amqpChannel);
104-
MessageListener listener = (MessageListener) container.getMessageListener();
104+
MessageListener listener = container.getMessageListener();
105105
listener.onMessage(new Message("Hello world!".getBytes()));
106106
verifyLogReceived(logList);
107107
}

Diff for: spring-integration-core/src/main/java/org/springframework/integration/util/SimplePool.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ private static class PoolSemaphore extends Semaphore {
280280
}
281281

282282
@Override
283-
public void reducePermits(int reduction) { // NOSONAR increases visibility
284-
super.reducePermits(reduction > availablePermits() ? availablePermits() : reduction);
283+
public void reducePermits(int reduction) {
284+
super.reducePermits(Math.min(reduction, availablePermits()));
285285
}
286286

287287
}

Diff for: spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencerTests.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -17,7 +17,7 @@
1717
package org.springframework.integration.aggregator;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20-
import static org.assertj.core.api.Assertions.fail;
20+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2121
import static org.mockito.Mockito.mock;
2222

2323
import java.util.ArrayList;
@@ -200,13 +200,9 @@ public void testResequencingWithCapacity() {
200200
Message<?> message3 = createMessage("789", "ABC", 4, 1, replyChannel);
201201
this.resequencer.handleMessage(message1);
202202
this.resequencer.handleMessage(message2);
203-
try {
204-
this.resequencer.handleMessage(message3);
205-
fail("Expected exception");
206-
}
207-
catch (MessagingException e) {
208-
assertThat(e.getMessage()).contains("out of capacity (2) for group 'ABC'");
209-
}
203+
assertThatExceptionOfType(MessagingException.class)
204+
.isThrownBy(() -> this.resequencer.handleMessage(message3))
205+
.withStackTraceContaining("out of capacity (2) for group 'ABC'");
210206
}
211207

212208
@Test

Diff for: spring-integration-core/src/test/java/org/springframework/integration/channel/reactive/ReactiveStreamsConsumerTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 the original author or authors.
2+
* Copyright 2016-2022 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.
@@ -100,7 +100,7 @@ public void testReactiveStreamsConsumerFluxMessageChannel() throws InterruptedEx
100100
assertThatExceptionOfType(MessageDeliveryException.class)
101101
.isThrownBy(() -> testChannel.send(testMessage))
102102
.withCauseInstanceOf(IllegalStateException.class)
103-
.withMessageContaining("doesn't have subscribers to accept messages");
103+
.withStackTraceContaining("doesn't have subscribers to accept messages");
104104

105105
reactiveConsumer.start();
106106

@@ -279,7 +279,7 @@ public void testReactiveStreamsConsumerViaConsumerEndpointFactoryBean() throws E
279279
assertThatExceptionOfType(MessageDeliveryException.class)
280280
.isThrownBy(() -> testChannel.send(testMessage))
281281
.withCauseInstanceOf(IllegalStateException.class)
282-
.withMessageContaining("doesn't have subscribers to accept messages");
282+
.withStackTraceContaining("doesn't have subscribers to accept messages");
283283

284284
endpointFactoryBean.start();
285285

@@ -321,7 +321,7 @@ public void testReactiveStreamsConsumerFluxMessageChannelReactiveMessageHandler(
321321
assertThatExceptionOfType(MessageDeliveryException.class)
322322
.isThrownBy(() -> testChannel.send(testMessage))
323323
.withCauseInstanceOf(IllegalStateException.class)
324-
.withMessageContaining("doesn't have subscribers to accept messages");
324+
.withStackTraceContaining("doesn't have subscribers to accept messages");
325325

326326
reactiveConsumer.start();
327327

Diff for: spring-integration-core/src/test/java/org/springframework/integration/channel/registry/HeaderChannelRegistryTests.java

+21-38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2019 the original author or authors.
2+
* Copyright 2013-2022 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.
@@ -17,15 +17,14 @@
1717
package org.springframework.integration.channel.registry;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20-
import static org.assertj.core.api.Assertions.fail;
20+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2121
import static org.mockito.Mockito.doAnswer;
2222
import static org.mockito.Mockito.mock;
2323
import static org.mockito.Mockito.when;
2424

2525
import java.util.Map;
2626

27-
import org.junit.Test;
28-
import org.junit.runner.RunWith;
27+
import org.junit.jupiter.api.Test;
2928

3029
import org.springframework.beans.factory.BeanFactory;
3130
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -49,8 +48,7 @@
4948
import org.springframework.messaging.support.GenericMessage;
5049
import org.springframework.scheduling.TaskScheduler;
5150
import org.springframework.test.annotation.DirtiesContext;
52-
import org.springframework.test.context.ContextConfiguration;
53-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
51+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
5452

5553
/**
5654
* @author Gary Russell
@@ -59,8 +57,7 @@
5957
* @since 3.0
6058
*
6159
*/
62-
@ContextConfiguration
63-
@RunWith(SpringJUnit4ClassRunner.class)
60+
@SpringJUnitConfig
6461
@DirtiesContext
6562
public class HeaderChannelRegistryTests {
6663

@@ -95,7 +92,7 @@ public class HeaderChannelRegistryTests {
9592
public void testReplace() {
9693
MessagingTemplate template = new MessagingTemplate();
9794
template.setDefaultDestination(this.input);
98-
Message<?> reply = template.sendAndReceive(new GenericMessage<String>("foo"));
95+
Message<?> reply = template.sendAndReceive(new GenericMessage<>("foo"));
9996
assertThat(reply).isNotNull();
10097
assertThat(reply.getPayload()).isEqualTo("echo:foo");
10198
String stringReplyChannel = reply.getHeaders().get("stringReplyChannel", String.class);
@@ -109,7 +106,7 @@ public void testReplace() {
109106
public void testReplaceTtl() {
110107
MessagingTemplate template = new MessagingTemplate();
111108
template.setDefaultDestination(this.inputTtl);
112-
Message<?> reply = template.sendAndReceive(new GenericMessage<String>("ttl"));
109+
Message<?> reply = template.sendAndReceive(new GenericMessage<>("ttl"));
113110
assertThat(reply).isNotNull();
114111
assertThat(reply.getPayload()).isEqualTo("echo:ttl");
115112
String stringReplyChannel = reply.getHeaders().get("stringReplyChannel", String.class);
@@ -135,7 +132,7 @@ public void testReplaceCustomTtl() {
135132
.get(stringReplyChannel), "expireAt", Long.class) - System.currentTimeMillis())
136133
.isGreaterThan(160000L).isLessThan(181000L);
137134
// Now for Elvis...
138-
reply = template.sendAndReceive(new GenericMessage<String>("ttl"));
135+
reply = template.sendAndReceive(new GenericMessage<>("ttl"));
139136
assertThat(reply).isNotNull();
140137
assertThat(reply.getPayload()).isEqualTo("echo:ttl");
141138
stringReplyChannel = reply.getHeaders().get("stringReplyChannel", String.class);
@@ -167,7 +164,7 @@ public void testReplaceGatewayWithExplicitReplyChannel() {
167164
public void testReplaceError() {
168165
MessagingTemplate template = new MessagingTemplate();
169166
template.setDefaultDestination(this.inputPolled);
170-
Message<?> reply = template.sendAndReceive(new GenericMessage<String>("bar"));
167+
Message<?> reply = template.sendAndReceive(new GenericMessage<>("bar"));
171168
assertThat(reply).isNotNull();
172169
assertThat(reply instanceof ErrorMessage).isTrue();
173170
assertThat(((ErrorMessage) reply).getOriginalMessage()).isNotNull();
@@ -188,15 +185,9 @@ public void testAlreadyAString() {
188185

189186
@Test
190187
public void testNull() {
191-
Message<String> requestMessage = MessageBuilder.withPayload("foo")
192-
.build();
193-
try {
194-
this.input.send(requestMessage);
195-
fail("expected exception");
196-
}
197-
catch (Exception e) {
198-
assertThat(e.getMessage()).contains("no output-channel or replyChannel");
199-
}
188+
assertThatExceptionOfType(Exception.class)
189+
.isThrownBy(() -> this.input.send(new GenericMessage<>("test")))
190+
.withStackTraceContaining("no output-channel or replyChannel");
200191
}
201192

202193
@Test
@@ -223,14 +214,10 @@ public void testBFCRWithRegistry() {
223214
throw new NoSuchBeanDefinitionException("bar");
224215
}).when(beanFactory).getBean("foo", MessageChannel.class);
225216
resolver.setBeanFactory(beanFactory);
226-
try {
227-
resolver.resolveDestination("foo");
228-
fail("Expected exception");
229-
}
230-
catch (DestinationResolutionException e) {
231-
assertThat(e.getMessage()).contains("failed to look up MessageChannel with name 'foo' in the BeanFactory" +
232-
".");
233-
}
217+
218+
assertThatExceptionOfType(DestinationResolutionException.class)
219+
.isThrownBy(() -> resolver.resolveDestination("foo"))
220+
.withMessageContaining("failed to look up MessageChannel with name 'foo' in the BeanFactory.");
234221
}
235222

236223
@Test
@@ -241,15 +228,11 @@ public void testBFCRNoRegistry() {
241228
throw new NoSuchBeanDefinitionException("bar");
242229
}).when(beanFactory).getBean("foo", MessageChannel.class);
243230
resolver.setBeanFactory(beanFactory);
244-
try {
245-
resolver.resolveDestination("foo");
246-
fail("Expected exception");
247-
}
248-
catch (DestinationResolutionException e) {
249-
assertThat(e.getMessage()).contains("failed to look up MessageChannel with name 'foo' in the BeanFactory" +
250-
" " +
251-
"(and there is no HeaderChannelRegistry present).");
252-
}
231+
232+
assertThatExceptionOfType(DestinationResolutionException.class)
233+
.isThrownBy(() -> resolver.resolveDestination("foo"))
234+
.withMessageContaining("failed to look up MessageChannel with name 'foo' in the BeanFactory" +
235+
" (and there is no HeaderChannelRegistry present).");
253236
}
254237

255238
@Test

Diff for: spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java

+12-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -17,7 +17,7 @@
1717
package org.springframework.integration.config;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20-
import static org.assertj.core.api.Assertions.fail;
20+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2121

2222
import java.time.Duration;
2323
import java.util.ArrayList;
@@ -217,24 +217,17 @@ public void testSimpleJavaBeanAggregator() {
217217

218218
@Test
219219
public void testMissingMethodOnAggregator() {
220-
try {
221-
new ClassPathXmlApplicationContext("invalidMethodNameAggregator.xml", this.getClass()).close();
222-
fail("Expected exception");
223-
}
224-
catch (BeanCreationException e) {
225-
assertThat(e.getMessage()).contains("Adder] has no eligible methods");
226-
}
220+
assertThatExceptionOfType(BeanCreationException.class)
221+
.isThrownBy(() -> new ClassPathXmlApplicationContext("invalidMethodNameAggregator.xml", getClass()))
222+
.withStackTraceContaining("Adder] has no eligible methods");
227223
}
228224

229225
@Test
230226
public void testMissingReleaseStrategyDefinition() {
231-
try {
232-
new ClassPathXmlApplicationContext("ReleaseStrategyMethodWithMissingReference.xml", this.getClass()).close();
233-
fail("Expected exception");
234-
}
235-
catch (BeanCreationException e) {
236-
assertThat(e.getMessage()).contains("No bean named 'testReleaseStrategy' available");
237-
}
227+
assertThatExceptionOfType(BeanCreationException.class)
228+
.isThrownBy(() -> new ClassPathXmlApplicationContext("ReleaseStrategyMethodWithMissingReference.xml",
229+
getClass()))
230+
.withStackTraceContaining("No bean named 'testReleaseStrategy' available");
238231
}
239232

240233
@Test
@@ -289,13 +282,9 @@ public void testAggregatorWithPojoReleaseStrategyAsCollection() {
289282

290283
@Test
291284
public void testAggregatorWithInvalidReleaseStrategyMethod() {
292-
try {
293-
new ClassPathXmlApplicationContext("invalidReleaseStrategyMethod.xml", this.getClass()).close();
294-
fail("Expected exception");
295-
}
296-
catch (BeanCreationException e) {
297-
assertThat(e.getMessage()).contains("TestReleaseStrategy] has no eligible methods");
298-
}
285+
assertThatExceptionOfType(BeanCreationException.class)
286+
.isThrownBy(() -> new ClassPathXmlApplicationContext("invalidReleaseStrategyMethod.xml", getClass()))
287+
.withStackTraceContaining("TestReleaseStrategy] has no eligible methods");
299288
}
300289

301290
@Test

Diff for: spring-integration-core/src/test/java/org/springframework/integration/config/CorrelationStrategyInvalidConfigurationTests.java

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -16,28 +16,26 @@
1616

1717
package org.springframework.integration.config;
1818

19-
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2020

21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

2323
import org.springframework.beans.factory.BeanCreationException;
2424
import org.springframework.context.support.ClassPathXmlApplicationContext;
2525

2626
/**
2727
* @author Marius Bogoevici
2828
* @author Gary Russell
29+
* @author Artem Bilan
2930
*/
3031
public class CorrelationStrategyInvalidConfigurationTests {
3132

3233
@Test
3334
public void testCorrelationStrategyWithVoidReturningMethods() throws Exception {
34-
try {
35-
new ClassPathXmlApplicationContext("correlationStrategyWithVoidMethods.xml",
36-
CorrelationStrategyInvalidConfigurationTests.class).close();
37-
}
38-
catch (BeanCreationException e) {
39-
assertThat(e.getMessage()).contains("MessageCountReleaseStrategy] has no eligible methods");
40-
}
35+
assertThatExceptionOfType(BeanCreationException.class)
36+
.isThrownBy(() -> new ClassPathXmlApplicationContext("correlationStrategyWithVoidMethods.xml",
37+
getClass()))
38+
.withStackTraceContaining("MessageCountReleaseStrategy] has no eligible methods");
4139
}
4240

4341
public static class VoidReturningCorrelationStrategy {

0 commit comments

Comments
 (0)