INT-722 Modified the ApplicationEventMulicasterParser and affected tests for Spring 3.0 support.

This commit is contained in:
Mark Fisher
2009-07-15 16:55:24 +00:00
parent 7837421b83
commit 1088a0d1bd
2 changed files with 21 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.core.SpringVersion;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.util.StringUtils;
@@ -59,7 +60,10 @@ public class ApplicationEventMulticasterParser extends AbstractSingleBeanDefinit
TaskExecutor taskExecutor = IntegrationContextUtils.createThreadPoolTaskExecutor(1, 10, 0, "event-multicaster-");
builder.addPropertyValue("taskExecutor", taskExecutor);
}
builder.addPropertyValue("collectionClass", CopyOnWriteArraySet.class);
String springVersion = SpringVersion.getVersion();
if (springVersion != null && springVersion.startsWith("2")) {
builder.addPropertyValue("collectionClass", CopyOnWriteArraySet.class);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.integration.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
@@ -25,6 +26,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.event.SimpleApplicationEventMulticaster;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.SpringVersion;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.integration.channel.BeanFactoryChannelResolver;
import org.springframework.integration.context.IntegrationContextUtils;
@@ -61,7 +63,12 @@ public class MessageBusParserTests {
context.getBean(AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME);
DirectFieldAccessor accessor = new DirectFieldAccessor(multicaster);
Object taskExecutor = accessor.getPropertyValue("taskExecutor");
assertEquals(SyncTaskExecutor.class, taskExecutor.getClass());
if (SpringVersion.getVersion().startsWith("2")) {
assertEquals(SyncTaskExecutor.class, taskExecutor.getClass());
}
else {
assertNull(taskExecutor);
}
}
@Test
@@ -73,7 +80,12 @@ public class MessageBusParserTests {
context.getBean(AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME);
DirectFieldAccessor accessor = new DirectFieldAccessor(multicaster);
Object taskExecutor = accessor.getPropertyValue("taskExecutor");
assertEquals(SyncTaskExecutor.class, taskExecutor.getClass());
if (SpringVersion.getVersion().startsWith("2")) {
assertEquals(SyncTaskExecutor.class, taskExecutor.getClass());
}
else {
assertNull(taskExecutor);
}
}
@Test