INT-4376: Upgage to Log4J 2 (#2321)
* INT-4376: Upgage to Log4J 2 JIRA: https://jira.spring.io/browse/INT-4376 * Deprecate Log4J 1.x components in favor of newly added a `Log4j2LevelAdjuster` JUnit `@Rule` * Update all the logging configuration to Log4J 2 * Polishing after testing
This commit is contained in:
committed by
Gary Russell
parent
422f651113
commit
30450c48be
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
17
spring-integration-amqp/src/test/resources/log4j2-test.xml
Normal file
17
spring-integration-amqp/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="test" level="debug"/>
|
||||
<Logger name="org.springframework" level="warn"/>
|
||||
<Logger name="org.springframework.amqp" level="warn"/>
|
||||
<Logger name="org.springframework.integration.amqp" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(mock(BeanFactory.class));
|
||||
assertEquals("foo", processor.processMessage(new GenericMessage<String>("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<String> 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<String>("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<String> 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<String>("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<String> 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<String>("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<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(mock(BeanFactory.class));
|
||||
Message<String> 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<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(mock(BeanFactory.class));
|
||||
Message<String> 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<UUID> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(mock(BeanFactory.class));
|
||||
GenericMessage<String> message = new GenericMessage<String>("foo");
|
||||
GenericMessage<String> 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<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(context);
|
||||
processor.afterPropertiesSet();
|
||||
GenericMessage<String> message = new GenericMessage<String>("foo");
|
||||
GenericMessage<String> 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<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(context);
|
||||
processor.afterPropertiesSet();
|
||||
GenericMessage<String> message = new GenericMessage<String>("foo");
|
||||
GenericMessage<String> message = new GenericMessage<>("foo");
|
||||
assertEquals("barfoo", processor.processMessage(message));
|
||||
}
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
|
||||
@Test
|
||||
public void testProcessMessageBadExpression() {
|
||||
expected.expect(new TypeSafeMatcher<Exception>(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<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(mock(BeanFactory.class));
|
||||
assertEquals("foo", processor.processMessage(new GenericMessage<String>("foo")));
|
||||
assertEquals("foo", processor.processMessage(new GenericMessage<>("foo")));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testProcessMessageExpressionThrowsRuntimeException() {
|
||||
expected.expect(new TypeSafeMatcher<Exception>(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<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(mock(BeanFactory.class));
|
||||
assertEquals("foo", processor.processMessage(new GenericMessage<TestPayload>(new TestPayload())));
|
||||
assertEquals("foo", processor.processMessage(new GenericMessage<>(new TestPayload())));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testProcessMessageExpressionThrowsCheckedException() {
|
||||
expected.expect(new TypeSafeMatcher<Exception>(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<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
|
||||
processor.setBeanFactory(mock(BeanFactory.class));
|
||||
assertEquals("foo", processor.processMessage(new GenericMessage<TestPayload>(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")
|
||||
|
||||
@@ -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
|
||||
14
spring-integration-core/src/test/resources/log4j2-test.xml
Normal file
14
spring-integration-core/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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
|
||||
15
spring-integration-event/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-event/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.event" level="info"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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
|
||||
15
spring-integration-feed/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-feed/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.feed" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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
|
||||
15
spring-integration-file/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-file/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.file" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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
|
||||
17
spring-integration-ftp/src/test/resources/log4j2-test.xml
Normal file
17
spring-integration-ftp/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.file" level="warn"/>
|
||||
<Logger name="org.springframework.integration.ftp" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="[%t] %-5p: %c - %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="info" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.gemfire" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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
|
||||
16
spring-integration-groovy/src/test/resources/log4j2-test.xml
Normal file
16
spring-integration-groovy/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.groovy" level="warn"/>
|
||||
<Logger name="org.springframework.integration.scripting" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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
|
||||
18
spring-integration-http/src/test/resources/log4j2-test.xml
Normal file
18
spring-integration-http/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.web" level="warn"/>
|
||||
<Logger name="org.springframework.http" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.groovy" level="warn"/>
|
||||
<Logger name="org.springframework.integration.http" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
15
spring-integration-ip/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-ip/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.ip" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
17
spring-integration-jdbc/src/test/resources/log4j2-test.xml
Normal file
17
spring-integration-jdbc/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.apache.derby" level="warn"/>
|
||||
<Logger name="org.springframework.jdbc" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.jdbc" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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() {
|
||||
|
||||
@@ -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<Object> reply = new AtomicReference<Object>();
|
||||
final AtomicReference<Object> reply = new AtomicReference<>();
|
||||
final CountDownLatch latch1 = new CountDownLatch(1);
|
||||
final CountDownLatch latch2 = new CountDownLatch(1);
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
latch1.countDown();
|
||||
try {
|
||||
reply.set(gateway.handleRequestMessage(new GenericMessage<String>("foo")));
|
||||
reply.set(gateway.handleRequestMessage(new GenericMessage<>("foo")));
|
||||
}
|
||||
finally {
|
||||
latch2.countDown();
|
||||
@@ -245,7 +251,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
|
||||
javax.jms.Message request = template.receive(requestQueue4);
|
||||
assertNotNull(request);
|
||||
final javax.jms.Message jmsReply = request;
|
||||
template.send(request.getJMSReplyTo(), (MessageCreator) session -> {
|
||||
template.send(request.getJMSReplyTo(), session -> {
|
||||
jmsReply.setJMSCorrelationID(jmsReply.getJMSMessageID());
|
||||
return jmsReply;
|
||||
});
|
||||
@@ -263,7 +269,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());
|
||||
@@ -273,13 +279,13 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
|
||||
gateway.setComponentName("testContainerWithTemporary.gateway");
|
||||
gateway.afterPropertiesSet();
|
||||
gateway.start();
|
||||
final AtomicReference<Object> reply = new AtomicReference<Object>();
|
||||
final AtomicReference<Object> reply = new AtomicReference<>();
|
||||
final CountDownLatch latch1 = new CountDownLatch(1);
|
||||
final CountDownLatch latch2 = new CountDownLatch(1);
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
latch1.countDown();
|
||||
try {
|
||||
reply.set(gateway.handleRequestMessage(new GenericMessage<String>("foo")));
|
||||
reply.set(gateway.handleRequestMessage(new GenericMessage<>("foo")));
|
||||
}
|
||||
finally {
|
||||
latch2.countDown();
|
||||
@@ -292,7 +298,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
|
||||
javax.jms.Message request = template.receive(requestQueue5);
|
||||
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());
|
||||
|
||||
@@ -307,7 +313,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());
|
||||
@@ -315,13 +321,13 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
|
||||
gateway.setUseReplyContainer(true);
|
||||
gateway.afterPropertiesSet();
|
||||
gateway.start();
|
||||
final AtomicReference<Object> reply = new AtomicReference<Object>();
|
||||
final AtomicReference<Object> reply = new AtomicReference<>();
|
||||
final CountDownLatch latch1 = new CountDownLatch(1);
|
||||
final CountDownLatch latch2 = new CountDownLatch(1);
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
latch1.countDown();
|
||||
try {
|
||||
reply.set(gateway.handleRequestMessage(new GenericMessage<String>("foo")));
|
||||
reply.set(gateway.handleRequestMessage(new GenericMessage<>("foo")));
|
||||
}
|
||||
finally {
|
||||
latch2.countDown();
|
||||
@@ -334,7 +340,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
|
||||
javax.jms.Message request = template.receive(requestQueue6);
|
||||
assertNotNull(request);
|
||||
final javax.jms.Message jmsReply = request;
|
||||
template.send(request.getJMSReplyTo(), (MessageCreator) session -> {
|
||||
template.send(request.getJMSReplyTo(), session -> {
|
||||
jmsReply.setJMSCorrelationID(jmsReply.getJMSMessageID());
|
||||
return jmsReply;
|
||||
});
|
||||
@@ -352,7 +358,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());
|
||||
@@ -373,7 +379,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
|
||||
receiveAndSend(template);
|
||||
});
|
||||
|
||||
assertNotNull(gateway.handleRequestMessage(new GenericMessage<String>("foo")));
|
||||
assertNotNull(gateway.handleRequestMessage(new GenericMessage<>("foo")));
|
||||
DefaultMessageListenerContainer container = TestUtils.getPropertyValue(gateway, "replyContainer",
|
||||
DefaultMessageListenerContainer.class);
|
||||
int n = 0;
|
||||
@@ -381,7 +387,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertFalse(container.isRunning());
|
||||
assertNotNull(gateway.handleRequestMessage(new GenericMessage<String>("foo")));
|
||||
assertNotNull(gateway.handleRequestMessage(new GenericMessage<>("foo")));
|
||||
assertTrue(container.isRunning());
|
||||
|
||||
gateway.stop();
|
||||
@@ -393,7 +399,7 @@ public class OutboundGatewayFunctionTests extends LogAdjustingTestSupport {
|
||||
javax.jms.Message request = template.receive(requestQueue7);
|
||||
final javax.jms.Message jmsReply = request;
|
||||
try {
|
||||
template.send(request.getJMSReplyTo(), (MessageCreator) session -> jmsReply);
|
||||
template.send(request.getJMSReplyTo(), session -> jmsReply);
|
||||
}
|
||||
catch (JmsException | JMSException e) {
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
log4j.rootCategory=ERROR, 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=ERROR
|
||||
log4j.category.org.springframework.integration=ERROR
|
||||
log4j.category.org.springframework.integration.jms.request_reply=INFO
|
||||
log4j.category.si.jmsgateway.debug=DEBUG
|
||||
19
spring-integration-jms/src/test/resources/log4j2-test.xml
Normal file
19
spring-integration-jms/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.apache.derby" level="warn"/>
|
||||
<Logger name="org.springframework" level="error"/>
|
||||
<Logger name="org.springframework.integration" level="error"/>
|
||||
<Logger name="org.springframework.integration.jms" level="warn"/>
|
||||
<Logger name="org.springframework.integration.jms.jms.request_reply" level="info"/>
|
||||
<Logger name="si.jmsgateway.debug" level="debug"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=WARN
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.jmx=WARN
|
||||
log4j.category.org.springframework.integration.monitor=WARN
|
||||
17
spring-integration-jmx/src/test/resources/log4j2-test.xml
Normal file
17
spring-integration-jmx/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.jmx" level="warn"/>
|
||||
<Logger name="org.springframework.integration.monitor" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d %p [%c] - <%m>%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.jpa=INFO
|
||||
15
spring-integration-jpa/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-jpa/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.jpa" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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.mail=WARN
|
||||
15
spring-integration-mail/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-mail/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.mail" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.mongodb=INFO
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.mongodb" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.mqtt=INFO
|
||||
15
spring-integration-mqtt/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-mqtt/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.mqtt" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,5 +0,0 @@
|
||||
# minimal config
|
||||
#daemonize yes
|
||||
bind 127.0.0.1
|
||||
loglevel debug
|
||||
port 7379
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2013-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 static org.junit.Assert.fail;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -38,7 +37,7 @@ import org.springframework.integration.redis.rules.RedisAvailableTests;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.rule.Log4jLevelAdjuster;
|
||||
import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
|
||||
import org.springframework.integration.test.support.LongRunningIntegrationTest;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -59,8 +58,10 @@ public class DelayerHandlerRescheduleIntegrationTests extends RedisAvailableTest
|
||||
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
|
||||
|
||||
@Rule
|
||||
public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.DEBUG, "org.springframework.integration",
|
||||
"org.springframework.data.redis");
|
||||
public Log4j2LevelAdjuster adjuster =
|
||||
Log4j2LevelAdjuster.trace()
|
||||
.categories("org.springframework.integration",
|
||||
"org.springframework.data.redis");
|
||||
|
||||
@Test
|
||||
@RedisAvailable
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.concurrent.locks.Lock;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.log4j.Level;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -48,7 +47,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.integration.redis.rules.RedisAvailable;
|
||||
import org.springframework.integration.redis.rules.RedisAvailableTests;
|
||||
import org.springframework.integration.test.rule.Log4jLevelAdjuster;
|
||||
import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
|
||||
/**
|
||||
@@ -68,7 +67,9 @@ public class RedisLockRegistryTests extends RedisAvailableTests {
|
||||
private final String registryKey2 = UUID.randomUUID().toString();
|
||||
|
||||
@Rule
|
||||
public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE, "org.springframework.integration.redis");
|
||||
public Log4j2LevelAdjuster adjuster =
|
||||
Log4j2LevelAdjuster.trace()
|
||||
.categories("org.springframework.data.redis");
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@@ -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 %5p %t [%c] - <%m>%n
|
||||
|
||||
log4j.category.org.springframework.data.redis=WARN
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.redis=INFO
|
||||
16
spring-integration-redis/src/test/resources/log4j2-test.xml
Normal file
16
spring-integration-redis/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.data.redis" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.redis" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.rmi=WARN
|
||||
15
spring-integration-rmi/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-rmi/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.rmi" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="[%t] %-5p: %c - %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration.scripting.jsr223">
|
||||
<level value="info" />
|
||||
</logger>
|
||||
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="info" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.scripting.jsr223" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d %5p %c{1} [%t] : %m%n
|
||||
|
||||
log4j.category.org.springframework.integration.security=WARN
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.security" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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.com.jcraft.jsch=WARN
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.sftp=WARN
|
||||
16
spring-integration-sftp/src/test/resources/log4j2-test.xml
Normal file
16
spring-integration-sftp/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="com.jcraft.jsch" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.sftp" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -28,6 +28,7 @@ import static org.junit.Assert.fail;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
@@ -51,7 +52,7 @@ import org.springframework.integration.stomp.event.StompSessionConnectedEvent;
|
||||
import org.springframework.integration.stomp.inbound.StompInboundChannelAdapter;
|
||||
import org.springframework.integration.stomp.outbound.StompMessageHandler;
|
||||
import org.springframework.integration.support.converter.PassThruMessageConverter;
|
||||
import org.springframework.integration.test.support.LogAdjustingTestSupport;
|
||||
import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
@@ -66,19 +67,23 @@ import org.springframework.util.SocketUtils;
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public class StompServerIntegrationTests extends LogAdjustingTestSupport {
|
||||
public class StompServerIntegrationTests {
|
||||
|
||||
private static BrokerService activeMQBroker;
|
||||
|
||||
private static ReactorNettyTcpStompClient stompClient;
|
||||
|
||||
|
||||
public StompServerIntegrationTests() {
|
||||
super("org.springframework", "org.springframework.integration.stomp",
|
||||
"org.apache.activemq.broker", "reactor.ipc", "io.netty");
|
||||
}
|
||||
@Rule
|
||||
public Log4j2LevelAdjuster adjuster =
|
||||
Log4j2LevelAdjuster.trace()
|
||||
.categories("org.springframework",
|
||||
"org.springframework.integration.stomp",
|
||||
"org.apache.activemq.broker",
|
||||
"reactor.ipc",
|
||||
"io.netty");
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -50,7 +51,7 @@ import org.springframework.integration.stomp.event.StompConnectionFailedEvent;
|
||||
import org.springframework.integration.stomp.event.StompIntegrationEvent;
|
||||
import org.springframework.integration.stomp.event.StompReceiptEvent;
|
||||
import org.springframework.integration.stomp.event.StompSessionConnectedEvent;
|
||||
import org.springframework.integration.test.support.LogAdjustingTestSupport;
|
||||
import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
|
||||
import org.springframework.integration.websocket.TomcatWebSocketTestServer;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
@@ -90,12 +91,18 @@ import org.springframework.web.socket.sockjs.client.WebSocketTransport;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
@ContextConfiguration(classes = StompInboundChannelAdapterWebSocketIntegrationTests.ContextConfiguration.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class StompInboundChannelAdapterWebSocketIntegrationTests extends LogAdjustingTestSupport {
|
||||
public class StompInboundChannelAdapterWebSocketIntegrationTests {
|
||||
|
||||
@Rule
|
||||
public Log4j2LevelAdjuster adjuster =
|
||||
Log4j2LevelAdjuster.trace()
|
||||
.categories("org.springframework", "org.springframework.integration.stomp");
|
||||
|
||||
@Value("#{server.serverContext}")
|
||||
private ConfigurableApplicationContext serverContext;
|
||||
@@ -115,9 +122,6 @@ public class StompInboundChannelAdapterWebSocketIntegrationTests extends LogAdju
|
||||
@Autowired
|
||||
private StompInboundChannelAdapter stompInboundChannelAdapter;
|
||||
|
||||
public StompInboundChannelAdapterWebSocketIntegrationTests() {
|
||||
super("org.springframework", "org.springframework.integration.stomp");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWebSocketStompClient() throws Exception {
|
||||
@@ -274,7 +278,7 @@ public class StompInboundChannelAdapterWebSocketIntegrationTests extends LogAdju
|
||||
handshakeHeaders.setOrigin("http://foo.com");
|
||||
webSocketStompSessionManager.setHandshakeHeaders(handshakeHeaders);
|
||||
StompHeaders stompHeaders = new StompHeaders();
|
||||
stompHeaders.setHeartbeat(new long[] {10000, 10000});
|
||||
stompHeaders.setHeartbeat(new long[] { 10000, 10000 });
|
||||
webSocketStompSessionManager.setConnectHeaders(stompHeaders);
|
||||
return webSocketStompSessionManager;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
* Copyright 2015-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,6 +33,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -55,7 +56,7 @@ import org.springframework.integration.stomp.event.StompExceptionEvent;
|
||||
import org.springframework.integration.stomp.event.StompIntegrationEvent;
|
||||
import org.springframework.integration.stomp.event.StompReceiptEvent;
|
||||
import org.springframework.integration.stomp.event.StompSessionConnectedEvent;
|
||||
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.websocket.TomcatWebSocketTestServer;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -97,11 +98,16 @@ import org.springframework.web.socket.sockjs.client.WebSocketTransport;
|
||||
@ContextConfiguration(classes = StompMessageHandlerWebSocketIntegrationTests.ContextConfiguration.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class StompMessageHandlerWebSocketIntegrationTests extends LogAdjustingTestSupport {
|
||||
public class StompMessageHandlerWebSocketIntegrationTests {
|
||||
|
||||
@ClassRule
|
||||
public static LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
|
||||
|
||||
@Rule
|
||||
public Log4j2LevelAdjuster adjuster =
|
||||
Log4j2LevelAdjuster.trace()
|
||||
.categories("org.springframework", "org.springframework.integration.stomp");
|
||||
|
||||
@Value("#{server.serverContext}")
|
||||
private ApplicationContext serverContext;
|
||||
|
||||
@@ -113,10 +119,6 @@ public class StompMessageHandlerWebSocketIntegrationTests extends LogAdjustingTe
|
||||
@Qualifier("stompEvents")
|
||||
private PollableChannel stompEvents;
|
||||
|
||||
public StompMessageHandlerWebSocketIntegrationTests() {
|
||||
super("org.springframework", "org.springframework.integration.stomp");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStompMessageHandler() throws InterruptedException {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SEND);
|
||||
@@ -225,10 +227,11 @@ public class StompMessageHandlerWebSocketIntegrationTests extends LogAdjustingTe
|
||||
|
||||
// WebSocket Server part
|
||||
|
||||
@Target({ElementType.TYPE})
|
||||
@Target({ ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Controller
|
||||
private @interface IntegrationTestController {
|
||||
|
||||
}
|
||||
|
||||
@IntegrationTestController
|
||||
|
||||
@@ -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=DEBUG
|
||||
log4j.category.org.springframework.integration.stomp=WARN
|
||||
16
spring-integration-stomp/src/test/resources/log4j2-test.xml
Normal file
16
spring-integration-stomp/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.stomp" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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.stream=DEBUG
|
||||
15
spring-integration-stream/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-stream/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.stream" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.syslog=WARN
|
||||
15
spring-integration-syslog/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-syslog/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.syslog" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.test.rule;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.core.LoggerContext;
|
||||
import org.apache.logging.log4j.core.config.Configuration;
|
||||
import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||
import org.junit.rules.MethodRule;
|
||||
import org.junit.runners.model.FrameworkMethod;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* A JUnit method {@link org.junit.Rule} that changes the Log4J 2 logger level for a set of classes
|
||||
* or packages while a test method is running. Useful for performance or scalability tests
|
||||
* where we don't want to generate a large log in a tight inner loop, or
|
||||
* enabling debug logging for a test case.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 5.0.1
|
||||
*
|
||||
*/
|
||||
public class Log4j2LevelAdjuster implements MethodRule {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(Log4j2LevelAdjuster.class);
|
||||
|
||||
private final Class<?>[] classes;
|
||||
|
||||
private final Level level;
|
||||
|
||||
private final String[] categories;
|
||||
|
||||
private Log4j2LevelAdjuster(Level level) {
|
||||
this(level, null, new String[] { "org.springframework.integration" });
|
||||
}
|
||||
|
||||
private Log4j2LevelAdjuster(Level level, Class<?>[] classes, String[] categories) {
|
||||
Assert.notNull(level, "'level' must be null");
|
||||
this.level = level;
|
||||
this.classes = classes != null ? classes : new Class<?>[0];
|
||||
|
||||
Stream<String> categoryStream = Stream.of(getClass().getPackage().getName());
|
||||
|
||||
if (!ObjectUtils.isEmpty(categories)) {
|
||||
categoryStream = Stream.concat(Arrays.stream(categories), categoryStream);
|
||||
}
|
||||
|
||||
this.categories = categoryStream.toArray(String[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statement apply(final Statement base, final FrameworkMethod method, Object target) {
|
||||
return new Statement() {
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration config = ctx.getConfiguration();
|
||||
|
||||
Map<Class<?>, Level> classLevels = new HashMap<>();
|
||||
for (Class<?> cls : Log4j2LevelAdjuster.this.classes) {
|
||||
String className = cls.getName();
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(className);
|
||||
LoggerConfig specificConfig = loggerConfig;
|
||||
|
||||
// We need a specific configuration for this logger,
|
||||
// otherwise we would change the level of all other loggers
|
||||
// having the original configuration as parent as well
|
||||
|
||||
if (!loggerConfig.getName().equals(className)) {
|
||||
specificConfig = new LoggerConfig(className, Log4j2LevelAdjuster.this.level, true);
|
||||
specificConfig.setParent(loggerConfig);
|
||||
config.addLogger(className, specificConfig);
|
||||
}
|
||||
|
||||
classLevels.put(cls, specificConfig.getLevel());
|
||||
specificConfig.setLevel(Log4j2LevelAdjuster.this.level);
|
||||
}
|
||||
|
||||
Map<String, Level> categoryLevels = new HashMap<>();
|
||||
for (String category : Log4j2LevelAdjuster.this.categories) {
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(category);
|
||||
LoggerConfig specificConfig = loggerConfig;
|
||||
|
||||
// We need a specific configuration for this logger,
|
||||
// otherwise we would change the level of all other loggers
|
||||
// having the original configuration as parent as well
|
||||
|
||||
if (!loggerConfig.getName().equals(category)) {
|
||||
specificConfig = new LoggerConfig(category, Log4j2LevelAdjuster.this.level, true);
|
||||
specificConfig.setParent(loggerConfig);
|
||||
config.addLogger(category, specificConfig);
|
||||
}
|
||||
|
||||
categoryLevels.put(category, specificConfig.getLevel());
|
||||
specificConfig.setLevel(Log4j2LevelAdjuster.this.level);
|
||||
}
|
||||
|
||||
ctx.updateLoggers();
|
||||
|
||||
logger.debug("++++++++++++++++++++++++++++ "
|
||||
+ "Overridden log level setting for: " + Arrays.toString(Log4j2LevelAdjuster.this.classes)
|
||||
+ " and " + Arrays.toString(Log4j2LevelAdjuster.this.categories)
|
||||
+ " for test " + method.getName());
|
||||
|
||||
try {
|
||||
base.evaluate();
|
||||
}
|
||||
finally {
|
||||
logger.debug("++++++++++++++++++++++++++++ "
|
||||
+ "Restoring log level setting for: " + Arrays.toString(Log4j2LevelAdjuster.this.classes)
|
||||
+ " and " + Arrays.toString(Log4j2LevelAdjuster.this.categories)
|
||||
+ " for test " + method.getName());
|
||||
|
||||
for (Class<?> cls : Log4j2LevelAdjuster.this.classes) {
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(cls.getName());
|
||||
loggerConfig.setLevel(classLevels.get(cls));
|
||||
}
|
||||
|
||||
for (String category : Log4j2LevelAdjuster.this.categories) {
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(category);
|
||||
loggerConfig.setLevel(categoryLevels.get(category));
|
||||
}
|
||||
|
||||
ctx.updateLoggers();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the classes for logging level adjusting configured before.
|
||||
* A new copy Log4j2LevelAdjuster instance is produced by this method.
|
||||
* The provided classes parameter overrides existing value in the {@link #classes}.
|
||||
* @param classes the classes to use for logging level adjusting
|
||||
* @return a Log4j2LevelAdjuster copy with the provided classes
|
||||
*/
|
||||
public Log4j2LevelAdjuster classes(Class<?>... classes) {
|
||||
return new Log4j2LevelAdjuster(this.level, classes, this.categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the categories for logging level adjusting configured before.
|
||||
* A new copy Log4j2LevelAdjuster instance is produced by this method.
|
||||
* The provided categories parameter overrides existing value in the {@link #categories}.
|
||||
* @param categories the categories to use for logging level adjusting
|
||||
* @return a Log4j2LevelAdjuster copy with the provided categories
|
||||
*/
|
||||
public Log4j2LevelAdjuster categories(String... categories) {
|
||||
return new Log4j2LevelAdjuster(this.level, this.classes, categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* The factory to produce Log4j2LevelAdjuster instances for {@link Level#TRACE} logging
|
||||
* with the {@code org.springframework.integration} as default category.
|
||||
* @return the Log4j2LevelAdjuster instance
|
||||
*/
|
||||
public static Log4j2LevelAdjuster trace() {
|
||||
return level(Level.TRACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* The factory to produce Log4j2LevelAdjuster instances for {@link Level#DEBUG} logging
|
||||
* with the {@code org.springframework.integration} as default category.
|
||||
* @return the Log4j2LevelAdjuster instance
|
||||
*/
|
||||
public static Log4j2LevelAdjuster debug() {
|
||||
return level(Level.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
* The factory to produce Log4j2LevelAdjuster instances for {@link Level#INFO} logging
|
||||
* with the {@code org.springframework.integration} as default category.
|
||||
* @return the Log4j2LevelAdjuster instance
|
||||
*/
|
||||
public static Log4j2LevelAdjuster info() {
|
||||
return level(Level.INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* The factory to produce Log4j2LevelAdjuster instances for arbitrary logging {@link Level}
|
||||
* with the {@code org.springframework.integration} as default category.
|
||||
* @return the Log4j2LevelAdjuster instance
|
||||
*/
|
||||
public static Log4j2LevelAdjuster level(Level level) {
|
||||
return new Log4j2LevelAdjuster(level);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-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,10 +41,16 @@ import org.junit.runners.model.Statement;
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @deprecated since 5.0.1 in favor of {@link Log4j2LevelAdjuster}.
|
||||
* Will be removed in 5.1.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Log4jLevelAdjuster implements MethodRule {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(Log4jLevelAdjuster.class);
|
||||
private static final Log logger =
|
||||
LogFactory.getLog(org.springframework.integration.test.rule.Log4jLevelAdjuster.class);
|
||||
|
||||
private final Class<?>[] classes;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-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,7 +40,11 @@ import org.junit.rules.TestName;
|
||||
*
|
||||
* @since 4.2.2
|
||||
*
|
||||
* @deprecated since 5.0.1 in favor of {@link org.springframework.integration.test.rule.Log4j2LevelAdjuster}.
|
||||
* Will be removed in 5.1.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class LogAdjustingTestSupport {
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
|
||||
|
||||
log4j.category.org.springframework.integration.test=INFO
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
15
spring-integration-test/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-test/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.test" level="info"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -32,7 +32,6 @@ import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -46,7 +45,7 @@ import org.springframework.integration.metadata.MetadataStore;
|
||||
import org.springframework.integration.redis.metadata.RedisMetadataStore;
|
||||
import org.springframework.integration.redis.rules.RedisAvailable;
|
||||
import org.springframework.integration.redis.rules.RedisAvailableTests;
|
||||
import org.springframework.integration.test.rule.Log4jLevelAdjuster;
|
||||
import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
@@ -74,7 +73,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
public class SearchReceivingMessageSourceWithRedisTests extends RedisAvailableTests {
|
||||
|
||||
@Rule
|
||||
public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE, "org.springframework.integration");
|
||||
public Log4j2LevelAdjuster adjuster = Log4j2LevelAdjuster.trace();
|
||||
|
||||
@Autowired
|
||||
private SourcePollingChannelAdapter twitterSearchAdapter;
|
||||
|
||||
@@ -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=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
|
||||
|
||||
# log4j.category.org.springframework.integration=DEBUG
|
||||
log4j.category.org.springframework.integration.twitter=WARN
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.twitter" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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.webflux=WARN
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework" level="warn"/>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.webflux" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.websocket=WARN
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.websocket" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.ws=WARN
|
||||
15
spring-integration-ws/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-ws/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.ws" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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
|
||||
15
spring-integration-xml/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-xml/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.xml" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.xmpp=INFO
|
||||
@@ -11,7 +11,7 @@
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
|
||||
<context:property-placeholder location="test.properties"/>
|
||||
<context:property-placeholder location="../../../../../../resources/test.properties"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
|
||||
<context:property-placeholder location="test.properties"/>
|
||||
<context:property-placeholder location="../../../../../../resources/test.properties"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder location="test.properties"/>
|
||||
<context:property-placeholder location="../../../../../../resources/test.properties"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
|
||||
15
spring-integration-xmpp/src/test/resources/log4j2-test.xml
Normal file
15
spring-integration-xmpp/src/test/resources/log4j2-test.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.xmpp" level="warn"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -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.integration=WARN
|
||||
log4j.category.org.springframework.integration.zookeeper=INFO
|
||||
log4j.category.org.springframework.integration.support.SmartLifecycleRoleController=DEBUG
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.zookeeper" level="warn"/>
|
||||
<Logger name="org.springframework.integration.support.SmartLifecycleRoleController" level="debug"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user