You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Minh Tran <da...@gmail.com> on 2015/11/24 07:14:00 UTC

mocking Type Converters

Hi

I was wondering if it was possible to mock sections of my route in unit tests that are using a type converter. e.g.

convertBodyTo(PO.class)

My converter class looks something like

public class PurchaseOrderConverter implements TypeConverters {
   @Converter
   public PO convert(XYZ xyz) {
    …..
   } 
}

From my understanding, these type converters aren’t spring beans so I can't inject mocked beans. And I don’t believe @MockEndpoints will mock these things either. Any ideas? I’m using Camel 2.16.1. Thanks.

Re: mocking Type Converters

Posted by Minh Tran <da...@gmail.com>.
Thanks for the tip Claus!

> On 24 Nov 2015, at 5:19 PM, Claus Ibsen <cl...@gmail.com> wrote:
> 
> You can just add a new type converter to the type converter registry
> to override any existing.
> 
> See more at
> http://camel.apache.org/type-converter.html
> 
> On Tue, Nov 24, 2015 at 7:14 AM, Minh Tran <da...@gmail.com> wrote:
>> Hi
>> 
>> I was wondering if it was possible to mock sections of my route in unit tests that are using a type converter. e.g.
>> 
>> convertBodyTo(PO.class)
>> 
>> My converter class looks something like
>> 
>> public class PurchaseOrderConverter implements TypeConverters {
>>   @Converter
>>   public PO convert(XYZ xyz) {
>>    …..
>>   }
>> }
>> 
>> From my understanding, these type converters aren’t spring beans so I can't inject mocked beans. And I don’t believe @MockEndpoints will mock these things either. Any ideas? I’m using Camel 2.16.1. Thanks.
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2


Re: mocking Type Converters

Posted by Claus Ibsen <cl...@gmail.com>.
You can just add a new type converter to the type converter registry
to override any existing.

See more at
http://camel.apache.org/type-converter.html

On Tue, Nov 24, 2015 at 7:14 AM, Minh Tran <da...@gmail.com> wrote:
> Hi
>
> I was wondering if it was possible to mock sections of my route in unit tests that are using a type converter. e.g.
>
> convertBodyTo(PO.class)
>
> My converter class looks something like
>
> public class PurchaseOrderConverter implements TypeConverters {
>    @Converter
>    public PO convert(XYZ xyz) {
>     …..
>    }
> }
>
> From my understanding, these type converters aren’t spring beans so I can't inject mocked beans. And I don’t believe @MockEndpoints will mock these things either. Any ideas? I’m using Camel 2.16.1. Thanks.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2