Search in sources :

Example 1 with MessageSource

use of org.springframework.integration.core.MessageSource in project spring-integration by spring-projects.

the class PollerAdviceTests method testMixedAdvice.

@Test
public void testMixedAdvice() throws Exception {
    SourcePollingChannelAdapter adapter = new SourcePollingChannelAdapter();
    final List<String> callOrder = new ArrayList<>();
    final AtomicReference<CountDownLatch> latch = new AtomicReference<>(new CountDownLatch(4));
    MessageSource<Object> source = () -> {
        callOrder.add("c");
        latch.get().countDown();
        return null;
    };
    adapter.setSource(source);
    OnlyOnceTrigger trigger = new OnlyOnceTrigger();
    adapter.setTrigger(trigger);
    configure(adapter);
    List<Advice> adviceChain = new ArrayList<>();
    adviceChain.add((MethodInterceptor) invocation -> {
        callOrder.add("a");
        latch.get().countDown();
        return invocation.proceed();
    });
    final AtomicInteger count = new AtomicInteger();
    class TestSourceAdvice extends AbstractMessageSourceAdvice {

        @Override
        public boolean beforeReceive(MessageSource<?> target) {
            count.incrementAndGet();
            callOrder.add("b");
            latch.get().countDown();
            return true;
        }

        @Override
        public Message<?> afterReceive(Message<?> result, MessageSource<?> target) {
            callOrder.add("d");
            latch.get().countDown();
            return result;
        }
    }
    adviceChain.add(new TestSourceAdvice());
    adapter.setAdviceChain(adviceChain);
    adapter.afterPropertiesSet();
    adapter.start();
    assertTrue(latch.get().await(10, TimeUnit.SECONDS));
    // advice + advice + source + advice
    assertThat(callOrder, contains("a", "b", "c", "d"));
    adapter.stop();
    trigger.reset();
    latch.set(new CountDownLatch(4));
    adapter.start();
    assertTrue(latch.get().await(10, TimeUnit.SECONDS));
    adapter.stop();
    assertEquals(2, count.get());
    // Now test when the source is already a proxy.
    ProxyFactory pf = new ProxyFactory(source);
    pf.addAdvice((MethodInterceptor) Joinpoint::proceed);
    adapter.setSource((MessageSource<?>) pf.getProxy());
    trigger.reset();
    latch.set(new CountDownLatch(4));
    count.set(0);
    callOrder.clear();
    adapter.start();
    assertTrue(latch.get().await(10, TimeUnit.SECONDS));
    // advice + advice + source + advice
    assertThat(callOrder, contains("a", "b", "c", "d"));
    adapter.stop();
    trigger.reset();
    latch.set(new CountDownLatch(4));
    adapter.start();
    assertTrue(latch.get().await(10, TimeUnit.SECONDS));
    adapter.stop();
    assertEquals(2, count.get());
    Advisor[] advisors = ((Advised) adapter.getMessageSource()).getAdvisors();
    // make sure we didn't remove the original one
    assertEquals(2, advisors.length);
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) Date(java.util.Date) SimpleActiveIdleMessageSourceAdvice(org.springframework.integration.aop.SimpleActiveIdleMessageSourceAdvice) Autowired(org.springframework.beans.factory.annotation.Autowired) DynamicPeriodicTrigger(org.springframework.integration.util.DynamicPeriodicTrigger) Assert.assertThat(org.junit.Assert.assertThat) OnlyOnceTrigger(org.springframework.integration.test.util.OnlyOnceTrigger) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) NullChannel(org.springframework.integration.channel.NullChannel) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Mockito.atLeast(org.mockito.Mockito.atLeast) TriggerContext(org.springframework.scheduling.TriggerContext) Trigger(org.springframework.scheduling.Trigger) CompoundTriggerAdvice(org.springframework.integration.aop.CompoundTriggerAdvice) EnableIntegration(org.springframework.integration.config.EnableIntegration) MessageChannel(org.springframework.messaging.MessageChannel) SimplePollSkipStrategy(org.springframework.integration.scheduling.SimplePollSkipStrategy) Configuration(org.springframework.context.annotation.Configuration) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Log4j2LevelAdjuster(org.springframework.integration.test.rule.Log4j2LevelAdjuster) Matchers.contains(org.hamcrest.Matchers.contains) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) DirectChannel(org.springframework.integration.channel.DirectChannel) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) AbstractMessageSourceAdvice(org.springframework.integration.aop.AbstractMessageSourceAdvice) Advised(org.springframework.aop.framework.Advised) RunWith(org.junit.runner.RunWith) ExpressionControlBusFactoryBean(org.springframework.integration.config.ExpressionControlBusFactoryBean) Mockito.spy(org.mockito.Mockito.spy) TestUtils(org.springframework.integration.test.util.TestUtils) AtomicReference(java.util.concurrent.atomic.AtomicReference) MessageSource(org.springframework.integration.core.MessageSource) ArrayList(java.util.ArrayList) Joinpoint(org.aopalliance.intercept.Joinpoint) Advice(org.aopalliance.aop.Advice) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Message(org.springframework.messaging.Message) ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) LinkedList(java.util.LinkedList) Advisor(org.springframework.aop.Advisor) PeriodicTrigger(org.springframework.scheduling.support.PeriodicTrigger) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) PollSkipAdvice(org.springframework.integration.scheduling.PollSkipAdvice) MethodInterceptor(org.aopalliance.intercept.MethodInterceptor) Rule(org.junit.Rule) BeanFactory(org.springframework.beans.factory.BeanFactory) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ProxyFactory(org.springframework.aop.framework.ProxyFactory) Bean(org.springframework.context.annotation.Bean) CompoundTrigger(org.springframework.integration.util.CompoundTrigger) GenericMessage(org.springframework.messaging.support.GenericMessage) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) AbstractMessageSourceAdvice(org.springframework.integration.aop.AbstractMessageSourceAdvice) Message(org.springframework.messaging.Message) GenericMessage(org.springframework.messaging.support.GenericMessage) ProxyFactory(org.springframework.aop.framework.ProxyFactory) ArrayList(java.util.ArrayList) MessageSource(org.springframework.integration.core.MessageSource) Advisor(org.springframework.aop.Advisor) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) OnlyOnceTrigger(org.springframework.integration.test.util.OnlyOnceTrigger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Advised(org.springframework.aop.framework.Advised) SimpleActiveIdleMessageSourceAdvice(org.springframework.integration.aop.SimpleActiveIdleMessageSourceAdvice) CompoundTriggerAdvice(org.springframework.integration.aop.CompoundTriggerAdvice) AbstractMessageSourceAdvice(org.springframework.integration.aop.AbstractMessageSourceAdvice) Advice(org.aopalliance.aop.Advice) PollSkipAdvice(org.springframework.integration.scheduling.PollSkipAdvice) Test(org.junit.Test)

Example 2 with MessageSource

use of org.springframework.integration.core.MessageSource in project spring-integration by spring-projects.

the class PollerAdviceTests method testSkipSimple.

@Test
public void testSkipSimple() throws Exception {
    SourcePollingChannelAdapter adapter = new SourcePollingChannelAdapter();
    class LocalSource implements MessageSource<Object> {

        private final CountDownLatch latch;

        private LocalSource(CountDownLatch latch) {
            this.latch = latch;
        }

        @Override
        public Message<Object> receive() {
            latch.countDown();
            return null;
        }
    }
    CountDownLatch latch = new CountDownLatch(1);
    adapter.setSource(new LocalSource(latch));
    class OneAndDone10msTrigger implements Trigger {

        private boolean done;

        @Override
        public Date nextExecutionTime(TriggerContext triggerContext) {
            Date date = done ? null : new Date(System.currentTimeMillis() + 10);
            done = true;
            return date;
        }
    }
    adapter.setTrigger(new OneAndDone10msTrigger());
    configure(adapter);
    List<Advice> adviceChain = new ArrayList<>();
    SimplePollSkipStrategy skipper = new SimplePollSkipStrategy();
    skipper.skipPolls();
    PollSkipAdvice advice = new PollSkipAdvice(skipper);
    adviceChain.add(advice);
    adapter.setAdviceChain(adviceChain);
    adapter.afterPropertiesSet();
    adapter.start();
    assertFalse(latch.await(1, TimeUnit.SECONDS));
    adapter.stop();
    skipper.reset();
    latch = new CountDownLatch(1);
    adapter.setSource(new LocalSource(latch));
    adapter.setTrigger(new OneAndDone10msTrigger());
    adapter.start();
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    adapter.stop();
}
Also used : ArrayList(java.util.ArrayList) MessageSource(org.springframework.integration.core.MessageSource) CountDownLatch(java.util.concurrent.CountDownLatch) Date(java.util.Date) DynamicPeriodicTrigger(org.springframework.integration.util.DynamicPeriodicTrigger) OnlyOnceTrigger(org.springframework.integration.test.util.OnlyOnceTrigger) Trigger(org.springframework.scheduling.Trigger) PeriodicTrigger(org.springframework.scheduling.support.PeriodicTrigger) CompoundTrigger(org.springframework.integration.util.CompoundTrigger) TriggerContext(org.springframework.scheduling.TriggerContext) SimplePollSkipStrategy(org.springframework.integration.scheduling.SimplePollSkipStrategy) PollSkipAdvice(org.springframework.integration.scheduling.PollSkipAdvice) SimpleActiveIdleMessageSourceAdvice(org.springframework.integration.aop.SimpleActiveIdleMessageSourceAdvice) CompoundTriggerAdvice(org.springframework.integration.aop.CompoundTriggerAdvice) AbstractMessageSourceAdvice(org.springframework.integration.aop.AbstractMessageSourceAdvice) Advice(org.aopalliance.aop.Advice) PollSkipAdvice(org.springframework.integration.scheduling.PollSkipAdvice) Test(org.junit.Test)

Example 3 with MessageSource

use of org.springframework.integration.core.MessageSource in project spring-integration by spring-projects.

the class InboundChannelAdapterAnnotationPostProcessor method createMessageSource.

private MessageSource<?> createMessageSource(Object bean, String beanName, Method method) {
    MessageSource<?> messageSource = null;
    if (AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) {
        Object target = this.resolveTargetBeanFromMethodWithBeanAnnotation(method);
        Assert.isTrue(target instanceof MessageSource || target instanceof Supplier, "The '" + this.annotationType + "' on @Bean method " + "level is allowed only for: " + MessageSource.class.getName() + " or " + Supplier.class.getName() + " beans");
        if (target instanceof MessageSource<?>) {
            messageSource = (MessageSource<?>) target;
        } else {
            method = ReflectionUtils.findMethod(Supplier.class, "get");
            bean = target;
        }
    }
    if (messageSource == null) {
        MethodInvokingMessageSource methodInvokingMessageSource = new MethodInvokingMessageSource();
        methodInvokingMessageSource.setObject(bean);
        methodInvokingMessageSource.setMethod(method);
        String messageSourceBeanName = this.generateHandlerBeanName(beanName, method);
        this.beanFactory.registerSingleton(messageSourceBeanName, methodInvokingMessageSource);
        messageSource = (MessageSource<?>) this.beanFactory.initializeBean(methodInvokingMessageSource, messageSourceBeanName);
    }
    return messageSource;
}
Also used : MethodInvokingMessageSource(org.springframework.integration.endpoint.MethodInvokingMessageSource) MessageSource(org.springframework.integration.core.MessageSource) MethodInvokingMessageSource(org.springframework.integration.endpoint.MethodInvokingMessageSource) Supplier(java.util.function.Supplier) Bean(org.springframework.context.annotation.Bean)

Example 4 with MessageSource

use of org.springframework.integration.core.MessageSource in project spring-integration by spring-projects.

the class IntegrationFlowBeanPostProcessor method processStandardIntegrationFlow.

private Object processStandardIntegrationFlow(StandardIntegrationFlow flow, String flowBeanName) {
    String flowNamePrefix = flowBeanName + ".";
    int subFlowNameIndex = 0;
    int channelNameIndex = 0;
    Map<Object, String> integrationComponents = flow.getIntegrationComponents();
    Map<Object, String> targetIntegrationComponents = new LinkedHashMap<>(integrationComponents.size());
    for (Map.Entry<Object, String> entry : integrationComponents.entrySet()) {
        Object component = entry.getKey();
        if (component instanceof ConsumerEndpointSpec) {
            ConsumerEndpointSpec<?, ?> endpointSpec = (ConsumerEndpointSpec<?, ?>) component;
            MessageHandler messageHandler = endpointSpec.get().getT2();
            ConsumerEndpointFactoryBean endpoint = endpointSpec.get().getT1();
            String id = endpointSpec.getId();
            if (id == null) {
                id = generateBeanName(endpoint, entry.getValue());
            }
            Collection<?> messageHandlers = this.beanFactory.getBeansOfType(messageHandler.getClass(), false, false).values();
            if (!messageHandlers.contains(messageHandler)) {
                String handlerBeanName = generateBeanName(messageHandler);
                String[] handlerAlias = new String[] { id + IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX };
                registerComponent(messageHandler, handlerBeanName, flowBeanName);
                for (String alias : handlerAlias) {
                    this.beanFactory.registerAlias(handlerBeanName, alias);
                }
            }
            registerComponent(endpoint, id, flowBeanName);
            targetIntegrationComponents.put(endpoint, id);
        } else {
            Collection<?> values = this.beanFactory.getBeansOfType(component.getClass(), false, false).values();
            if (!values.contains(component)) {
                if (component instanceof AbstractMessageChannel) {
                    String channelBeanName = ((AbstractMessageChannel) component).getComponentName();
                    if (channelBeanName == null) {
                        channelBeanName = entry.getValue();
                        if (channelBeanName == null) {
                            channelBeanName = flowNamePrefix + "channel" + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + channelNameIndex++;
                        }
                    }
                    registerComponent(component, channelBeanName, flowBeanName);
                    targetIntegrationComponents.put(component, channelBeanName);
                } else if (component instanceof MessageChannelReference) {
                    String channelBeanName = ((MessageChannelReference) component).getName();
                    if (!this.beanFactory.containsBean(channelBeanName)) {
                        DirectChannel directChannel = new DirectChannel();
                        registerComponent(directChannel, channelBeanName, flowBeanName);
                        targetIntegrationComponents.put(directChannel, channelBeanName);
                    }
                } else if (component instanceof FixedSubscriberChannel) {
                    FixedSubscriberChannel fixedSubscriberChannel = (FixedSubscriberChannel) component;
                    String channelBeanName = fixedSubscriberChannel.getComponentName();
                    if ("Unnamed fixed subscriber channel".equals(channelBeanName)) {
                        channelBeanName = flowNamePrefix + "channel" + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + channelNameIndex++;
                    }
                    registerComponent(component, channelBeanName, flowBeanName);
                    targetIntegrationComponents.put(component, channelBeanName);
                } else if (component instanceof SourcePollingChannelAdapterSpec) {
                    SourcePollingChannelAdapterSpec spec = (SourcePollingChannelAdapterSpec) component;
                    Map<Object, String> componentsToRegister = spec.getComponentsToRegister();
                    if (!CollectionUtils.isEmpty(componentsToRegister)) {
                        componentsToRegister.entrySet().stream().filter(o -> !this.beanFactory.getBeansOfType(o.getKey().getClass(), false, false).values().contains(o.getKey())).forEach(o -> registerComponent(o.getKey(), generateBeanName(o.getKey(), o.getValue())));
                    }
                    SourcePollingChannelAdapterFactoryBean pollingChannelAdapterFactoryBean = spec.get().getT1();
                    String id = spec.getId();
                    if (!StringUtils.hasText(id)) {
                        id = generateBeanName(pollingChannelAdapterFactoryBean, entry.getValue());
                    }
                    registerComponent(pollingChannelAdapterFactoryBean, id, flowBeanName);
                    targetIntegrationComponents.put(pollingChannelAdapterFactoryBean, id);
                    MessageSource<?> messageSource = spec.get().getT2();
                    if (!this.beanFactory.getBeansOfType(messageSource.getClass(), false, false).values().contains(messageSource)) {
                        String messageSourceId = id + ".source";
                        if (messageSource instanceof NamedComponent && ((NamedComponent) messageSource).getComponentName() != null) {
                            messageSourceId = ((NamedComponent) messageSource).getComponentName();
                        }
                        registerComponent(messageSource, messageSourceId, flowBeanName);
                    }
                } else if (component instanceof StandardIntegrationFlow) {
                    String subFlowBeanName = entry.getValue() != null ? entry.getValue() : flowNamePrefix + "subFlow" + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + subFlowNameIndex++;
                    registerComponent(component, subFlowBeanName, flowBeanName);
                    targetIntegrationComponents.put(component, subFlowBeanName);
                } else if (component instanceof AnnotationGatewayProxyFactoryBean) {
                    AnnotationGatewayProxyFactoryBean gateway = (AnnotationGatewayProxyFactoryBean) component;
                    String gatewayId = entry.getValue();
                    if (gatewayId == null) {
                        gatewayId = gateway.getComponentName();
                    }
                    if (gatewayId == null) {
                        gatewayId = flowNamePrefix + "gateway";
                    }
                    registerComponent(gateway, gatewayId, flowBeanName, beanDefinition -> {
                        ((AbstractBeanDefinition) beanDefinition).setSource(new DescriptiveResource(gateway.getObjectType().getName()));
                    });
                    targetIntegrationComponents.put(component, gatewayId);
                } else {
                    String generatedBeanName = generateBeanName(component, entry.getValue());
                    registerComponent(component, generatedBeanName, flowBeanName);
                    targetIntegrationComponents.put(component, generatedBeanName);
                }
            } else {
                targetIntegrationComponents.put(entry.getKey(), entry.getValue());
            }
        }
    }
    flow.setIntegrationComponents(targetIntegrationComponents);
    return flow;
}
Also used : DescriptiveResource(org.springframework.core.io.DescriptiveResource) BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) BeanCreationNotAllowedException(org.springframework.beans.factory.BeanCreationNotAllowedException) NamedComponent(org.springframework.integration.support.context.NamedComponent) BeanFactoryUtils(org.springframework.beans.factory.BeanFactoryUtils) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) AbstractMessageChannel(org.springframework.integration.channel.AbstractMessageChannel) MessageSource(org.springframework.integration.core.MessageSource) ConfigurableListableBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory) LinkedHashMap(java.util.LinkedHashMap) BeanFactoryAware(org.springframework.beans.factory.BeanFactoryAware) Map(java.util.Map) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) BeanDefinitionCustomizer(org.springframework.beans.factory.config.BeanDefinitionCustomizer) MessageChannelReference(org.springframework.integration.dsl.support.MessageChannelReference) Collection(java.util.Collection) BeansException(org.springframework.beans.BeansException) ConsumerEndpointFactoryBean(org.springframework.integration.config.ConsumerEndpointFactoryBean) SmartInitializingSingleton(org.springframework.beans.factory.SmartInitializingSingleton) BeanPostProcessor(org.springframework.beans.factory.config.BeanPostProcessor) IntegrationConfigUtils(org.springframework.integration.config.IntegrationConfigUtils) MessageHandler(org.springframework.messaging.MessageHandler) CollectionUtils(org.springframework.util.CollectionUtils) BeanFactory(org.springframework.beans.factory.BeanFactory) FixedSubscriberChannel(org.springframework.integration.channel.FixedSubscriberChannel) SourcePollingChannelAdapterFactoryBean(org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean) AnnotationGatewayProxyFactoryBean(org.springframework.integration.gateway.AnnotationGatewayProxyFactoryBean) DirectChannel(org.springframework.integration.channel.DirectChannel) Assert(org.springframework.util.Assert) StringUtils(org.springframework.util.StringUtils) MessageHandler(org.springframework.messaging.MessageHandler) DirectChannel(org.springframework.integration.channel.DirectChannel) LinkedHashMap(java.util.LinkedHashMap) MessageChannelReference(org.springframework.integration.dsl.support.MessageChannelReference) ConsumerEndpointFactoryBean(org.springframework.integration.config.ConsumerEndpointFactoryBean) AnnotationGatewayProxyFactoryBean(org.springframework.integration.gateway.AnnotationGatewayProxyFactoryBean) AbstractMessageChannel(org.springframework.integration.channel.AbstractMessageChannel) SourcePollingChannelAdapterFactoryBean(org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean) MessageSource(org.springframework.integration.core.MessageSource) DescriptiveResource(org.springframework.core.io.DescriptiveResource) NamedComponent(org.springframework.integration.support.context.NamedComponent) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) FixedSubscriberChannel(org.springframework.integration.channel.FixedSubscriberChannel)

Example 5 with MessageSource

use of org.springframework.integration.core.MessageSource in project spring-integration by spring-projects.

the class ConsoleInboundChannelAdapterParserTests method adapterWithDefaultCharset.

@Test
public void adapterWithDefaultCharset() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("consoleInboundChannelAdapterParserTests.xml", ConsoleInboundChannelAdapterParserTests.class);
    SourcePollingChannelAdapter adapter = context.getBean("adapterWithDefaultCharset.adapter", SourcePollingChannelAdapter.class);
    MessageSource<?> source = (MessageSource<?>) new DirectFieldAccessor(adapter).getPropertyValue("source");
    assertTrue(source instanceof NamedComponent);
    assertEquals("adapterWithDefaultCharset.adapter", adapter.getComponentName());
    assertEquals("stream:stdin-channel-adapter(character)", adapter.getComponentType());
    assertEquals("stream:stdin-channel-adapter(character)", ((NamedComponent) source).getComponentType());
    DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(source);
    Reader bufferedReader = (Reader) sourceAccessor.getPropertyValue("reader");
    assertEquals(BufferedReader.class, bufferedReader.getClass());
    DirectFieldAccessor bufferedReaderAccessor = new DirectFieldAccessor(bufferedReader);
    Reader reader = (Reader) bufferedReaderAccessor.getPropertyValue("in");
    assertEquals(InputStreamReader.class, reader.getClass());
    Charset readerCharset = Charset.forName(((InputStreamReader) reader).getEncoding());
    assertEquals(Charset.defaultCharset(), readerCharset);
    Message<?> message = source.receive();
    assertNotNull(message);
    assertEquals("foo", message.getPayload());
    adapter = context.getBean("pipedAdapterNoCharset.adapter", SourcePollingChannelAdapter.class);
    source = adapter.getMessageSource();
    assertTrue(TestUtils.getPropertyValue(source, "blockToDetectEOF", Boolean.class));
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SourcePollingChannelAdapter(org.springframework.integration.endpoint.SourcePollingChannelAdapter) MessageSource(org.springframework.integration.core.MessageSource) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) Charset(java.nio.charset.Charset) NamedComponent(org.springframework.integration.support.context.NamedComponent) Test(org.junit.Test)

Aggregations

MessageSource (org.springframework.integration.core.MessageSource)6 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Advice (org.aopalliance.aop.Advice)2 AbstractMessageSourceAdvice (org.springframework.integration.aop.AbstractMessageSourceAdvice)2 CompoundTriggerAdvice (org.springframework.integration.aop.CompoundTriggerAdvice)2 SimpleActiveIdleMessageSourceAdvice (org.springframework.integration.aop.SimpleActiveIdleMessageSourceAdvice)2 PollSkipAdvice (org.springframework.integration.scheduling.PollSkipAdvice)2 SimplePollSkipStrategy (org.springframework.integration.scheduling.SimplePollSkipStrategy)2 NamedComponent (org.springframework.integration.support.context.NamedComponent)2 OnlyOnceTrigger (org.springframework.integration.test.util.OnlyOnceTrigger)2 CompoundTrigger (org.springframework.integration.util.CompoundTrigger)2 DynamicPeriodicTrigger (org.springframework.integration.util.DynamicPeriodicTrigger)2 Trigger (org.springframework.scheduling.Trigger)2 TriggerContext (org.springframework.scheduling.TriggerContext)2 PeriodicTrigger (org.springframework.scheduling.support.PeriodicTrigger)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1