INT-1263, added more changes and tests related valdating MessageHistory in every module

This commit is contained in:
Oleg Zhurakousky
2010-09-22 18:44:51 -04:00
parent dee91f6871
commit b6e058c59b
46 changed files with 367 additions and 114 deletions

View File

@@ -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<String> {
public class CharacterStreamReadingMessageSource extends IntegrationObjectSupport implements MessageSource<String> {
private final BufferedReader reader;
@@ -87,5 +88,8 @@ public class CharacterStreamReadingMessageSource implements MessageSource<String
throw new IllegalArgumentException("unsupported encoding: " + charsetName, e);
}
}
public String getComponentType(){
return "stream:stdin-channel-adapter";
}
}

View File

@@ -16,6 +16,7 @@
package org.springframework.integration.stream.config;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -33,6 +34,7 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
@@ -54,6 +56,10 @@ public class ConsoleInboundChannelAdapterParserTests {
SourcePollingChannelAdapter adapter =
(SourcePollingChannelAdapter) context.getBean("adapterWithDefaultCharset.adapter");
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());
}

View File

@@ -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">
<integration:message-history/>
<stdin-channel-adapter id="adapterWithDefaultCharset" auto-startup="false"/>