@Test public void getDescriptionInJson() throws Throwable { host.testStart(1); Operation op = Operation.createGet(UriUtils.buildUri(host, SwaggerDescriptorService.SELF_LINK)) .setReferer(host.getUri()) .setCompletion(host.getSafeHandler(this::assertDescriptorJson)); host.sendRequest(op); host.testWait(); }
@Test public void getDescriptionInYaml() throws Throwable { host.testStart(1); Operation op = Operation.createGet(UriUtils.buildUri(host, SwaggerDescriptorService.SELF_LINK)) .addRequestHeader(Operation.ACCEPT_HEADER, "text/x-yaml") .setReferer(host.getUri()) .setCompletion(host.getSafeHandler(this::assertDescriptorYaml)); host.sendRequest(op); host.testWait(); }
@Test public void testSwaggerUiAvailable() throws Throwable { host.testStart(1); URI uri = UriUtils.buildUri( host, SwaggerDescriptorService.SELF_LINK + ServiceUriPaths.UI_PATH_SUFFIX); Operation op = Operation.createGet(new URI(uri.toString() + "/")) .setReferer(host.getUri()) .setCompletion(host.getSafeHandler(this::assertSwaggerUiAvailable)); host.sendRequest(op); host.testWait(); }
@BeforeClass public static void setup() throws Throwable { host = VerificationHost.create(0); SwaggerDescriptorService swagger = new SwaggerDescriptorService(); Info info = new Info(); info.setDescription(INFO_DESCRIPTION); info.setTermsOfService(INFO_TERMS_OF_SERVICE); info.setTitle("title"); info.setVersion("version"); swagger.setInfo(info); swagger.setExcludedPrefixes("/core/authz/"); host.start(); host.startService(swagger); host.startService( Operation.createPost(UriUtils.buildFactoryUri(host, ExampleService.class)), ExampleService.createFactory()); host.startService( Operation.createPost(UriUtils.buildFactoryUri(host, CarService.class)), CarService.createFactory()); host.startService( Operation.createPost(UriUtils.buildUri(host, UiService.class)), new UiService()); host.startService( Operation.createPost(UriUtils.buildFactoryUri(host, ExampleService.class)), new ExampleService()); host.startService( Operation.createPost(UriUtils.buildUri(host, TokenService.class)), new TokenService()); host.waitForServiceAvailable(SwaggerDescriptorService.SELF_LINK); }
@AfterClass public static void destroy() { host.stop(); }