Added namespace support for ObjectToStringTransformer (INT-516).

This commit is contained in:
Mark Fisher
2008-12-12 21:13:09 +00:00
parent b1881f7b95
commit 9f22033303
5 changed files with 172 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?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">
<channel id="directInput"/>
<channel id="queueInput">
<queue capacity="1"/>
</channel>
<channel id="output">
<queue capacity="1"/>
</channel>
<object-to-string-transformer input-channel="directInput" output-channel="output"/>
<object-to-string-transformer input-channel="queueInput" output-channel="output">
<poller>
<interval-trigger interval="10000"/>
</poller>
</object-to-string-transformer>
</beans:beans>

View File

@@ -0,0 +1,95 @@
/*
* Copyright 2002-2008 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.config.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.StringMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class ObjectToStringTransformerParserTests {
@Autowired
@Qualifier("directInput")
private MessageChannel directInput;
@Autowired
@Qualifier("queueInput")
private MessageChannel queueInput;
@Autowired
@Qualifier("output")
private PollableChannel output;
@Test
public void directChannelWithStringMessage() {
directInput.send(new StringMessage("foo"));
Message<?> result = output.receive(0);
assertNotNull(result);
assertEquals("foo", result.getPayload());
}
@Test
public void queueChannelWithStringMessage() {
queueInput.send(new StringMessage("foo"));
Message<?> result = output.receive(3000);
assertNotNull(result);
assertEquals("foo", result.getPayload());
}
@Test
public void directChannelWithObjectMessage() {
directInput.send(new GenericMessage<TestBean>(new TestBean()));
Message<?> result = output.receive(0);
assertNotNull(result);
assertEquals("test", result.getPayload());
}
@Test
public void queueChannelWithObjectMessage() {
queueInput.send(new GenericMessage<TestBean>(new TestBean()));
Message<?> result = output.receive(3000);
assertNotNull(result);
assertEquals("test", result.getPayload());
}
private static class TestBean {
public String toString() {
return "test";
}
}
}