use of com.sun.jersey.api.client.filter.LoggingFilter in project hadoop by apache.
the class TestNMWebServicesContainers method testNodeHelper.
public void testNodeHelper(String path, String media) throws JSONException, Exception {
WebResource r = resource();
Application app = new MockApp(1);
nmContext.getApplications().put(app.getAppId(), app);
addAppContainers(app);
Application app2 = new MockApp(2);
nmContext.getApplications().put(app2.getAppId(), app2);
addAppContainers(app2);
client().addFilter(new LoggingFilter());
ClientResponse response = r.path("ws").path("v1").path("node").path(path).accept(media).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
JSONObject info = json.getJSONObject("containers");
assertEquals("incorrect number of elements", 1, info.length());
JSONArray conInfo = info.getJSONArray("container");
assertEquals("incorrect number of elements", 4, conInfo.length());
for (int i = 0; i < conInfo.length(); i++) {
verifyNodeContainerInfo(conInfo.getJSONObject(i), nmContext.getContainers().get(ContainerId.fromString(conInfo.getJSONObject(i).getString("id"))));
}
}
use of com.sun.jersey.api.client.filter.LoggingFilter in project gfm_viewer by satyagraha.
the class WebServiceClientDefault method transform.
@Override
public String transform(String mdText) {
if (StringUtils.isBlank(config.getApiUrl())) {
String responseText = String.format("<pre>\n%s\n</pre>", StringEscapeUtils.escapeHtml4(mdText));
return responseText;
}
Client client = getClient(config.getApiUrl());
LOGGER.fine("client: " + client);
String username = config.getUsername();
if (username != null && username.length() > 0) {
String password = config.getPassword();
client.removeFilter(null);
client.addFilter(new HTTPBasicAuthFilter(username, password));
}
client.addFilter(new LoggingFilter(LOGGER));
WebResource webResource = client.resource(config.getApiUrl());
Markdown markdown = new Markdown(mdText);
ClientResponse response = webResource.path("markdown").type(MediaType.APPLICATION_JSON).entity(markdown).accept(MediaType.TEXT_HTML).post(ClientResponse.class);
String responseText = response.getEntity(String.class);
return responseText;
}
Aggregations