Skip to content

Commit d050010

Browse files
committed
Start version 7.0
* Upgrade to the latest dependencies, including Spring Boot 4.0 * Spring Boot 4.0 has split an auto-configuration modules to many much smaller. Therefore, we have to include specific starter or that module in some places * Migrate JUnit 4 tests to JUnit Jupiter * Fix JPA 3.2 deprecations * Fix WebSocket samples to add required `handshakeHandler` bean
1 parent 405053f commit d050010

File tree

44 files changed

+525
-616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+525
-616
lines changed

advanced/advanced-testing-examples/src/test/java/org/springframework/integration/samples/advance/testing/jms/JmsMockTests.java

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,17 @@
1616

1717
package org.springframework.integration.samples.advance.testing.jms;
1818

19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertTrue;
21-
import static org.mockito.ArgumentMatchers.isNull;
22-
import static org.mockito.BDDMockito.willAnswer;
23-
import static org.mockito.BDDMockito.willReturn;
24-
import static org.mockito.Mockito.mock;
25-
2619
import java.io.IOException;
2720
import java.util.concurrent.CountDownLatch;
2821
import java.util.concurrent.TimeUnit;
2922
import java.util.concurrent.atomic.AtomicReference;
3023

24+
import jakarta.jms.JMSException;
25+
import jakarta.jms.TextMessage;
3126
import org.apache.commons.logging.Log;
3227
import org.apache.commons.logging.LogFactory;
33-
import org.junit.Before;
34-
import org.junit.Test;
35-
import org.junit.runner.RunWith;
28+
import org.junit.jupiter.api.BeforeEach;
29+
import org.junit.jupiter.api.Test;
3630
import org.mockito.Mockito;
3731
import org.mockito.stubbing.Answer;
3832

@@ -49,18 +43,21 @@
4943
import org.springframework.test.annotation.DirtiesContext;
5044
import org.springframework.test.annotation.DirtiesContext.ClassMode;
5145
import org.springframework.test.context.ContextConfiguration;
52-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
46+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
5347

54-
import jakarta.jms.JMSException;
55-
import jakarta.jms.TextMessage;
48+
import static org.assertj.core.api.Assertions.assertThat;
49+
import static org.mockito.ArgumentMatchers.isNull;
50+
import static org.mockito.BDDMockito.willAnswer;
51+
import static org.mockito.BDDMockito.willReturn;
52+
import static org.mockito.Mockito.mock;
5653

5754
/**
5855
* @author David Turanski
5956
* @author Gunnar Hillert
6057
* @author Gary Russell
6158
* @author Artem Bilan
6259
*/
63-
@RunWith(SpringJUnit4ClassRunner.class)
60+
@SpringJUnitConfig
6461
@ContextConfiguration
6562
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
6663
public class JmsMockTests {
@@ -87,8 +84,7 @@ public class JmsMockTests {
8784
@Qualifier("invalidMessageChannel")
8885
private SubscribableChannel invalidMessageChannel;
8986

90-
91-
@Before
87+
@BeforeEach
9288
public void setup() throws JMSException {
9389
Mockito.reset(this.mockJmsTemplate);
9490
TextMessage message = mock(TextMessage.class);
@@ -99,18 +95,13 @@ public void setup() throws JMSException {
9995
willReturn(message)
10096
.given(this.mockJmsTemplate).receiveSelected(isNull());
10197

102-
10398
willAnswer((Answer<String>) invocation -> testMessageHolder.get())
10499
.given(message).getText();
105100
}
106101

107102
/**
108103
* This test verifies that a message received on a polling JMS inbound channel adapter is
109104
* routed to the designated channel and that the message payload is as expected
110-
*
111-
* @throws JMSException
112-
* @throws InterruptedException
113-
* @throws IOException
114105
*/
115106
@Test
116107
public void testReceiveMessage() throws JMSException, InterruptedException, IOException {
@@ -120,20 +111,16 @@ public void testReceiveMessage() throws JMSException, InterruptedException, IOEx
120111

121112
@Override
122113
protected void verifyMessage(Message<?> message) {
123-
assertEquals("hello", message.getPayload());
114+
assertThat(message.getPayload()).isEqualTo("hello");
124115
}
125116
}
126117
);
127-
assertTrue("message not sent to expected output channel", sent);
118+
assertThat(sent).as("message not sent to expected output channel").isTrue();
128119
}
129120

130121
/**
131122
* This test verifies that a message received on a polling JMS inbound channel adapter is
132123
* routed to the errorChannel and that the message payload is the expected exception
133-
*
134-
* @throws JMSException
135-
* @throws IOException
136-
* @throws InterruptedException
137124
*/
138125
@Test
139126
public void testReceiveInvalidMessage() throws JMSException, IOException, InterruptedException {
@@ -142,12 +129,12 @@ public void testReceiveInvalidMessage() throws JMSException, IOException, Interr
142129

143130
@Override
144131
protected void verifyMessage(Message<?> message) {
145-
assertEquals("invalid payload", message.getPayload());
132+
assertThat(message.getPayload()).isEqualTo("invalid payload");
146133
}
147134

148135
}
149136
);
150-
assertTrue("message not sent to expected output channel", sent);
137+
assertThat(sent).as("message not sent to expected output channel").isTrue();
151138
}
152139

153140
/**
@@ -157,15 +144,13 @@ protected void verifyMessage(Message<?> message) {
157144
* @param expectedOutputChannel The expected output channel
158145
* @param handler An instance of CountDownHandler to handle (verify) the output message
159146
* @return true if the message was received on the expected channel
160-
* @throws JMSException
161-
* @throws InterruptedException
162147
*/
163148
protected boolean verifyJmsMessageReceivedOnOutputChannel(Object obj, SubscribableChannel expectedOutputChannel,
164149
CountDownHandler handler) throws InterruptedException {
150+
165151
return verifyJmsMessageOnOutputChannel(obj, expectedOutputChannel, handler, 10000);
166152
}
167153

168-
169154
/**
170155
* Provide a message via a mock JMS template and wait for the specified timeout to receive the message
171156
* on the expected channel
@@ -176,8 +161,6 @@ protected boolean verifyJmsMessageReceivedOnOutputChannel(Object obj, Subscribab
176161
* to process the entire flow. Only set if the default is
177162
* not long enough
178163
* @return true if the message was received on the expected channel
179-
* @throws JMSException
180-
* @throws InterruptedException
181164
*/
182165
protected boolean verifyJmsMessageOnOutputChannel(Object obj, SubscribableChannel expectedOutputChannel,
183166
CountDownHandler handler, int timeoutMillisec) throws InterruptedException {
@@ -195,7 +178,6 @@ protected boolean verifyJmsMessageOnOutputChannel(Object obj, SubscribableChanne
195178
CountDownLatch latch = new CountDownLatch(1);
196179
handler.setLatch(latch);
197180

198-
199181
expectedOutputChannel.subscribe(handler);
200182

201183
this.jmsInboundChannelAdapter.start();
@@ -213,7 +195,7 @@ protected boolean verifyJmsMessageOnOutputChannel(Object obj, SubscribableChanne
213195
/*
214196
* A MessageHandler that uses a CountDownLatch to synchronize with the calling thread
215197
*/
216-
private abstract class CountDownHandler implements MessageHandler {
198+
private abstract static class CountDownHandler implements MessageHandler {
217199

218200
CountDownLatch latch;
219201

advanced/dynamic-tcp-client/src/test/java/org/springframework/integration/samples/dynamictcp/DynamicTcpClientApplicationTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package org.springframework.integration.samples.dynamictcp;
22

3-
import org.junit.Test;
4-
import org.junit.runner.RunWith;
3+
import org.junit.jupiter.api.Test;
4+
55
import org.springframework.boot.test.context.SpringBootTest;
6-
import org.springframework.test.context.junit4.SpringRunner;
76

8-
@RunWith(SpringRunner.class)
97
@SpringBootTest
108
public class DynamicTcpClientApplicationTests {
119

applications/cafe/cafe-si/src/main/java/org/springframework/integration/samples/cafe/Delivery.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,37 @@
1616

1717
package org.springframework.integration.samples.cafe;
1818

19+
import java.io.Serial;
1920
import java.io.Serializable;
21+
import java.util.ArrayList;
2022
import java.util.List;
2123

2224
/**
2325
* @author Marius Bogoevici
2426
* @author Tom McCuch
2527
* @author Gunnar Hillert
28+
* @author Artem Bilan
2629
*/
27-
public class Delivery implements Serializable{
30+
public class Delivery implements Serializable {
2831

32+
@Serial
2933
private static final long serialVersionUID = 1L;
3034

3135
private static final String SEPARATOR = "-----------------------";
3236

33-
private List<Drink> deliveredDrinks;
37+
private ArrayList<Drink> deliveredDrinks;
3438

3539
private int orderNumber;
3640

3741
// Default constructor required by Jackson Java JSON-processor
38-
public Delivery() {}
42+
public Delivery() {
43+
}
3944

4045
public Delivery(List<Drink> deliveredDrinks) {
41-
assert(deliveredDrinks.size() > 0);
42-
this.deliveredDrinks = deliveredDrinks;
46+
this.deliveredDrinks = new ArrayList<>(deliveredDrinks);
4347
this.orderNumber = deliveredDrinks.get(0).getOrderNumber();
4448
}
4549

46-
4750
public int getOrderNumber() {
4851
return orderNumber;
4952
}
@@ -57,13 +60,13 @@ public List<Drink> getDeliveredDrinks() {
5760
}
5861

5962
public void setDeliveredDrinks(List<Drink> deliveredDrinks) {
60-
this.deliveredDrinks = deliveredDrinks;
63+
this.deliveredDrinks = new ArrayList<>(deliveredDrinks);
6164
}
6265

6366
@Override
6467
public String toString() {
65-
StringBuffer buffer = new StringBuffer(SEPARATOR + "\n");
66-
buffer.append("Order #" + getOrderNumber() + "\n");
68+
StringBuilder buffer = new StringBuilder(SEPARATOR + "\n");
69+
buffer.append("Order #").append(getOrderNumber()).append("\n");
6770
for (Drink drink : getDeliveredDrinks()) {
6871
buffer.append(drink);
6972
buffer.append("\n");

applications/cafe/cafe-si/src/main/java/org/springframework/integration/samples/cafe/Order.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.integration.samples.cafe;
1818

19+
import java.io.Serial;
1920
import java.io.Serializable;
2021
import java.util.ArrayList;
2122
import java.util.List;
@@ -25,18 +26,21 @@
2526
* @author Marius Bogoevici
2627
* @author Tom McCuch
2728
* @author Gunnar Hillert
29+
* @author Artem Bilan
2830
*/
29-
public class Order implements Serializable{
31+
public class Order implements Serializable {
3032

33+
@Serial
3134
private static final long serialVersionUID = 1L;
3235

33-
private List<OrderItem> orderItems = new ArrayList<OrderItem>();
36+
private ArrayList<OrderItem> orderItems = new ArrayList<>();
3437

3538
/** the order number used for tracking */
3639
private int number;
3740

3841
// Default constructor required by Jackson Java JSON-processor
39-
public Order() {}
42+
public Order() {
43+
}
4044

4145
public Order(int number) {
4246
this.number = number;
@@ -59,6 +63,7 @@ public List<OrderItem> getItems() {
5963
}
6064

6165
public void setItems(List<OrderItem> orderItems) {
62-
this.orderItems = orderItems;
66+
this.orderItems = new ArrayList<>(orderItems);
6367
}
68+
6469
}

applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.springframework.beans.factory.annotation.Autowired;
2727
import org.springframework.boot.SpringApplication;
2828
import org.springframework.boot.autoconfigure.SpringBootApplication;
29-
import org.springframework.boot.autoconfigure.mail.MailProperties;
29+
import org.springframework.boot.mail.autoconfigure.MailProperties;
3030
import org.springframework.context.annotation.Bean;
3131
import org.springframework.integration.dsl.IntegrationFlow;
3232
import org.springframework.integration.dsl.Pollers;

applications/loanshark/src/main/resources/META-INF/persistence.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence https://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
33
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
4-
<provider>org.hibernate.ejb.HibernatePersistence</provider>
54
<properties>
65
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
76
<!--value='create' to build a new database on each run; value='update' to modify an existing database; value='create-drop' means the same as 'create' but also drops tables when Hibernate closes; value='validate' makes no changes to the database-->
Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jee https://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd">
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:context="http://www.springframework.org/schema/context"
4+
xmlns:tx="http://www.springframework.org/schema/tx"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd">
7+
38
<import resource="integrationContext.xml"/>
4-
<!--
9+
<!--
510
This will automatically locate any and all property files you have
611
within your classpath, provided they fall under the META-INF/spring
712
directory. The located property files are parsed and their values can
813
then be used within application context files in the form of
914
${propertyKey}.
1015
-->
11-
<context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
12-
<!--
16+
<context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
17+
<!--
1318
Turn on AspectJ @Configurable support. As a result, any time you
1419
instantiate an object, Spring will attempt to perform dependency
1520
injection on that object. This occurs for instantiation via the "new"
@@ -22,8 +27,8 @@
2227
method). Roo applications use this useful feature in a number of
2328
areas, such as @PersistenceContext injection into entities.
2429
-->
25-
<context:spring-configured/>
26-
<!--
30+
<context:spring-configured/>
31+
<!--
2732
This declaration will cause Spring to locate every @Component,
2833
@Repository and @Service in your application. In practical terms this
2934
allows you to write a POJO and then simply annotate the new POJO as an
@@ -44,22 +49,31 @@
4449
The most commonly used annotation is @Autowired, which instructs Spring to
4550
dependency inject an object into your class.
4651
-->
47-
<context:component-scan base-package="org.springframework.integration.samples.loanbroker.loanshark">
48-
<context:exclude-filter expression=".*_Roo_.*" type="regex"/>
49-
<context:exclude-filter expression=".*TestAccumulator.*" type="regex"/>
50-
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
51-
</context:component-scan>
52-
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
53-
<property name="driverClassName" value="${database.driverClassName}"/>
54-
<property name="url" value="${database.url}"/>
55-
<property name="username" value="${database.username}"/>
56-
<property name="password" value="${database.password}"/>
57-
</bean>
58-
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
59-
<property name="entityManagerFactory" ref="entityManagerFactory"/>
60-
</bean>
61-
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
62-
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
63-
<property name="dataSource" ref="dataSource"/>
64-
</bean>
52+
<context:component-scan base-package="org.springframework.integration.samples.loanbroker.loanshark">
53+
<context:exclude-filter expression=".*_Roo_.*" type="regex"/>
54+
<context:exclude-filter expression=".*TestAccumulator.*" type="regex"/>
55+
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
56+
</context:component-scan>
57+
58+
<bean class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close" id="dataSource">
59+
<property name="driverClassName" value="${database.driverClassName}"/>
60+
<property name="url" value="${database.url}"/>
61+
<property name="username" value="${database.username}"/>
62+
<property name="password" value="${database.password}"/>
63+
</bean>
64+
65+
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
66+
<property name="entityManagerFactory" ref="entityManagerFactory"/>
67+
</bean>
68+
69+
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
70+
71+
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
72+
<property name="dataSource" ref="dataSource"/>
73+
<property name="persistenceUnitName" value="persistenceUnit"/>
74+
<property name="jpaVendorAdapter">
75+
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
76+
</property>
77+
</bean>
78+
6579
</beans>

0 commit comments

Comments
 (0)