14
14
package org .asynchttpclient ;
15
15
16
16
import static io .netty .handler .codec .http .HttpHeaderNames .*;
17
+ import static io .netty .util .internal .ThrowableUtil .unknownStackTrace ;
17
18
import static java .nio .charset .StandardCharsets .ISO_8859_1 ;
18
19
import static java .util .concurrent .TimeUnit .SECONDS ;
19
20
import static org .asynchttpclient .Dsl .*;
63
64
import org .testng .annotations .BeforeClass ;
64
65
import org .testng .annotations .Test ;
65
66
66
-
67
67
public class BasicHttpTest extends HttpTest {
68
68
69
69
private static HttpServer server ;
@@ -578,7 +578,8 @@ public void exceptionInOnCompletedGetNotifiedToOnThrowable() throws Throwable {
578
578
client .prepareGet (getTargetUrl ()).execute (new AsyncCompletionHandlerAdapter () {
579
579
@ Override
580
580
public Response onCompleted (Response response ) throws Exception {
581
- throw new IllegalStateException ("FOO" );
581
+ throw unknownStackTrace (new IllegalStateException ("FOO" ), BasicHttpTest .class , "exceptionInOnCompletedGetNotifiedToOnThrowable" );
582
+
582
583
}
583
584
584
585
@ Override
@@ -605,7 +606,7 @@ public void exceptionInOnCompletedGetNotifiedToFuture() throws Throwable {
605
606
Future <Response > whenResponse = client .prepareGet (getTargetUrl ()).execute (new AsyncCompletionHandlerAdapter () {
606
607
@ Override
607
608
public Response onCompleted (Response response ) throws Exception {
608
- throw new IllegalStateException ("FOO" );
609
+ throw unknownStackTrace ( new IllegalStateException ("FOO" ), BasicHttpTest . class , "exceptionInOnCompletedGetNotifiedToFuture " );
609
610
}
610
611
611
612
@ Override
@@ -932,10 +933,10 @@ public void postUnboundedInputStreamAsBodyStream() throws Throwable {
932
933
h .add (CONTENT_TYPE , HttpHeaderValues .APPLICATION_JSON );
933
934
server .enqueue (new AbstractHandler () {
934
935
EchoHandler chain = new EchoHandler ();
936
+
935
937
@ 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 {
939
940
assertEquals (request .getHeader (TRANSFER_ENCODING .toString ()), HttpHeaderValues .CHUNKED .toString ());
940
941
assertNull (request .getHeader (CONTENT_LENGTH .toString ()));
941
942
chain .handle (target , request , httpServletRequest , httpServletResponse );
@@ -944,16 +945,16 @@ public void handle(String target, org.eclipse.jetty.server.Request request,
944
945
server .enqueueEcho ();
945
946
946
947
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 );
957
958
});
958
959
});
959
960
}
@@ -966,13 +967,13 @@ public void postInputStreamWithContentLengthAsBodyGenerator() throws Throwable {
966
967
h .add (CONTENT_TYPE , HttpHeaderValues .APPLICATION_JSON );
967
968
server .enqueue (new AbstractHandler () {
968
969
EchoHandler chain = new EchoHandler ();
970
+
969
971
@ 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 {
973
974
assertNull (request .getHeader (TRANSFER_ENCODING .toString ()));
974
975
assertEquals (request .getHeader (CONTENT_LENGTH .toString ()),//
975
- Integer .toString ("{}" .getBytes (StandardCharsets .ISO_8859_1 ).length ));
976
+ Integer .toString ("{}" .getBytes (StandardCharsets .ISO_8859_1 ).length ));
976
977
chain .handle (target , request , httpServletRequest , httpServletResponse );
977
978
}
978
979
});
@@ -981,17 +982,17 @@ public void handle(String target, org.eclipse.jetty.server.Request request,
981
982
InputStream bodyStream = new ByteArrayInputStream (bodyBytes );
982
983
983
984
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 );
995
996
});
996
997
});
997
998
}
0 commit comments