Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C3D447C4D for ; Thu, 15 Dec 2011 13:47:29 +0000 (UTC) Received: (qmail 72351 invoked by uid 500); 15 Dec 2011 13:47:29 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 72327 invoked by uid 500); 15 Dec 2011 13:47:29 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 72314 invoked by uid 99); 15 Dec 2011 13:47:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Dec 2011 13:47:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Dec 2011 13:47:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F3ED123888FD for ; Thu, 15 Dec 2011 13:47:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1214754 - /felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/test/java/org/apache/felix/httplite/osgi/test/AbstractHttpliteTestCase.java Date: Thu, 15 Dec 2011 13:47:04 -0000 To: commits@felix.apache.org From: kgilmer@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111215134704.F3ED123888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 ); }