diff options
author | Koushik Dutta <koushd@gmail.com> | 2013-08-31 17:46:03 -0700 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2013-08-31 18:14:36 -0700 |
commit | 7d29a8b01a9844e40731708c288b60022b991950 (patch) | |
tree | 1b768b340661b0cc02955f447f136dbf31e5f2d4 /AndroidAsyncTest/src/com | |
parent | 78b2436f574b41531e8b47f6a86d7964f80ac2b1 (diff) | |
download | AndroidAsync-7d29a8b01a9844e40731708c288b60022b991950.tar.gz AndroidAsync-7d29a8b01a9844e40731708c288b60022b991950.tar.bz2 AndroidAsync-7d29a8b01a9844e40731708c288b60022b991950.zip |
Add test around Issue59
Change-Id: Ica8b0be5017cad66a78ade2ebf09a359b24c1639
Diffstat (limited to 'AndroidAsyncTest/src/com')
-rw-r--r-- | AndroidAsyncTest/src/com/koushikdutta/async/test/Issue59.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/AndroidAsyncTest/src/com/koushikdutta/async/test/Issue59.java b/AndroidAsyncTest/src/com/koushikdutta/async/test/Issue59.java new file mode 100644 index 0000000..45d0392 --- /dev/null +++ b/AndroidAsyncTest/src/com/koushikdutta/async/test/Issue59.java @@ -0,0 +1,50 @@ +package com.koushikdutta.async.test; + +import android.util.Log; + +import com.koushikdutta.async.AsyncServer; +import com.koushikdutta.async.Util; +import com.koushikdutta.async.callback.CompletedCallback; +import com.koushikdutta.async.http.AsyncHttpClient; +import com.koushikdutta.async.http.AsyncHttpGet; +import com.koushikdutta.async.http.server.AsyncHttpServer; +import com.koushikdutta.async.http.server.AsyncHttpServerRequest; +import com.koushikdutta.async.http.server.AsyncHttpServerResponse; +import com.koushikdutta.async.http.server.HttpServerRequestCallback; + +import junit.framework.TestCase; + +import java.util.concurrent.TimeUnit; + +/** + * Created by koush on 8/31/13. + */ +public class Issue59 extends TestCase { + public void testIssue() throws Exception { + try { + AsyncHttpServer httpServer = new AsyncHttpServer(); + httpServer.get("/", new HttpServerRequestCallback() { + @Override + public void onRequest(AsyncHttpServerRequest request, final AsyncHttpServerResponse response) { + response.getHeaders().getHeaders().set("Transfer-Encoding", ""); + Util.writeAll(response, "foobarbeepboop".getBytes(), new CompletedCallback() { + @Override + public void onCompleted(Exception ex) { + response.close(); + } + }); + } + }); + + httpServer.listen(5959); + + AsyncHttpGet get = new AsyncHttpGet("http://localhost:5959/"); + get.setLogging("issue59", Log.VERBOSE); + + assertEquals("foobarbeepboop", AsyncHttpClient.getDefaultInstance().executeString(get).get(1000, TimeUnit.MILLISECONDS)); + } + finally { + AsyncServer.getDefault().stop(); + } + } +} |