Exemplo n.º 1
0
 @Test
 public void testFiltersAnnotated() throws ExecutionException, InterruptedException {
   final ResourceConfig resourceConfig =
       new ResourceConfig(
           MyServerFilter.class,
           MyClientFilter.class,
           MyServerWrongFilter.class,
           MyServerFilterWithoutConstraint.class,
           Resource.class);
   resourceConfig.registerInstances(new MyServerWrongFilter2(), new MyServerFilter2());
   ApplicationHandler handler = new ApplicationHandler(resourceConfig);
   final ContainerResponse response =
       handler.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
   Assert.assertEquals("called", response.getHeaderString("MyServerFilter"));
   Assert.assertEquals("called", response.getHeaderString("MyServerFilter2"));
   Assert.assertEquals("called", response.getHeaderString("MyServerFilterWithoutConstraint"));
 }
Exemplo n.º 2
0
 @Test
 public void testClientAndServerProvider() throws ExecutionException, InterruptedException {
   final ResourceConfig resourceConfig =
       new ResourceConfig(Resource.class, MyServerAndClientFilter.class);
   ApplicationHandler handler = new ApplicationHandler(resourceConfig);
   final ContainerResponse response =
       handler.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("called", response.getHeaderString("MyServerAndClientFilter"));
 }