Replacing Schedule with Trigger.
This commit is contained in:
@@ -41,7 +41,7 @@ import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.PollableSource;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.integration.scheduling.PollingSchedule;
|
||||
import org.springframework.integration.scheduling.IntervalTrigger;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -206,7 +206,7 @@ public class DefaultMessageBusTests {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
SourcePollingChannelAdapter channelAdapter = new SourcePollingChannelAdapter();
|
||||
channelAdapter.setSource(new FailingSource(latch));
|
||||
channelAdapter.setSchedule(new PollingSchedule(1000));
|
||||
channelAdapter.setTrigger(new IntervalTrigger(1000));
|
||||
channelAdapter.setOutputChannel(outputChannel);
|
||||
channelAdapter.setBeanName("testChannel");
|
||||
context.getBeanFactory().registerSingleton("testChannel", channelAdapter);
|
||||
|
||||
@@ -49,8 +49,8 @@ import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.integration.scheduling.PollingSchedule;
|
||||
import org.springframework.integration.scheduling.Schedule;
|
||||
import org.springframework.integration.scheduling.IntervalTrigger;
|
||||
import org.springframework.integration.scheduling.Trigger;
|
||||
import org.springframework.integration.util.MethodInvoker;
|
||||
|
||||
/**
|
||||
@@ -329,13 +329,12 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
processedEndpoint.afterPropertiesSet();
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(processedEndpoint);
|
||||
ChannelPoller poller = (ChannelPoller) accessor.getPropertyValue("poller");
|
||||
Schedule schedule = (Schedule) new DirectFieldAccessor(poller).getPropertyValue("schedule");
|
||||
assertEquals(PollingSchedule.class, schedule.getClass());
|
||||
PollingSchedule pollingSchedule = (PollingSchedule) schedule;
|
||||
assertEquals(1234, pollingSchedule.getPeriod());
|
||||
assertEquals(5678, pollingSchedule.getInitialDelay());
|
||||
assertEquals(true, pollingSchedule.getFixedRate());
|
||||
assertEquals(TimeUnit.SECONDS, pollingSchedule.getTimeUnit());
|
||||
Trigger trigger = (Trigger) new DirectFieldAccessor(poller).getPropertyValue("trigger");
|
||||
assertEquals(IntervalTrigger.class, trigger.getClass());
|
||||
DirectFieldAccessor triggerAccessor = new DirectFieldAccessor(trigger);
|
||||
assertEquals(new Long(123000), triggerAccessor.getPropertyValue("interval"));
|
||||
assertEquals(new Long(456000), triggerAccessor.getPropertyValue("initialDelay"));
|
||||
assertEquals(true, triggerAccessor.getPropertyValue("fixedRate"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -448,7 +447,7 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
private static class AnnotatedEndpointWithPolledAnnotation {
|
||||
|
||||
@ServiceActivator(inputChannel="testChannel")
|
||||
@Poller(period=1234, initialDelay=5678, fixedRate=true, timeUnit=TimeUnit.SECONDS)
|
||||
@Poller(interval=123, initialDelay=456, fixedRate=true, timeUnit=TimeUnit.SECONDS)
|
||||
public String prependFoo(String s) {
|
||||
return "foo" + s;
|
||||
}
|
||||
@@ -470,7 +469,7 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
private static class ChannelAdapterAnnotationTestBean {
|
||||
|
||||
@ChannelAdapter("testChannel")
|
||||
@Poller(period = 1000, initialDelay = 0, maxMessagesPerPoll = 1)
|
||||
@Poller(interval=1000, initialDelay=0, maxMessagesPerPoll=1)
|
||||
public String test() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageRejectedException;
|
||||
import org.springframework.integration.scheduling.Schedule;
|
||||
import org.springframework.integration.scheduling.Trigger;
|
||||
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
@@ -39,16 +39,16 @@ import org.springframework.integration.scheduling.Schedule;
|
||||
public class ChannelPollerTests {
|
||||
|
||||
private ChannelPoller poller;
|
||||
private Schedule scheduleMock = createMock(Schedule.class);
|
||||
private Trigger triggerMock = createMock(Trigger.class);
|
||||
private PollableChannel channelMock = createMock(PollableChannel.class);
|
||||
private MessageConsumer endpointMock = createMock(MessageConsumer.class);
|
||||
private Message messageMock = createMock(Message.class);
|
||||
private Object[] globalMocks = new Object[] { scheduleMock, channelMock, endpointMock, messageMock };
|
||||
private Object[] globalMocks = new Object[] { triggerMock, channelMock, endpointMock, messageMock };
|
||||
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
poller = new ChannelPoller(channelMock, scheduleMock);
|
||||
poller = new ChannelPoller(channelMock, triggerMock);
|
||||
poller.subscribe(endpointMock);
|
||||
poller.setReceiveTimeout(-1);
|
||||
reset(globalMocks);
|
||||
@@ -112,7 +112,7 @@ public class ChannelPollerTests {
|
||||
|
||||
@Test
|
||||
public void blockingSourceTimedOut() {
|
||||
poller = new ChannelPoller(channelMock, scheduleMock);
|
||||
poller = new ChannelPoller(channelMock, triggerMock);
|
||||
poller.subscribe(endpointMock);
|
||||
// we don't need to await the timeout, returning null suffices
|
||||
expect(channelMock.receive(1)).andReturn(null);
|
||||
@@ -124,7 +124,7 @@ public class ChannelPollerTests {
|
||||
|
||||
@Test
|
||||
public void blockingSourceNotTimedOut() {
|
||||
poller = new ChannelPoller(channelMock, scheduleMock);
|
||||
poller = new ChannelPoller(channelMock, triggerMock);
|
||||
poller.subscribe(endpointMock);
|
||||
expect(channelMock.receive(1)).andReturn(messageMock);
|
||||
endpointMock.onMessage(messageMock);
|
||||
|
||||
Reference in New Issue
Block a user