Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/test/java/seatsio/ErrorHandlingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public void test400() {

@Test
public void test500() {
SeatsioException e = assertThrows(SeatsioException.class, () -> new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbin.seatsio.net/status/500")));
assertThat(e.getMessage()).isEqualTo("GET https://httpbin.seatsio.net/status/500 resulted in a 500 Internal Server Error response. Body: ");
SeatsioException e = assertThrows(SeatsioException.class, () -> new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbingo.org/status/500")));
assertThat(e.getMessage()).isEqualTo("GET https://httpbingo.org/status/500 resulted in a 500 Internal Server Error response. Body: ");
assertThat(e.errors).isNull();
}

Expand All @@ -35,8 +35,8 @@ public void testWeirdError() {

@Test
public void testSocketTimeout() {
SeatsioException e = assertThrows(SeatsioException.class, () -> new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbin.seatsio.net/delay/5").socketTimeout(10)));
assertThat(e.getMessage()).contains("Error while executing GET https://httpbin.seatsio.net/delay/5");
SeatsioException e = assertThrows(SeatsioException.class, () -> new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbingo.org/delay/5").socketTimeout(10)));
assertThat(e.getMessage()).contains("Error while executing GET https://httpbingo.org/delay/5");
assertThat(e.getCause()).isInstanceOf(UnirestException.class);
assertThat(e.getCause().getCause()).isInstanceOf(java.net.SocketTimeoutException.class);
assertThat(e.errors).isNull();
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/seatsio/ExponentialBackoffTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ExponentialBackoffTest {
public void abortsEventuallyIfServerKeepsReturning429() {
Instant start = Instant.now();
try {
new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbin.seatsio.net/status/429"));
new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbingo.org/status/429"));
throw new RuntimeException("Should have failed");
} catch (SeatsioException e) {
// TODO: check for RateLimitExceededException when httpbin supports status 429 with a JSON response body
Expand All @@ -28,10 +28,10 @@ public void abortsEventuallyIfServerKeepsReturning429() {
public void abortsDirectlyIfServerReturnsOtherErrorThan429() {
Instant start = Instant.now();
try {
new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbin.seatsio.net/status/400"));
new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbingo.org/status/400"));
throw new RuntimeException("Should have failed");
} catch (SeatsioException e) {
assertThat(e.getMessage()).isEqualTo("GET https://httpbin.seatsio.net/status/400 resulted in a 400 Bad Request response. Body: ");
assertThat(e.getMessage()).isEqualTo("GET https://httpbingo.org/status/400 resulted in a 400 Bad Request response. Body: ");
long waitTime = Instant.now().toEpochMilli() - start.toEpochMilli();
assertThat(waitTime).isLessThan(2000);
}
Expand All @@ -41,10 +41,10 @@ public void abortsDirectlyIfServerReturnsOtherErrorThan429() {
public void abortsDirectlyIfMaxRetries0AndServerReturns429() {
Instant start = Instant.now();
try {
new UnirestWrapper("secretKey", null).maxRetries(0).stringResponse(get("https://httpbin.seatsio.net/status/429"));
new UnirestWrapper("secretKey", null).maxRetries(0).stringResponse(get("https://httpbingo.org/status/429"));
throw new RuntimeException("Should have failed");
} catch (SeatsioException e) {
assertThat(e.getMessage()).isEqualTo("GET https://httpbin.seatsio.net/status/429 resulted in a 429 Too Many Requests response. Body: ");
assertThat(e.getMessage()).isEqualTo("GET https://httpbingo.org/status/429 resulted in a 429 Too Many Requests response. Body: ");
long waitTime = Instant.now().toEpochMilli() - start.toEpochMilli();
assertThat(waitTime).isLessThan(2000);
}
Expand All @@ -55,7 +55,7 @@ public void returnsSuccessfullyWhenTheServerSendsA429FirstAndThenASuccessfulResp
for (int i = 0; i < 10; ++i) {
new UnirestWrapper("secretKey", null)
.maxRetries(20)
.stringResponse(get("https://httpbin.seatsio.net/status/429:0.25,204:0.75"));
.stringResponse(get("https://httpbingo.org/status/429:0.25,204:0.75"));
}
}
}
Loading