use of org.springframework.integration.handler.LoggingHandler in project spring-integration-samples by spring-projects.
the class Application method logger.
private LoggingHandler logger() {
LoggingHandler loggingHandler = new LoggingHandler("INFO");
loggingHandler.setLoggerName("siSample");
return loggingHandler;
}
use of org.springframework.integration.handler.LoggingHandler in project spring-integration by spring-projects.
the class LoggingChannelAdapterParserTests method verifyExpressionAndOtherDefaultConfig.
@Test
public void verifyExpressionAndOtherDefaultConfig() {
LoggingHandler loggingHandler = TestUtils.getPropertyValue(loggerWithExpression, "handler", LoggingHandler.class);
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"));
assertNotNull(TestUtils.getPropertyValue(loggingHandler, "evaluationContext.beanResolver"));
}
use of org.springframework.integration.handler.LoggingHandler in project spring-integration-samples by spring-projects.
the class Application method loggingChannelAdapter.
@Bean
@ServiceActivator(inputChannel = "sendTimeChannel")
public MessageHandler loggingChannelAdapter() {
LoggingHandler loggingHandler = new LoggingHandler("info");
loggingHandler.setLogExpressionString("'The time ' + payload + ' has been sent to the WebSocketSession ' + headers.simpSessionId");
return loggingHandler;
}
use of org.springframework.integration.handler.LoggingHandler in project spring-integration by spring-projects.
the class LoggingChannelAdapterParserTests method verifyConfig.
@Test
public void verifyConfig() {
LoggingHandler loggingHandler = TestUtils.getPropertyValue(loggerConsumer, "handler", LoggingHandler.class);
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"));
}
use of org.springframework.integration.handler.LoggingHandler in project spring-integration by spring-projects.
the class ChainParserTests method chainWithLoggingChannelAdapter.
// INT-2275, INT-2958
@Test
public void chainWithLoggingChannelAdapter() {
Log logger = mock(Log.class);
final AtomicReference<String> log = new AtomicReference<String>();
when(logger.isWarnEnabled()).thenReturn(true);
doAnswer(invocation -> {
log.set(invocation.getArgument(0));
return null;
}).when(logger).warn(any());
@SuppressWarnings("unchecked") List<MessageHandler> handlers = TestUtils.getPropertyValue(this.logChain, "handlers", List.class);
MessageHandler handler = handlers.get(2);
assertTrue(handler instanceof LoggingHandler);
DirectFieldAccessor dfa = new DirectFieldAccessor(handler);
dfa.setPropertyValue("messageLogger", logger);
this.loggingChannelAdapterChannel.send(MessageBuilder.withPayload(new byte[] { 116, 101, 115, 116 }).build());
assertNotNull(log.get());
assertEquals("TEST", log.get());
}
Aggregations