Skip to content

Commit a525703

Browse files
committed
Test clean up + Jetty 9.2.13 upgrade
1 parent d6a73e5 commit a525703

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
package org.asynchttpclient;
1717

1818
import static org.asynchttpclient.Dsl.*;
19-
import static org.asynchttpclient.test.TestUtils.TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET;
19+
import static org.asynchttpclient.test.TestUtils.*;
2020
import static org.testng.Assert.*;
2121
import io.netty.handler.codec.http.HttpHeaders;
2222

2323
import java.util.Arrays;
24-
import java.util.Locale;
2524
import java.util.concurrent.CountDownLatch;
2625
import java.util.concurrent.Future;
2726
import java.util.concurrent.TimeUnit;
@@ -68,7 +67,7 @@ public void onThrowable(Throwable t) {
6867

6968
HttpHeaders h = responseHeaders.get();
7069
assertNotNull(h, "No response headers");
71-
assertEquals(h.get(HttpHeaders.Names.CONTENT_TYPE), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET, "Unexpected content-type");
70+
assertContentTypesEquals(h.get(HttpHeaders.Names.CONTENT_TYPE), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
7271
assertNull(throwable.get(), "Unexpected exception");
7372
}
7473
}
@@ -106,7 +105,7 @@ public String onCompleted() throws Exception {
106105
String responseBody = f.get(10, TimeUnit.SECONDS);
107106
HttpHeaders h = responseHeaders.get();
108107
assertNotNull(h);
109-
assertEquals(h.get(HttpHeaders.Names.CONTENT_TYPE), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
108+
assertContentTypesEquals(h.get(HttpHeaders.Names.CONTENT_TYPE), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
110109
assertEquals(responseBody, RESPONSE);
111110
}
112111
}
@@ -147,7 +146,7 @@ public void onThrowable(Throwable t) {
147146
assertTrue(!bodyReceived.get(), "Interrupted not working");
148147
HttpHeaders h = responseHeaders.get();
149148
assertNotNull(h, "Should receive non null headers");
150-
assertEquals(h.get(HttpHeaders.Names.CONTENT_TYPE).toLowerCase(Locale.ENGLISH), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET.toLowerCase(Locale.ENGLISH), "Unexpected content-type");
149+
assertContentTypesEquals(h.get(HttpHeaders.Names.CONTENT_TYPE), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
151150
assertNull(throwable.get(), "Should get an exception");
152151
}
153152
}
@@ -186,7 +185,7 @@ public void onThrowable(Throwable t) {
186185
String responseBody = f.get(5, TimeUnit.SECONDS);
187186
HttpHeaders h = responseHeaders.get();
188187
assertNotNull(h, "Should receive non null headers");
189-
assertEquals(h.get(HttpHeaders.Names.CONTENT_TYPE).toLowerCase(Locale.ENGLISH), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET.toLowerCase(Locale.ENGLISH), "Unexpected content-type");
188+
assertContentTypesEquals(h.get(HttpHeaders.Names.CONTENT_TYPE), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
190189
assertNotNull(responseBody, "No response body");
191190
assertEquals(responseBody.trim(), RESPONSE, "Unexpected response body");
192191
assertNull(throwable.get(), "Unexpected exception");
@@ -256,7 +255,7 @@ public String onCompleted() throws Exception {
256255
String r = f.get(5, TimeUnit.SECONDS);
257256
HttpHeaders h = responseHeaders.get();
258257
assertNotNull(h, "Should receive non null headers");
259-
assertEquals(h.get(HttpHeaders.Names.CONTENT_TYPE).toLowerCase(Locale.ENGLISH), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET.toLowerCase(Locale.ENGLISH), "Unexpected content-type");
258+
assertContentTypesEquals(h.get(HttpHeaders.Names.CONTENT_TYPE), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
260259
assertNotNull(r, "No response body");
261260
assertEquals(r.trim(), RESPONSE, "Unexpected response body");
262261

@@ -287,7 +286,7 @@ public String onCompleted() throws Exception {
287286
f.get(5, TimeUnit.SECONDS);
288287
h = responseHeaders.get();
289288
assertNotNull(h, "Should receive non null headers");
290-
assertEquals(h.get(HttpHeaders.Names.CONTENT_TYPE).toLowerCase(Locale.ENGLISH), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET.toLowerCase(Locale.ENGLISH), "Unexpected content-type");
289+
assertContentTypesEquals(h.get(HttpHeaders.Names.CONTENT_TYPE), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
291290
assertNotNull(r, "No response body");
292291
assertEquals(r.trim(), RESPONSE, "Unexpected response body");
293292
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void asyncContentTypeGETTest() throws Exception {
176176
public Response onCompleted(Response response) throws Exception {
177177
try {
178178
assertEquals(response.getStatusCode(), 200);
179-
assertEquals(response.getContentType(), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
179+
assertContentTypesEquals(response.getContentType(), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
180180
} finally {
181181
l.countDown();
182182
}
@@ -200,7 +200,7 @@ public void asyncHeaderGETTest() throws Exception {
200200
public Response onCompleted(Response response) throws Exception {
201201
try {
202202
assertEquals(response.getStatusCode(), 200);
203-
assertEquals(response.getContentType(), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
203+
assertContentTypesEquals(response.getContentType(), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
204204
} finally {
205205
l.countDown();
206206
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public void handle(String pathInContext, Request request, HttpServletRequest htt
2929
if (request.getMethod().equalsIgnoreCase("OPTIONS")) {
3030
httpResponse.addHeader("Allow", "GET,HEAD,POST,OPTIONS,TRACE");
3131
}
32-
;
3332

3433
Enumeration<?> e = httpRequest.getHeaderNames();
3534
String param;

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.HashSet;
2525
import java.util.Iterator;
2626
import java.util.List;
27+
import java.util.Locale;
2728
import java.util.Set;
2829
import java.util.UUID;
2930
import java.util.concurrent.atomic.AtomicBoolean;
@@ -64,8 +65,8 @@ public class TestUtils {
6465

6566
public static final String USER = "user";
6667
public static final String ADMIN = "admin";
67-
public static final String TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET = "text/html; charset=UTF-8";
68-
public static final String TEXT_HTML_CONTENT_TYPE_WITH_ISO_8859_1_CHARSET = "text/html; charset=ISO-8859-1";
68+
public static final String TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET = "text/html;charset=UTF-8";
69+
public static final String TEXT_HTML_CONTENT_TYPE_WITH_ISO_8859_1_CHARSET = "text/html;charset=ISO-8859-1";
6970
public static final File TMP_DIR = new File(System.getProperty("java.io.tmpdir"), "ahc-tests-" + UUID.randomUUID().toString().substring(0, 8));
7071
public static final byte[] PATTERN_BYTES = "FooBarBazQixFooBarBazQixFooBarBazQixFooBarBazQixFooBarBazQixFooBarBazQix".getBytes(Charset.forName("UTF-16"));
7172
public static final File LARGE_IMAGE_FILE;
@@ -340,4 +341,9 @@ public static File getClasspathFile(String file) throws FileNotFoundException {
340341
throw new FileNotFoundException(file);
341342
}
342343
}
344+
345+
public static void assertContentTypesEquals(String actual, String expected) {
346+
assertEquals(actual.replace("; ", "").toLowerCase(Locale.ENGLISH), expected.replace("; ", "").toLowerCase(Locale.ENGLISH), "Unexpected content-type");
347+
348+
}
343349
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@
382382
<logback.version>1.1.3</logback.version>
383383
<log4j.version>1.2.17</log4j.version>
384384
<testng.version>6.9.9</testng.version>
385-
<jetty.version>9.2.11.v20150529</jetty.version>
385+
<jetty.version>9.2.13.v20150730</jetty.version>
386386
<tomcat.version>6.0.29</tomcat.version>
387387
<commons-io.version>2.4</commons-io.version>
388388
<commons-fileupload.version>1.3</commons-fileupload.version>

0 commit comments

Comments
 (0)