Author: ningjiang
Date: Mon Jul 7 00:13:40 2008
New Revision: 674408
URL: http://svn.apache.org/viewvc?rev=674408&view=rev
Log:
Polished the CamelSourceApdaterTest
Modified:
activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapterTest.java
activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/ConfigurationTest.java
activemq/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml
Modified:
activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapterTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapterTest.java?rev=674408&r1=674407&r2=674408&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapterTest.java
(original)
+++
activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/CamelSourceAdapterTest.java
Mon Jul 7 00:13:40 2008
@@ -19,17 +19,20 @@
import org.apache.camel.component.spring.integration.HelloWorldService;
import org.apache.camel.spring.SpringTestSupport;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.integration.channel.MessageChannel;
+import org.springframework.integration.message.Message;
public class CamelSourceAdapterTest extends SpringTestSupport {
public void testSendingOneWayMessage() throws Exception {
- HelloWorldService service = (HelloWorldService)
applicationContext.getBean("helloService");
- template.sendBody("direct:EndpointA", "Willem");
- assertEquals("The service should be called ", service.getCount(), 1);
+ MessageChannel channelA = (MessageChannel)
applicationContext.getBean("channelA");
+ template.sendBody("direct:OneWay", "Willem");
+ Message message = channelA.receive();
+ assertEquals("We should get the message from channelA",
message.getPayload(), "Willem");
}
public void testSendingTwoWayMessage() throws Exception {
- String result = (String) template.sendBody("direct:EndpointA",
"Willem");
+ String result = (String) template.sendBody("direct:TwoWay", "Willem");
assertEquals("Can't get the right response", result, "Hello Willem");
}
Modified:
activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/ConfigurationTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/ConfigurationTest.java?rev=674408&r1=674407&r2=674408&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/ConfigurationTest.java
(original)
+++
activemq/camel/trunk/components/camel-spring-integration/src/test/java/org/apache/camel/component/spring/integration/adapter/ConfigurationTest.java
Mon Jul 7 00:13:40 2008
@@ -17,33 +17,39 @@
package org.apache.camel.component.spring.integration.adapter;
import junit.framework.TestCase;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.endpoint.HandlerEndpoint;
public class ConfigurationTest extends TestCase {
+ private AbstractXmlApplicationContext context;
+
public void testCamelSourceEndpoint() throws Exception {
- ClassPathXmlApplicationContext ctx =
+ context =
new ClassPathXmlApplicationContext(new String[]
{"/org/apache/camel/component/spring/integration/adapter/CamelSource.xml"});
- CamelSourceAdapter camelSourceA = (CamelSourceAdapter)
ctx.getBean("camelSourceA");
+ CamelSourceAdapter camelSourceA = (CamelSourceAdapter)
context.getBean("camelSourceA");
assertNotNull(camelSourceA);
assertEquals("Get the wrong request channel name",
camelSourceA.getChannel().getName(), "channelA");
assertEquals("ExpectReply should be false ",
camelSourceA.isExpectReply(), false);
- CamelSourceAdapter camelSourceB = (CamelSourceAdapter)
ctx.getBean("camelSourceB");
+ CamelSourceAdapter camelSourceB = (CamelSourceAdapter)
context.getBean("camelSourceB");
assertNotNull(camelSourceB);
assertEquals("Get the wrong request channel name",
camelSourceB.getChannel().getName(), "channelB");
assertEquals("ExpectReply should be true ",
camelSourceB.isExpectReply(), true);
+ context.destroy();
}
public void testCamelTragetEndpoint() throws Exception {
- ClassPathXmlApplicationContext ctx =
+ context =
new ClassPathXmlApplicationContext(new String[]
{"/org/apache/camel/component/spring/integration/adapter/CamelTarget.xml"});
- HandlerEndpoint handlerEndpointA =
(HandlerEndpoint)ctx.getBean("camelTargetA");
+ HandlerEndpoint handlerEndpointA =
(HandlerEndpoint)context.getBean("camelTargetA");
assertNotNull(handlerEndpointA);
assertEquals("Subscript the wrong channel name",
handlerEndpointA.getSubscription().getChannelName(), "channelA");
- HandlerEndpoint handlerEndpointB =
(HandlerEndpoint)ctx.getBean("camelTargetA");
+ HandlerEndpoint handlerEndpointB =
(HandlerEndpoint)context.getBean("camelTargetA");
assertNotNull(handlerEndpointB);
assertEquals("Subscript the wrong channel name",
handlerEndpointB.getSubscription().getChannelName(), "channelA");
+ context.destroy();
}
}
Modified:
activemq/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml?rev=674408&r1=674407&r2=674408&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml
(original)
+++
activemq/camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml
Mon Jul 7 00:13:40 2008
@@ -47,11 +47,11 @@
<!-- START SNIPPET: example -->
<camelContext id="camelSourceContext"
xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
- <from uri="direct:EndpointA"/>
+ <from uri="direct:OneWay"/>
<to uri="direct:EndpointB" />
</route>
<route>
- <from uri="direct:EndpointA"/>
+ <from uri="direct:TwoWay"/>
<to uri="direct:EndpointC" />
</route>
</camelContext>