Example usage for org.springframework.integration.channel ExecutorChannel setBeanName

List of usage examples for org.springframework.integration.channel ExecutorChannel setBeanName

Introduction

In this page you can find the example usage for org.springframework.integration.channel ExecutorChannel setBeanName.

Prototype

@Override
    public final void setBeanName(String beanName) 

Source Link

Usage

From source file:org.springframework.integration.channel.P2pChannelTests.java

@Test
public void testExecutorChannelLoggingWithMoreThenOneSubscriber() {
    final ExecutorChannel channel = new ExecutorChannel(mock(Executor.class));
    channel.setBeanName("executorChannel");

    final Log logger = mock(Log.class);
    when(logger.isInfoEnabled()).thenReturn(true);
    ReflectionUtils.doWithFields(AbstractMessageChannel.class, new FieldCallback() {

        public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
            if ("logger".equals(field.getName())) {
                field.setAccessible(true);
                field.set(channel, logger);
            }// w  ww . ja  va  2  s. c  o m
        }
    });
    channel.subscribe(mock(MessageHandler.class));
    channel.subscribe(mock(MessageHandler.class));
    verify(logger, times(2)).info(Mockito.anyString());
}