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

@@ -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());
}

View File

@@ -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"));
}
}

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-2.0.xsd">
<int:message-history/>
<int-file:inbound-channel-adapter id="fileAdapter" directory="input"
auto-startup="true"
channel="outChannel"
auto-create-directory="true">
<int:poller fixed-rate="100"/>
</int-file:inbound-channel-adapter>
<int:channel id="outChannel">
<int:queue/>
</int:channel>
</beans>