You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2012/01/28 20:45:22 UTC
svn commit: r1237148 -
/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java
Author: bvahdat
Date: Sat Jan 28 19:45:21 2012
New Revision: 1237148
URL: http://svn.apache.org/viewvc?rev=1237148&view=rev
Log:
Polished test.
Modified:
camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java
Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java?rev=1237148&r1=1237147&r2=1237148&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java (original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java Sat Jan 28 19:45:21 2012
@@ -31,30 +31,33 @@ public class FallbackTypeConverterShould
@Test
public void testJaxbModel() throws InterruptedException {
- getMockEndpoint("mock:a").expectedMessageCount(1);
- getMockEndpoint("mock:b").expectedMessageCount(1);
+ Object foo = new Foo();
+ getMockEndpoint("mock:a").expectedBodiesReceived(foo);
+ getMockEndpoint("mock:b").expectedBodiesReceived(foo);
- template.sendBody("direct:a", new Foo());
+ template.sendBody("direct:a", foo);
assertMockEndpointsSatisfied();
}
@Test
public void testNoneJaxbModel() throws InterruptedException {
- getMockEndpoint("mock:a").expectedMessageCount(1);
- getMockEndpoint("mock:b").expectedMessageCount(1);
+ Object camel = "Camel";
+ getMockEndpoint("mock:a").expectedBodiesReceived(camel);
+ getMockEndpoint("mock:b").expectedBodiesReceived(camel);
- template.sendBody("direct:a", "Camel");
+ template.sendBody("direct:a", camel);
assertMockEndpointsSatisfied();
}
@Test
public void testAnotherJaxbModel() throws InterruptedException {
- getMockEndpoint("mock:a").expectedMessageCount(1);
- getMockEndpoint("mock:b").expectedMessageCount(1);
+ Object bar = new Bar();
+ getMockEndpoint("mock:a").expectedBodiesReceived(bar);
+ getMockEndpoint("mock:b").expectedBodiesReceived(bar);
- template.sendBody("direct:a", new Bar());
+ template.sendBody("direct:a", bar);
assertMockEndpointsSatisfied();
}
@@ -62,18 +65,33 @@ public class FallbackTypeConverterShould
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder(context) {
+
@Override
public void configure() throws Exception {
from("direct:a").process(new Processor() {
+
+ @Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().getBody(Foo.class);
+ // should return null and not throw any exception if the conversion fails
+ Foo foo = exchange.getIn().getBody(Foo.class);
+ if (!(exchange.getIn().getBody() instanceof Foo)) {
+ assertNull("Failed conversion didn't return null", foo);
+ }
}
+
}).to("mock:a").process(new Processor() {
+
+ @Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().getBody(List.class);
+ // should return null and not throw any exception if the conversion fails
+ List<?> list = exchange.getIn().getBody(List.class);
+ assertNull("Failed conversion didn't return null", list);
}
+
}).to("mock:b");
}
+
};
}
+
}
\ No newline at end of file