问题描述
部署后,我的REST API可以正常工作,但是使用Jersey Arquillian扩展程序,我的测试失败:
notebook
我得到了错误:
@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);
}
我的JAX-RS程序看起来不错:
Error HTTP method POST is not supported by this URL
解决方法
@ArquillianResteasyResource
的默认值为rest
,但是我的JaxRsActivator设置为api
。
我使用以下方法解决该问题:
@ArquillianResteasyResource("api")
要获取完整的URI:webTarget.getUri()