我的rest api在部署时工作正常,但我的测试在使用jersey arquillian扩展时失败:
@Test
@RunAsClient
public void postTest(@ArquillianResteasyResource final WebTarget webTarget) {
MyRequest request = new MyRequest();
String response = webTarget.path("/demo").request(MediaType.APPLICATION_JSON)
.post(Entity.json(request)).readEntity(String.class);
Assert.assertEquals("OK", response);
}
我得到一个错误:
Error HTTP method POST is not supported by this URL
我的jax-rs程序看起来不错:
@ApplicationPath("api")
public class JaxRsActivator extends Application {
}
@Path("/demo")
@Stateless
public class DemoResource extends BaseResource {
@POST
public Response demo(MyRequest request) {
return Response.ok().entity("OK").build();
}
}
1条答案
按热度按时间m4pnthwp1#
的默认值
@ArquillianResteasyResource
是rest
,但我的jaxrsactivator设置为api
.为了解决这个问题,我使用了:
要获取完整的uri:
webTarget.getUri()