use of com.google.gerrit.server.project.CreateProjectArgs in project gerrit by GerritCodeReview.
the class SshCancellationIT method handleServerDeadlineExceeded.
@Test
public void handleServerDeadlineExceeded() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
throw new RequestCancelledException(RequestStateProvider.Reason.SERVER_DEADLINE_EXCEEDED, /* cancellationMessage= */
null);
}
};
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
adminSshSession.exec("gerrit create-project " + name("new"));
adminSshSession.assertFailure("Server Deadline Exceeded");
}
}
use of com.google.gerrit.server.project.CreateProjectArgs in project gerrit by GerritCodeReview.
the class SshCancellationIT method handleClientDisconnected.
@Test
public void handleClientDisconnected() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
throw new RequestCancelledException(RequestStateProvider.Reason.CLIENT_CLOSED_REQUEST, /* cancellationMessage= */
null);
}
};
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
adminSshSession.exec("gerrit create-project " + name("new"));
adminSshSession.assertFailure("Client Closed Request");
}
}
use of com.google.gerrit.server.project.CreateProjectArgs in project gerrit by GerritCodeReview.
the class CancellationIT method handleClientDisconnected.
@Test
public void handleClientDisconnected() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
// set when a request is cancelled.
throw new RequestCancelledException(RequestStateProvider.Reason.CLIENT_CLOSED_REQUEST, /* cancellationMessage= */
null);
}
};
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
RestResponse response = adminRestSession.put("/projects/" + name("new"));
assertThat(response.getStatusCode()).isEqualTo(SC_CLIENT_CLOSED_REQUEST);
assertThat(response.getEntityContent()).isEqualTo("Client Closed Request");
}
}
use of com.google.gerrit.server.project.CreateProjectArgs in project gerrit by GerritCodeReview.
the class CancellationIT method handleRequestCancellationWithMessage.
@Test
public void handleRequestCancellationWithMessage() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
// Simulate an exceeded deadline by throwing RequestCancelledException.
throw 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");
}
}
use of com.google.gerrit.server.project.CreateProjectArgs in project gerrit by GerritCodeReview.
the class SshCancellationIT method handleRequestCancellationWithMessage.
@Test
public void handleRequestCancellationWithMessage() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
throw new RequestCancelledException(RequestStateProvider.Reason.SERVER_DEADLINE_EXCEEDED, "deadline = 10m");
}
};
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
adminSshSession.exec("gerrit create-project " + name("new"));
adminSshSession.assertFailure("Server Deadline Exceeded (deadline = 10m)");
}
}
Aggregations