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