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:53:58 UTC
svn commit: r1237149 - in /camel/branches/camel-2.8.x/components/camel-jaxb:
./
src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java
Author: bvahdat
Date: Sat Jan 28 19:53:57 2012
New Revision: 1237149
URL: http://svn.apache.org/viewvc?rev=1237149&view=rev
Log:
Polished test.
Modified:
camel/branches/camel-2.8.x/components/camel-jaxb/ (props changed)
camel/branches/camel-2.8.x/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java
Propchange: camel/branches/camel-2.8.x/components/camel-jaxb/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jan 28 19:53:57 2012
@@ -1,2 +1,2 @@
/camel/branches/camel-2.9.x/components/camel-jaxb:1227549,1228229,1229567,1234054,1236672
-/camel/trunk/components/camel-jaxb:1226860,1227540,1228223,1229565,1234043,1236403-1236663,1236667
+/camel/trunk/components/camel-jaxb:1226860,1227540,1228223,1229565,1234043,1236403-1236663,1236667,1237148
Modified: camel/branches/camel-2.8.x/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java?rev=1237149&r1=1237148&r2=1237149&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterShouldNotThrowExceptionTest.java Sat Jan 28 19:53:57 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