Hi,

I'd like to be able to write some tests using JUnit to rest server resource 
classes. I'm encountering a problem when I try to pass a JacksonRepresentation 
in. My test class looks something a little like this:

{
        TransactionResource resource = new MyResource();
        MyData data = new MyData(etc);

        Representation entity = new JacksonRepresentation<MyData>(myData);

        entity.setMediaType(MediaType.APPLICATION_JSON);
        
        Representation response = resource.post(entity);
}

This is all fine as far as I know. But I receive an error in my ServerResource 
derived class when I try and deserialize the object using Jackson:

            MyData myData = new JacksonRepresentation<>(entity, MyData.class)
                    .getObject();

com.fasterxml.jackson.databind.JsonMappingException: No content to map due to 
end-of-input
 at [Source: UNKNOWN; line: 1, column: 1]
        at 
com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164)
        at 
com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:1298)
        at 
com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1199)
        at 
com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:798)
        at 
org.restlet.ext.jackson.JacksonRepresentation.getObject(JacksonRepresentation.java:309)

Is this the correct approach? Am I doing something wrong in my test case in 
setting up the call to my resource class?

Thanks

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3086450

Reply via email to