Added tests for explicitly defined TaskScheduler.

This commit is contained in:
Mark Fisher
2008-11-11 23:20:09 +00:00
parent 16dfec6601
commit 818226069f
4 changed files with 20 additions and 18 deletions

View File

@@ -27,6 +27,8 @@ import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.integration.channel.BeanFactoryChannelResolver;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
@@ -86,4 +88,20 @@ public class MessageBusParserTests {
assertEquals(ThreadPoolTaskExecutor.class, taskExecutor.getClass());
}
@Test
public void testExplicitlyDefinedTaskSchedulerHasCorrectType() {
AbstractApplicationContext context = new ClassPathXmlApplicationContext(
"messageBusWithTaskScheduler.xml", this.getClass());
TaskScheduler scheduler = (TaskScheduler) context.getBean("taskScheduler");
assertEquals(StubTaskScheduler.class, scheduler.getClass());
}
@Test
public void testExplicitlyDefinedTaskSchedulerMatchesUtilLookup() {
AbstractApplicationContext context = new ClassPathXmlApplicationContext(
"messageBusWithTaskScheduler.xml", this.getClass());
TaskScheduler scheduler = (TaskScheduler) context.getBean("taskScheduler");
assertEquals(scheduler, IntegrationContextUtils.getTaskScheduler(context));
}
}

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<message-bus auto-startup="false"/>
<beans:bean id="listener" class="org.springframework.integration.bus.MessageBusEventTests$TestMessageBusEventListener"/>
</beans:beans>

View File

@@ -7,8 +7,8 @@
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<message-bus task-scheduler="testScheduler"/>
<channel id="test"/>
<beans:bean id="testScheduler" class="org.springframework.integration.config.StubTaskScheduler"/>
<beans:bean id="taskScheduler" class="org.springframework.integration.config.StubTaskScheduler"/>
</beans:beans>