More @DirtiesContext for tests in core

An attempt to mitigate a memory impact on limited CI/CD runners

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
This commit is contained in:
Artem Bilan
2024-08-13 16:33:47 -04:00
parent fdac8f1634
commit b5ec098eb5
24 changed files with 126 additions and 171 deletions

View File

@@ -16,38 +16,53 @@
package org.springframework.integration.config.xml;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatNoException;
/**
*
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
*
*/
public class ChannelAutoCreationTests {
@Test // no assertions since it validates that no exception is thrown
@Test
public void testEnablingAutoChannelCreationBeforeWithCustom() {
new ClassPathXmlApplicationContext("TestEnableChannelAutoCreation-before-context.xml", this.getClass()).close();
assertThatNoException()
.isThrownBy(() ->
new ClassPathXmlApplicationContext(
"TestEnableChannelAutoCreation-before-context.xml", this.getClass()));
}
@Test // no assertions since it validates that no exception is thrown
@Test
public void testEnablingAutoChannelCreationAfterWithCustom() {
new ClassPathXmlApplicationContext("TestEnableChannelAutoCreation-after-context.xml", this.getClass()).close();
assertThatNoException()
.isThrownBy(() ->
new ClassPathXmlApplicationContext(
"TestEnableChannelAutoCreation-after-context.xml", this.getClass()));
}
@Test(expected = BeanCreationException.class)
@Test
public void testDisablingAutoChannelCreationAfter() {
new ClassPathXmlApplicationContext("TestDisableChannelAutoCreation-after-context.xml", this.getClass()).close();
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() ->
new ClassPathXmlApplicationContext(
"TestDisableChannelAutoCreation-after-context.xml", getClass()));
}
@Test(expected = BeanCreationException.class)
@Test
public void testDisablingAutoChannelCreationBefore() {
new ClassPathXmlApplicationContext("TestDisableChannelAutoCreation-before-context.xml", this.getClass())
.close();
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() ->
new ClassPathXmlApplicationContext(
"TestDisableChannelAutoCreation-before-context.xml", this.getClass()));
}
}

View File

@@ -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,14 +16,13 @@
package org.springframework.integration.config.xml;
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.test.util.TestUtils;
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;
@@ -34,22 +33,20 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class EnricherParserTests2 {
@SpringJUnitConfig
@DirtiesContext
public class EnricherParser2Tests {
@Autowired
private ApplicationContext context;
@Test
public void configurationCheckRequiresReply() {
Object endpoint = context.getBean("enricher");
boolean requiresReply = TestUtils.getPropertyValue(endpoint, "handler.requiresReply", Boolean.class);
assertThat(requiresReply).as("Was expecting requiresReply to be 'false'").isFalse();
}
}

View File

@@ -17,7 +17,7 @@
<property name="nested.value" expression="@someBean.someOtherProperty" />
</enricher>
<beans:bean id="someBean" class="org.springframework.integration.config.xml.EnricherParserTests3$SomeBean">
<beans:bean id="someBean" class="org.springframework.integration.config.xml.EnricherParser3Tests$SomeBean">
<beans:constructor-arg value="baz" />
</beans:bean>

View File

@@ -17,7 +17,7 @@
<property name="@someBean.nested.value" value="qux" />
</enricher>
<beans:bean id="someBean" class="org.springframework.integration.config.xml.EnricherParserTests3$SomeBean">
<beans:bean id="someBean" class="org.springframework.integration.config.xml.EnricherParser3Tests$SomeBean">
<beans:constructor-arg value="baz" />
</beans:bean>

View File

@@ -27,14 +27,14 @@ import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Gary Russell
*
* @since 2.1.1
*/
public class EnricherParserTests3 {
public class EnricherParser3Tests {
@Test
public void testSourceBeanResolver() {
@@ -44,7 +44,7 @@ public class EnricherParserTests3 {
PollableChannel beanResolveOut = context.getBean("beanResolveOut", PollableChannel.class);
SomeBean payload = new SomeBean("foo");
assertThat(payload.getNested().getValue()).isEqualTo("foo");
beanResolveIn.send(new GenericMessage<SomeBean>(payload));
beanResolveIn.send(new GenericMessage<>(payload));
@SuppressWarnings("unchecked")
Message<SomeBean> out = (Message<SomeBean>) beanResolveOut.receive();
assertThat(out.getPayload()).isSameAs(payload);
@@ -59,13 +59,9 @@ public class EnricherParserTests3 {
MessageChannel beanResolveIn = context.getBean("beanResolveIn", MessageChannel.class);
SomeBean payload = new SomeBean("foo");
assertThat(payload.getNested().getValue()).isEqualTo("foo");
try {
beanResolveIn.send(new GenericMessage<SomeBean>(payload));
fail("Expected SpEL Exception");
}
catch (MessageHandlingException e) {
assertThat(e.getCause() instanceof SpelEvaluationException).isTrue();
}
assertThatExceptionOfType(MessageHandlingException.class)
.isThrownBy(() -> beanResolveIn.send(new GenericMessage<>(payload)))
.withCauseInstanceOf(SpelEvaluationException.class);
context.close();
}
@@ -85,7 +81,7 @@ public class EnricherParserTests3 {
return "bar";
}
public class Nested {
public static class Nested {
private String value;

View File

@@ -40,10 +40,10 @@
null-result-expression="'Could not determine the notOverwrite'"/>
<request-handler-advice-chain>
<beans:bean class="org.springframework.integration.config.xml.EnricherParserTests4$FooAdvice" />
<beans:bean class="org.springframework.integration.config.xml.EnricherParser4Tests$FooAdvice" />
</request-handler-advice-chain>
</enricher>
<util:constant id="testBean" static-field="org.springframework.integration.config.xml.EnricherParserTests4$Gender.MALE"/>
<util:constant id="testBean" static-field="org.springframework.integration.config.xml.EnricherParser4Tests$Gender.MALE"/>
</beans:beans>

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.config.xml;
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,19 +28,20 @@ import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.SubscribableChannel;
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 Liujiong
* @author Artem Bilan
*
* @since 4.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class EnricherParserTests4 {
@SpringJUnitConfig
@DirtiesContext
public class EnricherParser4Tests {
@Autowired
private ApplicationContext context;

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.config.xml;
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;
@@ -26,8 +25,8 @@ import org.springframework.integration.handler.AbstractReplyProducingMessageHand
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
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;
@@ -36,11 +35,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* a default object in case of downstream failure.
*
* @author Kris Jacyna
* @author Artem Bilan
*
* @since 4.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class EnricherParserTests5 {
@SpringJUnitConfig
@DirtiesContext
public class EnricherParser5Tests {
@Autowired
private ApplicationContext context;

View File

@@ -43,10 +43,6 @@
</request-handler-advice-chain>
</enricher>
<enricher input-channel="input2" output-channel="output">
<header name="foo" expression="new java.util.Date()"/>
</enricher>
<util:constant id="testBean" static-field="org.springframework.integration.config.xml.EnricherParserTests$Gender.MALE"/>
</beans:beans>

View File

@@ -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.
@@ -18,11 +18,9 @@ package org.springframework.integration.config.xml;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.TypeMismatchException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.expression.Expression;
@@ -35,12 +33,10 @@ import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.transformer.ContentEnricher;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.SubscribableChannel;
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;
@@ -52,8 +48,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class EnricherParserTests {
@Autowired
@@ -101,7 +97,6 @@ public class EnricherParserTests {
@Test
public void configurationCheckTimeoutParameters() {
Object endpoint = context.getBean("enricher");
Long requestTimeout = TestUtils.getPropertyValue(endpoint, "handler.requestTimeout", Long.class);
@@ -109,18 +104,15 @@ public class EnricherParserTests {
assertThat(requestTimeout).isEqualTo(Long.valueOf(1234L));
assertThat(replyTimeout).isEqualTo(Long.valueOf(9876L));
}
@Test
public void configurationCheckRequiresReply() {
Object endpoint = context.getBean("enricher");
boolean requiresReply = TestUtils.getPropertyValue(endpoint, "handler.requiresReply", Boolean.class);
assertThat(requiresReply).as("Was expecting requiresReply to be 'false'").isTrue();
}
@Test
@@ -167,32 +159,7 @@ public class EnricherParserTests {
adviceCalled--;
}
@Test
public void testInt3027WrongHeaderType() {
MessageChannel input = context.getBean("input2", MessageChannel.class);
try {
input.send(new GenericMessage<Object>("test"));
}
catch (Exception e) {
assertThat(e).isInstanceOf(MessageHandlingException.class);
assertThat(e.getCause()).isInstanceOf(TypeMismatchException.class);
assertThat(e.getCause().getMessage())
.startsWith("Failed to convert value of type 'java.util.Date' to required type 'int'");
}
}
private static class Source {
private final String sourceName;
Source(String sourceName) {
this.sourceName = sourceName;
}
@SuppressWarnings("unused")
public String getSourceName() {
return sourceName;
}
private record Source(String sourceName) {
}

View File

@@ -18,8 +18,7 @@ package org.springframework.integration.config.xml;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,8 +31,8 @@ import org.springframework.integration.transformer.ContentEnricher;
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.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;
@@ -43,8 +42,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class EnricherParserTestsWithoutRequestChannel {
@Autowired

View File

@@ -18,8 +18,7 @@ package org.springframework.integration.config.xml;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,8 +33,8 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.SubscribableChannel;
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;
@@ -45,8 +44,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class EnricherParserWithRequestPayloadExpressionTests {
@Autowired
@@ -114,18 +113,7 @@ public class EnricherParserWithRequestPayloadExpressionTests {
assertThat(enriched).isSameAs(original);
}
private static class Source {
private final String sourceName;
Source(String sourceName) {
this.sourceName = sourceName;
}
@SuppressWarnings("unused")
public String getSourceName() {
return sourceName;
}
private record Source(String sourceName) {
}

View File

@@ -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,6 +27,7 @@ import org.springframework.integration.handler.LoggingHandler;
import org.springframework.integration.test.util.TestUtils;
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;
@@ -36,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Artem Bilan
*/
@SpringJUnitConfig
@DirtiesContext
public class ErrorChannelAutoCreationTests {
@Autowired

View File

@@ -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,15 +16,14 @@
package org.springframework.integration.config.xml;
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.messaging.MessageChannel;
import org.springframework.messaging.support.ErrorMessage;
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;
@@ -33,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gunnar Hillert
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class ErrorMessageExceptionTypeRouterParserTests {
@Autowired

View File

@@ -19,8 +19,7 @@ package org.springframework.integration.config.xml;
import java.util.HashMap;
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.context.ApplicationContext;
@@ -28,8 +27,8 @@ 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;
@@ -39,8 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class HeaderEnricherMethodInvokingTests {
@Autowired

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.config.xml;
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,8 +28,8 @@ 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.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;
@@ -40,8 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class HeaderEnricherOverwriteTests {
@Autowired
@@ -156,7 +155,7 @@ public class HeaderEnricherOverwriteTests {
MessageChannel channel = this.context.getBean("priorityExplicitOverwriteTrueInput", MessageChannel.class);
MessagingTemplate template = new MessagingTemplate();
template.setDefaultDestination(channel);
Message<?> result = template.sendAndReceive(new GenericMessage<String>("test"));
Message<?> result = template.sendAndReceive(new GenericMessage<>("test"));
assertThat(result).isNotNull();
assertThat(new IntegrationMessageHeaderAccessor(result).getPriority()).isEqualTo(42);
}
@@ -312,17 +311,7 @@ public class HeaderEnricherOverwriteTests {
assertThat(result.getHeaders().get("foo")).isEqualTo("ABC");
}
public static class TestBean {
private final String text;
public TestBean(String text) {
this.text = text;
}
public String text() {
return this.text;
}
public record TestBean(String text) {
}

View File

@@ -27,6 +27,7 @@ import org.springframework.integration.transformer.MessageTransformationExceptio
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
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.assertThatExceptionOfType;
* @since 2.0
*/
@SpringJUnitConfig
@DirtiesContext
class HeaderEnricherParserTests {
@Autowired

View File

@@ -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 static org.assertj.core.api.Assertions.assertThat;
@@ -49,6 +50,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 2.0
*/
@SpringJUnitConfig
@DirtiesContext
public class HeaderEnricherTests {
@Autowired

View File

@@ -16,24 +16,25 @@
package org.springframework.integration.config.xml;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.test.util.TestUtils;
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;
/**
* @author Mark Fisher
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class InnerBeanConfigTests {
@Autowired
@@ -42,12 +43,12 @@ public class InnerBeanConfigTests {
@Autowired
private ApplicationContext context;
// INT-1528: the inner bean should not be registered in the context
@Test(expected = NoSuchBeanDefinitionException.class)
@Test
public void checkInnerBean() {
Object innerBean = TestUtils.getPropertyValue(testEndpoint, "handler.processor.delegate.targetObject");
assertThat(innerBean).isNotNull();
context.getBean(TestBean.class);
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> context.getBean(TestBean.class));
}
public static class TestBean {

View File

@@ -16,24 +16,25 @@
package org.springframework.integration.config.xml;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.Ordered;
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 1.0.3
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class OrderedHandlersTests {
@Autowired

View File

@@ -18,16 +18,15 @@ package org.springframework.integration.config.xml;
import java.util.List;
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.aggregator.AggregatingMessageHandler;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.test.util.TestUtils;
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;
@@ -37,8 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class PNamespaceTests {
@Autowired

View File

@@ -37,6 +37,7 @@ 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.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.util.FileCopyUtils;
@@ -48,6 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Artem Bilan
*/
@SpringJUnitConfig
@DirtiesContext
public class PayloadDeserializingTransformerParserTests {
@Autowired
@@ -69,7 +71,7 @@ public class PayloadDeserializingTransformerParserTests {
@Test
public void directChannelWithSerializedStringMessage() throws Exception {
byte[] bytes = serialize("foo");
directInput.send(new GenericMessage<byte[]>(bytes));
directInput.send(new GenericMessage<>(bytes));
Message<?> result = output.receive(10000);
assertThat(result).isNotNull();
assertThat(result.getPayload() instanceof String).isTrue();