@Test
public void testResponseIdResync() throws YarnException, IOException {

  this.responseId = 10;
  AllocateResponse response = this.relayer.allocate(getAllocateRequest());
  Assert.assertEquals(this.responseId + 1, response.getResponseId());
  int expected = 5;
  this.mockAMS.setResponseIdReset(expected);
  try {
    this.relayer.allocate(getAllocateRequest());
    Assert.fail("Expecting exception from RM");
  } catch (InvalidApplicationMasterRequestException e) {
    // Expected exception
  }
  // Verify that the responseId is overridden
  response = this.relayer.allocate(getAllocateRequest());
  Assert.assertEquals(expected + 1, response.getResponseId());
  // Verify it is no longer overriden
  this.responseId = response.getResponseId();
  response = this.relayer.allocate(getAllocateRequest());
  Assert.assertEquals(this.responseId + 1, response.getResponseId());
}