@Test
public void testCreateReservation() {

  ResourceManager rm = setupResourceManager();
  ClientRMService clientService = rm.getClientRMService();
  Clock clock = new UTCClock();
  long arrival = clock.getTime();
  long duration = 60000;
  long deadline = (long) (arrival + 1.05 * duration);
  ReservationSubmissionRequest sRequest =
      submitReservationTestHelper(clientService, arrival, deadline, duration);
  // Submit the reservation again with the same request and make sure it
  // passes.
  try {
    clientService.submitReservation(sRequest);
  } catch (Exception e) {
    Assert.fail(e.getMessage());
  }
  // Submit the reservation with the same reservation id but different
  // reservation definition, and ensure YarnException is thrown.
  arrival = clock.getTime();
  ReservationDefinition rDef = sRequest.getReservationDefinition();
  rDef.setArrival(arrival + duration);
  sRequest.setReservationDefinition(rDef);
  try {
    clientService.submitReservation(sRequest);
    Assert.fail("Reservation submission should fail if a duplicate "
        + "reservation id is used, but the reservation definition has been "
        + "updated.");
  } catch (Exception e) {
    Assert.assertTrue(e instanceof YarnException);
  }
  rm.stop();
}