use of com.google.gerrit.server.git.validators.CommitValidationListener in project gerrit by GerritCodeReview.
the class CancellationIT method handleClientDisconnectedForPush.
@Test
public void handleClientDisconnectedForPush() throws Exception {
CommitValidationListener commitValidationListener = new CommitValidationListener() {
@Override
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent) throws CommitValidationException {
// to the client.
throw new RequestCancelledException(RequestStateProvider.Reason.CLIENT_CLOSED_REQUEST, /* cancellationMessage= */
null);
}
};
try (Registration registration = extensionRegistry.newRegistration().add(commitValidationListener)) {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/heads/master");
r.assertErrorStatus("Client Closed Request");
}
}
use of com.google.gerrit.server.git.validators.CommitValidationListener in project gerrit by GerritCodeReview.
the class CancellationIT method handleServerDeadlineExceededForPush.
@Test
public void handleServerDeadlineExceededForPush() throws Exception {
CommitValidationListener commitValidationListener = new CommitValidationListener() {
@Override
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent) throws CommitValidationException {
// Simulate an exceeded deadline by throwing RequestCancelledException.
throw new RequestCancelledException(RequestStateProvider.Reason.SERVER_DEADLINE_EXCEEDED, /* cancellationMessage= */
null);
}
};
try (Registration registration = extensionRegistry.newRegistration().add(commitValidationListener)) {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/heads/master");
r.assertErrorStatus("Server Deadline Exceeded");
}
}
use of com.google.gerrit.server.git.validators.CommitValidationListener in project gerrit by GerritCodeReview.
the class CancellationIT method handleWrappedRequestCancelledExceptionForPush.
@Test
public void handleWrappedRequestCancelledExceptionForPush() throws Exception {
CommitValidationListener commitValidationListener = new CommitValidationListener() {
@Override
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent) throws CommitValidationException {
// 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(commitValidationListener)) {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/heads/master");
r.assertErrorStatus("Server Deadline Exceeded (deadline = 10m)");
}
}
use of com.google.gerrit.server.git.validators.CommitValidationListener in project gerrit by GerritCodeReview.
the class CancellationIT method handleClientDeadlineExceededForPush.
@Test
public void handleClientDeadlineExceededForPush() throws Exception {
CommitValidationListener commitValidationListener = new CommitValidationListener() {
@Override
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent) throws CommitValidationException {
// Simulate an exceeded deadline by throwing RequestCancelledException.
throw new RequestCancelledException(RequestStateProvider.Reason.CLIENT_PROVIDED_DEADLINE_EXCEEDED, /* cancellationMessage= */
null);
}
};
try (Registration registration = extensionRegistry.newRegistration().add(commitValidationListener)) {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/heads/master");
r.assertErrorStatus("Client Provided Deadline Exceeded");
}
}
use of com.google.gerrit.server.git.validators.CommitValidationListener in project gerrit by GerritCodeReview.
the class CancellationIT method handleRequestCancellationWithMessageForPush.
@Test
public void handleRequestCancellationWithMessageForPush() throws Exception {
CommitValidationListener commitValidationListener = new CommitValidationListener() {
@Override
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent) throws CommitValidationException {
// Simulate an exceeded deadline by throwing RequestCancelledException.
throw new RequestCancelledException(RequestStateProvider.Reason.SERVER_DEADLINE_EXCEEDED, "deadline = 10m");
}
};
try (Registration registration = extensionRegistry.newRegistration().add(commitValidationListener)) {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/heads/master");
r.assertErrorStatus("Server Deadline Exceeded (deadline = 10m)");
}
}
Aggregations