Aaaand problem is solved.
I have quite often monolog here leading to fixing the problem :D
This dependency fixed it:

<dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jackson</artifactId>
            <version>${camel.version}</version>
            <scope>test</scope>
        </dependency>

Where camel.version is 2.11.0 for my case and thanks to the test scope the
correct artifact version is used for testing :)


On Tue, Sep 10, 2013 at 1:15 PM, Martin Stiborský <
martin.stibor...@gmail.com> wrote:

> I see that JacksonDataFormat for Camel 2.11.x is using already the newer
> Jackson:
>
> https://github.com/apache/camel/blob/camel-2.11.x/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
>
> So the problem I have is most probably wrong camel-jackson artifact used
> while running the unit tests (my guess :))
>
>
> On Tue, Sep 10, 2013 at 12:42 PM, Martin Stiborský <
> martin.stibor...@gmail.com> wrote:
>
>> Hello guys,
>> I have this problem, it was first quite strange, why it's happening, but
>> then I saw the obvious problem...
>> It's about POJO classes and (de)serializing to/from JSON.
>>
>> I have a simple route, where jaxrs takes a JSON request body from POST
>> http request.
>> Then the JSON string is deserialized into corresponding class, with
>> "unmarshall" and Jackson library.
>>
>> .unmarshal().json(JsonLibrary.Jackson, MyPojo.class)
>>
>> This works without problems on production. But, I have a problem to write
>> unittests for this route.
>> Because the JSON string is not deserialized:
>>
>> org.codehaus.jackson.map.JsonMappingException: No suitable constructor
>> found for type...
>>
>> I know this error, and it was strange to me because there is public
>> constructor with @JsonProperty annotations for each pojo property.
>> Plus, it works on production and tests for the POJO itself passed as well.
>>
>> The problem is in jackson version. For the unit tests, there have to be
>> some older version of Jackson used, you can see there is the old package
>> name - org.codehaus.jackson...
>>
>> I'm using newer version of Jackson in the project - 2.1.2, they changed
>> package name to "com.fasterxml...".
>>
>> My biggest question is now - how is the Jackson version resolved in
>> CamelContext?
>> I'm trying to digg the corresponding DataFormat object, to find out, but
>> if you can give me good hint, that would be nice.
>>
>> The version of Apache Camel is 2.11.0 and the unittest - nothing special,
>> CamelTestSupport is inherited.
>> I guess, I have to somehow pass the DataFormat object with Jackson to the
>> testing CamelContext?
>> I know there is the "createJndiContext" method, I'm using it to pass
>> mocked dependencies for the routes in test...is this the way?
>>
>> Thanks!
>>
>> --
>> S pozdravem / Best regards
>> Martin Stiborský
>>
>> Jabber: st...@njs.netlab.cz
>>  Twitter: http://www.twitter.com/stibi
>>
>
>
>
> --
> S pozdravem / Best regards
> Martin Stiborský
>
> Jabber: st...@njs.netlab.cz
> Twitter: http://www.twitter.com/stibi
>



-- 
S pozdravem / Best regards
Martin Stiborský

Jabber: st...@njs.netlab.cz
Twitter: http://www.twitter.com/stibi

Reply via email to