use of com.sun.jersey.api.json.JSONJAXBContext in project hadoop by apache.
the class TestRMWebServicesReservation method testDeleteReservationHelper.
private void testDeleteReservationHelper(String path, ReservationId reservationId, String media) throws JSONException, Exception {
String reservationJson = loadJsonFile("delete-reservation.json");
JSONJAXBContext jc = new JSONJAXBContext(JSONConfiguration.mapped().build(), ReservationDeleteRequestInfo.class);
JSONUnmarshaller unmarshaller = jc.createJSONUnmarshaller();
ReservationDeleteRequestInfo rsci = unmarshaller.unmarshalFromJSON(new StringReader(reservationJson), ReservationDeleteRequestInfo.class);
if (this.isAuthenticationEnabled()) {
// only works when previous submit worked
if (rsci.getReservationId() == null) {
throw new IOException("Incorrectly parsed the reservatinId");
}
rsci.setReservationId(reservationId.toString());
}
Thread.sleep(1000);
ClientResponse response = constructWebResource(path).entity(rsci, MediaType.APPLICATION_JSON).accept(media).post(ClientResponse.class);
if (!this.isAuthenticationEnabled()) {
assertResponseStatusCode(Status.UNAUTHORIZED, response.getStatusInfo());
return;
}
System.out.println("RESPONSE:" + response);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
assertResponseStatusCode(Status.OK, response.getStatusInfo());
}
use of com.sun.jersey.api.json.JSONJAXBContext in project hadoop by apache.
the class TestRMWebServicesReservation method submitAndVerifyReservation.
private ClientResponse submitAndVerifyReservation(String path, String media, String reservationJson) throws Exception {
JSONJAXBContext jc = new JSONJAXBContext(JSONConfiguration.mapped().build(), ReservationSubmissionRequestInfo.class);
JSONUnmarshaller unmarshaller = jc.createJSONUnmarshaller();
ReservationSubmissionRequestInfo rsci = unmarshaller.unmarshalFromJSON(new StringReader(reservationJson), ReservationSubmissionRequestInfo.class);
Thread.sleep(1000);
ClientResponse response = constructWebResource(path).entity(rsci, MediaType.APPLICATION_JSON).accept(media).post(ClientResponse.class);
if (!this.isAuthenticationEnabled()) {
assertResponseStatusCode(Status.UNAUTHORIZED, response.getStatusInfo());
}
return response;
}
use of com.sun.jersey.api.json.JSONJAXBContext in project hadoop by apache.
the class TestRMWebServicesAppsModification method appStateToJSON.
private static String appStateToJSON(AppState state) throws Exception {
StringWriter sw = new StringWriter();
JSONJAXBContext ctx = new JSONJAXBContext(AppState.class);
JSONMarshaller jm = ctx.createJSONMarshaller();
jm.marshallToJSON(state, sw);
return sw.toString();
}
Aggregations