With JAX-RS, do I need to test a JAXB element?
Can (should) the container verify the validity of the contents?
Can (should) the container automatically respond to BAD_REQUEST when disconnected Itembefore calling the REST method?
Can (May) respond to container requests INTERNAL_SERVER_ERROR when a client sends unmarshallable (or empty) content?
@XmlRootElement
class Item {
}
@PUT
@Path("/items/{item_id: \\d+}")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response updateItem(@PathParam("item_id") final Long itemId,
final Item item) {
assert itemId != null;
assert item != null;
}
One more question, what about byte[]?
@Consumes({MediaType.APPLICATION_OCTET_STREAM})
@PUT
@Path("/players/{player_id: \\d+}/picture");
public Response updatePicture(..., final byte[] bytes) {
assert bytes != null;
}
Oh, I think I found the answer.
http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-460004.2.4
MessageBodyReader , JAXB, Java, ; null. JAXB MessageBodyReader WebApplicationException (HTTP 400) .