use of org.apache.cxf.jaxrs.client.WebClient in project cxf by apache.
the class SwaggerToOpenApiConversionTest method doTestSwagger2JSON.
private void doTestSwagger2JSON() throws Exception {
final WebClient client = createWebClient("/swagger.json");
AbstractSwagger2ServiceDescriptionTest.doTestApiListingIsProperlyReturnedJSON(client, false);
}
use of org.apache.cxf.jaxrs.client.WebClient in project cxf by apache.
the class SwaggerToOpenApiConversionTest method testOpenApiJSON.
@Test
public void testOpenApiJSON() throws Exception {
final WebClient client = createWebClient("/openapi.json");
String openApiResponse = client.get(String.class);
JsonMapObject openApiJson = new JsonMapObjectReaderWriter().fromJsonToJsonObject(openApiResponse);
assertEquals(6, openApiJson.size());
// version
assertEquals("3.0.0", openApiJson.getProperty("openapi"));
// servers
List<Map<String, Object>> servers = openApiJson.getListMapProperty("servers");
assertEquals(1, servers.size());
assertEquals(1, servers.get(0).size());
assertEquals("http://localhost:" + PORT, servers.get(0).get("url"));
// info
JsonMapObject info = openApiJson.getJsonMapProperty("info");
assertEquals(4, info.size());
assertEquals(DESCRIPTION, info.getProperty("description"));
assertEquals(TITLE, info.getProperty("title"));
JsonMapObject contact = info.getJsonMapProperty("contact");
assertEquals(1, contact.size());
assertEquals(CONTACT, contact.getProperty("name"));
JsonMapObject license = info.getJsonMapProperty("license");
assertEquals(2, license.size());
assertEquals(LICENSE, license.getProperty("name"));
assertEquals(LICENSE_URL, license.getProperty("url"));
// tags
List<Map<String, Object>> tags = openApiJson.getListMapProperty("tags");
assertEquals(1, tags.size());
assertEquals(1, tags.get(0).size());
assertEquals("bookstore", tags.get(0).get("name"));
// paths
JsonMapObject paths = openApiJson.getJsonMapProperty("paths");
assertEquals(2, paths.size());
// 1: bookstore
JsonMapObject bookstore = paths.getJsonMapProperty("/bookstore");
assertEquals(1, bookstore.size());
// get
verifyBookStoreGet(bookstore);
// 2: bookstore/{id}
JsonMapObject bookstoreId = paths.getJsonMapProperty("/bookstore/{id}");
assertEquals(2, bookstoreId.size());
// get
verifyBookStoreIdGet(bookstoreId);
// delete
verifyBookStoreIdDelete(bookstoreId);
// components
JsonMapObject comps = openApiJson.getJsonMapProperty("components");
assertEquals(3, comps.size());
JsonMapObject requestBodies = comps.getJsonMapProperty("requestBodies");
assertEquals(0, requestBodies.size());
JsonMapObject schemas = comps.getJsonMapProperty("schemas");
assertEquals(1, schemas.size());
JsonMapObject secSchemes = comps.getJsonMapProperty("securitySchemes");
assertEquals(1, secSchemes.size());
// Finally check swagger.json can still be generated.
doTestSwagger2JSON();
}
use of org.apache.cxf.jaxrs.client.WebClient in project cxf by apache.
the class AbstractOpenApiServiceDescriptionTest method testUiResource.
@Test
public void testUiResource() {
// Test that Swagger UI resources do not interfere with
// application-specific ones and are accessible.
WebClient uiClient = WebClient.create(getBaseUrl() + "/swagger-ui.css").accept("text/css");
String css = uiClient.get(String.class);
assertThat(css, containsString(".swagger-ui{"));
}
use of org.apache.cxf.jaxrs.client.WebClient in project cxf by apache.
the class AbstractOpenApiServiceDescriptionTest method checkUiResource.
protected void checkUiResource() {
WebClient uiClient = WebClient.create(getBaseUrl() + "/api-docs").accept(MediaType.WILDCARD);
String uiHtml = uiClient.get(String.class);
assertTrue(uiHtml.contains("<title>Swagger UI</title>"));
}
use of org.apache.cxf.jaxrs.client.WebClient in project cxf by apache.
the class JAXRSClientServerTikaTest method createWebClient.
private WebClient createWebClient(final String url) {
WebClient wc = WebClient.create("http://localhost:" + PORT + url, Arrays.asList(new MultipartProvider(), new JacksonJsonProvider()));
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
return wc;
}
Aggregations