Skip to content

Commit 27bc852

Browse files
committed
Add logs to debug failing test
1 parent 5bdac75 commit 27bc852

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private static String getTargetUrl() {
5959

6060
@Test
6161
public void postBodyOverHttps() throws Throwable {
62+
logger.debug(">>> postBodyOverHttps");
6263
withClient(config().setSslEngineFactory(createSslEngineFactory())).run(client -> {
6364
withServer(server).run(server -> {
6465
server.enqueueEcho();
@@ -69,28 +70,31 @@ public void postBodyOverHttps() throws Throwable {
6970
assertEquals(resp.getResponseBody(), SIMPLE_TEXT_FILE_STRING);
7071
});
7172
});
73+
logger.debug("<<< postBodyOverHttps");
7274
}
7375

7476
@Test
7577
public void multipleSequentialPostRequestsOverHttps() throws Throwable {
78+
logger.debug(">>> multipleSequentialPostRequestsOverHttps");
7679
withClient(config().setSslEngineFactory(createSslEngineFactory())).run(client -> {
7780
withServer(server).run(server -> {
7881
server.enqueueEcho();
7982
server.enqueueEcho();
8083

8184
String body = "hello there";
82-
8385
Response response = client.preparePost(getTargetUrl()).setBody(body).setHeader(CONTENT_TYPE, "text/html").execute().get(TIMEOUT, SECONDS);
8486
assertEquals(response.getResponseBody(), body);
8587

8688
response = client.preparePost(getTargetUrl()).setBody(body).setHeader(CONTENT_TYPE, "text/html").execute().get(TIMEOUT, SECONDS);
8789
assertEquals(response.getResponseBody(), body);
8890
});
8991
});
92+
logger.debug("<<< multipleSequentialPostRequestsOverHttps");
9093
}
9194

9295
@Test
9396
public void multipleConcurrentPostRequestsOverHttpsWithDisabledKeepAliveStrategy() throws Throwable {
97+
logger.debug(">>> multipleConcurrentPostRequestsOverHttpsWithDisabledKeepAliveStrategy");
9498

9599
KeepAliveStrategy keepAliveStrategy = new KeepAliveStrategy() {
96100
@Override
@@ -114,14 +118,17 @@ public boolean keepAlive(Request ahcRequest, HttpRequest nettyRequest, HttpRespo
114118
assertEquals(response.getResponseBody(), body);
115119
});
116120
});
121+
122+
logger.debug("<<< multipleConcurrentPostRequestsOverHttpsWithDisabledKeepAliveStrategy");
117123
}
118124

119125
@Test
120126
public void reconnectAfterFailedCertificationPath() throws Throwable {
127+
logger.debug(">>> reconnectAfterFailedCertificationPath");
121128

122129
AtomicBoolean trust = new AtomicBoolean();
123130

124-
withClient(config().setSslEngineFactory(createSslEngineFactory(trust))).run(client -> {
131+
withClient(config().setMaxRequestRetry(0).setSslEngineFactory(createSslEngineFactory(trust))).run(client -> {
125132
withServer(server).run(server -> {
126133
server.enqueueEcho();
127134
server.enqueueEcho();
@@ -144,11 +151,14 @@ public void reconnectAfterFailedCertificationPath() throws Throwable {
144151
assertEquals(response.getResponseBody(), body);
145152
});
146153
});
154+
logger.debug("<<< reconnectAfterFailedCertificationPath");
147155
}
148156

149157
@Test(timeOut = 2000, expectedExceptions = SSLHandshakeException.class)
150158
public void failInstantlyIfNotAllowedSelfSignedCertificate() throws Throwable {
151-
withClient(config().setRequestTimeout(2000)).run(client -> {
159+
logger.debug(">>> failInstantlyIfNotAllowedSelfSignedCertificate");
160+
161+
withClient(config().setMaxRequestRetry(0).setRequestTimeout(2000)).run(client -> {
152162
withServer(server).run(server -> {
153163
server.enqueueEcho();
154164
try {
@@ -158,10 +168,14 @@ public void failInstantlyIfNotAllowedSelfSignedCertificate() throws Throwable {
158168
}
159169
});
160170
});
171+
logger.debug("<<< failInstantlyIfNotAllowedSelfSignedCertificate");
172+
161173
}
162174

163175
@Test(groups = "standalone")
164176
public void testNormalEventsFired() throws Throwable {
177+
logger.debug(">>> testNormalEventsFired");
178+
165179
withClient(config().setSslEngineFactory(createSslEngineFactory())).run(client -> {
166180
withServer(server).run(server -> {
167181
EventCollectingHandler handler = new EventCollectingHandler();
@@ -188,5 +202,6 @@ public void testNormalEventsFired() throws Throwable {
188202
assertEquals(handler.firedEvents.toArray(), expectedEvents, "Got " + Arrays.toString(handler.firedEvents.toArray()));
189203
});
190204
});
205+
logger.debug("<<< testNormalEventsFired");
191206
}
192207
}

client/src/test/java/org/asynchttpclient/testserver/HttpTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@
1313
*/
1414
package org.asynchttpclient.testserver;
1515

16+
import static org.asynchttpclient.Dsl.*;
17+
1618
import org.asynchttpclient.AsyncHttpClient;
1719
import org.asynchttpclient.AsyncHttpClientConfig;
1820
import org.asynchttpclient.DefaultAsyncHttpClientConfig;
19-
20-
import static org.asynchttpclient.Dsl.*;
21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
2123

2224
public abstract class HttpTest {
25+
26+
protected final Logger logger = LoggerFactory.getLogger(getClass());
2327

2428
protected static final String COMPLETED_EVENT = "Completed";
2529
protected static final String STATUS_RECEIVED_EVENT = "StatusReceived";

0 commit comments

Comments
 (0)