Skip to content

Commit 14cc500

Browse files
committed
Remove test expected exceptions stacktrace
1 parent 660d52d commit 14cc500

File tree

2 files changed

+35
-32
lines changed

2 files changed

+35
-32
lines changed

client/src/test/java/org/asynchttpclient/AsyncStreamHandlerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import io.netty.handler.codec.http.HttpHeaderValues;
2424
import io.netty.handler.codec.http.HttpHeaders;
2525

26+
import static io.netty.util.internal.ThrowableUtil.*;
27+
2628
import java.util.Arrays;
2729
import java.util.concurrent.CountDownLatch;
2830
import java.util.concurrent.Future;
@@ -217,7 +219,7 @@ public void asyncStreamThrowableRefusedTest() throws Throwable {
217219

218220
@Override
219221
public State onHeadersReceived(HttpResponseHeaders content) throws Exception {
220-
throw new RuntimeException("FOO");
222+
throw unknownStackTrace(new RuntimeException("FOO"), AsyncStreamHandlerTest.class, "asyncStreamThrowableRefusedTest");
221223
}
222224

223225
@Override

client/src/test/java/org/asynchttpclient/BasicHttpTest.java

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package org.asynchttpclient;
1515

1616
import static io.netty.handler.codec.http.HttpHeaderNames.*;
17+
import static io.netty.util.internal.ThrowableUtil.unknownStackTrace;
1718
import static java.nio.charset.StandardCharsets.ISO_8859_1;
1819
import static java.util.concurrent.TimeUnit.SECONDS;
1920
import static org.asynchttpclient.Dsl.*;
@@ -63,7 +64,6 @@
6364
import org.testng.annotations.BeforeClass;
6465
import org.testng.annotations.Test;
6566

66-
6767
public class BasicHttpTest extends HttpTest {
6868

6969
private static HttpServer server;
@@ -578,7 +578,8 @@ public void exceptionInOnCompletedGetNotifiedToOnThrowable() throws Throwable {
578578
client.prepareGet(getTargetUrl()).execute(new AsyncCompletionHandlerAdapter() {
579579
@Override
580580
public Response onCompleted(Response response) throws Exception {
581-
throw new IllegalStateException("FOO");
581+
throw unknownStackTrace(new IllegalStateException("FOO"), BasicHttpTest.class, "exceptionInOnCompletedGetNotifiedToOnThrowable");
582+
582583
}
583584

584585
@Override
@@ -605,7 +606,7 @@ public void exceptionInOnCompletedGetNotifiedToFuture() throws Throwable {
605606
Future<Response> whenResponse = client.prepareGet(getTargetUrl()).execute(new AsyncCompletionHandlerAdapter() {
606607
@Override
607608
public Response onCompleted(Response response) throws Exception {
608-
throw new IllegalStateException("FOO");
609+
throw unknownStackTrace(new IllegalStateException("FOO"), BasicHttpTest.class, "exceptionInOnCompletedGetNotifiedToFuture");
609610
}
610611

611612
@Override
@@ -932,10 +933,10 @@ public void postUnboundedInputStreamAsBodyStream() throws Throwable {
932933
h.add(CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON);
933934
server.enqueue(new AbstractHandler() {
934935
EchoHandler chain = new EchoHandler();
936+
935937
@Override
936-
public void handle(String target, org.eclipse.jetty.server.Request request,
937-
HttpServletRequest httpServletRequest,
938-
HttpServletResponse httpServletResponse) throws IOException, ServletException {
938+
public void handle(String target, org.eclipse.jetty.server.Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
939+
throws IOException, ServletException {
939940
assertEquals(request.getHeader(TRANSFER_ENCODING.toString()), HttpHeaderValues.CHUNKED.toString());
940941
assertNull(request.getHeader(CONTENT_LENGTH.toString()));
941942
chain.handle(target, request, httpServletRequest, httpServletResponse);
@@ -944,16 +945,16 @@ public void handle(String target, org.eclipse.jetty.server.Request request,
944945
server.enqueueEcho();
945946

946947
client.preparePost(getTargetUrl())//
947-
.setHeaders(h)//
948-
.setBody(new ByteArrayInputStream("{}".getBytes(StandardCharsets.ISO_8859_1)))//
949-
.execute(new AsyncCompletionHandlerAdapter() {
950-
@Override
951-
public Response onCompleted(Response response) throws Exception {
952-
assertEquals(response.getStatusCode(), 200);
953-
assertEquals(response.getResponseBody(), "{}");
954-
return response;
955-
}
956-
}).get(TIMEOUT, SECONDS);
948+
.setHeaders(h)//
949+
.setBody(new ByteArrayInputStream("{}".getBytes(StandardCharsets.ISO_8859_1)))//
950+
.execute(new AsyncCompletionHandlerAdapter() {
951+
@Override
952+
public Response onCompleted(Response response) throws Exception {
953+
assertEquals(response.getStatusCode(), 200);
954+
assertEquals(response.getResponseBody(), "{}");
955+
return response;
956+
}
957+
}).get(TIMEOUT, SECONDS);
957958
});
958959
});
959960
}
@@ -966,13 +967,13 @@ public void postInputStreamWithContentLengthAsBodyGenerator() throws Throwable {
966967
h.add(CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON);
967968
server.enqueue(new AbstractHandler() {
968969
EchoHandler chain = new EchoHandler();
970+
969971
@Override
970-
public void handle(String target, org.eclipse.jetty.server.Request request,
971-
HttpServletRequest httpServletRequest,
972-
HttpServletResponse httpServletResponse) throws IOException, ServletException {
972+
public void handle(String target, org.eclipse.jetty.server.Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
973+
throws IOException, ServletException {
973974
assertNull(request.getHeader(TRANSFER_ENCODING.toString()));
974975
assertEquals(request.getHeader(CONTENT_LENGTH.toString()),//
975-
Integer.toString("{}".getBytes(StandardCharsets.ISO_8859_1).length));
976+
Integer.toString("{}".getBytes(StandardCharsets.ISO_8859_1).length));
976977
chain.handle(target, request, httpServletRequest, httpServletResponse);
977978
}
978979
});
@@ -981,17 +982,17 @@ public void handle(String target, org.eclipse.jetty.server.Request request,
981982
InputStream bodyStream = new ByteArrayInputStream(bodyBytes);
982983

983984
client.preparePost(getTargetUrl())//
984-
.setHeaders(h)//
985-
.setBody(new InputStreamBodyGenerator(bodyStream, bodyBytes.length))//
986-
.execute(new AsyncCompletionHandlerAdapter() {
987-
988-
@Override
989-
public Response onCompleted(Response response) throws Exception {
990-
assertEquals(response.getStatusCode(), 200);
991-
assertEquals(response.getResponseBody(), "{}");
992-
return response;
993-
}
994-
}).get(TIMEOUT, SECONDS);
985+
.setHeaders(h)//
986+
.setBody(new InputStreamBodyGenerator(bodyStream, bodyBytes.length))//
987+
.execute(new AsyncCompletionHandlerAdapter() {
988+
989+
@Override
990+
public Response onCompleted(Response response) throws Exception {
991+
assertEquals(response.getStatusCode(), 200);
992+
assertEquals(response.getResponseBody(), "{}");
993+
return response;
994+
}
995+
}).get(TIMEOUT, SECONDS);
995996
});
996997
});
997998
}

0 commit comments

Comments
 (0)