Hi,
I made a webapp using Jersey. After that, I wrote unit tests for it. The
test data is in json format and parsed by jackson json. The object will be
input to the business layer class for test. Every time I run it, error
occurred.
Later, I created a simple project with only an entity class and a unit test
class. When I just included the jackson json dependency in maven, everything
run smoothly. However, when I added jersey dependency, the same error
occurred.
Originally, I would like to use the jersey built-in json support for my unit
test. Since my test is not at service layer, I cannot get the Providers
instance, hence I cannot get the MessageBodyReader instance.
Thanks.
Franz
the error :
java.lang.VerifyError: (class: org/codehaus/jackson/map/ObjectMapper,
method: writeValueAsBytes signature: (Ljava/lang/Object;)[B) Incompatible
argument to function
my test :
ObjectMapper objMapper = new ObjectMapper();
User user = (User) objMapper.readValue("{\"name\" : \"franzwong\",
\"itemList\" : [\"apple\", \"orange\"]}", User.class);
Assert.assertEquals("franzwong", user.getName());