You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Brendan Long <br...@realgo.com> on 2011/07/05 21:43:04 UTC
Problem with type converters in unit tests
I'm trying to do some unit tests on my type converters in what seems
like an obvious way:
public class MyObjectTest extends CamelTestSupport {
public void testCamelSerialize() {
Exchange exchange = new DefaultExchange(this.context);
MyObject object = new MyObject();
exchange.setIn(object.toMessage());
assertEquals(object, exchange.getIn(MyObject.class);
}
}
If I do this, it doesn't call my type converter method at all:
@Converter
public static MyObject fromMessage(Message message) {
System.out.println("This message never shows up");
// more stuff
}
Am I missing something about how this is supposed to work?
Re: Problem with type converters in unit tests
Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi Brendan,
Since you are using Eclipse, I would encourage you to use m2Eclipse & Maven.
It will add a Maven Dependencies section to your project and you not need to
worry about classpath issues.
It is much nicer and Maven will automatically include src/main/resources and
src/main/java to the classpath.
Cheers,
Ashwin...
-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com
Blog: http://opensourceknowledge.blogspot.com
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-type-converters-in-unit-tests-tp4554461p4554646.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Problem with type converters in unit tests
Posted by Brendan Long <br...@realgo.com>.
I figured this out right after posting. I needed to add
src/main/resources as a source folder in Eclipse (so it would pick up
META-INF/services/org/apache/camel/TypeConverter).
On 2011-07-05 1:43 PM, Brendan Long wrote:
> I'm trying to do some unit tests on my type converters in what seems
> like an obvious way:
>
> public class MyObjectTest extends CamelTestSupport {
> public void testCamelSerialize() {
> Exchange exchange = new DefaultExchange(this.context);
> MyObject object = new MyObject();
> exchange.setIn(object.toMessage());
> assertEquals(object, exchange.getIn(MyObject.class);
> }
> }
>
> If I do this, it doesn't call my type converter method at all:
>
> @Converter
> public static MyObject fromMessage(Message message) {
> System.out.println("This message never shows up");
> // more stuff
> }
>
> Am I missing something about how this is supposed to work?