Rename to AcmeRateLimitedException

pull/55/head
Richard Körber 2017-08-13 14:08:37 +02:00
parent 27bd913891
commit 7c88a2cdac
4 changed files with 18 additions and 18 deletions

View File

@ -47,7 +47,7 @@ import org.shredzone.acme4j.Session;
import org.shredzone.acme4j.exception.AcmeException;
import org.shredzone.acme4j.exception.AcmeNetworkException;
import org.shredzone.acme4j.exception.AcmeProtocolException;
import org.shredzone.acme4j.exception.AcmeRateLimitExceededException;
import org.shredzone.acme4j.exception.AcmeRateLimitedException;
import org.shredzone.acme4j.exception.AcmeRetryAfterException;
import org.shredzone.acme4j.exception.AcmeServerException;
import org.shredzone.acme4j.exception.AcmeUnauthorizedException;
@ -422,7 +422,7 @@ public class DefaultConnection implements Connection {
if ("rateLimited".equals(error)) {
Optional<Instant> retryAfter = getRetryAfterHeader();
Collection<URI> rateLimits = getLinks("urn:ietf:params:acme:documentation");
return new AcmeRateLimitExceededException(problem, retryAfter.orElse(null), rateLimits);
return new AcmeRateLimitedException(problem, retryAfter.orElse(null), rateLimits);
}
return new AcmeServerException(problem);

View File

@ -23,14 +23,14 @@ import org.shredzone.acme4j.Problem;
/**
* An exception that is thrown when a rate limit was exceeded.
*/
public class AcmeRateLimitExceededException extends AcmeServerException {
public class AcmeRateLimitedException extends AcmeServerException {
private static final long serialVersionUID = 4150484059796413069L;
private final Instant retryAfter;
private final Collection<URI> documents;
/**
* Creates a new {@link AcmeRateLimitExceededException}.
* Creates a new {@link AcmeRateLimitedException}.
*
* @param problem
* {@link Problem} that caused the exception
@ -40,7 +40,7 @@ public class AcmeRateLimitExceededException extends AcmeServerException {
* @param documents
* URIs pointing to documents about the rate limit that was hit
*/
public AcmeRateLimitExceededException(Problem problem, Instant retryAfter, Collection<URI> documents) {
public AcmeRateLimitedException(Problem problem, Instant retryAfter, Collection<URI> documents) {
super(problem);
this.retryAfter = retryAfter;
this.documents =

View File

@ -46,7 +46,7 @@ import org.shredzone.acme4j.Session;
import org.shredzone.acme4j.exception.AcmeException;
import org.shredzone.acme4j.exception.AcmeNetworkException;
import org.shredzone.acme4j.exception.AcmeProtocolException;
import org.shredzone.acme4j.exception.AcmeRateLimitExceededException;
import org.shredzone.acme4j.exception.AcmeRateLimitedException;
import org.shredzone.acme4j.exception.AcmeRetryAfterException;
import org.shredzone.acme4j.exception.AcmeServerException;
import org.shredzone.acme4j.exception.AcmeUnauthorizedException;
@ -481,10 +481,10 @@ public class DefaultConnectionTest {
}
/**
* Test if an {@link AcmeRateLimitExceededException} is thrown on an acme problem.
* Test if an {@link AcmeRateLimitedException} is thrown on an acme problem.
*/
@Test
public void testAcceptThrowsRateLimitExceededException() throws Exception {
public void testAcceptThrowsRateLimitedException() throws Exception {
String jsonData = "{\"type\":\"urn:ietf:params:acme:error:rateLimited\",\"detail\":\"Too many invocations\"}";
Map<String, List<String>> linkHeader = new HashMap<>();
@ -504,7 +504,7 @@ public class DefaultConnectionTest {
conn.conn = mockUrlConnection;
conn.accept(HttpURLConnection.HTTP_OK);
fail("Expected to fail");
} catch (AcmeRateLimitExceededException ex) {
} catch (AcmeRateLimitedException ex) {
assertThat(ex.getType(), is(URI.create("urn:ietf:params:acme:error:rateLimited")));
assertThat(ex.getMessage(), is("Too many invocations"));
assertThat(ex.getRetryAfter(), is(retryAfter));
@ -512,7 +512,7 @@ public class DefaultConnectionTest {
assertThat(ex.getDocuments().size(), is(1));
assertThat(ex.getDocuments().iterator().next(), is(URI.create("https://example.com/rates.pdf")));
} catch (AcmeException ex) {
fail("Expected an AcmeRateLimitExceededException");
fail("Expected an AcmeRateLimitedException");
}
verify(mockUrlConnection, atLeastOnce()).getHeaderField("Content-Type");

View File

@ -27,15 +27,15 @@ import org.junit.Test;
import org.shredzone.acme4j.Problem;
/**
* Unit tests for {@link AcmeRateLimitExceededException}.
* Unit tests for {@link AcmeRateLimitedException}.
*/
public class AcmeRateLimitExceededExceptionTest {
public class AcmeRateLimitedExceptionTest {
/**
* Test that parameters are correctly returned.
*/
@Test
public void testAcmeRateLimitExceededException() {
public void testAcmeRateLimitedException() {
URI type = URI.create("urn:ietf:params:acme:error:rateLimited");
String detail = "Too many requests per minute";
Instant retryAfter = Instant.now().plus(Duration.ofMinutes(1));
@ -45,8 +45,8 @@ public class AcmeRateLimitExceededExceptionTest {
Problem problem = createProblem(type, detail, null);
AcmeRateLimitExceededException ex
= new AcmeRateLimitExceededException(problem, retryAfter, documents);
AcmeRateLimitedException ex
= new AcmeRateLimitedException(problem, retryAfter, documents);
assertThat(ex.getType(), is(type));
assertThat(ex.getMessage(), is(detail));
@ -58,14 +58,14 @@ public class AcmeRateLimitExceededExceptionTest {
* Test that optional parameters are null-safe.
*/
@Test
public void testNullAcmeRateLimitExceededException() {
public void testNullAcmeRateLimitedException() {
URI type = URI.create("urn:ietf:params:acme:error:rateLimited");
String detail = "Too many requests per minute";
Problem problem = createProblem(type, detail, null);
AcmeRateLimitExceededException ex
= new AcmeRateLimitExceededException(problem, null, null);
AcmeRateLimitedException ex
= new AcmeRateLimitedException(problem, null, null);
assertThat(ex.getType(), is(type));
assertThat(ex.getMessage(), is(detail));