DubboSwaggerApiListingResource extends BaseApiListingResource implements DubboSwaggerService { @Override public Response getListingJson(Application app, ServletConfig sc, HttpHeaders headers, UriInfo uriInfo) throws JsonProcessingException { Response response = getListingJsonResponse(app, context, sc, headers, uriInfo); response.getHeaders().add("Access-Control-Allow-Origin", "*"); response.getHeaders().add("Access-Control-Allow-Headers", "x-requested-with, ssi-token"); response.getHeaders().add("Access-Control-Max-Age", "3600"); response.getHeaders().add("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,OPTIONS"); return response; }  @Override Response getListingJson(Application app, ServletConfig sc,
                                   HttpHeaders headers, UriInfo uriInfo);  }
@Test public void test() throws Exception { DubboSwaggerApiListingResource resource = new DubboSwaggerApiListingResource(); app = mock(Application.class); sc = mock(ServletConfig.class); Set<Class<?>> sets = new HashSet<Class<?>>(); sets.add(SwaggerService.class); when(sc.getServletContext()).thenReturn(mock(ServletContext.class)); when(app.getClasses()).thenReturn(sets); Response response = resource.getListingJson(app, sc, null, new ResteasyUriInfo(new URI("http: Assertions.assertNotNull(response); Swagger swagger = (Swagger)response.getEntity(); Assertions.assertEquals("SwaggerService",swagger.getTags().get(0).getName()); Assertions.assertEquals("/demoService/hello",swagger.getPaths().keySet().toArray()[0].toString()); }