Search in sources :

Example 1 with ReservationUpdateRequestInfo

use of org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationUpdateRequestInfo in project hadoop by apache.

the class TestRMWebServicesReservation method updateReservationTestHelper.

private void updateReservationTestHelper(String path, ReservationId reservationId, String media) throws JSONException, Exception {
    String reservationJson = loadJsonFile("update-reservation.json");
    JSONJAXBContext jc = new JSONJAXBContext(JSONConfiguration.mapped().build(), ReservationUpdateRequestInfo.class);
    JSONUnmarshaller unmarshaller = jc.createJSONUnmarshaller();
    ReservationUpdateRequestInfo rsci = unmarshaller.unmarshalFromJSON(new StringReader(reservationJson), ReservationUpdateRequestInfo.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());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) StringReader(java.io.StringReader) IOException(java.io.IOException) ReservationUpdateRequestInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationUpdateRequestInfo) JSONUnmarshaller(com.sun.jersey.api.json.JSONUnmarshaller) JSONJAXBContext(com.sun.jersey.api.json.JSONJAXBContext)

Aggregations

ClientResponse (com.sun.jersey.api.client.ClientResponse)1 JSONJAXBContext (com.sun.jersey.api.json.JSONJAXBContext)1 JSONUnmarshaller (com.sun.jersey.api.json.JSONUnmarshaller)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ReservationUpdateRequestInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationUpdateRequestInfo)1