The client doesn't get the exception - that is turned in to an HTTP STATUS = 403 that is part of the response object you get back from the request. You need to check the http status value vs 403.
resteasy return 403 not handle in junit
Pergunta
This is in a reference of
Return HTTP error from RESTeasy interface
I am doing the same just for reference
@Path("/foo")
public class FooBar {
@GET
@Path("/bar")
@Produces("application/json")
public Object testMethod(@HeaderParam("var_1") @DefaultValue("") String var1,
@HeaderParam("var_2") @DefaultValue("") String var2 {
if (var1.equals(var2)) {
return "All Good";
} else {
throw new WebApplicationException(HttpURLConnection.HTTP_FORBIDDEN);
}
}
}
But when it throws the error I can not catch it in my junit test. It is not comming in any asserts below.
@Test
@RunAsClient
public void test403() {
try {
Object obj = fooBarService.testMethod("test2", "test");
Assert.assertFalse(true);
} catch(WebApplicationException ex) {
Assert.assertTrue(true);
}
}
How to check the 403 ?
Thank you
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow