Search in sources :

Example 6 with SourcePollingChannelAdapter

use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.

the class InboundChannelAdapterExpressionTests method triggerRef.

@Test
public void triggerRef() {
    SourcePollingChannelAdapter adapter = context.getBean("triggerRefProducer", SourcePollingChannelAdapter.class);
    assertTrue(adapter.isAutoStartup());
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
    Trigger trigger = TestUtils.getPropertyValue(adapter, "trigger", Trigger.class);
    assertEquals(context.getBean("customTrigger"), trigger);
    assertEquals(context.getBean("triggerRefChannel"), adapterAccessor.getPropertyValue("outputChannel"));
    Expression expression = TestUtils.getPropertyValue(adapter, "source.expression", Expression.class);
    assertEquals("'triggerRefTest'", expression.getExpressionString());
}
Also used : PeriodicTrigger(org.springframework.scheduling.support.PeriodicTrigger) Trigger(org.springframework.scheduling.Trigger) CronTrigger(org.springframework.scheduling.support.CronTrigger) Expression(org.springframework.expression.Expression) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SourcePollingChannelAdapter(org.springframework.integration.endpoint.SourcePollingChannelAdapter) Test(org.junit.Test)

Example 7 with SourcePollingChannelAdapter

use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.

the class InboundChannelAdapterExpressionTests method headerExpressions.

@Test
@SuppressWarnings("unchecked")
public void headerExpressions() {
    SourcePollingChannelAdapter adapter = context.getBean("headerExpressionsProducer", SourcePollingChannelAdapter.class);
    assertFalse(adapter.isAutoStartup());
    Map<String, Expression> headerExpressions = TestUtils.getPropertyValue(adapter, "source.headerExpressions", Map.class);
    assertEquals(2, headerExpressions.size());
    assertEquals("6 * 7", headerExpressions.get("foo").getExpressionString());
    assertEquals("x", headerExpressions.get("bar").getExpressionString());
    assertEquals(42, headerExpressions.get("foo").getValue());
    assertEquals("x", headerExpressions.get("bar").getValue());
}
Also used : Expression(org.springframework.expression.Expression) SourcePollingChannelAdapter(org.springframework.integration.endpoint.SourcePollingChannelAdapter) Test(org.junit.Test)

Example 8 with SourcePollingChannelAdapter

use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.

the class PollerWithErrorChannelTests method testWithErrorChannelAndHeaderWithSendFailure.

@Test
public // config the same as above but the error wil come from the send
void testWithErrorChannelAndHeaderWithSendFailure() throws Exception {
    ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass());
    SourcePollingChannelAdapter adapter = ac.getBean("withErrorChannelAndHeaderErrorOnSend", SourcePollingChannelAdapter.class);
    adapter.start();
    PollableChannel errorChannel = ac.getBean("errChannel", PollableChannel.class);
    assertNotNull(errorChannel.receive(10000));
    adapter.stop();
    ac.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) SourcePollingChannelAdapter(org.springframework.integration.endpoint.SourcePollingChannelAdapter) Test(org.junit.Test)

Example 9 with SourcePollingChannelAdapter

use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.

the class PollerWithErrorChannelTests method testWithErrorChannelAndHeader.

@Test
public void testWithErrorChannelAndHeader() throws Exception {
    ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass());
    SourcePollingChannelAdapter adapter = ac.getBean("withErrorChannelAndHeader", SourcePollingChannelAdapter.class);
    adapter.start();
    PollableChannel errorChannel = ac.getBean("eChannel", PollableChannel.class);
    assertNotNull(errorChannel.receive(10000));
    adapter.stop();
    ac.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) SourcePollingChannelAdapter(org.springframework.integration.endpoint.SourcePollingChannelAdapter) Test(org.junit.Test)

Example 10 with SourcePollingChannelAdapter

use of org.springframework.integration.endpoint.SourcePollingChannelAdapter in project spring-integration by spring-projects.

the class PollerWithErrorChannelTests method testWithErrorChannel.

@Test
public void testWithErrorChannel() throws Exception {
    ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass());
    SourcePollingChannelAdapter adapter = ac.getBean("withErrorChannel", SourcePollingChannelAdapter.class);
    adapter.start();
    PollableChannel errorChannel = ac.getBean("eChannel", PollableChannel.class);
    assertNotNull(errorChannel.receive(10000));
    adapter.stop();
    ac.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) SourcePollingChannelAdapter(org.springframework.integration.endpoint.SourcePollingChannelAdapter) Test(org.junit.Test)

Aggregations

SourcePollingChannelAdapter (org.springframework.integration.endpoint.SourcePollingChannelAdapter)66 Test (org.junit.Test)58 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)29 Message (org.springframework.messaging.Message)15 PollableChannel (org.springframework.messaging.PollableChannel)13 Collection (java.util.Collection)10 ArrayList (java.util.ArrayList)9 QueueChannel (org.springframework.integration.channel.QueueChannel)9 JpaExecutor (org.springframework.integration.jpa.core.JpaExecutor)9 Consumer (org.springframework.integration.jpa.test.Consumer)9 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)8 PeriodicTrigger (org.springframework.scheduling.support.PeriodicTrigger)8 Trigger (org.springframework.scheduling.Trigger)7 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)6 Expression (org.springframework.expression.Expression)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 BeanFactory (org.springframework.beans.factory.BeanFactory)5 RedisConnectionFactory (org.springframework.data.redis.connection.RedisConnectionFactory)5 RedisAvailable (org.springframework.integration.redis.rules.RedisAvailable)5 File (java.io.File)4