incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r724304 - /incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
Date Mon, 08 Dec 2008 10:30:50 GMT
Author: bdelacretaz
Date: Mon Dec  8 02:30:49 2008
New Revision: 724304

URL: http://svn.apache.org/viewvc?rev=724304&view=rev
Log:
use getResponseBodyAsStream() instead of getResponseBodyAsString() to avoid warnings when
testing

Modified:
    incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java

Modified: incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java?rev=724304&r1=724303&r2=724304&view=diff
==============================================================================
--- incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
(original)
+++ incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
Mon Dec  8 02:30:49 2008
@@ -292,7 +292,14 @@
             get.setQueryString(params.toArray(nvp));
         }
         final int status = httpClient.executeMethod(get);
-        final String content = get.getResponseBodyAsString();
+        final InputStream is = get.getResponseBodyAsStream();
+        final StringBuffer content = new StringBuffer();
+        final String charset = get.getResponseCharSet();
+        final byte [] buffer = new byte[16384];
+        int n = 0;
+        while( (n = is.read(buffer, 0, buffer.length)) > 0) {
+            content.append(new String(buffer, 0, n, charset));
+        }
         assertEquals("Expected status 200 for " + url + " (content=" + content + ")",200,status);
         final Header h = get.getResponseHeader("Content-Type");
         if(expectedContentType == null) {
@@ -313,7 +320,7 @@
                 h.getValue().startsWith(expectedContentType)
             );
         }
-        return content;
+        return content.toString();
     }
 
     /** upload rendering test script, and return its URL for future deletion */



Mime
View raw message