Skip to content

Commit a7216fc

Browse files
TomGranotLorenzNickel
authored andcommitted
Fix Failing Github Actions Tests (#1753)
* Bump GitHub Actions runner version to Ubuntu 20.04 * AsyncStreamHandlerTest.asyncOptionsTest - Allow for the appearance of the TRACE method in the server's response * MaxTotalConnectionTest.testMaxTotalConnections - https://github.com --> https://www.youtube.com, https://google.com --> https://www.google.com * TextMessageTest.onFailureTest - Refactor logic for more granular testing (accept ConnectException in addition to UnknownHostException, but check for "DNS Name not found" in exception cause)
1 parent fbf477f commit a7216fc

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.github/workflows/maven.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
build:
12-
runs-on: ubuntu-16.04
12+
runs-on: ubuntu-20.04
1313
steps:
1414
- uses: actions/checkout@v2
1515
- name: Set up JDK 1.8

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,10 @@ public void asyncOptionsTest() throws Throwable {
436436

437437
final AtomicReference<HttpHeaders> responseHeaders = new AtomicReference<>();
438438

439+
// Some responses contain the TRACE method, some do not - account for both
440+
// FIXME: Actually refactor this test to account for both cases
439441
final String[] expected = {"GET", "HEAD", "OPTIONS", "POST"};
442+
final String[] expectedWithTrace = {"GET", "HEAD", "OPTIONS", "POST", "TRACE"};
440443
Future<String> f = client.prepareOptions("http://www.apache.org/").execute(new AsyncHandlerAdapter() {
441444

442445
@Override
@@ -455,10 +458,16 @@ public String onCompleted() {
455458
HttpHeaders h = responseHeaders.get();
456459
assertNotNull(h);
457460
String[] values = h.get(ALLOW).split(",|, ");
458-
assertNotNull(values);
459-
assertEquals(values.length, expected.length);
461+
assertNotNull(values);
462+
// Some responses contain the TRACE method, some do not - account for both
463+
assert(values.length == expected.length || values.length == expectedWithTrace.length);
460464
Arrays.sort(values);
461-
assertEquals(values, expected);
465+
// Some responses contain the TRACE method, some do not - account for both
466+
if(values.length == expected.length) {
467+
assertEquals(values, expected);
468+
} else {
469+
assertEquals(values, expectedWithTrace);
470+
}
462471
}));
463472
}
464473

client/src/test/java/org/asynchttpclient/channel/MaxTotalConnectionTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void testMaxTotalConnectionsExceedingException() throws IOException {
6969

7070
@Test(groups = "online")
7171
public void testMaxTotalConnections() throws Exception {
72-
String[] urls = new String[]{"https://google.com", "https://github.com"};
72+
String[] urls = new String[]{"https://www.google.com", "https://www.youtube.com"};
7373

7474
final CountDownLatch latch = new CountDownLatch(2);
7575
final AtomicReference<Throwable> ex = new AtomicReference<>();

client/src/test/java/org/asynchttpclient/ws/TextMessageTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.testng.annotations.Test;
1717

1818
import java.net.UnknownHostException;
19+
import java.net.ConnectException;
1920
import java.util.concurrent.CountDownLatch;
2021
import java.util.concurrent.ExecutionException;
2122
import java.util.concurrent.atomic.AtomicReference;
@@ -70,11 +71,14 @@ public void onEmptyListenerTest() throws Exception {
7071
}
7172
}
7273

73-
@Test(timeOut = 60000, expectedExceptions = UnknownHostException.class)
74+
@Test(timeOut = 60000, expectedExceptions = {UnknownHostException.class, ConnectException.class})
7475
public void onFailureTest() throws Throwable {
7576
try (AsyncHttpClient c = asyncHttpClient()) {
7677
c.prepareGet("ws://abcdefg").execute(new WebSocketUpgradeHandler.Builder().build()).get();
7778
} catch (ExecutionException e) {
79+
80+
String expectedMessage = "DNS name not found";
81+
assertTrue(e.getCause().toString().contains(expectedMessage));
7882
throw e.getCause();
7983
}
8084
}

0 commit comments

Comments
 (0)