GH-9996: Migrating tests to Junit Jupiter and Deprecate Junit4 utilities

Fixes: https://github.com/spring-projects/spring-integration/issues/9996

Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
This commit is contained in:
Jiandong
2025-06-09 23:46:42 +08:00
committed by GitHub
parent bf9d3910cb
commit d229cb4930
54 changed files with 396 additions and 287 deletions

View File

@@ -299,9 +299,6 @@ configure(javaProjects) { subproject ->
testImplementation("org.awaitility:awaitility:$awaitilityVersion") {
exclude group: 'org.hamcrest'
}
testImplementation("junit:junit:$junit4Version") {
exclude group: 'org.hamcrest'
}
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
testImplementation("com.willowtreeapps.assertk:assertk-jvm:$assertkVersion") {
@@ -314,8 +311,6 @@ configure(javaProjects) { subproject ->
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
// To support JUnit 4 tests
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
testRuntimeOnly 'org.apache.logging.log4j:log4j-core'
testRuntimeOnly 'org.apache.logging.log4j:log4j-jcl'

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,7 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import org.springframework.integration.test.predicate.MessagePredicate;
import org.springframework.integration.test.support.AbstractRequestResponseScenarioTests;
import org.springframework.integration.test.support.AbstractRequestResponseScenarioTest;
import org.springframework.integration.test.support.MessageValidator;
import org.springframework.integration.test.support.PayloadValidator;
import org.springframework.integration.test.support.RequestResponseScenario;
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ContextConfiguration
@DirtiesContext
public class MessageScenariosTests extends AbstractRequestResponseScenarioTests {
public class MessageScenariosTests extends AbstractRequestResponseScenarioTest {
@Override
protected List<RequestResponseScenario> defineRequestResponseScenarios() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -18,7 +18,7 @@ package org.springframework.integration.support;
import org.springframework.integration.test.support.PayloadValidator;
import org.springframework.integration.test.support.RequestResponseScenario;
import org.springframework.integration.test.support.SingleRequestResponseScenarioTests;
import org.springframework.integration.test.support.SingleRequestResponseScenarioTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ContextConfiguration("MessageScenariosTests-context.xml")
@DirtiesContext
public class SingleScenarioTests extends SingleRequestResponseScenarioTests {
public class SingleScenarioTests extends SingleRequestResponseScenarioTest {
@Override
protected RequestResponseScenario defineRequestResponseScenario() {

View File

@@ -19,11 +19,8 @@
directory="#{inputDirectory.path}"
channel="fileMessages" filter="compositeFilter"/>
<bean id="temp" class="org.junit.rules.TemporaryFolder"
init-method="create" destroy-method="delete"/>
<bean id="inputDirectory" class="java.io.File">
<constructor-arg value="#{temp.newFolder('FileToChannelIntegrationTests').path}"/>
<constructor-arg value="#{T(org.springframework.integration.file.FileToChannelIntegrationTests).tempDir.path}"/>
</bean>
<si:channel id="fileMessages">

View File

@@ -19,6 +19,7 @@ package org.springframework.integration.file;
import java.io.File;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
@@ -37,6 +38,9 @@ import static org.assertj.core.api.Assertions.assertThat;
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class FileToChannelIntegrationTests {
@TempDir
public static File tempDir;
@Autowired
File inputDirectory;

View File

@@ -11,17 +11,19 @@
https://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
<!-- under test -->
<file:inbound-channel-adapter id="customLockingAdapter" directory="#{directory.root}">
<file:inbound-channel-adapter id="customLockingAdapter" directory="#{directory}">
<file:locker ref="customLocker"/>
</file:inbound-channel-adapter>
<file:inbound-channel-adapter id="nioLockingAdapter" directory="#{directory.root}">
<file:inbound-channel-adapter id="nioLockingAdapter" directory="#{directory}">
<file:nio-locker/>
</file:inbound-channel-adapter>
<bean id="customLocker" class="org.springframework.integration.file.locking.FileLockingNamespaceTests$StubLocker"/>
<bean id="directory" class="org.junit.rules.TemporaryFolder" init-method="create" destroy-method="delete"/>
<bean id="directory" class="java.io.File">
<constructor-arg value="#{T(org.springframework.integration.file.locking.FileLockingNamespaceTests).tempDir.path}"/>
</bean>
<si:poller default="true" fixed-delay="100000000"/>

View File

@@ -20,6 +20,7 @@ import java.io.File;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +42,9 @@ import static org.assertj.core.api.Assertions.assertThat;
@DirtiesContext
public class FileLockingNamespaceTests {
@TempDir
public static File tempDir;
@Autowired
@Qualifier("nioLockingAdapter.adapter")
SourcePollingChannelAdapter nioAdapter;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.management.MBeanServer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.jmx.support.MBeanServerFactoryBean;
import org.springframework.jmx.support.ObjectNameManager;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2025 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.
@@ -21,9 +21,9 @@ import java.util.Map;
import javax.management.MBeanServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.jmx.support.MBeanServerFactoryBean;
@@ -40,7 +40,7 @@ public class MBeanTreePollingMessageSourceTests {
private static MBeanServer server;
@BeforeClass
@BeforeAll
public static void setup() {
factoryBean = new MBeanServerFactoryBean();
factoryBean.setLocateExistingServerIfPossible(true);
@@ -48,7 +48,7 @@ public class MBeanTreePollingMessageSourceTests {
server = factoryBean.getObject();
}
@AfterClass
@AfterAll
public static void tearDown() {
factoryBean.destroy();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -22,11 +22,11 @@ import javax.management.MBeanServer;
import javax.management.Notification;
import javax.management.ObjectName;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanFactory;
@@ -59,13 +59,13 @@ public class NotificationListeningMessageProducerTests {
private ObjectName objectName;
@BeforeClass
@BeforeAll
public static void setupClass() {
serverFactoryBean = new MBeanServerFactoryBean();
serverFactoryBean.afterPropertiesSet();
}
@Before
@BeforeEach
public void setup() throws Exception {
this.server = serverFactoryBean.getObject();
MBeanExporter exporter = new MBeanExporter();
@@ -75,12 +75,12 @@ public class NotificationListeningMessageProducerTests {
exporter.registerManagedResource(this.numberHolder, this.objectName);
}
@After
@AfterEach
public void cleanup() throws Exception {
this.server.unregisterMBean(this.objectName);
}
@AfterClass
@AfterAll
public static void tearDown() {
serverFactoryBean.destroy();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,9 +23,9 @@ import javax.management.Notification;
import javax.management.NotificationListener;
import javax.management.ObjectName;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -54,7 +54,7 @@ public class NotificationPublishingMessageHandlerTests {
private volatile ObjectName publisherObjectName;
@Before
@BeforeEach
public void setup() throws Exception {
this.publisherObjectName = ObjectNameManager.getInstance("test:type=publisher");
this.context.registerBean("mbeanServer", MBeanServerFactoryBean.class, MBeanServerFactoryBean::new);
@@ -72,7 +72,7 @@ public class NotificationPublishingMessageHandlerTests {
exporter.getServer().addNotificationListener(publisherObjectName, this.listener, null, null);
}
@After
@AfterEach
public void cleanup() {
this.listener.clearNotifications();
context.close();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,11 +23,11 @@ import java.util.Map;
import javax.management.MBeanServer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.channel.QueueChannel;
@@ -39,6 +39,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.mock;
/**
@@ -61,24 +62,24 @@ public class OperationInvokingMessageHandlerTests {
private final String objectName = "si:name=test";
@BeforeClass
@BeforeAll
public static void setupClass() {
factoryBean = new MBeanServerFactoryBean();
factoryBean.afterPropertiesSet();
server = factoryBean.getObject();
}
@AfterClass
@AfterAll
public static void tearDown() {
factoryBean.destroy();
}
@Before
@BeforeEach
public void setup() throws Exception {
server.registerMBean(new TestOps(), ObjectNameManager.getInstance(this.objectName));
}
@After
@AfterEach
public void cleanup() throws Exception {
server.unregisterMBean(ObjectNameManager.getInstance(this.objectName));
}
@@ -115,7 +116,7 @@ public class OperationInvokingMessageHandlerTests {
handler.handleMessage(message);
}
@Test(expected = MessagingException.class)
@Test
public void invocationWithMapPayloadNotEnoughParameters() {
QueueChannel outputChannel = new QueueChannel();
OperationInvokingMessageHandler handler = new OperationInvokingMessageHandler(server);
@@ -127,10 +128,8 @@ public class OperationInvokingMessageHandlerTests {
Map<String, Object> params = new HashMap<>();
params.put("p1", "foo");
Message<?> message = MessageBuilder.withPayload(params).build();
handler.handleMessage(message);
Message<?> reply = outputChannel.receive(0);
assertThat(reply).isNotNull();
assertThat(reply.getPayload()).isEqualTo("foobar");
assertThatExceptionOfType(MessagingException.class)
.isThrownBy(() -> handler.handleMessage(message));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,8 +16,7 @@
package org.springframework.integration.jmx.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -27,8 +26,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
@@ -38,8 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class AttributePollingChannelAdapterParserTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,15 +16,14 @@
package org.springframework.integration.jmx.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.messaging.MessageChannel;
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;
@@ -35,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.0
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ControlBusParserTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2025 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,7 @@ import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,8 +38,7 @@ import org.springframework.integration.support.management.IntegrationManagedReso
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
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 org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;
@@ -51,8 +49,7 @@ import static org.mockito.Mockito.mock;
* @author Gary Russell
* @since 4.2.1
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class CustomObjectNameTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -19,9 +19,8 @@ package org.springframework.integration.jmx.config;
import java.util.HashMap;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -31,8 +30,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;
@@ -41,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class DynamicRouterTests {
@@ -119,7 +116,7 @@ public class DynamicRouterTests {
@Test
@DirtiesContext
@Ignore
@Disabled
public void testPerf() throws Exception {
// this.nullChannel.enableStats(false);
for (int i = 0; i < 1000000000; i++) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -21,8 +21,8 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -40,7 +40,7 @@ public class MBeanAutoDetectTests {
private ClassPathXmlApplicationContext context;
@After
@AfterEach
public void close() {
if (context != null) {
context.close();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,7 +16,8 @@
package org.springframework.integration.jmx.config;
import org.junit.Test;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -27,9 +28,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class MBeanExporterNameTests {
@Test(expected = BeanDefinitionParsingException.class)
public void testHandlerMBeanRegistration() throws Exception {
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()).close();
@Test
public void testHandlerMBeanRegistration() {
Assertions.assertThatExceptionOfType(BeanDefinitionParsingException.class)
.isThrownBy(() -> new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()));
}
public static class Source {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2024 the original author or authors.
* Copyright 2013-2025 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.
@@ -22,15 +22,13 @@ import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jmx.export.naming.KeyNamingStrategy;
import org.springframework.jmx.export.naming.ObjectNamingStrategy;
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 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 3.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MBeanRegistrationCustomNamingTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -24,15 +24,13 @@ import javax.management.MBeanOperationInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.gateway.MessagingGatewaySupport;
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;
@@ -41,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MBeanRegistrationTests {
@@ -78,7 +75,7 @@ public class MBeanRegistrationTests {
}
@Test
@Ignore // re-instate this if Spring decides to look for @ManagedResource on super classes
@Disabled // re-instate this if Spring decides to look for @ManagedResource on super classes
public void testServiceActivatorMBeanHasTrackableComponent() throws Exception {
Set<ObjectName> names = server.queryNames(new ObjectName("test.MBeanRegistration:type=ServiceActivatingHandler,name=service,*"), null);
Map<String, MBeanOperationInfo> infos = new HashMap<String, MBeanOperationInfo>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -21,13 +21,11 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
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;
@@ -36,8 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MessageStoreTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -21,16 +21,14 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.SubscribableChannel;
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 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MethodInvokerTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -18,8 +18,7 @@ package org.springframework.integration.jmx.config;
import javax.management.Notification;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -29,8 +28,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class NotificationListeningChannelAdapterParserTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,9 +25,8 @@ import javax.management.Notification;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,8 +37,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
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;
import static org.assertj.core.api.Assertions.fail;
@@ -50,8 +48,7 @@ import static org.assertj.core.api.Assertions.fail;
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class NotificationPublishingChannelAdapterParserTests {
@@ -72,7 +69,7 @@ public class NotificationPublishingChannelAdapterParserTests {
private static volatile int adviceCalled;
@After
@AfterEach
public void clearListener() {
listener.lastNotification = null;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -21,9 +21,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -38,8 +37,7 @@ import org.springframework.messaging.MessagingException;
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;
import static org.assertj.core.api.Assertions.fail;
@@ -50,8 +48,7 @@ import static org.assertj.core.api.Assertions.fail;
* @author Gary Russell
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class OperationInvokingOutboundGatewayTests {
@@ -79,7 +76,7 @@ public class OperationInvokingOutboundGatewayTests {
private static volatile int adviceCalled;
@After
@AfterEach
public void resetLists() {
testBean.messages.clear();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -21,13 +21,11 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
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;
@@ -36,8 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class PollingAdapterMBeanTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -21,15 +21,13 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.channel.QueueChannelOperations;
import org.springframework.messaging.PollableChannel;
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;
@@ -38,8 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class PriorityChannelTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,11 +23,9 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -37,59 +35,65 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
* @since 2.0
*/
@RunWith(Parameterized.class)
public class RouterMBeanTests {
private final MBeanServer server;
private MBeanServer server;
private final ClassPathXmlApplicationContext context;
private ClassPathXmlApplicationContext context;
public RouterMBeanTests(String configLocation) {
public void initContext(String configLocation) {
context = new ClassPathXmlApplicationContext(configLocation, getClass());
server = context.getBean(MBeanServer.class);
}
@Parameters
public static List<Object[]> getParameters() {
public static List<String> contexts() {
return Arrays.asList(
new Object[] {"RouterMBeanTests-context.xml"},
new Object[] {"RouterMBeanGatewayTests-context.xml"},
new Object[] {"RouterMBeanNoneTests-context.xml"},
new Object[] {"RouterMBeanSwitchTests-context.xml"});
"RouterMBeanTests-context.xml",
"RouterMBeanGatewayTests-context.xml",
"RouterMBeanNoneTests-context.xml",
"RouterMBeanSwitchTests-context.xml");
}
@After
@AfterEach
public void close() {
if (context != null) {
context.close();
}
}
@Test
public void testRouterMBeanExists() throws Exception {
@ParameterizedTest
@MethodSource("contexts")
public void testRouterMBeanExists(String context) throws Exception {
initContext(context);
// System . err.println(server.queryNames(new ObjectName("test.RouterMBean:*"), null));
Set<ObjectName> names = server.queryNames(
new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
assertThat(names.size()).isEqualTo(1);
}
@Test
public void testInputChannelMBeanExists() throws Exception {
@ParameterizedTest
@MethodSource("contexts")
public void testInputChannelMBeanExists(String context) throws Exception {
initContext(context);
// System . err.println(server.queryNames(new ObjectName("test.RouterMBean:type=MessageChannel,*"), null));
Set<ObjectName> names = server.queryNames(
new ObjectName("test.RouterMBean:type=MessageChannel,name=testChannel,*"), null);
assertThat(names.size()).isEqualTo(1);
}
@Test
public void testErrorChannelMBeanExists() throws Exception {
@ParameterizedTest
@MethodSource("contexts")
public void testErrorChannelMBeanExists(String context) throws Exception {
initContext(context);
Set<ObjectName> names = server.queryNames(
new ObjectName("test.RouterMBean:type=MessageChannel,name=errorChannel,*"), null);
assertThat(names.size()).isEqualTo(1);
}
@Test
public void testRouterMBeanOnlyRegisteredOnce() throws Exception {
@ParameterizedTest
@MethodSource("contexts")
public void testRouterMBeanOnlyRegisteredOnce(String context) throws Exception {
initContext(context);
// System . err.println(server.queryNames(new ObjectName("*:type=MessageHandler,*"), null));
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
assertThat(names.size()).isEqualTo(1);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -21,13 +21,11 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
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;
@@ -36,8 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class RouterMBeanVanillaTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,14 +16,12 @@
package org.springframework.integration.monitor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
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;
@@ -33,8 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ChainWithMessageProducingHandlersTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2025 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.
@@ -22,7 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2025 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.
@@ -24,8 +24,8 @@ import javax.management.MBeanOperationInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.beans.factory.FactoryBean;
@@ -66,7 +66,7 @@ public class MBeanExporterIntegrationTests {
private GenericXmlApplicationContext context;
@After
@AfterEach
public void close() {
if (context != null) {
context.close();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2025 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.
@@ -21,8 +21,7 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@@ -34,8 +33,7 @@ import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
import org.springframework.jmx.support.MBeanServerFactoryBean;
import org.springframework.messaging.MessageChannel;
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;
@@ -44,8 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @since 4.2.1
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MessagingGatewaySupportRegistrationTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -18,8 +18,7 @@ package org.springframework.integration.monitor;
import javax.management.Notification;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
@@ -27,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;
@@ -44,8 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 2.2
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class RemoteMBeanServerTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,8 +16,7 @@
package org.springframework.integration.monitor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -29,7 +28,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.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class TransformerContextTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,7 +16,7 @@
package org.springframework.integration_.mbeanexporterhelper;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -22,7 +22,7 @@ import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectInstance;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.test.util.TestUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -18,8 +18,8 @@ package org.springframework.integration.jpa.config.xml;
import java.util.List;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.context.ConfigurableApplicationContext;
@@ -210,7 +210,7 @@ public class JpaMessageHandlerParserTests {
}
@After
@AfterEach
public void tearDown() {
if (context != null) {
context.close();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,7 +16,7 @@
package org.springframework.integration.jpa.inbound;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.integration.jpa.core.JpaExecutor;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2025 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,8 +16,7 @@
package org.springframework.integration.redis.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -27,8 +26,7 @@ import org.springframework.integration.redis.outbound.RedisQueueOutboundGateway;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageChannel;
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;
@@ -37,8 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* since 4.1
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class RedisQueueOutboundGatewayParserTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -18,7 +18,7 @@ package org.springframework.integration.stream;
import java.io.ByteArrayInputStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.messaging.Message;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -19,9 +19,9 @@ package org.springframework.integration.stream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.channel.QueueChannel;
@@ -51,7 +51,7 @@ public class ByteStreamWritingMessageHandlerTests {
private ThreadPoolTaskScheduler scheduler;
@Before
@BeforeEach
public void initialize() {
stream = new ByteArrayOutputStream();
handler = new ByteStreamWritingMessageHandler(stream);
@@ -65,7 +65,7 @@ public class ByteStreamWritingMessageHandlerTests {
endpoint.setBeanFactory(mock(BeanFactory.class));
}
@After
@AfterEach
public void stop() throws Exception {
scheduler.destroy();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2025 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,7 +20,7 @@ import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.integration.syslog.SyslogHeaders;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2024 the original author or authors.
* Copyright 2018-2025 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.
@@ -24,6 +24,7 @@ import org.junit.rules.MethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import org.springframework.integration.test.condition.LogLevels;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.test.util.TestUtils.LevelsContainer;
import org.springframework.util.Assert;
@@ -37,10 +38,13 @@ import org.springframework.util.ObjectUtils;
*
* @author Artem Bilan
* @author Gary Russell
* @author Jiandong Ma
*
* @since 5.0.1
*
* @deprecated since 7.0 in favor of {@link LogLevels}
*/
@Deprecated(since = "7.0", forRemoval = true)
public final class Log4j2LevelAdjuster implements MethodRule {
private final Class<?>[] classes;

View File

@@ -0,0 +1,108 @@
/*
* Copyright 2002-2025 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.test.support;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Convenience class for testing Spring Integration request-response message scenarios.
* Users create subclasses to execute on or more {@link RequestResponseScenario} tests.
* each scenario defines:
* <ul>
* <li>An inputChannelName</li>
* <li>An outputChannelName</li>
* <li>A payload or message to send as a request message on the inputChannel</li>
* <li>A handler to validate the response received on the outputChannel</li>
* </ul>
*
* @author David Turanski
* @author Gary Russell
* @author Artem Bilan
* @author Jiandong Ma
*/
@SpringJUnitConfig
@DirtiesContext
public abstract class AbstractRequestResponseScenarioTest {
private List<RequestResponseScenario> scenarios = null;
@Autowired
private ApplicationContext applicationContext;
@BeforeEach
public void setUp() {
scenarios = defineRequestResponseScenarios();
}
/**
* Execute each scenario. Instantiate the message channels, send the request message
* on the input channel and invoke the validator on the response received on the
* output channel. This can handle subscribable or pollable output channels.
*/
@Test
public void testRequestResponseScenarios() {
int i = 1;
for (RequestResponseScenario scenario : scenarios) {
String name = scenario.getName() == null ? "scenario-" + (i++) : scenario.getName();
scenario.init();
MessageChannel inputChannel = applicationContext.getBean(scenario.getInputChannelName(),
MessageChannel.class);
MessageChannel outputChannel = applicationContext.getBean(scenario.getOutputChannelName(),
MessageChannel.class);
if (outputChannel instanceof SubscribableChannel) {
((SubscribableChannel) outputChannel).subscribe(scenario.getResponseValidator());
}
assertThat(inputChannel.send(scenario.getMessage()))
.as(name + ": message not sent on " + scenario.getInputChannelName()).isTrue();
if (outputChannel instanceof PollableChannel) {
Message<?> response = ((PollableChannel) outputChannel).receive(10000); // NOSONAR magic number
assertThat(response).as(name + ": receive timeout on " + scenario.getOutputChannelName()).isNotNull();
scenario.getResponseValidator().handleMessage(response);
}
assertThat(scenario.getResponseValidator().getLastMessage())
.as("message was not handled on " + outputChannel + " for scenario '" + name + "'.").isNotNull();
if (outputChannel instanceof SubscribableChannel) {
((SubscribableChannel) outputChannel).unsubscribe(scenario.getResponseValidator());
}
}
}
/**
* Implement this method to define RequestResponse scenarios
* @return - A List of {@link RequestResponseScenario}
*/
protected abstract List<RequestResponseScenario> defineRequestResponseScenarios();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -47,9 +47,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author David Turanski
* @author Gary Russell
* @author Artem Bilan
* @author Jiandong Ma
*
* @deprecated since 7.0 in favor of {@link AbstractRequestResponseScenarioTest}
*/
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
@Deprecated(since = "7.0", forRemoval = true)
public abstract class AbstractRequestResponseScenarioTests {
private List<RequestResponseScenario> scenarios = null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2025 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,16 +23,21 @@ import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.springframework.integration.test.condition.LongRunningTest;
/**
* Rule to prevent long running tests from running on every build; set environment
* variable RUN_LONG_INTEGRATION_TESTS on a CI nightly build to ensure coverage.
*
* @author Gary Russell
* @author Artem Bilan
* @author Jiandong Ma
*
* @since 3.0
*
* @deprecated since 7.0 in favor of {@link LongRunningTest}.
*/
@Deprecated(since = "7.0", forRemoval = true)
public class LongRunningIntegrationTest extends TestWatcher {
private static final Log LOGGER = LogFactory.getLog(LongRunningIntegrationTest.class);

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2002-2025 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.test.support;
import java.util.Collections;
import java.util.List;
/**
* Convenience class for a single {@link RequestResponseScenario} test
*
* @author David Turanski
* @author Jiandong Ma
*
*/
public abstract class SingleRequestResponseScenarioTest extends AbstractRequestResponseScenarioTest {
@Override
protected List<RequestResponseScenario> defineRequestResponseScenarios() {
return Collections.singletonList(defineRequestResponseScenario());
}
protected abstract RequestResponseScenario defineRequestResponseScenario();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2025 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,7 +23,11 @@ import java.util.List;
* Convenience class for a single {@link RequestResponseScenario} test
*
* @author David Turanski
* @author Jiandong Ma
*
* @deprecated since 7.0 in favor of {@link SingleRequestResponseScenarioTest}
*/
@Deprecated(since = "7.0", forRemoval = true)
public abstract class SingleRequestResponseScenarioTests extends AbstractRequestResponseScenarioTests {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -19,12 +19,9 @@ package org.springframework.integration.test.matcher;
import java.util.Date;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
@@ -33,6 +30,7 @@ import org.springframework.messaging.support.MessageBuilder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -43,7 +41,6 @@ import static org.mockito.Mockito.when;
* @author Artem Bilan
*
*/
@RunWith(MockitoJUnitRunner.Silent.class)
public class MockitoMessageMatchersTests {
static final Date SOME_PAYLOAD = new Date();
@@ -52,15 +49,13 @@ public class MockitoMessageMatchersTests {
static final String SOME_HEADER_KEY = "test.foo";
@Mock
MessageHandler handler;
MessageHandler handler = mock();
@Mock
MessageChannel channel;
MessageChannel channel = mock();
Message<Date> message;
@Before
@BeforeEach
public void setUp() {
this.message =
MessageBuilder.withPayload(SOME_PAYLOAD)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -29,7 +29,7 @@ import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.MimeHeaders;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPMessage;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.NodeList;
import org.springframework.messaging.MessageHeaders;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2024 the original author or authors.
* Copyright 2016-2025 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,8 +23,7 @@ import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Element;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,8 +42,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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 org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.EndpointMapping;
@@ -70,8 +68,7 @@ import static org.mockito.Mockito.when;
* @author Artem Bilan
* @since 4.3
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class WebServiceInboundGatewayJavaConfigTests {

View File

@@ -114,20 +114,18 @@ public void testWithEntityClass() throws Exception {
The `org.springframework.integration.test.support` package contains various abstract classes that you should implement in target tests
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/AbstractRequestResponseScenarioTests.html[`AbstractRequestResponseScenarioTests`]
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/AbstractRequestResponseScenarioTest.html[`AbstractRequestResponseScenarioTest`]
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/AbstractResponseValidator.html[`AbstractResponseValidator`]
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/LogAdjustingTestSupport.html[`LogAdjustingTestSupport`] (Deprecated)
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/MessageValidator.html[`MessageValidator`]
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/PayloadValidator.html[`PayloadValidator`]
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/RequestResponseScenario.html[`RequestResponseScenario`]
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/SingleRequestResponseScenarioTests.html[`SingleRequestResponseScenarioTests`]
* https://docs.spring.io/spring-integration/api/org/springframework/integration/test/support/SingleRequestResponseScenarioTest.html[`SingleRequestResponseScenarioTest`]
[[test-junit-rules]]
=== JUnit Rules and Conditions
[[test-junit-conditions]]
=== JUnit Conditions
The `LongRunningIntegrationTest` JUnit 4 test rule is present to indicate if test should be run if `RUN_LONG_INTEGRATION_TESTS` environment or system property is set to `true`.
The `@LongRunningTest` conditional annotation is present to indicate if test should be run if `RUN_LONG_INTEGRATION_TESTS` environment or system property is set to `true`.
Otherwise, it is skipped.
For the same reason since version 5.1, a `@LongRunningTest` conditional annotation is provided for JUnit 5 tests.
[[hamcrest-and-mockito-matchers]]
=== Hamcrest and Mockito Matchers
@@ -231,7 +229,7 @@ After test is performed you can restore the state of endpoint beans to the real
[source,java]
----
@After
@AfterEach
public void tearDown() {
this.mockIntegrationContext.resetBeans();
}

View File

@@ -17,6 +17,8 @@ Java 17 is still baseline, but Java 24 is supported.
[[x7.0-general]]
== General Changes
Junit 4 Based Support Components are deprecated.
[[x7.0-new-components]]
== New Components