vmtest/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java
branchemul
changeset 638 f203b54b3d33
parent 626 f08eb4df84c1
child 667 5866e89ef568
     1.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java	Thu Jan 31 19:21:37 2013 +0100
     1.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/HttpResourceTest.java	Fri Feb 01 14:16:26 2013 +0100
     1.3 @@ -17,6 +17,7 @@
     1.4   */
     1.5  package org.apidesign.bck2brwsr.tck;
     1.6  
     1.7 +import java.io.InputStream;
     1.8  import java.net.URL;
     1.9  import org.apidesign.bck2brwsr.core.JavaScriptBody;
    1.10  import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
    1.11 @@ -65,6 +66,17 @@
    1.12          assert arr.length == 1 : "One byte " + arr.length;
    1.13          assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
    1.14      }
    1.15 +
    1.16 +    @HttpResource(path = "/bytes", content = "", resource = "0xfe", mimeType = "x-application/binary")
    1.17 +    @BrwsrTest
    1.18 +    public void testReadByteViaInputStream() throws Exception {
    1.19 +        URL url = new URL("http:/bytes");
    1.20 +        InputStream is = url.openStream();
    1.21 +        byte[] arr = new byte[10];
    1.22 +        int len = is.read(arr);
    1.23 +        assert len == 1 : "One byte " + len;
    1.24 +        assert arr[0] == 0xfe : "It is 0xfe: " + Integer.toHexString(arr[0]);
    1.25 +    }
    1.26      
    1.27      @JavaScriptBody(args = { "url" }, body = 
    1.28            "var req = new XMLHttpRequest();\n"