More @DirtiesContext for tests in attempt to mitigate OOM error on CI/CD
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2023 the original author or authors.
|
||||
* Copyright 2018-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.integration.amqp.dsl.Amqp;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -52,6 +53,7 @@ import static org.mockito.Mockito.spy;
|
||||
*
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
@RabbitAvailable(queues = BoundRabbitChannelAdviceIntegrationTests.QUEUE)
|
||||
public class BoundRabbitChannelAdviceIntegrationTests {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -36,7 +35,7 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
@@ -53,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @since 2.0
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@ContextConfiguration
|
||||
@DirtiesContext
|
||||
@TestExecutionListeners(DependencyInjectionTestExecutionListener.class)
|
||||
public class EventInboundChannelAdapterParserTests {
|
||||
|
||||
@@ -73,44 +72,38 @@ public class EventInboundChannelAdapterParserTests {
|
||||
@Test
|
||||
public void validateEventParser() {
|
||||
Object adapter = context.getBean("eventAdapterSimple");
|
||||
assertThat(adapter).isNotNull();
|
||||
assertThat(adapter instanceof ApplicationEventListeningMessageProducer).isTrue();
|
||||
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
|
||||
assertThat(adapterAccessor.getPropertyValue("outputChannel")).isEqualTo(context.getBean("input"));
|
||||
assertThat(adapterAccessor.getPropertyValue("errorChannel")).isSameAs(errorChannel);
|
||||
assertThat(adapter).isInstanceOf(ApplicationEventListeningMessageProducer.class);
|
||||
assertThat(TestUtils.getPropertyValue(adapter, "outputChannel")).isEqualTo(context.getBean("input"));
|
||||
assertThat(TestUtils.getPropertyValue(adapter, "errorChannel")).isSameAs(errorChannel);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void validateEventParserWithEventTypes() {
|
||||
Object adapter = context.getBean("eventAdapterFiltered");
|
||||
assertThat(adapter).isNotNull();
|
||||
assertThat(adapter instanceof ApplicationEventListeningMessageProducer).isTrue();
|
||||
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
|
||||
assertThat(adapterAccessor.getPropertyValue("outputChannel")).isEqualTo(context.getBean("inputFiltered"));
|
||||
Set<ResolvableType> eventTypes = (Set<ResolvableType>) adapterAccessor.getPropertyValue("eventTypes");
|
||||
assertThat(eventTypes).isNotNull();
|
||||
assertThat(eventTypes.size() == 3).isTrue();
|
||||
assertThat(eventTypes.contains(ResolvableType.forClass(SampleEvent.class))).isTrue();
|
||||
assertThat(eventTypes.contains(ResolvableType.forClass(AnotherSampleEvent.class))).isTrue();
|
||||
assertThat(eventTypes.contains(ResolvableType.forClass(Date.class))).isTrue();
|
||||
assertThat(adapterAccessor.getPropertyValue("errorChannel")).isNull();
|
||||
assertThat(adapter).isInstanceOf(ApplicationEventListeningMessageProducer.class);
|
||||
assertThat(TestUtils.getPropertyValue(adapter, "outputChannel")).isEqualTo(context.getBean("inputFiltered"));
|
||||
Set<ResolvableType> eventTypes = TestUtils.getPropertyValue(adapter, "eventTypes", Set.class);
|
||||
assertThat(eventTypes)
|
||||
.hasSize(3)
|
||||
.contains(ResolvableType.forClass(SampleEvent.class),
|
||||
ResolvableType.forClass(AnotherSampleEvent.class),
|
||||
ResolvableType.forClass(Date.class));
|
||||
assertThat(TestUtils.getPropertyValue(adapter, "errorChannel")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void validateEventParserWithEventTypesAndPlaceholder() {
|
||||
Object adapter = context.getBean("eventAdapterFilteredPlaceHolder");
|
||||
assertThat(adapter).isNotNull();
|
||||
assertThat(adapter instanceof ApplicationEventListeningMessageProducer).isTrue();
|
||||
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
|
||||
assertThat(adapterAccessor.getPropertyValue("outputChannel"))
|
||||
assertThat(adapter).isInstanceOf(ApplicationEventListeningMessageProducer.class);
|
||||
assertThat(TestUtils.getPropertyValue(adapter, "outputChannel"))
|
||||
.isEqualTo(context.getBean("inputFilteredPlaceHolder"));
|
||||
Set<ResolvableType> eventTypes = (Set<ResolvableType>) adapterAccessor.getPropertyValue("eventTypes");
|
||||
assertThat(eventTypes).isNotNull();
|
||||
assertThat(eventTypes.size() == 2).isTrue();
|
||||
assertThat(eventTypes.contains(ResolvableType.forClass(SampleEvent.class))).isTrue();
|
||||
assertThat(eventTypes.contains(ResolvableType.forClass(AnotherSampleEvent.class))).isTrue();
|
||||
Set<ResolvableType> eventTypes = TestUtils.getPropertyValue(adapter, "eventTypes", Set.class);
|
||||
assertThat(eventTypes)
|
||||
.hasSize(2)
|
||||
.contains(ResolvableType.forClass(SampleEvent.class), ResolvableType.forClass(AnotherSampleEvent.class));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,9 +125,8 @@ public class EventInboundChannelAdapterParserTests {
|
||||
public void validatePayloadExpression() {
|
||||
Object adapter = context.getBean("eventAdapterSpel");
|
||||
assertThat(adapter).isNotNull();
|
||||
assertThat(adapter instanceof ApplicationEventListeningMessageProducer).isTrue();
|
||||
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
|
||||
Expression expression = (Expression) adapterAccessor.getPropertyValue("payloadExpression");
|
||||
assertThat(adapter).isInstanceOf(ApplicationEventListeningMessageProducer.class);
|
||||
Expression expression = TestUtils.getPropertyValue(adapter, "payloadExpression", Expression.class);
|
||||
assertThat(expression.getExpressionString()).isEqualTo("source + '-test'");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,6 +38,7 @@ import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -50,6 +51,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @since 2.0
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class GroovyFilterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.integration.groovy.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
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.QueueChannel;
|
||||
@@ -29,8 +28,8 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -41,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class GroovyHeaderEnricherTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,16 +20,15 @@ import java.beans.PropertyEditorSupport;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
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.core.io.AbstractResource;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -39,8 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class GroovyRefreshTests {
|
||||
|
||||
@Autowired
|
||||
@@ -70,7 +69,7 @@ public class GroovyRefreshTests {
|
||||
|
||||
private int count = -1;
|
||||
|
||||
private String[] scripts =
|
||||
private final String[] scripts =
|
||||
{"\"groovy-${binding.variables['payload']}-0\"",
|
||||
"\"groovy-${binding.variables['payload']}-1\""};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.groovy.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;
|
||||
@@ -30,8 +29,8 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -41,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class GroovyRouterTests {
|
||||
|
||||
@Autowired
|
||||
@@ -105,12 +104,12 @@ public class GroovyRouterTests {
|
||||
|
||||
@Test
|
||||
public void testInt2433VerifyRiddingOfMessageProcessorsWrapping() {
|
||||
assertThat(this.groovyRouterMessageHandler instanceof MethodInvokingRouter).isTrue();
|
||||
assertThat(this.groovyRouterMessageHandler).isInstanceOf(MethodInvokingRouter.class);
|
||||
@SuppressWarnings("rawtypes")
|
||||
MessageProcessor messageProcessor = TestUtils.getPropertyValue(this.groovyRouterMessageHandler,
|
||||
"messageProcessor", MessageProcessor.class);
|
||||
//before it was MethodInvokingMessageProcessor
|
||||
assertThat(messageProcessor instanceof GroovyScriptExecutingMessageProcessor).isTrue();
|
||||
assertThat(messageProcessor).isInstanceOf(GroovyScriptExecutingMessageProcessor.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.ErrorMessage;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.scripting.groovy.GroovyObjectCustomizer;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -55,6 +56,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @since 2.0
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class GroovyServiceActivatorTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
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.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -39,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @since 2.0
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class GroovySplitterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
package org.springframework.integration.groovy.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;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.groovy.GroovyScriptExecutingMessageProcessor;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.transformer.AbstractMessageProcessingTransformer;
|
||||
@@ -32,18 +30,19 @@ import org.springframework.integration.transformer.Transformer;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class GroovyTransformerTests {
|
||||
|
||||
@Autowired
|
||||
@@ -87,12 +86,12 @@ public class GroovyTransformerTests {
|
||||
@Test
|
||||
public void testInt2433VerifyRiddingOfMessageProcessorsWrapping() {
|
||||
assertThat(this.groovyTransformerMessageHandler instanceof MessageTransformingHandler).isTrue();
|
||||
Transformer transformer = TestUtils.getPropertyValue(this.groovyTransformerMessageHandler, "transformer", Transformer.class);
|
||||
assertThat(transformer instanceof AbstractMessageProcessingTransformer).isTrue();
|
||||
@SuppressWarnings("rawtypes")
|
||||
MessageProcessor messageProcessor = TestUtils.getPropertyValue(transformer, "messageProcessor", MessageProcessor.class);
|
||||
Transformer transformer =
|
||||
TestUtils.getPropertyValue(this.groovyTransformerMessageHandler, "transformer", Transformer.class);
|
||||
assertThat(transformer).isInstanceOf(AbstractMessageProcessingTransformer.class);
|
||||
//before it was MethodInvokingMessageProcessor
|
||||
assertThat(messageProcessor instanceof GroovyScriptExecutingMessageProcessor).isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(transformer, "messageProcessor"))
|
||||
.isInstanceOf(GroovyScriptExecutingMessageProcessor.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
* Copyright 2013-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,27 +19,27 @@ package org.springframework.integration.scripting.config.jsr223;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class Int3164Jsr223RefreshTests {
|
||||
|
||||
private static File workDir;
|
||||
@@ -52,7 +52,7 @@ public class Int3164Jsr223RefreshTests {
|
||||
@Autowired
|
||||
private PollableChannel outputChannel;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void start() throws IOException {
|
||||
String basePath = System.getProperty("java.io.tmpdir") + File.separator + "Int3164Jsr223RefreshTests";
|
||||
workDir = new File(basePath);
|
||||
@@ -64,7 +64,7 @@ public class Int3164Jsr223RefreshTests {
|
||||
FileCopyUtils.copy("1".getBytes(), scriptFile);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void shutdown() {
|
||||
if (workDir != null && workDir.exists()) {
|
||||
for (File file : workDir.listFiles()) {
|
||||
|
||||
@@ -16,26 +16,27 @@
|
||||
|
||||
package org.springframework.integration.scripting.config.jsr223;
|
||||
|
||||
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.QueueChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class Jsr223FilterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -35,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @since 2.1
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class Jsr223HeaderEnricherTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -18,36 +18,36 @@ package org.springframework.integration.scripting.config.jsr223;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
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.core.io.AbstractResource;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class Jsr223RefreshTests {
|
||||
|
||||
@Autowired
|
||||
private MessageChannel referencedScriptInput;
|
||||
|
||||
@Test
|
||||
public void referencedScript() throws Exception {
|
||||
public void referencedScript() {
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
replyChannel.setBeanName("returnAddress");
|
||||
this.referencedScriptInput.send(MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build());
|
||||
@@ -87,12 +87,12 @@ public class Jsr223RefreshTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long lastModified() throws IOException {
|
||||
public long lastModified() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
public InputStream getInputStream() {
|
||||
if (++count > scripts.length - 1) {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ import org.springframework.integration.scripting.ScriptVariableGenerator;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -45,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @since 2.0
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class Jsr223ServiceActivatorTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -16,25 +16,26 @@
|
||||
|
||||
package org.springframework.integration.scripting.config.jsr223;
|
||||
|
||||
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.QueueChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class Jsr223SplitterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.messaging.Message;
|
||||
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.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -39,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @since 2.0
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class Jsr223TransformerTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.scripting.PolyglotScriptExecutor;
|
||||
import org.springframework.integration.scripting.ScriptExecutor;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -42,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
*
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class DeriveLanguageFromExtensionTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
/**
|
||||
* @author Markus Spann
|
||||
* @author Prafull Kumar Soni
|
||||
* @author Artem Bilan
|
||||
*
|
||||
*/
|
||||
public class SmbParserInboundTests extends AbstractBaseTests {
|
||||
@@ -41,11 +42,13 @@ public class SmbParserInboundTests extends AbstractBaseTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("try")
|
||||
public void testLocalFilesAutoCreationTrue() {
|
||||
assertFileNotExists(new File("test-temp/local-10"));
|
||||
new ClassPathXmlApplicationContext(getApplicationContextXmlFile(), this.getClass());
|
||||
assertFileExists(new File("test-temp/local-10"));
|
||||
assertFileNotExists(new File("test-temp/local-6"));
|
||||
try (var ctx = new ClassPathXmlApplicationContext(getApplicationContextXmlFile(), getClass())) {
|
||||
assertFileExists(new File("test-temp/local-10"));
|
||||
assertFileNotExists(new File("test-temp/local-6"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.integration.smb.inbound.SmbInboundFileSynchronizingMe
|
||||
import org.springframework.integration.smb.session.SmbSession;
|
||||
import org.springframework.integration.smb.session.SmbSessionFactory;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -51,12 +52,14 @@ import static org.mockito.Mockito.when;
|
||||
* @author Gregory Bragg
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class SmbInboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
ApplicationContext applicationContext;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSmbInboundChannelAdapterComplete() {
|
||||
|
||||
final SourcePollingChannelAdapter adapter =
|
||||
@@ -76,7 +79,7 @@ public class SmbInboundChannelAdapterParserTests {
|
||||
assertThat(".working.tmp").isEqualTo(TestUtils.getPropertyValue(fisync, "temporaryFileSuffix", String.class));
|
||||
String remoteFileSeparator = (String) TestUtils.getPropertyValue(fisync, "remoteFileSeparator");
|
||||
assertThat(remoteFileSeparator).isNotNull();
|
||||
assertThat("").isEqualTo(remoteFileSeparator);
|
||||
assertThat(remoteFileSeparator).isEqualTo("");
|
||||
FileListFilter<?> filter = TestUtils.getPropertyValue(fisync, "filter", FileListFilter.class);
|
||||
assertThat(filter).isNotNull();
|
||||
assertThat(filter).isInstanceOf(CompositeFileListFilter.class);
|
||||
@@ -86,11 +89,12 @@ public class SmbInboundChannelAdapterParserTests {
|
||||
assertThat(filtersIterator.next()).isInstanceOf(SmbSimplePatternFileListFilter.class);
|
||||
assertThat(filtersIterator.next()).isInstanceOf(SmbPersistentAcceptOnceFileListFilter.class);
|
||||
Object sessionFactory = TestUtils.getPropertyValue(fisync, "remoteFileTemplate.sessionFactory");
|
||||
assertThat(SmbSessionFactory.class.isAssignableFrom(sessionFactory.getClass())).isTrue();
|
||||
assertThat(sessionFactory).isInstanceOf(SmbSessionFactory.class);
|
||||
|
||||
FileListFilter<?> acceptAllFilter = this.applicationContext.getBean("acceptAllFilter", FileListFilter.class);
|
||||
assertThat(TestUtils.getPropertyValue(inbound, "fileSource.scanner.filter.fileFilters", Collection.class)
|
||||
.contains(acceptAllFilter)).isTrue();
|
||||
|
||||
assertThat(TestUtils.getPropertyValue(inbound, "fileSource.scanner.filter.fileFilters", Collection.class))
|
||||
.contains(acceptAllFilter);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,7 +108,7 @@ public class SmbInboundChannelAdapterParserTests {
|
||||
TestUtils.getPropertyValue(adapter, "source.synchronizer", SmbInboundFileSynchronizer.class);
|
||||
String remoteFileSeparator = (String) TestUtils.getPropertyValue(fisync, "remoteFileSeparator");
|
||||
assertThat(remoteFileSeparator).isNotNull();
|
||||
assertThat("/").isEqualTo(remoteFileSeparator);
|
||||
assertThat(remoteFileSeparator).isEqualTo("/");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
@@ -39,10 +39,11 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -53,8 +54,8 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class ConsoleOutboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
@@ -82,7 +83,8 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void stdoutAdapterWithDefaultCharset() throws IOException {
|
||||
BufferedWriter bufferedWriter = TestUtils.getPropertyValue(this.stdoutAdapterWithDefaultCharsetHandler, "writer", BufferedWriter.class);
|
||||
BufferedWriter bufferedWriter =
|
||||
TestUtils.getPropertyValue(this.stdoutAdapterWithDefaultCharsetHandler, "writer", BufferedWriter.class);
|
||||
Writer writer = TestUtils.getPropertyValue(bufferedWriter, "out", Writer.class);
|
||||
assertThat(writer.getClass()).isEqualTo(OutputStreamWriter.class);
|
||||
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
|
||||
@@ -96,7 +98,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(this.stdoutAdapterWithDefaultCharsetHandler);
|
||||
dfa.setPropertyValue("writer", bufferedWriter);
|
||||
|
||||
this.stdoutAdapterWithDefaultCharsetHandler.handleMessage(new GenericMessage<String>("foo"));
|
||||
this.stdoutAdapterWithDefaultCharsetHandler.handleMessage(new GenericMessage<>("foo"));
|
||||
|
||||
verify(bufferedWriter, times(1)).write(eq("foo"));
|
||||
assertThat(TestUtils.getPropertyValue(this.stdoutAdapterWithDefaultCharsetHandler, "order")).isEqualTo(23);
|
||||
@@ -104,11 +106,12 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void stdoutAdapterWithProvidedCharset() throws IOException {
|
||||
BufferedWriter bufferedWriter = TestUtils.getPropertyValue(this.stdoutAdapterWithProvidedCharsetHandler, "writer", BufferedWriter.class);
|
||||
BufferedWriter bufferedWriter =
|
||||
TestUtils.getPropertyValue(this.stdoutAdapterWithProvidedCharsetHandler, "writer", BufferedWriter.class);
|
||||
Writer writer = TestUtils.getPropertyValue(bufferedWriter, "out", Writer.class);
|
||||
assertThat(writer.getClass()).isEqualTo(OutputStreamWriter.class);
|
||||
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
|
||||
assertThat(writerCharset).isEqualTo(Charset.forName("UTF-8"));
|
||||
assertThat(writerCharset).isEqualTo(StandardCharsets.UTF_8);
|
||||
|
||||
Object lock = TestUtils.getPropertyValue(writer, "lock");
|
||||
assertThat(lock).isEqualTo(System.out);
|
||||
@@ -118,28 +121,23 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(this.stdoutAdapterWithProvidedCharsetHandler);
|
||||
dfa.setPropertyValue("writer", bufferedWriter);
|
||||
|
||||
this.stdoutAdapterWithProvidedCharsetHandler.handleMessage(new GenericMessage<String>("bar"));
|
||||
this.stdoutAdapterWithProvidedCharsetHandler.handleMessage(new GenericMessage<>("bar"));
|
||||
|
||||
verify(bufferedWriter, times(1)).write(eq("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stdoutAdapterWithInvalidCharset() {
|
||||
BeanCreationException beanCreationException = null;
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("invalidConsoleOutboundChannelAdapterParserTests.xml",
|
||||
ConsoleOutboundChannelAdapterParserTests.class).close();
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
beanCreationException = e;
|
||||
}
|
||||
Throwable rootCause = beanCreationException.getRootCause();
|
||||
assertThat(rootCause.getClass()).isEqualTo(UnsupportedEncodingException.class);
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> new ClassPathXmlApplicationContext("invalidConsoleOutboundChannelAdapterParserTests.xml",
|
||||
ConsoleOutboundChannelAdapterParserTests.class))
|
||||
.withRootCauseInstanceOf(UnsupportedEncodingException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stderrAdapter() throws IOException {
|
||||
BufferedWriter bufferedWriter = TestUtils.getPropertyValue(this.stderrAdapterHandler, "writer", BufferedWriter.class);
|
||||
BufferedWriter bufferedWriter =
|
||||
TestUtils.getPropertyValue(this.stderrAdapterHandler, "writer", BufferedWriter.class);
|
||||
Writer writer = TestUtils.getPropertyValue(bufferedWriter, "out", Writer.class);
|
||||
assertThat(writer.getClass()).isEqualTo(OutputStreamWriter.class);
|
||||
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
|
||||
@@ -153,7 +151,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(this.stderrAdapterHandler);
|
||||
dfa.setPropertyValue("writer", bufferedWriter);
|
||||
|
||||
this.stderrAdapterHandler.handleMessage(new GenericMessage<String>("bar"));
|
||||
this.stderrAdapterHandler.handleMessage(new GenericMessage<>("bar"));
|
||||
|
||||
verify(bufferedWriter, times(1)).write(eq("bar"));
|
||||
|
||||
@@ -162,7 +160,8 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void stdoutAdatperWithAppendNewLine() throws IOException {
|
||||
BufferedWriter bufferedWriter = TestUtils.getPropertyValue(this.newlineAdapterHandler, "writer", BufferedWriter.class);
|
||||
BufferedWriter bufferedWriter =
|
||||
TestUtils.getPropertyValue(this.newlineAdapterHandler, "writer", BufferedWriter.class);
|
||||
Writer writer = TestUtils.getPropertyValue(bufferedWriter, "out", Writer.class);
|
||||
assertThat(writer.getClass()).isEqualTo(OutputStreamWriter.class);
|
||||
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
|
||||
@@ -176,7 +175,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(this.newlineAdapterHandler);
|
||||
dfa.setPropertyValue("writer", bufferedWriter);
|
||||
|
||||
this.newlineAdapterHandler.handleMessage(new GenericMessage<String>("bar"));
|
||||
this.newlineAdapterHandler.handleMessage(new GenericMessage<>("bar"));
|
||||
|
||||
verify(bufferedWriter, times(1)).write(eq("bar"));
|
||||
verify(bufferedWriter, times(1)).newLine();
|
||||
@@ -208,7 +207,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(stdoutHandler);
|
||||
dfa.setPropertyValue("writer", bufferedWriter);
|
||||
|
||||
this.stdoutInsideNestedChain.send(new GenericMessage<String>("foo"));
|
||||
this.stdoutInsideNestedChain.send(new GenericMessage<>("foo"));
|
||||
verify(bufferedWriter, times(1)).write(eq("foobar"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,6 +40,7 @@ import org.springframework.integration.syslog.inbound.UdpSyslogReceivingChannelA
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -54,6 +55,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
*
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class SyslogReceivingChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.endpoint.ReactiveMessageSourceProducer;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
@@ -29,11 +30,13 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
* to be inherited by concrete subclasses.
|
||||
*
|
||||
* @author Chris Bono
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 6.2.10
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@SpringIntegrationTest(noAutoStartup = "*")
|
||||
@DirtiesContext
|
||||
class AbstractIntegrationTest {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.oxm.Marshaller;
|
||||
import org.springframework.oxm.MarshallingFailureException;
|
||||
import org.springframework.oxm.Unmarshaller;
|
||||
import org.springframework.oxm.XmlMappingException;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
@@ -54,6 +55,7 @@ import static org.mockito.Mockito.when;
|
||||
*/
|
||||
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class MarshallingWebServiceIntegrationTests {
|
||||
|
||||
private static final String input = "<hello/>";
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.ws.client.WebServiceClientException;
|
||||
import org.springframework.ws.client.WebServiceIOException;
|
||||
@@ -73,6 +74,7 @@ import static org.mockito.Mockito.doAnswer;
|
||||
* @since 2.1
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class UriVariableTests {
|
||||
|
||||
@Autowired
|
||||
@@ -179,7 +181,6 @@ public class UriVariableTests {
|
||||
Mockito.verify(producer).setPriority(5);
|
||||
}
|
||||
|
||||
@Disabled("Until SF for for URL parser")
|
||||
@Test
|
||||
public void testInt2720EmailUriVariables() {
|
||||
final String testEmailTo = "user@example.com";
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.oxm.Marshaller;
|
||||
import org.springframework.oxm.Unmarshaller;
|
||||
import org.springframework.scheduling.support.PeriodicTrigger;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
import org.springframework.ws.WebServiceMessageFactory;
|
||||
@@ -70,6 +71,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class WebServiceOutboundGatewayParserTests {
|
||||
|
||||
private static volatile int adviceCalled;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,8 +27,7 @@ import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -48,7 +47,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.oxm.Unmarshaller;
|
||||
import org.springframework.oxm.XmlMappingException;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.WebServiceMessageFactory;
|
||||
@@ -69,26 +68,30 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class WebServiceOutboundGatewayWithHeaderMapperTests {
|
||||
|
||||
private static String responseSoapMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> " +
|
||||
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
|
||||
" <SOAP-ENV:Header/>" +
|
||||
" <SOAP-ENV:Body> " +
|
||||
" <root><name>jane</name></root>" +
|
||||
" </SOAP-ENV:Body> " +
|
||||
"</SOAP-ENV:Envelope>";
|
||||
private static final String responseSoapMessage = """
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<SOAP-ENV:Header/>
|
||||
<SOAP-ENV:Body>
|
||||
<root><name>jane</name></root>
|
||||
</SOAP-ENV:Body>
|
||||
</SOAP-ENV:Envelope>
|
||||
""";
|
||||
|
||||
private static String responseNonSoapMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> " +
|
||||
"<person><name>oleg</name></person>";
|
||||
private static final String responseNonSoapMessage = """
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<person><name>oleg</name></person>
|
||||
""";
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void headerMapperParserTest() throws Exception {
|
||||
public void headerMapperParserTest() {
|
||||
SimpleWebServiceOutboundGateway gateway =
|
||||
TestUtils.getPropertyValue(this.context.getBean("withHeaderMapper"),
|
||||
"handler", SimpleWebServiceOutboundGateway.class);
|
||||
@@ -152,7 +155,7 @@ public class WebServiceOutboundGatewayWithHeaderMapperTests {
|
||||
Document document = docBuilder.parse(new ByteArrayInputStream("<root><name>bill</name></root>".getBytes()));
|
||||
DOMSource payload = new DOMSource(document);
|
||||
Message<?> replyMessage = process(payload, "withHeaderMapper", "inputChannel", true);
|
||||
assertThat(replyMessage.getPayload() instanceof DOMSource).isTrue();
|
||||
assertThat(replyMessage.getPayload()).isInstanceOf(DOMSource.class);
|
||||
assertThat(replyMessage.getHeaders().get("bar")).isEqualTo("bar");
|
||||
assertThat(replyMessage.getHeaders().get("baz")).isNull();
|
||||
}
|
||||
@@ -164,7 +167,7 @@ public class WebServiceOutboundGatewayWithHeaderMapperTests {
|
||||
Document document = docBuilder.parse(new ByteArrayInputStream("<root><name>bill</name></root>".getBytes()));
|
||||
DOMSource payload = new DOMSource(document);
|
||||
Message<?> replyMessage = process(payload, "withHeaderMapper", "inputChannel", false);
|
||||
assertThat(replyMessage.getPayload() instanceof DOMSource).isTrue();
|
||||
assertThat(replyMessage.getPayload()).isInstanceOf(DOMSource.class);
|
||||
assertThat(this.extractStringResult(replyMessage).contains("<person><name>oleg</name></person>")).isTrue();
|
||||
}
|
||||
|
||||
@@ -174,7 +177,7 @@ public class WebServiceOutboundGatewayWithHeaderMapperTests {
|
||||
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
|
||||
Document payload = docBuilder.parse(new ByteArrayInputStream("<root><name>bill</name></root>".getBytes()));
|
||||
Message<?> replyMessage = process(payload, "withHeaderMapper", "inputChannel", true);
|
||||
assertThat(replyMessage.getPayload() instanceof Document).isTrue();
|
||||
assertThat(replyMessage.getPayload()).isInstanceOf(Document.class);
|
||||
assertThat(replyMessage.getHeaders().get("bar")).isEqualTo("bar");
|
||||
assertThat(replyMessage.getHeaders().get("baz")).isNull();
|
||||
}
|
||||
@@ -185,7 +188,7 @@ public class WebServiceOutboundGatewayWithHeaderMapperTests {
|
||||
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
|
||||
Document payload = docBuilder.parse(new ByteArrayInputStream("<root><name>bill</name></root>".getBytes()));
|
||||
Message<?> replyMessage = process(payload, "withHeaderMapper", "inputChannel", false);
|
||||
assertThat(replyMessage.getPayload() instanceof Document).isTrue();
|
||||
assertThat(replyMessage.getPayload()).isInstanceOf(Document.class);
|
||||
assertThat(this.extractStringResult(replyMessage).contains("<person><name>oleg</name></person>")).isTrue();
|
||||
}
|
||||
|
||||
@@ -198,13 +201,16 @@ public class WebServiceOutboundGatewayWithHeaderMapperTests {
|
||||
assertThat(replyMessage.getHeaders().get("baz")).isNull();
|
||||
}
|
||||
|
||||
private Message<?> process(Object payload, String gatewayName, String channelName, final boolean soap) throws Exception {
|
||||
private Message<?> process(Object payload, String gatewayName, String channelName, final boolean soap)
|
||||
throws Exception {
|
||||
|
||||
AbstractWebServiceOutboundGateway gateway =
|
||||
TestUtils.getPropertyValue(this.context.getBean(gatewayName), "handler",
|
||||
AbstractWebServiceOutboundGateway.class);
|
||||
|
||||
if (!soap) {
|
||||
WebServiceTemplate template = TestUtils.getPropertyValue(gateway, "webServiceTemplate", WebServiceTemplate.class);
|
||||
WebServiceTemplate template =
|
||||
TestUtils.getPropertyValue(gateway, "webServiceTemplate", WebServiceTemplate.class);
|
||||
template.setMessageFactory(new DomPoxMessageFactory());
|
||||
}
|
||||
|
||||
@@ -265,9 +271,13 @@ public class WebServiceOutboundGatewayWithHeaderMapperTests {
|
||||
|
||||
MessageChannel inputChannel = context.getBean(channelName, MessageChannel.class);
|
||||
Message<?> message =
|
||||
MessageBuilder.withPayload(payload).
|
||||
setHeader("foo", "foo").setHeader("foobar", "foobar").setHeader("abaz", "abaz").setHeader("bar", "bar").
|
||||
setHeader(WebServiceHeaders.SOAP_ACTION, "someAction").build();
|
||||
MessageBuilder.withPayload(payload)
|
||||
.setHeader("foo", "foo")
|
||||
.setHeader("foobar", "foobar")
|
||||
.setHeader("abaz", "abaz")
|
||||
.setHeader("bar", "bar").
|
||||
setHeader(WebServiceHeaders.SOAP_ACTION, "someAction")
|
||||
.build();
|
||||
inputChannel.send(message);
|
||||
QueueChannel outputChannel = context.getBean("outputChannel", QueueChannel.class);
|
||||
return outputChannel.receive(0);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.messaging.Message;
|
||||
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.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.xml.transform.StringResult;
|
||||
@@ -47,6 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class MarshallingTransformerParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
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.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
@@ -45,8 +46,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Jonas Partner
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class UnmarshallingTransformerParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -40,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@DirtiesContext
|
||||
public class XPathMessageSplitterParserTests {
|
||||
|
||||
private static final String channelDefinitions = """
|
||||
@@ -89,6 +91,7 @@ public class XPathMessageSplitterParserTests {
|
||||
.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
|
||||
inputChannel.send(docMessage);
|
||||
assertThat(outputChannel.getQueueSize()).as("Wrong number of split messages ").isEqualTo(2);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -119,6 +122,7 @@ public class XPathMessageSplitterParserTests {
|
||||
.as("Splitter failed to create documents ").isInstanceOf(Document.class);
|
||||
assertThat(outputChannel.receive(1000).getPayload())
|
||||
.as("Splitter failed to create documents ").isInstanceOf(Document.class);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,6 +146,7 @@ public class XPathMessageSplitterParserTests {
|
||||
fieldAccessor = new DirectFieldAccessor(handler);
|
||||
Object documentBuilderFactory = fieldAccessor.getPropertyValue("documentBuilderFactory");
|
||||
assertThat(documentBuilderFactory).isInstanceOf(DocumentBuilderFactory.class);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,6 +167,7 @@ public class XPathMessageSplitterParserTests {
|
||||
fieldAccessor = new DirectFieldAccessor(handler);
|
||||
Object documentBuilderFactory = fieldAccessor.getPropertyValue("documentBuilderFactory");
|
||||
assertThat(documentBuilderFactory).isInstanceOf(DocumentBuilderFactory.class);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.messaging.Message;
|
||||
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.util.MultiValueMap;
|
||||
|
||||
@@ -55,6 +56,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@DirtiesContext
|
||||
public class XPathRouterParserTests {
|
||||
|
||||
String channelConfig = """
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.messaging.Message;
|
||||
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.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.xml.transform.StringResult;
|
||||
@@ -51,6 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class XsltPayloadTransformerParserTests {
|
||||
|
||||
private static final String doc = """
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -42,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class XsltTransformerTests {
|
||||
|
||||
private final String docAsString = """
|
||||
@@ -73,9 +75,12 @@ public class XsltTransformerTests {
|
||||
TestUtils.locateComponentInHistory(history, "paramHeadersWithStartWildCharacter", 0);
|
||||
assertThat(componentHistoryRecord).isNotNull();
|
||||
assertThat(componentHistoryRecord.get("type")).isEqualTo("xml:xslt-transformer");
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
assertThat(((String) resultMessage.getPayload()).contains("testParamValue")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("FOO")).isFalse();
|
||||
assertThat(resultMessage.getPayload())
|
||||
.as("Wrong payload type")
|
||||
.isInstanceOf(String.class)
|
||||
.asString()
|
||||
.contains("testParamValue")
|
||||
.doesNotContain("FOO");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,9 +92,11 @@ public class XsltTransformerTests {
|
||||
build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
assertThat(((String) resultMessage.getPayload()).contains("testParamValue")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("FOO")).isTrue();
|
||||
assertThat(resultMessage.getPayload())
|
||||
.as("Wrong payload type")
|
||||
.isInstanceOf(String.class)
|
||||
.asString()
|
||||
.contains("testParamValue", "FOO");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,10 +108,11 @@ public class XsltTransformerTests {
|
||||
build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
assertThat(((String) resultMessage.getPayload()).contains("testParamValue")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("FOO")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("hello")).isTrue();
|
||||
assertThat(resultMessage.getPayload())
|
||||
.as("Wrong payload type")
|
||||
.isInstanceOf(String.class)
|
||||
.asString()
|
||||
.contains("testParamValue", "FOO", "hello");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,10 +124,11 @@ public class XsltTransformerTests {
|
||||
build();
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertThat(resultMessage.getPayload().getClass()).as("Wrong payload type").isEqualTo(String.class);
|
||||
assertThat(((String) resultMessage.getPayload()).contains("testParamValue")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("FOO")).isTrue();
|
||||
assertThat(((String) resultMessage.getPayload()).contains("hello")).isTrue();
|
||||
assertThat(resultMessage.getPayload())
|
||||
.as("Wrong payload type")
|
||||
.isInstanceOf(String.class)
|
||||
.asString()
|
||||
.contains("testParamValue", "FOO", "hello");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.oxm.UnmarshallingFailureException;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
@@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class JaxbMarshallingIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
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.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.xml.xpath.NodeMapper;
|
||||
|
||||
@@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
* @since 3.0
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class XPathTests {
|
||||
|
||||
private static final String XML = """
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -54,6 +55,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Florian Schmaus
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class ChatMessageOutboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
@@ -72,20 +74,20 @@ public class ChatMessageOutboundChannelAdapterParserTests {
|
||||
Object pollingConsumer = context.getBean("withHeaderMapper");
|
||||
QueueChannel channel = (QueueChannel) TestUtils.getPropertyValue(pollingConsumer, "inputChannel");
|
||||
assertThat(channel.getComponentName()).isEqualTo("outboundPollingChannel");
|
||||
assertThat(pollingConsumer instanceof PollingConsumer).isTrue();
|
||||
assertThat(pollingConsumer).isInstanceOf(PollingConsumer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEventConsumerWithNoChannel() {
|
||||
Object eventConsumer = context.getBean("outboundNoChannelAdapter");
|
||||
assertThat(eventConsumer instanceof SubscribableChannel).isTrue();
|
||||
assertThat(eventConsumer).isInstanceOf(SubscribableChannel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advised() {
|
||||
MessageHandler handler = TestUtils.getPropertyValue(context.getBean("advised"),
|
||||
"handler", MessageHandler.class);
|
||||
handler.handleMessage(new GenericMessage<String>("foo"));
|
||||
handler.handleMessage(new GenericMessage<>("foo"));
|
||||
assertThat(adviceCalled).isEqualTo(1);
|
||||
}
|
||||
|
||||
@@ -103,7 +105,7 @@ public class ChatMessageOutboundChannelAdapterParserTests {
|
||||
assertThat(requestHeaderMatcher.matchHeader("bar123")).isTrue();
|
||||
assertThat(requestHeaderMatcher.matchHeader("biz")).isFalse();
|
||||
assertThat(requestHeaderMatcher.matchHeader("else")).isFalse();
|
||||
assertThat(eventConsumer instanceof EventDrivenConsumer).isTrue();
|
||||
assertThat(eventConsumer).isInstanceOf(EventDrivenConsumer.class);
|
||||
|
||||
MessageHandler outboundEventAdapterHandle =
|
||||
context.getBean("outboundEventAdapter.handler", MessageHandler.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,6 +32,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -44,6 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class PresenceOutboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
@@ -74,7 +76,7 @@ public class PresenceOutboundChannelAdapterParserTests {
|
||||
Object eventConsumer = context.getBean("advised");
|
||||
assertThat(eventConsumer instanceof EventDrivenConsumer).isTrue();
|
||||
MessageHandler handler = TestUtils.getPropertyValue(eventConsumer, "handler", MessageHandler.class);
|
||||
handler.handleMessage(new GenericMessage<String>("foo"));
|
||||
handler.handleMessage(new GenericMessage<>("foo"));
|
||||
assertThat(adviceCalled).isEqualTo(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user