@Test
public void testListReservationsByTimeInterval() {

  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);
  // List reservations, search by a point in time within the reservation
  // range.
  arrival = clock.getTime();
  ReservationId reservationID = sRequest.getReservationId();
  ReservationListRequest request = ReservationListRequest.newInstance(
      ReservationSystemTestUtil.reservationQ, "", arrival + duration / 2,
      arrival + duration / 2, true);
  ReservationListResponse response = null;
  try {
    response = clientService.listReservations(request);
  } catch (Exception e) {
    Assert.fail(e.getMessage());
  }
  Assert.assertNotNull(response);
  Assert.assertEquals(1, response.getReservationAllocationState().size());
  Assert.assertEquals(response.getReservationAllocationState().get(0)
      .getReservationId().getId(), reservationID.getId());
  // List reservations, search by time within reservation interval.
  request = ReservationListRequest.newInstance(
      ReservationSystemTestUtil.reservationQ, "", 1, Long.MAX_VALUE, true);
  response = null;
  try {
    response = clientService.listReservations(request);
  } catch (Exception e) {
    Assert.fail(e.getMessage());
  }
  Assert.assertNotNull(response);
  Assert.assertEquals(1, response.getReservationAllocationState().size());
  Assert.assertEquals(response.getReservationAllocationState().get(0)
      .getReservationId().getId(), reservationID.getId());
  // Verify that the full resource allocations exist.
  Assert.assertTrue(response.getReservationAllocationState().get(0)
      .getResourceAllocationRequests().size() > 0);
  // Verify that the full RDL is returned.
  ReservationRequests reservationRequests =
      response.getReservationAllocationState().get(0)
          .getReservationDefinition().getReservationRequests();
  Assert.assertEquals("R_ALL",
      reservationRequests.getInterpreter().toString());
  Assert.assertTrue(reservationRequests.getReservationResources().get(0)
      .getDuration() == duration);
  rm.stop();
}