diff --git a/spring-integration-core/src/main/java/org/springframework/integration/MessageDeliveryException.java b/spring-integration-core/src/main/java/org/springframework/integration/MessageDeliveryException.java index f84409eb66..18b33d085e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/MessageDeliveryException.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/MessageDeliveryException.java @@ -23,6 +23,10 @@ package org.springframework.integration; */ @SuppressWarnings("serial") public class MessageDeliveryException extends MessagingException { + + public MessageDeliveryException(String description) { + super(description); + } public MessageDeliveryException(Message undeliveredMessage) { super(undeliveredMessage); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/MessageTimeoutException.java b/spring-integration-core/src/main/java/org/springframework/integration/MessageTimeoutException.java index f67e782a4b..7480084975 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/MessageTimeoutException.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/MessageTimeoutException.java @@ -21,7 +21,11 @@ package org.springframework.integration; * @author Mark Fisher */ @SuppressWarnings("serial") -public class MessageTimeoutException extends MessageHandlingException { +public class MessageTimeoutException extends MessageDeliveryException { + + public MessageTimeoutException(String description) { + super(description); + } public MessageTimeoutException(Message failedMessage, String description, Throwable cause) { super(failedMessage, description, cause); @@ -31,10 +35,6 @@ public class MessageTimeoutException extends MessageHandlingException { super(failedMessage, description); } - public MessageTimeoutException(Message failedMessage, Throwable cause) { - super(failedMessage, cause); - } - public MessageTimeoutException(Message failedMessage) { super(failedMessage); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractTransformer.java index 89f712fa98..69b06995ae 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractTransformer.java @@ -17,16 +17,17 @@ package org.springframework.integration.transformer; import org.springframework.integration.Message; +import org.springframework.integration.context.IntegrationObjectSupport; import org.springframework.integration.support.MessageBuilder; /** * A base class for {@link Transformer} implementations. * * @author Mark Fisher + * @author Oleg Zhurakousky */ -public abstract class AbstractTransformer implements Transformer { +public abstract class AbstractTransformer extends IntegrationObjectSupport implements Transformer { - @SuppressWarnings("unchecked") public final Message transform(Message message) { try { Object result = this.doTransform(message); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java index bc57e087bb..a95bff668c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java @@ -19,11 +19,7 @@ package org.springframework.integration.transformer; import java.util.Map; import org.springframework.beans.BeanUtils; -import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.core.convert.ConversionService; import org.springframework.util.Assert; @@ -41,15 +37,11 @@ import org.springframework.validation.DataBinder; * @author Oleg Zhurakousky * @since 2.0 */ -public class MapToObjectTransformer extends AbstractPayloadTransformer, Object> implements BeanFactoryAware{ +public class MapToObjectTransformer extends AbstractPayloadTransformer, Object>{ private final Class targetClass; private final String targetBeanName; - - private volatile ConfigurableBeanFactory beanFactory; - - /** * @param targetClass */ @@ -73,25 +65,17 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer, protected Object transformPayload(Map payload) throws Exception { Object target = (this.targetClass != null) ? BeanUtils.instantiate(this.targetClass) - : this.beanFactory.getBean(this.targetBeanName); + : this.getBeanFactory().getBean(this.targetBeanName); DataBinder binder = new DataBinder(target); - binder.setConversionService(this.beanFactory.getConversionService()); + binder.setConversionService(((ConfigurableListableBeanFactory)this.getBeanFactory()).getConversionService()); binder.bind(new MutablePropertyValues(payload)); return target; } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory) - */ - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - Assert.isTrue(beanFactory instanceof ConfigurableListableBeanFactory, - "A ConfigurableListableBeanFactory is required."); - this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; + + protected void onInit(){ if (StringUtils.hasText(this.targetBeanName)) { - Assert.isTrue(this.beanFactory.isPrototype(this.targetBeanName), + Assert.isTrue(this.getBeanFactory().isPrototype(this.targetBeanName), "target bean [" + targetBeanName + "] must have 'prototype' scope"); } } - } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java index 16a5b21003..e957075aba 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java @@ -18,6 +18,7 @@ package org.springframework.integration.transformer; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.integration.Message; +import org.springframework.integration.context.NamedComponent; import org.springframework.integration.core.MessageHandler; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.util.Assert; @@ -48,7 +49,8 @@ public class MessageTransformingHandler extends AbstractReplyProducingMessageHan @Override public String getComponentType() { - return "transformer"; + return (this.transformer instanceof NamedComponent) ? + ((NamedComponent) this.transformer).getComponentType() : "transformer"; } @Override diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayRequiresReplyTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayRequiresReplyTests-context.xml index 3ee9230dde..6bcf7e80fe 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayRequiresReplyTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayRequiresReplyTests-context.xml @@ -2,8 +2,10 @@ @@ -11,9 +13,24 @@ default-request-channel="requestChannel" default-reply-timeout="3000" service-interface="org.springframework.integration.gateway.GatewayRequiresReplyTests$TestService" /> + + + + + + + + + + + + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayRequiresReplyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayRequiresReplyTests.java index 81283e6cb3..f128df7116 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayRequiresReplyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayRequiresReplyTests.java @@ -51,10 +51,24 @@ public class GatewayRequiresReplyTests { TestService gateway = (TestService) applicationContext.getBean("gateway"); gateway.test("bad"); } + + @Test + public void timedOutGateway() { + TestService gateway = (TestService) applicationContext.getBean("timeoutGateway"); + String result = gateway.test("hello"); + System.out.println("Result: " + result); + } public static interface TestService { public String test(String s); } + + public static class LongRunningService{ + public String echo(String value) throws Exception{ + Thread.sleep(5000); + return value; + } + } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/test/util/TestUtils.java b/spring-integration-core/src/test/java/org/springframework/integration/test/util/TestUtils.java index f4bcb08c95..fb4a1c3be0 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/test/util/TestUtils.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/test/util/TestUtils.java @@ -19,6 +19,7 @@ package org.springframework.integration.test.util; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; +import java.util.Properties; import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy; import org.hamcrest.Matcher; @@ -41,15 +42,18 @@ import org.springframework.integration.context.NamedComponent; import org.springframework.integration.core.MessageHandler; import org.springframework.integration.endpoint.AbstractEndpoint; import org.springframework.integration.endpoint.AbstractPollingEndpoint; +import org.springframework.integration.history.MessageHistory; import org.springframework.integration.support.channel.BeanFactoryChannelResolver; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.support.PeriodicTrigger; import org.springframework.util.Assert; import org.springframework.util.ErrorHandler; +import org.springframework.util.StringUtils; /** * @author Mark Fisher * @author Iwein Fuld + * @author Oleg Zhurakousky */ public abstract class TestUtils { @@ -159,4 +163,19 @@ public abstract class TestUtils { } }; } + + public static Properties locateComponentInHistory(MessageHistory history, String componentName, int startingIndex){ + Assert.notNull(history, "'history' must not be null"); + Assert.isTrue(StringUtils.hasText(componentName), "'componentName' must be provided"); + Assert.isTrue(startingIndex < history.size(), "'startingIndex' can not be greater then size of history"); + Properties component = null; + for (int i = startingIndex; i < history.size(); i++) { + Properties properties = history.get(i); + if (componentName.equals(properties.get("name"))){ + component = properties; + break; + } + } + return component; + } } \ No newline at end of file diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/MapToObjectTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/MapToObjectTransformerTests.java index b25a738dec..a5f4258964 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/MapToObjectTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/MapToObjectTransformerTests.java @@ -64,25 +64,6 @@ public class MapToObjectTransformerTests { assertNotNull(person.getAddress()); assertEquals("1123 Main st", person.getAddress().getStreet()); } - - @SuppressWarnings("unchecked") - @Test(expected=IllegalArgumentException.class) - public void testMapToObjectTransformationNonPrototype(){ - Map map = new HashMap(); - map.put("fname", "Justin"); - map.put("lname", "Case"); - Address address = new Address(); - address.setStreet("1123 Main st"); - map.put("address", address); - - Message message = MessageBuilder.withPayload(map).build(); - GenericApplicationContext context = new GenericApplicationContext(); - RootBeanDefinition personDef = new RootBeanDefinition(Person.class); - context.registerBeanDefinition("person", personDef); - MapToObjectTransformer transformer = new MapToObjectTransformer("person"); - transformer.setBeanFactory(context.getBeanFactory()); - transformer.transform(message); - } @SuppressWarnings("unchecked") @Test diff --git a/spring-integration-event/.settings/com.springsource.sts.config.flow.prefs b/spring-integration-event/.settings/com.springsource.sts.config.flow.prefs index ced4b60e7b..920caf3658 100644 --- a/spring-integration-event/.settings/com.springsource.sts.config.flow.prefs +++ b/spring-integration-event/.settings/com.springsource.sts.config.flow.prefs @@ -1,3 +1,3 @@ -#Thu Jul 29 17:49:43 EDT 2010 -//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml=\n\n\n\n\n\n +#Wed Sep 22 11:50:06 EDT 2010 +//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml=\n\n\n\n\n\n\n\n\n\n\n\n\n\n eclipse.preferences.version=1 diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml b/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml index dddd5381b2..bf71e51806 100644 --- a/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests-context.xml @@ -9,6 +9,8 @@ xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-event="http://www.springframework.org/schema/integration/event"> + + diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests.java b/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests.java index de0504f126..71ddf5fb50 100644 --- a/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests.java +++ b/spring-integration-event/src/test/java/org/springframework/integration/event/config/EventInboundChannelAdapterParserTests.java @@ -35,6 +35,7 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.integration.Message; import org.springframework.integration.core.PollableChannel; import org.springframework.integration.event.ApplicationEventInboundChannelAdapter; +import org.springframework.integration.history.MessageHistory; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -91,11 +92,13 @@ public class EventInboundChannelAdapterParserTests { } @Test - public void validateUsage() { + public void validateUsageWithHistory() { PollableChannel channel = context.getBean("input", PollableChannel.class); assertEquals(ContextRefreshedEvent.class, channel.receive(0).getPayload().getClass()); context.publishEvent(new SampleEvent("hello")); Message message = channel.receive(0); + MessageHistory history = MessageHistory.read(message); + assertTrue(history.containsComponent("eventAdapterSimple")); assertNotNull(message); assertEquals(SampleEvent.class, message.getPayload().getClass()); } diff --git a/spring-integration-file/.project b/spring-integration-file/.project index 42dea7a765..85e330e020 100644 --- a/spring-integration-file/.project +++ b/spring-integration-file/.project @@ -15,8 +15,14 @@ + + org.springframework.ide.eclipse.core.springbuilder + + + + org.springframework.ide.eclipse.core.springnature org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature diff --git a/spring-integration-file/input/FileMessageHistoryTest.txt b/spring-integration-file/input/FileMessageHistoryTest.txt new file mode 100644 index 0000000000..b6fc4c620b --- /dev/null +++ b/spring-integration-file/input/FileMessageHistoryTest.txt @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/AbstractInboundRemoteFileSystemSynchronizingMessageSource.java b/spring-integration-file/src/main/java/org/springframework/integration/file/AbstractInboundRemoteFileSystemSynchronizingMessageSource.java index 5b10d86056..e3e9af69c9 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/AbstractInboundRemoteFileSystemSynchronizingMessageSource.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/AbstractInboundRemoteFileSystemSynchronizingMessageSource.java @@ -2,8 +2,10 @@ package org.springframework.integration.file; import org.springframework.core.io.Resource; import org.springframework.integration.Message; +import org.springframework.integration.MessagingException; import org.springframework.integration.core.MessageSource; import org.springframework.integration.endpoint.AbstractEndpoint; +import org.springframework.integration.endpoint.MessageProducerSupport; import org.springframework.integration.file.entries.*; import java.io.File; @@ -27,7 +29,7 @@ import java.util.regex.Pattern; * * @author Josh Long */ -public abstract class AbstractInboundRemoteFileSystemSynchronizingMessageSource> extends AbstractEndpoint implements MessageSource { +public abstract class AbstractInboundRemoteFileSystemSynchronizingMessageSource> extends MessageProducerSupport implements MessageSource { /** * Extension used when downloading files. We change it right after we know it's downloaded */ @@ -74,7 +76,8 @@ public abstract class AbstractInboundRemoteFileSystemSynchronizingMessageSource< this.remotePredicate = remotePredicate; } - private EntryListFilter buildFilter() { + @SuppressWarnings("unchecked") + private EntryListFilter buildFilter() { FileEntryNamer fileEntryNamer = new FileEntryNamer(); Pattern completePattern = Pattern.compile("^.*(?( @@ -83,33 +86,42 @@ public abstract class AbstractInboundRemoteFileSystemSynchronizingMessageSource< } @Override - protected void onInit() throws Exception { - if (this.remotePredicate != null) { - this.synchronizer.setFilter(this.remotePredicate); - } + protected void onInit() { + try { + if (this.remotePredicate != null) { + this.synchronizer.setFilter(this.remotePredicate); + } - if (this.autoCreateDirectories) { - if ((this.localDirectory != null) && !this.localDirectory.exists() && this.localDirectory.getFile().mkdirs()) - logger.debug("the localDirectory " + this.localDirectory + " doesn't exist"); - } + if (this.autoCreateDirectories) { + if ((this.localDirectory != null) && !this.localDirectory.exists() && this.localDirectory.getFile().mkdirs()) + logger.debug("the localDirectory " + this.localDirectory + " doesn't exist"); + } - /** - * Handles making sure the remote files get here in one piece - */ - this.synchronizer.setLocalDirectory(this.localDirectory); - this.synchronizer.setTaskScheduler(this.getTaskScheduler()); - this.synchronizer.setBeanFactory(this.getBeanFactory()); - this.synchronizer.setPhase(this.getPhase()); - this.synchronizer.setBeanName(this.getComponentName()); + /** + * Handles making sure the remote files get here in one piece + */ + this.synchronizer.setLocalDirectory(this.localDirectory); + this.synchronizer.setTaskScheduler(this.getTaskScheduler()); + this.synchronizer.setBeanFactory(this.getBeanFactory()); + this.synchronizer.setPhase(this.getPhase()); + this.synchronizer.setBeanName(this.getComponentName()); - /** - * Handles forwarding files once they ultimately appear in the {@link #localDirectory} - */ - this.fileSource = new FileReadingMessageSource(); - this.fileSource.setFilter(buildFilter()); - this.fileSource.setDirectory(this.localDirectory.getFile()); - this.fileSource.afterPropertiesSet(); - this.synchronizer.afterPropertiesSet(); + /** + * Handles forwarding files once they ultimately appear in the {@link #localDirectory} + */ + this.fileSource = new FileReadingMessageSource(); + this.fileSource.setFilter(buildFilter()); + this.fileSource.setDirectory(this.localDirectory.getFile()); + this.fileSource.afterPropertiesSet(); + this.synchronizer.afterPropertiesSet(); + } catch (Exception e) { + if (e instanceof RuntimeException){ + throw (RuntimeException)e; + } else { + throw new MessagingException("Failure during initialization of " + this.getComponentName(), e); + } + } + } public Message receive() { diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java b/spring-integration-file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java index 95f5cf9964..3eade29e94 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java @@ -15,21 +15,25 @@ */ package org.springframework.integration.file; +import java.io.File; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.PriorityBlockingQueue; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; import org.springframework.integration.Message; import org.springframework.integration.MessagingException; import org.springframework.integration.aggregator.ResequencingMessageGroupProcessor; +import org.springframework.integration.context.IntegrationObjectSupport; import org.springframework.integration.core.MessageSource; import org.springframework.integration.file.entries.EntryListFilter; import org.springframework.integration.support.MessageBuilder; import org.springframework.util.Assert; -import java.io.File; -import java.util.*; -import java.util.concurrent.PriorityBlockingQueue; - /** * {@link MessageSource} that creates messages from a file system directory. To prevent messages for certain files, you @@ -52,8 +56,9 @@ import java.util.concurrent.PriorityBlockingQueue; * * @author Iwein Fuld * @author Mark Fisher + * @author Oleg Zhurakousky */ -public class FileReadingMessageSource implements MessageSource, InitializingBean { +public class FileReadingMessageSource extends IntegrationObjectSupport implements MessageSource{ private static final int DEFAULT_INTERNAL_QUEUE_CAPACITY = 5; private static final Log logger = LogFactory.getLog(FileReadingMessageSource.class); private volatile File directory; @@ -178,8 +183,7 @@ public class FileReadingMessageSource implements MessageSource, Initializi this.scanEachPoll = scanEachPoll; } - @SuppressWarnings({"ResultOfMethodCallIgnored"}) - public final void afterPropertiesSet() { + protected void onInit() { Assert.notNull(directory, "'directory' must not be set before initialization"); if (!this.directory.exists() && this.autoCreateDirectory) { @@ -254,4 +258,8 @@ public class FileReadingMessageSource implements MessageSource, Initializi logger.debug("Sent: " + sentMessage); } } + + public String getComponentType() { + return "file:inbound-channel-adapter"; + } } diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java index f12927b6b2..cd5cc874df 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java @@ -21,6 +21,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ApplicationContext; import org.springframework.integration.channel.AbstractMessageChannel; import org.springframework.integration.file.DefaultDirectoryScanner; @@ -47,7 +48,12 @@ public class FileInboundChannelAdapterParserTests { private ApplicationContext context; @Autowired + // @Qualifier("inputDirPoller") private FileReadingMessageSource source; + +// @Autowired +// @Qualifier("inputDirPollerWithChannel") +// private FileReadingMessageSource sourceWithChannel; private DirectFieldAccessor accessor; @@ -59,6 +65,7 @@ public class FileInboundChannelAdapterParserTests { @Test public void channelName() throws Exception { + Object adapter = context.getBean("inputDirPoller"); AbstractMessageChannel channel = context.getBean("inputDirPoller", AbstractMessageChannel.class); assertEquals("Channel should be available under specified id", "inputDirPoller", channel.getComponentName()); } diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileMessageHistoryTest.java b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileMessageHistoryTest.java new file mode 100644 index 0000000000..a0ee919cb4 --- /dev/null +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileMessageHistoryTest.java @@ -0,0 +1,55 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.integration.file.config; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.util.Properties; + +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.Message; +import org.springframework.integration.core.PollableChannel; +import org.springframework.integration.history.MessageHistory; +import org.springframework.integration.test.util.TestUtils; + +/** + * @author Oleg Zhurakousky + * + */ +public class FileMessageHistoryTest { + @Test + public void testMessageHistory() throws Exception{ + ApplicationContext context = new ClassPathXmlApplicationContext("file-message-history-context.xml", this.getClass()); + File file = new File("input/FileMessageHistoryTest.txt"); + BufferedWriter out = new BufferedWriter(new FileWriter(file)); + out.write("hello"); + out.close(); + + PollableChannel outChannel = context.getBean("outChannel", PollableChannel.class); + Message message = outChannel.receive(1000); + MessageHistory history = MessageHistory.read(message); + assertNotNull(history); + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "fileAdapter", 0); + assertNotNull(componentHistoryRecord); + assertEquals("file:inbound-channel-adapter", componentHistoryRecord.get("type")); + } +} diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/file-message-history-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/config/file-message-history-context.xml new file mode 100644 index 0000000000..0b5a606023 --- /dev/null +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/file-message-history-context.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/impl/FtpInboundRemoteFileSystemSynchronizingMessageSource.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/impl/FtpInboundRemoteFileSystemSynchronizingMessageSource.java index c868fd0c8c..adf5065bfb 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/impl/FtpInboundRemoteFileSystemSynchronizingMessageSource.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/impl/FtpInboundRemoteFileSystemSynchronizingMessageSource.java @@ -28,7 +28,7 @@ public class FtpInboundRemoteFileSystemSynchronizingMessageSource extends Abstra } @Override - protected void onInit() throws Exception { + protected void onInit() { super.onInit(); this.synchronizer.setClientPool(this.clientPool); } diff --git a/spring-integration-ftp/src/test/resources/inbound-ftp-context.xml b/spring-integration-ftp/src/test/resources/inbound-ftp-context.xml index cbffef591d..ae156da236 100644 --- a/spring-integration-ftp/src/test/resources/inbound-ftp-context.xml +++ b/spring-integration-ftp/src/test/resources/inbound-ftp-context.xml @@ -8,9 +8,9 @@ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - + + + message = requests.receive(0); MessageHistory history = MessageHistory.read(message); + assertNotNull(history); + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "postOnlyAdapter", 0); + assertNotNull(componentHistoryRecord); + assertEquals("http:inbound-channel-adapter", componentHistoryRecord.get("type")); + //System.out.println(componentHistoryRecord); assertTrue(history.containsComponent("postOnlyAdapter")); assertNotNull(message); assertEquals("test", message.getPayload()); diff --git a/spring-integration-ip/.settings/org.maven.ide.eclipse.prefs b/spring-integration-ip/.settings/org.maven.ide.eclipse.prefs index 85f2635658..78b6943cde 100644 --- a/spring-integration-ip/.settings/org.maven.ide.eclipse.prefs +++ b/spring-integration-ip/.settings/org.maven.ide.eclipse.prefs @@ -1,4 +1,4 @@ -#Mon Mar 01 13:38:53 GMT 2010 +#Wed Sep 22 13:42:49 EDT 2010 activeProfiles= eclipse.preferences.version=1 fullBuildGoals=process-test-resources diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java index cb451e4e7e..8561c978d0 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java @@ -85,5 +85,7 @@ public class TcpInboundGateway extends MessagingGatewaySupport implements TcpLis public void removeDeadConnection(TcpConnection connection) { connections.remove(connection.getConnectionId()); } - + public String getComponentType(){ + return "ip:tcp-inbound-gateway"; + } } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastReceivingChannelAdapter.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastReceivingChannelAdapter.java index 5b515630e4..a07014b00d 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastReceivingChannelAdapter.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastReceivingChannelAdapter.java @@ -199,5 +199,8 @@ public class UnicastReceivingChannelAdapter extends AbstractInternetProtocolRece public void setSoSendBufferSize(int soSendBufferSize) { this.soSendBufferSize = soSendBufferSize; } - + + public String getComponentType(){ + return "ip:udp-inbound-channel-adapter"; + } } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.java index e1e1339eb0..1d791264d0 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.java @@ -20,6 +20,8 @@ import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import java.util.Properties; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +33,7 @@ import org.springframework.integration.ip.tcp.connection.AbstractClientConnectio import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory; import org.springframework.integration.ip.tcp.connection.TcpConnection; import org.springframework.integration.support.MessageBuilder; +import org.springframework.integration.test.util.TestUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -69,7 +72,10 @@ public class ConnectionToConnectionTests { connection.send(MessageBuilder.withPayload("Test").build()); Message message = serverSideChannel.receive(10000); MessageHistory history = MessageHistory.read(message); - assertTrue(history.containsComponent("looper")); + //org.springframework.integration.test.util.TestUtils + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "looper", 0); + assertNotNull(componentHistoryRecord); + assertTrue(componentHistoryRecord.get("type").equals("ip:tcp-inbound-gateway")); assertNotNull(message); assertEquals("Test", new String((byte[]) message.getPayload())); } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java index 550930a976..4d9f76462f 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java @@ -16,16 +16,17 @@ package org.springframework.integration.ip.udp; +import static junit.framework.Assert.assertNotNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.Date; +import java.util.Properties; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -36,6 +37,7 @@ import org.springframework.integration.history.MessageHistory; import org.springframework.integration.message.GenericMessage; import org.springframework.integration.support.channel.BeanFactoryChannelResolver; import org.springframework.integration.support.channel.ChannelResolver; +import org.springframework.integration.test.util.TestUtils; /** * Sends and receives a simple message through to the Udp channel adapters. @@ -139,7 +141,9 @@ public class UdpUnicastEndToEndTests implements Runnable { QueueChannel channel = ctx.getBean("udpOutChannel", QueueChannel.class); finalMessage = (Message) channel.receive(); MessageHistory history = MessageHistory.read(finalMessage); - assertTrue(history.containsComponent("udpReceiver")); + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "udpReceiver", 0); + assertNotNull(componentHistoryRecord); + assertEquals("ip:udp-inbound-channel-adapter", componentHistoryRecord.get("type")); firstReceived.countDown(); try { doneProcessing.await(); diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcPollingChannelAdapter.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcPollingChannelAdapter.java index 5a9b4967f1..874cb9c073 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcPollingChannelAdapter.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcPollingChannelAdapter.java @@ -25,6 +25,7 @@ import javax.sql.DataSource; import org.springframework.dao.DataAccessException; import org.springframework.integration.Message; +import org.springframework.integration.context.IntegrationObjectSupport; import org.springframework.integration.core.MessageSource; import org.springframework.integration.support.MessageBuilder; import org.springframework.jdbc.core.ColumnMapRowMapper; @@ -45,7 +46,7 @@ import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; * @author Dave Syer * @since 2.0 */ -public class JdbcPollingChannelAdapter implements MessageSource { +public class JdbcPollingChannelAdapter extends IntegrationObjectSupport implements MessageSource { private final SimpleJdbcOperations jdbcOperations; @@ -199,7 +200,9 @@ public class JdbcPollingChannelAdapter implements MessageSource { } return payload; - + } + public String getComponentType(){ + return "jdbc:inbound-channel-adapter"; } } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/JdbcPollingChannelAdapterParserTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/JdbcPollingChannelAdapterParserTests.java index 5ec57f5eec..ed70cce76a 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/JdbcPollingChannelAdapterParserTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/JdbcPollingChannelAdapterParserTests.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue; import java.util.List; import java.util.Map; +import java.util.Properties; import javax.sql.DataSource; @@ -34,6 +35,7 @@ import org.springframework.integration.Message; import org.springframework.integration.core.MessagingTemplate; import org.springframework.integration.core.PollableChannel; import org.springframework.integration.history.MessageHistory; +import org.springframework.integration.test.util.TestUtils; import org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import org.springframework.transaction.PlatformTransactionManager; @@ -57,14 +59,17 @@ public class JdbcPollingChannelAdapterParserTests { private PlatformTransactionManager transactionManager; @Test - public void testSimpleInboundChannelAdapter(){ + public void testSimpleInboundChannelAdapterWithHistory(){ setUp("pollingForMapJdbcInboundChannelAdapterTest.xml", getClass()); this.jdbcTemplate.update("insert into item values(1,'',2)"); Message message = messagingTemplate.receive(); - MessageHistory history = MessageHistory.read(message); - assertTrue(history.containsComponent("jdbcAdapter")); assertNotNull("No message found ", message); assertTrue("Wrong payload type expected instance of List", message.getPayload() instanceof List); + MessageHistory history = MessageHistory.read(message); + assertNotNull(history); + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "jdbcAdapter", 0); + assertNotNull(componentHistoryRecord); + assertEquals("jdbc:inbound-channel-adapter", componentHistoryRecord.get("type")); } diff --git a/spring-integration-mail/pom.xml b/spring-integration-mail/pom.xml index 6a6af54f6e..de436a0beb 100644 --- a/spring-integration-mail/pom.xml +++ b/spring-integration-mail/pom.xml @@ -57,5 +57,9 @@ org.springframework spring-test + + org.springframework.integration + spring-integration-test + diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java index 964db5570e..cd96b01dd7 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java @@ -140,5 +140,8 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport { } } } + public String getComponentType(){ + return "mail:imap-idle-channel-adapter"; + } } diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java b/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java index 6d55c06fe6..04d65bbece 100644 --- a/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java +++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java @@ -15,6 +15,8 @@ */ package org.springframework.integration.mail; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -23,6 +25,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.Properties; + import javax.mail.Flags; import javax.mail.Flags.Flag; import javax.mail.Folder; @@ -39,6 +43,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.core.PollableChannel; import org.springframework.integration.history.MessageHistory; import org.springframework.integration.mail.config.ImapIdleChannelAdapterParserTests; +import org.springframework.integration.test.util.TestUtils; import com.sun.mail.imap.IMAPFolder; @@ -237,6 +242,9 @@ public class ImapMailReceiverTests { adapter.start(); org.springframework.integration.Message replMessage = channel.receive(10000); MessageHistory history = MessageHistory.read(replMessage); - assertTrue(history.containsComponent("simpleAdapter")); + assertNotNull(history); + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "simpleAdapter", 0); + assertNotNull(componentHistoryRecord); + assertEquals("mail:imap-idle-channel-adapter", componentHistoryRecord.get("type")); } } diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/impl/SftpInboundRemoteFileSystemSynchronizingMessageSource.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/impl/SftpInboundRemoteFileSystemSynchronizingMessageSource.java index ba9b45251c..da3a71ee78 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/impl/SftpInboundRemoteFileSystemSynchronizingMessageSource.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/impl/SftpInboundRemoteFileSystemSynchronizingMessageSource.java @@ -90,7 +90,7 @@ public class SftpInboundRemoteFileSystemSynchronizingMessageSource extends Abstr } @Override - protected void onInit() throws Exception { + protected void onInit() { super.onInit(); this.checkThatRemotePathExists(this.remotePath); diff --git a/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamReadingMessageSource.java b/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamReadingMessageSource.java index 787242abfd..2ec4a71122 100644 --- a/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamReadingMessageSource.java +++ b/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamReadingMessageSource.java @@ -24,6 +24,7 @@ import java.io.UnsupportedEncodingException; import org.springframework.integration.Message; import org.springframework.integration.MessagingException; +import org.springframework.integration.context.IntegrationObjectSupport; import org.springframework.integration.core.MessageSource; import org.springframework.integration.message.GenericMessage; import org.springframework.util.Assert; @@ -33,7 +34,7 @@ import org.springframework.util.Assert; * * @author Mark Fisher */ -public class CharacterStreamReadingMessageSource implements MessageSource { +public class CharacterStreamReadingMessageSource extends IntegrationObjectSupport implements MessageSource { private final BufferedReader reader; @@ -87,5 +88,8 @@ public class CharacterStreamReadingMessageSource implements MessageSource source = (MessageSource) new DirectFieldAccessor(adapter).getPropertyValue("source"); + assertTrue(source instanceof NamedComponent); + assertEquals("adapterWithDefaultCharset.adapter", adapter.getComponentName()); + assertEquals("stream:stdin-channel-adapter", adapter.getComponentType()); + assertEquals("stream:stdin-channel-adapter", ((NamedComponent)source).getComponentType()); DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(source); Reader bufferedReader = (Reader) sourceAccessor.getPropertyValue("reader"); assertEquals(BufferedReader.class, bufferedReader.getClass()); @@ -63,6 +69,7 @@ public class ConsoleInboundChannelAdapterParserTests { Charset readerCharset = Charset.forName(((InputStreamReader) reader).getEncoding()); assertEquals(Charset.defaultCharset(), readerCharset); Message message = source.receive(); + System.out.println(message); assertNotNull(message); assertEquals("foo", message.getPayload()); } diff --git a/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/consoleInboundChannelAdapterParserTests.xml b/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/consoleInboundChannelAdapterParserTests.xml index 132e89ca64..5d234a7606 100644 --- a/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/consoleInboundChannelAdapterParserTests.xml +++ b/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/consoleInboundChannelAdapterParserTests.xml @@ -9,6 +9,8 @@ http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd"> + + diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java b/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java index 5d1ad9bdca..51dd2b440f 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java @@ -40,17 +40,21 @@ import org.springframework.integration.context.NamedComponent; import org.springframework.integration.core.MessageHandler; import org.springframework.integration.endpoint.AbstractEndpoint; import org.springframework.integration.endpoint.AbstractPollingEndpoint; +import org.springframework.integration.history.MessageHistory; import org.springframework.integration.support.channel.BeanFactoryChannelResolver; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.support.PeriodicTrigger; import org.springframework.util.Assert; import org.springframework.util.ErrorHandler; +import org.springframework.util.StringUtils; +import java.util.Properties; import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy; /** * @author Mark Fisher * @author Iwein Fuld + * @author Oleg Zhurakousky */ public abstract class TestUtils { @@ -160,4 +164,18 @@ public abstract class TestUtils { } }; } + public static Properties locateComponentInHistory(MessageHistory history, String componentName, int startingIndex){ + Assert.notNull(history, "'history' must not be null"); + Assert.isTrue(StringUtils.hasText(componentName), "'componentName' must be provided"); + Assert.isTrue(startingIndex < history.size(), "'startingIndex' can not be greater then size of history"); + Properties component = null; + for (int i = startingIndex; i < history.size(); i++) { + Properties properties = history.get(i); + if (componentName.equals(properties.get("name"))){ + component = properties; + break; + } + } + return component; + } } diff --git a/spring-integration-ws/pom.xml b/spring-integration-ws/pom.xml index dd3bcd5ba8..79f62ae698 100644 --- a/spring-integration-ws/pom.xml +++ b/spring-integration-ws/pom.xml @@ -98,5 +98,9 @@ org.springframework spring-test + + org.springframework.integration + spring-integration-test + diff --git a/spring-integration-ws/src/main/java/org/springframework/integration/ws/MarshallingWebServiceInboundGateway.java b/spring-integration-ws/src/main/java/org/springframework/integration/ws/MarshallingWebServiceInboundGateway.java index cb10cec0cb..e8d95a2a42 100644 --- a/spring-integration-ws/src/main/java/org/springframework/integration/ws/MarshallingWebServiceInboundGateway.java +++ b/spring-integration-ws/src/main/java/org/springframework/integration/ws/MarshallingWebServiceInboundGateway.java @@ -194,6 +194,9 @@ public class MarshallingWebServiceInboundGateway extends AbstractMarshallingPayl public Object sendAndReceive(Object request) { return super.sendAndReceive(request); } + public String getComponentType() { + return "ws:outbound-gateway"; + } } public String getComponentName() { diff --git a/spring-integration-ws/src/main/java/org/springframework/integration/ws/SimpleWebServiceInboundGateway.java b/spring-integration-ws/src/main/java/org/springframework/integration/ws/SimpleWebServiceInboundGateway.java index f912c1695c..301956f692 100644 --- a/spring-integration-ws/src/main/java/org/springframework/integration/ws/SimpleWebServiceInboundGateway.java +++ b/spring-integration-ws/src/main/java/org/springframework/integration/ws/SimpleWebServiceInboundGateway.java @@ -130,4 +130,7 @@ public class SimpleWebServiceInboundGateway extends MessagingGatewaySupport impl } } + public String getComponentType() { + return "ws:outbound-gateway"; + } } diff --git a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests.java b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests.java index 9ea57447eb..1adddcf60d 100644 --- a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests.java +++ b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceInboundGatewayParserTests.java @@ -15,19 +15,21 @@ */ package org.springframework.integration.ws.config; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.util.Properties; + import javax.xml.transform.Source; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -35,6 +37,7 @@ import org.springframework.integration.Message; import org.springframework.integration.MessageChannel; import org.springframework.integration.core.PollableChannel; import org.springframework.integration.history.MessageHistory; +import org.springframework.integration.test.util.TestUtils; import org.springframework.integration.ws.MarshallingWebServiceInboundGateway; import org.springframework.integration.ws.SimpleWebServiceInboundGateway; import org.springframework.oxm.AbstractMarshaller; @@ -122,7 +125,10 @@ public class WebServiceInboundGatewayParserTests { marshallingGateway.invoke(context); Message message = requestsMarshalling.receive(100); MessageHistory history = MessageHistory.read(message); - assertTrue(history.containsComponent("marshalling")); + assertNotNull(history); + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "marshalling", 0); + assertNotNull(componentHistoryRecord); + assertEquals("ws:outbound-gateway", componentHistoryRecord.get("type")); } @Test public void testMessageHistoryWithSimpleGateway() throws Exception { @@ -130,6 +136,10 @@ public class WebServiceInboundGatewayParserTests { payloadExtractingGateway.invoke(context); Message message = requestsSimple.receive(100); MessageHistory history = MessageHistory.read(message); - assertTrue(history.containsComponent("extractsPayload")); + assertNotNull(history); + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "extractsPayload", 0); + System.out.println(componentHistoryRecord); + assertNotNull(componentHistoryRecord); + assertEquals("ws:outbound-gateway", componentHistoryRecord.get("type")); } } diff --git a/spring-integration-xml/pom.xml b/spring-integration-xml/pom.xml index c0ce14ed25..4bfb71f367 100644 --- a/spring-integration-xml/pom.xml +++ b/spring-integration-xml/pom.xml @@ -79,5 +79,9 @@ org.springframework spring-test + + org.springframework.integration + spring-integration-test + diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/router/AbstractXPathRouter.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/router/AbstractXPathRouter.java index 1a3b72121b..fad0bafb25 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/router/AbstractXPathRouter.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/router/AbstractXPathRouter.java @@ -99,5 +99,8 @@ public abstract class AbstractXPathRouter extends AbstractChannelNameResolvingMe protected XPathExpression getXPathExpression() { return this.xPathExpression; } - + + public String getComponentType(){ + return "xml:xpath-router"; + } } diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/splitter/XPathMessageSplitter.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/splitter/XPathMessageSplitter.java index 462411c412..44eeb9d248 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/splitter/XPathMessageSplitter.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/splitter/XPathMessageSplitter.java @@ -164,5 +164,9 @@ public class XPathMessageSplitter extends AbstractMessageSplitter { return this.documentBuilderFactory.newDocumentBuilder(); } } + + public String getComponentType(){ + return "xml:xpath-splitter"; + } } diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java index 249cff2b09..48e6f87690 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java @@ -16,7 +16,6 @@ package org.springframework.integration.xml.transformer; import java.io.IOException; -import java.util.HashMap; import java.util.Map; import javax.xml.parsers.ParserConfigurationException; @@ -35,8 +34,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.context.expression.MapAccessor; import org.springframework.core.io.Resource; import org.springframework.expression.Expression; -import org.springframework.expression.ExpressionParser; -import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.integration.Message; import org.springframework.integration.MessageHeaders; @@ -250,4 +247,7 @@ public class XsltPayloadTransformer extends AbstractTransformer { public void setXsltParamHeaders(String[] xsltParamHeaders) { this.xsltParamHeaders = xsltParamHeaders; } + public String getComponentType(){ + return "xml:xslt-transformer"; + } } diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltTransformerTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltTransformerTests.java index 801716ac5e..956eca8aaf 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltTransformerTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltTransformerTests.java @@ -15,6 +15,8 @@ */ package org.springframework.integration.xml.transformer; +import java.util.Properties; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -25,12 +27,14 @@ import org.springframework.integration.MessageChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.history.MessageHistory; import org.springframework.integration.support.MessageBuilder; +import org.springframework.integration.test.util.TestUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import static org.junit.Assert.assertFalse; import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; /** @@ -56,7 +60,10 @@ public class XsltTransformerTests { input.send(message); Message resultMessage = output.receive(); MessageHistory history = MessageHistory.read(resultMessage); - assertTrue(history.containsComponent("paramHeadersWithStartWildCharacter")); + assertNotNull(history); + Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "paramHeadersWithStartWildCharacter", 0); + assertNotNull(componentHistoryRecord); + assertEquals("xml:xslt-transformer", componentHistoryRecord.get("type")); assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass()); assertTrue(((String) resultMessage.getPayload()).contains("testParamValue")); assertFalse(((String) resultMessage.getPayload()).contains("FOO"));