Skip to content

Commit

Permalink
mobile: Use getMessage() to print the error message in AndroidEngineE…
Browse files Browse the repository at this point in the history
…xplicitFlowTest (#34254)

Risk Level: low (tests only)
Testing: unit test
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Fredy Wijaya <[email protected]>
  • Loading branch information
fredyw authored May 21, 2024
1 parent fbae6c7 commit ae4f171
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions mobile/test/java/integration/AndroidEngineExplicitFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public void get_simple() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("hello, world");
Expand All @@ -109,7 +110,8 @@ public void get_waitOnReadData() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("hello, world");
Expand Down Expand Up @@ -166,11 +168,12 @@ public void get_bufferSmallerThanResponseBody() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("hello, world");
assertThat(response.getNbResponseChunks()).isEqualTo(3); // response size: 12, buffer size: 4
assertThat(response.getNbResponseChunks()).isEqualTo(3); // response size: 12, buffer, size: 4
}
}

Expand All @@ -189,7 +192,8 @@ public void get_withDirectExecutor() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("hello, world");
Expand All @@ -208,7 +212,8 @@ public void get_noBody() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEmpty();
Expand All @@ -230,7 +235,8 @@ public void get_cancelOnResponseHeaders() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEmpty();
Expand All @@ -252,7 +258,8 @@ public void get_noBody_cancelOnResponseHeaders() throws Exception {
Thread.sleep(100); // If the Stream processes a spurious onCancel callback, we will notice.

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEmpty();
Expand All @@ -275,7 +282,8 @@ public void get_withThrottledBodyResponse_bufferLargerThanResponseBody() throws
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("hello, world");
Expand All @@ -298,7 +306,8 @@ public void get_withThrottledBodyResponse_bufferSmallerThanResponseBody() throws
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("hello, world");
Expand All @@ -322,7 +331,8 @@ public void get_veryLargeResponse() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo(responseBody);
Expand Down Expand Up @@ -352,7 +362,8 @@ public MockResponse dispatch(RecordedRequest recordedRequest) {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("This is my response Body");
Expand Down Expand Up @@ -381,7 +392,8 @@ public MockResponse dispatch(RecordedRequest recordedRequest) {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("This is my response Body");
Expand Down Expand Up @@ -411,7 +423,8 @@ public MockResponse dispatch(RecordedRequest recordedRequest) {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.getHeaders().getHttpStatus()).isEqualTo(200);
assertThat(response.getBodyAsString()).isEqualTo("This is my response Body");
Expand All @@ -429,7 +442,8 @@ public void post_cancelUploadOnChunkZero() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.isCancelled()).isTrue();
assertThat(response.getRequestChunkSent()).isEqualTo(0);
Expand All @@ -448,7 +462,8 @@ public void post_cancelUploadOnChunkOne() throws Exception {
Response response = sendRequest(requestScenario);

if (response.getEnvoyError() != null) {
fail(response.getEnvoyError().toString());
fail("Error code: " + response.getEnvoyError().getErrorCode() +
", error message: " + response.getEnvoyError().getMessage());
} else {
assertThat(response.isCancelled()).isTrue();
assertThat(response.getRequestChunkSent()).isEqualTo(1);
Expand Down

0 comments on commit ae4f171

Please sign in to comment.