List of usage examples for org.springframework.integration.endpoint SourcePollingChannelAdapter setMaxMessagesPerPoll
public void setMaxMessagesPerPoll(long maxMessagesPerPoll)
From source file:org.springframework.integration.config.SourcePollingChannelAdapterFactoryBeanTests.java
@Test public void testStartSourceBeforeRunPollingTask() { TaskScheduler taskScheduler = mock(TaskScheduler.class); willAnswer(invocation -> {/*from w w w .j a v a2 s .co m*/ Runnable task = invocation.getArgument(0); task.run(); return null; }).given(taskScheduler).schedule(any(Runnable.class), any(Trigger.class)); SourcePollingChannelAdapter pollingChannelAdapter = new SourcePollingChannelAdapter(); pollingChannelAdapter.setTaskScheduler(taskScheduler); pollingChannelAdapter.setSource(new LifecycleMessageSource()); pollingChannelAdapter.setMaxMessagesPerPoll(1); QueueChannel outputChannel = new QueueChannel(); pollingChannelAdapter.setOutputChannel(outputChannel); pollingChannelAdapter.setBeanFactory(mock(BeanFactory.class)); pollingChannelAdapter.afterPropertiesSet(); pollingChannelAdapter.start(); Message<?> receive = outputChannel.receive(10_000); assertNotNull(receive); assertEquals(true, receive.getPayload()); pollingChannelAdapter.stop(); }