I have following Problem. My tests are running allways positive even when the HttpHeaders.AUTHORIZATION headder has a wrong token. In theory it should fail because I have a filter that checks the token. My Jax-RS program is working perfectly in the browser or using a httpclient like postman. So I have to generate a token first and then use that token to run the HTTP commands otherwise it will return the statuscode 401. I think that my configuration is wrong and the Testframework is running the tests without triggering the filter. I never worked with Jax-RS before and I have no Idea how to fix that...
public class GamesTest extends JerseyTest{
@Override
protected Application configure() {
return new ResourceConfig(Games.class).register(new AbstractBinder() {
protected void configure() {
bind(GamesXMLDB.class).to(MyGameDBInterfaceDB.class).in(Singleton.class);
bind(UserXMLDB.class).to(MyUserInterfaceDB.class).in(Singleton.class);
}
});
}
@Test
public void getWithoutTokenTest() {
Response response = target("/games").request().header(HttpHeaders.AUTHORIZATION, "").get();
assertEquals(200, response.getStatus());
}
}