use of com.google.gerrit.server.cancellation.RequestCancelledException in project gerrit by GerritCodeReview.
the class CancellationIT method handleWrappedRequestCancelledException.
@Test
public void handleWrappedRequestCancelledException() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
// Simulate an exceeded deadline by throwing RequestCancelledException.
throw new RuntimeException(new RequestCancelledException(RequestStateProvider.Reason.SERVER_DEADLINE_EXCEEDED, "deadline = 10m"));
}
};
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
RestResponse response = adminRestSession.put("/projects/" + name("new"));
assertThat(response.getStatusCode()).isEqualTo(SC_REQUEST_TIMEOUT);
assertThat(response.getEntityContent()).isEqualTo("Server Deadline Exceeded\n\ndeadline = 10m");
}
}
Aggregations