Example usage for org.springframework.integration.handler LoggingHandler LoggingHandler

List of usage examples for org.springframework.integration.handler LoggingHandler LoggingHandler

Introduction

In this page you can find the example usage for org.springframework.integration.handler LoggingHandler LoggingHandler.

Prototype

public LoggingHandler(Level level) 

Source Link

Document

Create a LoggingHandler with the given log Level .

Usage

From source file:org.synyx.hera.si.config.DynamicServiceActivatorNamespaceIntegrationTest.java

@Test
public void invokesPluginBasedOnPayload() {

    sink.subscribe(new LoggingHandler("DEBUG"));
    Message<String> message = MessageBuilder.withPayload("FOO").build();
    channel.send(message);//from  www  .ja  v  a2 s.  com
}

From source file:com.create.application.configuration.IntegrationConfiguration.java

@Bean
@ServiceActivator(inputChannel = "loggingChannel")
public LoggingHandler loggingHandler() {
    return new LoggingHandler(LoggingHandler.Level.INFO.name());
}

From source file:org.thingsplode.server.BusConfig.java

@ServiceActivator(inputChannel = "errorChannel")
public LoggingHandler loggingHandler(Message<ErrorMessage> msg) {
    LoggingHandler loggingHandler = new LoggingHandler("ERROR");
    return loggingHandler;
}

From source file:com.nayidisha.slowglow.config.SpringMessagingConfig.java

/**
 * This message handler is just used for logging purposes
 * //from  www.  ja  va 2 s . c  o m
 * @return
 */
@Bean(name = "loggingHandler")
public LoggingHandler loggingHandler() {
    LoggingHandler loggingHandler = new LoggingHandler("DEBUG");

    return loggingHandler;
}

From source file:org.springframework.integration.handler.LoggingHandlerTests.java

@Test
public void assertMutuallyExclusive() {
    LoggingHandler loggingHandler = new LoggingHandler("INFO");
    loggingHandler.setExpression("'foo'");
    try {// w w  w  . j av a2  s . c om
        loggingHandler.setShouldLogFullMessage(true);
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        assertEquals("Cannot set both 'expression' AND 'shouldLogFullMessage' properties", e.getMessage());
    }

    loggingHandler = new LoggingHandler("INFO");
    loggingHandler.setShouldLogFullMessage(true);
    try {
        loggingHandler.setExpression("'foo'");
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        assertEquals("Cannot set both 'expression' AND 'shouldLogFullMessage' properties", e.getMessage());
    }
}

From source file:org.springframework.integration.handler.LoggingHandlerTests.java

@Test
public void testDontEvaluateIfNotEnabled() {
    LoggingHandler loggingHandler = new LoggingHandler("INFO");
    DirectFieldAccessor accessor = new DirectFieldAccessor(loggingHandler);
    Log log = (Log) accessor.getPropertyValue("messageLogger");
    log = spy(log);// www  .j a  v  a 2s  .co  m
    accessor.setPropertyValue("messageLogger", log);
    Expression expression = (Expression) accessor.getPropertyValue("expression");
    expression = spy(expression);
    accessor.setPropertyValue("expression", expression);
    when(log.isInfoEnabled()).thenReturn(false);
    loggingHandler.handleMessage(new GenericMessage<String>("foo"));
    verify(expression, never()).getValue(Mockito.any(EvaluationContext.class), Mockito.any());

    when(log.isInfoEnabled()).thenReturn(true);
    loggingHandler.handleMessage(new GenericMessage<String>("foo"));
    verify(expression, times(1)).getValue(Mockito.any(EvaluationContext.class), Mockito.any());
}

From source file:org.springframework.integration.handler.LoggingHandlerTests.java

@Test
public void testChangeLevel() {
    LoggingHandler loggingHandler = new LoggingHandler("INFO");
    DirectFieldAccessor accessor = new DirectFieldAccessor(loggingHandler);
    Log log = (Log) accessor.getPropertyValue("messageLogger");
    log = spy(log);/*from w  w  w .  j  av a2  s .com*/
    accessor.setPropertyValue("messageLogger", log);
    when(log.isInfoEnabled()).thenReturn(true);
    loggingHandler.handleMessage(new GenericMessage<String>("foo"));
    verify(log, times(1)).info(Mockito.anyString());
    verify(log, never()).warn(Mockito.anyString());

    loggingHandler.setLevel(Level.WARN);
    loggingHandler.handleMessage(new GenericMessage<String>("foo"));
    verify(log, times(1)).info(Mockito.anyString());
    verify(log, times(1)).warn(Mockito.anyString());
}

From source file:org.springframework.integration.samples.mqtt.Application.java

private LoggingHandler logger() {
    LoggingHandler loggingHandler = new LoggingHandler("INFO");
    loggingHandler.setLoggerName("siSample");
    return loggingHandler;
}