您好我有以下资源类
@Path("/api")
@Api("My API")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class MyResource {
public MyResource() {
// assign some values in teh constructor
}
@POST
@Timed
@UnitOfWork
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "",
response = Response.class)
@ApiResponses(
value = {@ApiResponse(code = 405, message = "Method not allowed"), @ApiResponse(code = 400,
message = "some custom mesage")})
public Response createMyObject(MyObject o, @Context UriInfo uriInfo)
throws JsonProcessingException {
}
我正在尝试使用此
对其进行单元测试@Test
public void testCreate() throws JsonProcessingException {
Entity<?> entity = Entity.entity(myObjInstance, MediaType.APPLICATION_JSON_TYPE);
final Response response = resources.target("/api").request().post(entity);
}
这给了我一个404,我已经验证资源是否正确注册。此资源中的GET方法也按预期工作。我做错了什么?