You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by kg...@apache.org on 2011/12/15 14:47:04 UTC

svn commit: r1214754 - /felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/test/java/org/apache/felix/httplite/osgi/test/AbstractHttpliteTestCase.java

Author: kgilmer
Date: Thu Dec 15 13:47:04 2011
New Revision: 1214754

URL: http://svn.apache.org/viewvc?rev=1214754&view=rev
Log:
httplite: add Apache commons-io as testing dependency

Modified:
    felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/test/java/org/apache/felix/httplite/osgi/test/AbstractHttpliteTestCase.java

Modified: felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/test/java/org/apache/felix/httplite/osgi/test/AbstractHttpliteTestCase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/test/java/org/apache/felix/httplite/osgi/test/AbstractHttpliteTestCase.java?rev=1214754&r1=1214753&r2=1214754&view=diff
==============================================================================
--- felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/test/java/org/apache/felix/httplite/osgi/test/AbstractHttpliteTestCase.java (original)
+++ felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/test/java/org/apache/felix/httplite/osgi/test/AbstractHttpliteTestCase.java Thu Dec 15 13:47:04 2011
@@ -19,19 +19,19 @@
 package org.apache.felix.httplite.osgi.test;
 
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 
+import org.apache.commons.io.IOUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.HttpService;
 
 
 /**
- * Base class with commong HTTP testing methods.
+ * Base class with commong HTTP testing methods.  Depends on Apache Commons-IO.
  *
  */
 public abstract class AbstractHttpliteTestCase extends AbstractPojoSRTestCase
@@ -39,12 +39,10 @@ public abstract class AbstractHttpliteTe
 
     protected static final int DEFAULT_PORT = 8080;
     protected static final String DEFAULT_BASE_URL = "http://localhost:" + DEFAULT_PORT;
-    private static final int COPY_BUFFER_SIZE = 1024 * 4;
-
 
     protected static String readInputAsString( InputStream in ) throws IOException
     {
-        return new String( readInputAsByteArray( in ) );
+        return IOUtils.toString( in );
     }
 
 
@@ -59,20 +57,7 @@ public abstract class AbstractHttpliteTe
      */
     protected static byte[] readInputAsByteArray( InputStream in ) throws IOException
     {
-        if ( in == null )
-            return null;
-
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
-        int read = 0;
-        byte[] buff = new byte[COPY_BUFFER_SIZE];
-
-        while ( ( read = in.read( buff ) ) > 0 )
-        {
-            os.write( buff, 0, read );
-        }
-        os.close();
-
-        return os.toByteArray();
+        return IOUtils.toByteArray( in );
     }