diff --git a/build.gradle b/build.gradle
index f0245690d5..76fc540800 100644
--- a/build.gradle
+++ b/build.gradle
@@ -118,7 +118,7 @@ subprojects { subproject ->
junitVersion = '4.12'
jythonVersion = '2.5.3'
kryoShadedVersion = '3.0.3'
- log4jVersion = '1.2.17'
+ log4jVersion = '2.10.0'
mockitoVersion = '2.11.0'
mysqlVersion = '6.0.6'
pahoMqttClientVersion = '1.2.0'
@@ -127,7 +127,6 @@ subprojects { subproject ->
reactorVersion = '3.1.2.RELEASE'
romeToolsVersion = '1.8.0'
servletApiVersion = '4.0.0'
- slf4jVersion = "1.7.25"
smackVersion = '4.2.2'
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.0.1.RELEASE'
springDataJpaVersion = '2.0.2.RELEASE'
@@ -160,7 +159,8 @@ subprojects { subproject ->
testCompile project(":spring-integration-test-support")
}
- testCompile "org.slf4j:slf4j-log4j12:$slf4jVersion"
+ testRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
+ testRuntime "org.apache.logging.log4j:log4j-jcl:$log4jVersion"
}
// enable all compiler warnings; individual projects may customize further
@@ -275,7 +275,8 @@ project('spring-integration-test-support') {
compile "org.springframework:spring-context:$springVersion"
compile "org.springframework:spring-messaging:$springVersion"
compile "org.springframework:spring-test:$springVersion"
- compile ("log4j:log4j:$log4jVersion", optional)
+ compile ("org.apache.logging.log4j:log4j-core:$log4jVersion" , optional)
+ compile ('log4j:log4j:1.2.17', optional)
}
}
diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java
index 99c03cbf97..97601888c2 100644
--- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java
+++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2017 the original author or authors.
+ * Copyright 2016-2018 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.
@@ -35,7 +35,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
-import org.apache.log4j.Level;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -59,7 +58,7 @@ import org.springframework.integration.amqp.support.ReturnedAmqpMessageException
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
-import org.springframework.integration.test.rule.Log4jLevelAdjuster;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.ErrorMessage;
@@ -78,8 +77,10 @@ public class AsyncAmqpGatewayTests {
public static BrokerRunning brokerRunning = BrokerRunning.isRunningWithEmptyQueues("asyncQ1", "asyncRQ1");
@Rule
- public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE, "org.springframework.integration",
- "org.springframework.amqp");
+ public Log4j2LevelAdjuster adjuster =
+ Log4j2LevelAdjuster.trace()
+ .categories("org.springframework.integration",
+ "org.springframework.amqp");
@AfterClass
public static void tearDown() {
diff --git a/spring-integration-amqp/src/test/resources/log4j.properties b/spring-integration-amqp/src/test/resources/log4j.properties
deleted file mode 100644
index cbcbba8150..0000000000
--- a/spring-integration-amqp/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %p [%t] [%c] - %m%n
-
-log4j.category.test=DEBUG
-log4j.category.org.springframework=WARN
-log4j.category.org.springframework.amqp=WARN
-log4j.category.org.springframework.integration.amqp=WARN
diff --git a/spring-integration-amqp/src/test/resources/log4j2-test.xml b/spring-integration-amqp/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..6961531500
--- /dev/null
+++ b/spring-integration-amqp/src/test/resources/log4j2-test.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorWithCustomReleaseStrategyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorWithCustomReleaseStrategyTests.java
index 20859c1b2b..a009c2bd99 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorWithCustomReleaseStrategyTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorWithCustomReleaseStrategyTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,60 +25,27 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
-import org.junit.Assume;
-import org.junit.Rule;
+import org.junit.ClassRule;
import org.junit.Test;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
+import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
+ * @author Artem Bilan
*
*/
public class AggregatorWithCustomReleaseStrategyTests {
- @Rule
- public TestWatcher longTests = new TestWatcher() {
-
- private static final String RUN_LONG_PROP = "RUN_LONG_INTEGRATION_TESTS";
-
- private boolean shouldRun;
-
- {
- for (String value: new String[]{System.getenv(RUN_LONG_PROP), System.getProperty(RUN_LONG_PROP)}) {
- if ("true".equalsIgnoreCase(value)) {
- this.shouldRun = true;
- break;
- }
- }
- }
-
- @Override
- public Statement apply(Statement base, Description description) {
- if (!this.shouldRun) {
- return new Statement() {
-
- @Override
- public void evaluate() throws Throwable {
- Assume.assumeTrue(false);
- }
- };
- }
- else {
- return super.apply(base, description);
- }
- }
-
- };
+ @ClassRule
+ public static LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
private static ExecutorService executor = Executors.newCachedThreadPool();
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/LoggingChannelAdapterParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/LoggingChannelAdapterParserTests.java
index 372e59eed9..4968db6acd 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/LoggingChannelAdapterParserTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/LoggingChannelAdapterParserTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2018 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.test.context.junit4.SpringJUnit4ClassRunner;
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
+ *
* @since 2.1
*/
@ContextConfiguration
@@ -56,7 +57,8 @@ public class LoggingChannelAdapterParserTests {
@Test
public void verifyConfig() {
LoggingHandler loggingHandler = TestUtils.getPropertyValue(loggerConsumer, "handler", LoggingHandler.class);
- assertEquals("org.springframework.integration.test.logger", TestUtils.getPropertyValue(loggingHandler, "messageLogger.name"));
+ assertEquals("org.springframework.integration.test.logger",
+ TestUtils.getPropertyValue(loggingHandler, "messageLogger.logger.name"));
assertEquals(1, TestUtils.getPropertyValue(loggingHandler, "order"));
assertEquals("WARN", TestUtils.getPropertyValue(loggingHandler, "level").toString());
assertEquals("#root", TestUtils.getPropertyValue(loggingHandler, "expression.expression"));
@@ -65,7 +67,8 @@ public class LoggingChannelAdapterParserTests {
@Test
public void verifyExpressionAndOtherDefaultConfig() {
LoggingHandler loggingHandler = TestUtils.getPropertyValue(loggerWithExpression, "handler", LoggingHandler.class);
- assertEquals("org.springframework.integration.handler.LoggingHandler", TestUtils.getPropertyValue(loggingHandler, "messageLogger.name"));
+ assertEquals("org.springframework.integration.handler.LoggingHandler",
+ TestUtils.getPropertyValue(loggingHandler, "messageLogger.logger.name"));
assertEquals(Ordered.LOWEST_PRECEDENCE, TestUtils.getPropertyValue(loggingHandler, "order"));
assertEquals("INFO", TestUtils.getPropertyValue(loggingHandler, "level").toString());
assertEquals("payload.foo", TestUtils.getPropertyValue(loggingHandler, "expression.expression"));
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java
index 275fff3f8c..24dda6f495 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2017 the original author or authors.
+ * Copyright 2014-2018 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.
@@ -42,7 +42,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.Joinpoint;
import org.aopalliance.intercept.MethodInterceptor;
-import org.apache.log4j.Level;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -67,7 +66,7 @@ import org.springframework.integration.config.ExpressionControlBusFactoryBean;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.scheduling.PollSkipAdvice;
import org.springframework.integration.scheduling.SimplePollSkipStrategy;
-import org.springframework.integration.test.rule.Log4jLevelAdjuster;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.integration.test.util.OnlyOnceTrigger;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.util.CompoundTrigger;
@@ -85,6 +84,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Gary Russell
+ * @author Artem Bilan
+ *
* @since 4.1
*
*/
@@ -94,7 +95,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class PollerAdviceTests {
@Rule
- public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE, "org.springframework.integration");
+ public Log4j2LevelAdjuster adjuster = Log4j2LevelAdjuster.trace();
@Autowired
private MessageChannel control;
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/ExpressionEvaluatingMessageProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/ExpressionEvaluatingMessageProcessorTests.java
index cc5998d719..30bdd368a4 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/handler/ExpressionEvaluatingMessageProcessorTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/ExpressionEvaluatingMessageProcessorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import java.util.Arrays;
+import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,7 +42,6 @@ import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
-import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.config.IntegrationEvaluationContextFactoryBean;
import org.springframework.integration.context.IntegrationContextUtils;
@@ -56,121 +56,122 @@ import org.springframework.messaging.support.GenericMessage;
* @author Gunnar Hillert
* @author Gary Russell
* @author Artem Bilan
+ *
* @since 2.0
*/
public class ExpressionEvaluatingMessageProcessorTests {
private static final Log logger = LogFactory.getLog(ExpressionEvaluatingMessageProcessorTests.class);
- private static final ExpressionParser expressionParser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
+ private static final ExpressionParser expressionParser = new SpelExpressionParser();
@Rule
public ExpectedException expected = ExpectedException.none();
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessage() {
Expression expression = expressionParser.parseExpression("payload");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
- assertEquals("foo", processor.processMessage(new GenericMessage("foo")));
+ assertEquals("foo", processor.processMessage(new GenericMessage<>("foo")));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageWithParameterCoercion() throws Exception {
@SuppressWarnings("unused")
class TestTarget {
+
public String stringify(int number) {
return number + "";
}
}
Expression expression = expressionParser.parseExpression("#target.stringify(payload)");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
processor.afterPropertiesSet();
- EvaluationContext evaluationContext = TestUtils.getPropertyValue(processor, "evaluationContext", EvaluationContext.class);
+ EvaluationContext evaluationContext =
+ TestUtils.getPropertyValue(processor, "evaluationContext", EvaluationContext.class);
evaluationContext.setVariable("target", new TestTarget());
- assertEquals("2", processor.processMessage(new GenericMessage("2")));
+ assertEquals("2", processor.processMessage(new GenericMessage<>("2")));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageWithVoidResult() throws Exception {
@SuppressWarnings("unused")
class TestTarget {
+
public void ping(String input) {
}
}
+
Expression expression = expressionParser.parseExpression("#target.ping(payload)");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
processor.afterPropertiesSet();
- EvaluationContext evaluationContext = TestUtils.getPropertyValue(processor, "evaluationContext", EvaluationContext.class);
+ EvaluationContext evaluationContext =
+ TestUtils.getPropertyValue(processor, "evaluationContext", EvaluationContext.class);
evaluationContext.setVariable("target", new TestTarget());
- assertEquals(null, processor.processMessage(new GenericMessage("2")));
+ assertEquals(null, processor.processMessage(new GenericMessage<>("2")));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageWithParameterCoercionToNonPrimitive() throws Exception {
class TestTarget {
+
@SuppressWarnings("unused")
public String find(Resource[] resources) {
- return Arrays.asList(resources).toString();
+ return Arrays.toString(resources);
}
}
Expression expression = expressionParser.parseExpression("#target.find(payload)");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
AbstractApplicationContext applicationContext = new GenericApplicationContext();
processor.setBeanFactory(applicationContext);
IntegrationEvaluationContextFactoryBean factoryBean = new IntegrationEvaluationContextFactoryBean();
factoryBean.setApplicationContext(applicationContext);
- applicationContext.getBeanFactory().registerSingleton(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME,
- factoryBean.getObject());
+ applicationContext.getBeanFactory()
+ .registerSingleton(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME,
+ factoryBean.getObject());
applicationContext.refresh();
processor.afterPropertiesSet();
- EvaluationContext evaluationContext = TestUtils.getPropertyValue(processor, "evaluationContext", EvaluationContext.class);
+ EvaluationContext evaluationContext =
+ TestUtils.getPropertyValue(processor, "evaluationContext", EvaluationContext.class);
evaluationContext.setVariable("target", new TestTarget());
- String result = (String) processor.processMessage(new GenericMessage("classpath*:*.properties"));
- assertTrue("Wrong result: " + result, result.contains("log4j.properties"));
+ String result = processor.processMessage(new GenericMessage<>("classpath*:*-test.xml"));
+ assertTrue("Wrong result: " + result, result.contains("log4j2-test.xml"));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageWithDollarInBrackets() {
Expression expression = expressionParser.parseExpression("headers['$foo_id']");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
Message message = MessageBuilder.withPayload("foo").setHeader("$foo_id", "abc").build();
assertEquals("abc", processor.processMessage(message));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageWithDollarPropertyAccess() {
Expression expression = expressionParser.parseExpression("headers.$foo_id");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
Message message = MessageBuilder.withPayload("foo").setHeader("$foo_id", "xyz").build();
assertEquals("xyz", processor.processMessage(message));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageWithStaticKey() {
Expression expression = expressionParser.parseExpression("headers[headers.ID]");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
- GenericMessage message = new GenericMessage("foo");
+ GenericMessage message = new GenericMessage<>("foo");
assertEquals(message.getHeaders().getId(), processor.processMessage(message));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageWithBeanAsMethodArgument() throws Exception {
StaticApplicationContext context = new StaticApplicationContext();
@@ -182,14 +183,13 @@ public class ExpressionEvaluatingMessageProcessorTests {
context.refresh();
Expression expression = expressionParser.parseExpression("payload.concat(@testString)");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(context);
processor.afterPropertiesSet();
- GenericMessage message = new GenericMessage("foo");
+ GenericMessage message = new GenericMessage<>("foo");
assertEquals("foobar", processor.processMessage(message));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageWithMethodCallOnBean() throws Exception {
StaticApplicationContext context = new StaticApplicationContext();
@@ -201,76 +201,83 @@ public class ExpressionEvaluatingMessageProcessorTests {
context.refresh();
Expression expression = expressionParser.parseExpression("@testString.concat(payload)");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(context);
processor.afterPropertiesSet();
- GenericMessage message = new GenericMessage("foo");
+ GenericMessage message = new GenericMessage<>("foo");
assertEquals("barfoo", processor.processMessage(message));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
+
@Test
public void testProcessMessageBadExpression() {
expected.expect(new TypeSafeMatcher(Exception.class) {
+
private Throwable cause;
+
@Override
public boolean matchesSafely(Exception item) {
logger.debug(item);
cause = item.getCause();
return cause instanceof EvaluationException;
}
+
@Override
public void describeTo(Description description) {
description.appendText("cause to be EvaluationException but was ").appendValue(cause);
}
});
Expression expression = expressionParser.parseExpression("payload.fixMe()");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
- assertEquals("foo", processor.processMessage(new GenericMessage("foo")));
+ assertEquals("foo", processor.processMessage(new GenericMessage<>("foo")));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageExpressionThrowsRuntimeException() {
expected.expect(new TypeSafeMatcher(Exception.class) {
+
private Throwable cause;
+
@Override
public boolean matchesSafely(Exception item) {
logger.debug(item);
cause = item.getCause();
return cause instanceof UnsupportedOperationException;
}
+
@Override
public void describeTo(Description description) {
description.appendText("cause to be UnsupportedOperationException but was ").appendValue(cause);
}
});
Expression expression = expressionParser.parseExpression("payload.throwRuntimeException()");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
- assertEquals("foo", processor.processMessage(new GenericMessage(new TestPayload())));
+ assertEquals("foo", processor.processMessage(new GenericMessage<>(new TestPayload())));
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testProcessMessageExpressionThrowsCheckedException() {
expected.expect(new TypeSafeMatcher(Exception.class) {
+
private Throwable cause;
+
@Override
public boolean matchesSafely(Exception item) {
logger.debug(item);
cause = item.getCause();
return cause instanceof CheckedException;
}
+
@Override
public void describeTo(Description description) {
description.appendText("cause to be CheckedException but was ").appendValue(cause);
}
});
Expression expression = expressionParser.parseExpression("payload.throwCheckedException()");
- ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
+ ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor<>(expression);
processor.setBeanFactory(mock(BeanFactory.class));
- assertEquals("foo", processor.processMessage(new GenericMessage(new TestPayload())));
+ assertEquals("foo", processor.processMessage(new GenericMessage<>(new TestPayload())));
}
@@ -288,6 +295,7 @@ public class ExpressionEvaluatingMessageProcessorTests {
public String throwCheckedException() throws Exception {
throw new CheckedException("Expected test exception");
}
+
}
@SuppressWarnings("serial")
diff --git a/spring-integration-core/src/test/resources/log4j.properties b/spring-integration-core/src/test/resources/log4j.properties
deleted file mode 100644
index c87f9f5b94..0000000000
--- a/spring-integration-core/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %p %c{1} [%t] : %m%n
-
-log4j.category.org.springframework.integration=WARN
diff --git a/spring-integration-core/src/test/resources/log4j2-test.xml b/spring-integration-core/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..0e6b0198e3
--- /dev/null
+++ b/spring-integration-core/src/test/resources/log4j2-test.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-event/src/test/java/log4j.properties b/spring-integration-event/src/test/java/log4j.properties
deleted file mode 100644
index 34495a6fda..0000000000
--- a/spring-integration-event/src/test/java/log4j.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%c{1}: (%t) %m%n
-
-log4j.category.org.springframework.integration=WARN
-log4j.category.org.springframework.integration.event=INFO
diff --git a/spring-integration-event/src/test/resources/log4j2-test.xml b/spring-integration-event/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..94419afcd9
--- /dev/null
+++ b/spring-integration-event/src/test/resources/log4j2-test.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-feed/src/test/java/log4j.properties b/spring-integration-feed/src/test/java/log4j.properties
deleted file mode 100644
index 54e2f03a72..0000000000
--- a/spring-integration-feed/src/test/java/log4j.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%c{1}: %m%n
-
-log4j.category.org.springframework.integration=WARN
-log4j.category.org.springframework.integration.feed=WARN
diff --git a/spring-integration-feed/src/test/resources/log4j2-test.xml b/spring-integration-feed/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..2802cef0d4
--- /dev/null
+++ b/spring-integration-feed/src/test/resources/log4j2-test.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-file/src/test/resources/log4j.properties b/spring-integration-file/src/test/resources/log4j.properties
deleted file mode 100644
index 941cbe4822..0000000000
--- a/spring-integration-file/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%c{1}: %m%n
-
-log4j.category.org.springframework.integration=WARN
-log4j.category.org.springframework.integration.file=WARN
diff --git a/spring-integration-file/src/test/resources/log4j2-test.xml b/spring-integration-file/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..3a7cc58bb2
--- /dev/null
+++ b/spring-integration-file/src/test/resources/log4j2-test.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-ftp/src/test/resources/log4j.properties b/spring-integration-ftp/src/test/resources/log4j.properties
deleted file mode 100644
index 5405a7cfd3..0000000000
--- a/spring-integration-ftp/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
-
-log4j.category.org.springframework=WARN
-log4j.category.org.springframework.integration=WARN
-log4j.category.org.springframework.integration.file=WARN
diff --git a/spring-integration-ftp/src/test/resources/log4j2-test.xml b/spring-integration-ftp/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..7541cd10b7
--- /dev/null
+++ b/spring-integration-ftp/src/test/resources/log4j2-test.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-gemfire/src/test/resources/log4j.xml b/spring-integration-gemfire/src/test/resources/log4j.xml
deleted file mode 100644
index e871f82216..0000000000
--- a/spring-integration-gemfire/src/test/resources/log4j.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-integration-gemfire/src/test/resources/log4j2-test.xml b/spring-integration-gemfire/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..d56e00716b
--- /dev/null
+++ b/spring-integration-gemfire/src/test/resources/log4j2-test.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-groovy/src/test/resources/log4j.properties b/spring-integration-groovy/src/test/resources/log4j.properties
deleted file mode 100644
index 538a5c4c9e..0000000000
--- a/spring-integration-groovy/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%c{1}: %m%n
-
-log4j.category.org.springframework.integration=WARN
diff --git a/spring-integration-groovy/src/test/resources/log4j2-test.xml b/spring-integration-groovy/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..d2a8388785
--- /dev/null
+++ b/spring-integration-groovy/src/test/resources/log4j2-test.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-http/src/test/resources/log4j.properties b/spring-integration-http/src/test/resources/log4j.properties
deleted file mode 100644
index 3cf693eac4..0000000000
--- a/spring-integration-http/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
-
-#log4j.category.org.springframework=DEBUG
-log4j.category.org.springframework.integration=WARN
-log4j.category.org.springframework.integration.http=WARN
diff --git a/spring-integration-http/src/test/resources/log4j2-test.xml b/spring-integration-http/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..7340a5bb79
--- /dev/null
+++ b/spring-integration-http/src/test/resources/log4j2-test.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpOutboundGatewayTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpOutboundGatewayTests.java
index accbe3892d..ccbc647b2b 100644
--- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpOutboundGatewayTests.java
+++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpOutboundGatewayTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -51,7 +51,10 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.net.ServerSocketFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mockito;
@@ -70,7 +73,7 @@ import org.springframework.integration.ip.tcp.connection.TcpConnectionSupport;
import org.springframework.integration.ip.tcp.connection.TcpNetClientConnectionFactory;
import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionFactory;
import org.springframework.integration.support.MessageBuilder;
-import org.springframework.integration.test.support.LogAdjustingTestSupport;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
@@ -80,13 +83,20 @@ import org.springframework.messaging.support.GenericMessage;
/**
* @author Gary Russell
* @author Artem Bilan
+ *
* @since 2.0
*/
-public class TcpOutboundGatewayTests extends LogAdjustingTestSupport {
+public class TcpOutboundGatewayTests {
+
+ private static final Log logger = LogFactory.getLog(TcpOutboundGatewayTests.class);
@ClassRule
public static LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
+ @Rule
+ public Log4j2LevelAdjuster adjuster = Log4j2LevelAdjuster.trace();
+
+
@Test
public void testGoodNetSingle() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionFactoryTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionFactoryTests.java
index cbc04dbc71..db7ed2df46 100644
--- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionFactoryTests.java
+++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionFactoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.junit.Rule;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -56,7 +57,7 @@ import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.ip.config.TcpConnectionFactoryFactoryBean;
import org.springframework.integration.ip.event.IpIntegrationEvent;
import org.springframework.integration.ip.tcp.TcpReceivingChannelAdapter;
-import org.springframework.integration.test.support.LogAdjustingTestSupport;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@@ -64,10 +65,14 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/**
* @author Gary Russell
* @author Artem Bilan
+ *
* @since 3.0
*
*/
-public class ConnectionFactoryTests extends LogAdjustingTestSupport {
+public class ConnectionFactoryTests {
+
+ @Rule
+ public Log4j2LevelAdjuster adjuster = Log4j2LevelAdjuster.trace();
@Test
public void factoryBeanTests() {
diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactoryTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactoryTests.java
index a7bce7bf53..7858a52720 100644
--- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactoryTests.java
+++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -41,7 +41,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Level;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mockito;
@@ -56,7 +55,7 @@ import org.springframework.integration.ip.IpHeaders;
import org.springframework.integration.ip.tcp.TcpInboundGateway;
import org.springframework.integration.ip.tcp.TcpOutboundGateway;
import org.springframework.integration.ip.util.TestingUtilities;
-import org.springframework.integration.test.rule.Log4jLevelAdjuster;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.util.SimplePool;
import org.springframework.messaging.Message;
@@ -66,6 +65,8 @@ import org.springframework.messaging.support.GenericMessage;
/**
* @author Gary Russell
+ * @author Artem Bilan
+ *
* @since 2.2
*
*/
@@ -85,8 +86,10 @@ public class FailoverClientConnectionFactoryTests {
};
@Rule
- public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE,
- "org.springframework.integration.ip.tcp", "org.springframework.integration.util.SimplePool");
+ public Log4j2LevelAdjuster adjuster =
+ Log4j2LevelAdjuster.trace()
+ .classes(SimplePool.class)
+ .categories("org.springframework.integration.ip.tcp");
@Test
public void testFailoverGood() throws Exception {
@@ -227,7 +230,8 @@ public class FailoverClientConnectionFactoryTests {
failoverFactory.getConnection().send(message);
fail("ExpectedFailure");
}
- catch (IOException e) { }
+ catch (IOException e) {
+ }
failoverFactory.getConnection().send(message);
Mockito.verify(conn2).send(message);
Mockito.verify(conn1, times(3)).send(message);
@@ -572,7 +576,7 @@ public class FailoverClientConnectionFactoryTests {
gateway2.start();
TestingUtilities.waitListening(server1, null);
TestingUtilities.waitListening(server2, null);
- Holder holder = new Holder();
+ Holder holder = new Holder();
holder.exec = exec;
holder.connectionId = connectionId;
holder.server1 = server1;
diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java
index 4240673df0..cbeffd04a2 100644
--- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java
+++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -64,7 +64,6 @@ import javax.net.SocketFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.log4j.Level;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
@@ -81,7 +80,7 @@ import org.springframework.integration.ip.tcp.serializer.MapJsonSerializer;
import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.converter.MapMessageConverter;
-import org.springframework.integration.test.rule.Log4jLevelAdjuster;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.util.CompositeExecutor;
import org.springframework.messaging.Message;
@@ -93,6 +92,8 @@ import org.springframework.util.ReflectionUtils;
/**
* @author Gary Russell
* @author John Anderson
+ * @author Artem Bilan
+ *
* @since 2.0
*
*/
@@ -101,8 +102,9 @@ public class TcpNioConnectionTests {
private final static Log logger = LogFactory.getLog(TcpNioConnectionTests.class);
@Rule
- public final Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE,
- "org.springframework.integration.ip.tcp");
+ public Log4j2LevelAdjuster adjuster =
+ Log4j2LevelAdjuster.trace()
+ .categories("org.springframework.integration.ip.tcp");
@Rule
public TestName testName = new TestName();
diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketMulticastSendingHandlerTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketMulticastSendingHandlerTests.java
index 2568b4a3de..ca80f10413 100644
--- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketMulticastSendingHandlerTests.java
+++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketMulticastSendingHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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,20 +31,19 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.commons.logging.LogFactory;
-import org.apache.log4j.Level;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.ip.IpHeaders;
import org.springframework.integration.support.MessageBuilder;
-import org.springframework.integration.test.rule.Log4jLevelAdjuster;
import org.springframework.messaging.Message;
/**
* @author Mark Fisher
* @author Gary Russell
+ * @author Artem Bilan
+ *
* @since 2.0
*/
public class DatagramPacketMulticastSendingHandlerTests {
@@ -52,9 +51,6 @@ public class DatagramPacketMulticastSendingHandlerTests {
@Rule
public MulticastRule multicastRule = new MulticastRule();
- @Rule
- public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.DEBUG, "org.springframework.integration");
-
@Test
public void verifySendMulticast() throws Exception {
MulticastSocket socket;
@@ -78,8 +74,6 @@ public class DatagramPacketMulticastSendingHandlerTests {
InetAddress group = InetAddress.getByName(multicastAddress);
socket1.joinGroup(group);
listening.countDown();
- LogFactory.getLog(getClass())
- .debug(Thread.currentThread().getName() + " waiting for packet");
socket1.receive(receivedPacket);
socket1.close();
byte[] src = receivedPacket.getData();
@@ -88,8 +82,6 @@ public class DatagramPacketMulticastSendingHandlerTests {
byte[] dest = new byte[length];
System.arraycopy(src, offset, dest, 0, length);
assertEquals(payload, new String(dest));
- LogFactory.getLog(getClass())
- .debug(Thread.currentThread().getName() + " received packet");
received.countDown();
}
catch (Exception e) {
@@ -140,7 +132,6 @@ public class DatagramPacketMulticastSendingHandlerTests {
socket1.joinGroup(group);
listening.countDown();
assertTrue(ackListening.await(10, TimeUnit.SECONDS));
- LogFactory.getLog(getClass()).debug(Thread.currentThread().getName() + " waiting for packet");
socket1.receive(receivedPacket);
socket1.close();
byte[] src = receivedPacket.getData();
@@ -149,7 +140,6 @@ public class DatagramPacketMulticastSendingHandlerTests {
byte[] dest = new byte[6];
System.arraycopy(src, offset + length - 6, dest, 0, 6);
assertEquals(payload, new String(dest));
- LogFactory.getLog(getClass()).debug(Thread.currentThread().getName() + " received packet");
DatagramPacketMessageMapper mapper = new DatagramPacketMessageMapper();
mapper.setAcknowledge(true);
mapper.setLengthCheck(true);
@@ -157,11 +147,9 @@ public class DatagramPacketMulticastSendingHandlerTests {
Object id = message.getHeaders().get(IpHeaders.ACK_ID);
byte[] ack = id.toString().getBytes();
DatagramPacket ackPack = new DatagramPacket(ack, ack.length,
- new InetSocketAddress(multicastRule.getNic(), ackPort.get()));
+ new InetSocketAddress(multicastRule.getNic(), ackPort.get()));
DatagramSocket out = new DatagramSocket();
out.send(ackPack);
- LogFactory.getLog(getClass()).debug(Thread.currentThread().getName() + " sent ack to "
- + ackPack.getSocketAddress());
out.close();
ackSent.countDown();
socket1.close();
@@ -176,7 +164,7 @@ public class DatagramPacketMulticastSendingHandlerTests {
executor.execute(catcher);
assertTrue(listening.await(10000, TimeUnit.MILLISECONDS));
MulticastSendingMessageHandler handler =
- new MulticastSendingMessageHandler(multicastAddress, testPort, true, true, "localhost", 0, 10000);
+ new MulticastSendingMessageHandler(multicastAddress, testPort, true, true, "localhost", 0, 10000);
handler.setLocalAddress(this.multicastRule.getNic());
handler.setMinAcksForSuccess(2);
handler.setBeanFactory(mock(BeanFactory.class));
diff --git a/spring-integration-ip/src/test/resources/log4j.properties b/spring-integration-ip/src/test/resources/log4j.properties
deleted file mode 100644
index 31e0d7ed7e..0000000000
--- a/spring-integration-ip/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %5p %c{1} [%t] : %m%n
-
-log4j.category.org.springframework.integration=WARN
diff --git a/spring-integration-ip/src/test/resources/log4j2-test.xml b/spring-integration-ip/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..13ed4369dc
--- /dev/null
+++ b/spring-integration-ip/src/test/resources/log4j2-test.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/leader/JdbcLockRegistryLeaderInitiatorTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/leader/JdbcLockRegistryLeaderInitiatorTests.java
index 00c7de9c74..5ef5a5604e 100644
--- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/leader/JdbcLockRegistryLeaderInitiatorTests.java
+++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/leader/JdbcLockRegistryLeaderInitiatorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2017 the original author or authors.
+ * Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.apache.log4j.Level;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -37,7 +36,7 @@ import org.springframework.integration.leader.Context;
import org.springframework.integration.leader.DefaultCandidate;
import org.springframework.integration.leader.event.LeaderEventPublisher;
import org.springframework.integration.support.leader.LockRegistryLeaderInitiator;
-import org.springframework.integration.test.rule.Log4jLevelAdjuster;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
@@ -54,8 +53,12 @@ public class JdbcLockRegistryLeaderInitiatorTests {
public static EmbeddedDatabase dataSource;
@Rule
- public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.DEBUG, "org.springframework.integration",
- "org.springframework.integration.jdbc", "org.springframework.jdbc", "org.apache.derby");
+ public Log4j2LevelAdjuster adjuster =
+ Log4j2LevelAdjuster.trace()
+ .categories("org.springframework.integration",
+ "org.springframework.integration.jdbc",
+ "org.springframework.jdbc",
+ "org.apache.derby");
@BeforeClass
public static void init() {
diff --git a/spring-integration-jdbc/src/test/resources/log4j.properties b/spring-integration-jdbc/src/test/resources/log4j.properties
deleted file mode 100644
index badf30e5cb..0000000000
--- a/spring-integration-jdbc/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-log4j.rootCategory=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
-
-log4j.category.org.springframework.integration=WARN
-log4j.category.org.apache.derby=WARN
-
-log4j.category.org.springframework.jdbc=WARN
-log4j.category.org.springframework.integration.jdbc=WARN
diff --git a/spring-integration-jdbc/src/test/resources/log4j2-test.xml b/spring-integration-jdbc/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000000..c062dcc347
--- /dev/null
+++ b/spring-integration-jdbc/src/test/resources/log4j2-test.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/JmsOutboundGatewayTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/JmsOutboundGatewayTests.java
index 38a19bbe80..83eace2cf9 100644
--- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/JmsOutboundGatewayTests.java
+++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/JmsOutboundGatewayTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -43,13 +43,14 @@ import javax.jms.TextMessage;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.junit.Rule;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.jms.JmsOutboundGateway.ReplyContainerProperties;
-import org.springframework.integration.test.support.LogAdjustingTestSupport;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
import org.springframework.jms.JmsException;
@@ -63,15 +64,17 @@ import org.springframework.util.ObjectUtils;
/**
* @author Gary Russell
* @author Artem Bilan
+ *
* @since 2.2.4
*/
-public class JmsOutboundGatewayTests extends LogAdjustingTestSupport {
+public class JmsOutboundGatewayTests {
private final Log logger = LogFactory.getLog(this.getClass());
- public JmsOutboundGatewayTests() {
- super("org.springframework.integration", "org.springframework.jms", "org.apache");
- }
+ @Rule
+ public Log4j2LevelAdjuster adjuster =
+ Log4j2LevelAdjuster.trace()
+ .categories("org.springframework.integration", "org.springframework.jms", "org.apache");
@Test
public void testContainerBeanNameWhenNoGatewayBeanName() {
diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/OutboundGatewayFunctionTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/OutboundGatewayFunctionTests.java
index 85dc042194..409fe6b7b2 100644
--- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/OutboundGatewayFunctionTests.java
+++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/OutboundGatewayFunctionTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -33,11 +33,12 @@ import javax.jms.JMSException;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
+import org.junit.Rule;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.context.IntegrationContextUtils;
-import org.springframework.integration.test.support.LogAdjustingTestSupport;
+import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.jms.JmsException;
import org.springframework.jms.connection.CachingConnectionFactory;
@@ -50,10 +51,12 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/**
* @author Gary Russell
+ * @author Artem Bilan
+ *
* @since 2.2
*
*/
-public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
+public class OutboundGatewayFunctionTests {
private static Destination requestQueue1 = new ActiveMQQueue("request1");
@@ -75,6 +78,9 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
private static Destination replyQueue7 = new ActiveMQQueue("reply7");
+ @Rule
+ public Log4j2LevelAdjuster adjuster = Log4j2LevelAdjuster.trace();
+
@Test
public void testContainerWithDest() throws Exception {
BeanFactory beanFactory = mock(BeanFactory.class);
@@ -82,7 +88,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.initialize();
when(beanFactory.getBean(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME, TaskScheduler.class))
- .thenReturn(scheduler);
+ .thenReturn(scheduler);
final JmsOutboundGateway gateway = new JmsOutboundGateway();
gateway.setBeanFactory(beanFactory);
ConnectionFactory connectionFactory = getConnectionFactory();
@@ -127,7 +133,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.initialize();
when(beanFactory.getBean(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME, TaskScheduler.class))
- .thenReturn(scheduler);
+ .thenReturn(scheduler);
final JmsOutboundGateway gateway = new JmsOutboundGateway();
gateway.setBeanFactory(beanFactory);
gateway.setConnectionFactory(getConnectionFactory());
@@ -173,7 +179,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.initialize();
when(beanFactory.getBean(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME, TaskScheduler.class))
- .thenReturn(scheduler);
+ .thenReturn(scheduler);
final JmsOutboundGateway gateway = new JmsOutboundGateway();
gateway.setBeanFactory(beanFactory);
gateway.setConnectionFactory(getConnectionFactory());
@@ -202,7 +208,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
javax.jms.Message request = template.receive(requestQueue3);
assertNotNull(request);
final javax.jms.Message jmsReply = request;
- template.send(request.getJMSReplyTo(), (MessageCreator) session -> jmsReply);
+ template.send(request.getJMSReplyTo(), session -> jmsReply);
assertTrue(latch2.await(10, TimeUnit.SECONDS));
assertNotNull(reply.get());
@@ -217,7 +223,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.initialize();
when(beanFactory.getBean(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME, TaskScheduler.class))
- .thenReturn(scheduler);
+ .thenReturn(scheduler);
final JmsOutboundGateway gateway = new JmsOutboundGateway();
gateway.setBeanFactory(beanFactory);
gateway.setConnectionFactory(getConnectionFactory());
@@ -226,13 +232,13 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
gateway.setUseReplyContainer(true);
gateway.afterPropertiesSet();
gateway.start();
- final AtomicReference