Why not simply use:

new ByteArrayInputStream(docs.getBytes(IOUtils.CHARSET_UTF_8))

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [email protected]


> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Thursday, December 06, 2012 2:34 PM
> To: [email protected]
> Subject: svn commit: r1417871 -
> /lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchm
> ark/byTask/feeds/EnwikiContentSourceTest.java
> 
> Author: doronc
> Date: Thu Dec  6 13:33:34 2012
> New Revision: 1417871
> 
> URL: http://svn.apache.org/viewvc?rev=1417871&view=rev
> Log:
> LUCENE-4588 (cont): (EnwikiContentSource fixes) avoid using the forbidden
> StringBufferInputStream..
> 
> Modified:
> 
> lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchma
> rk/byTask/feeds/EnwikiContentSourceTest.java
> 
> Modified:
> lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchma
> rk/byTask/feeds/EnwikiContentSourceTest.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/benchmark/src/tes
> t/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSourceTest.ja
> va?rev=1417871&r1=1417870&r2=1417871&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchma
> rk/byTask/feeds/EnwikiContentSourceTest.java (original)
> +++
> lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchma
> +++ rk/byTask/feeds/EnwikiContentSourceTest.java Thu Dec  6 13:33:34
> +++ 2012
> @@ -17,14 +17,17 @@ package org.apache.lucene.benchmark.byTa
>   * limitations under the License.
>   */
> 
> +import java.io.ByteArrayInputStream;
> +import java.io.ByteArrayOutputStream;
>  import java.io.IOException;
>  import java.io.InputStream;
> +import java.io.OutputStreamWriter;
>  import java.text.ParseException;
>  import java.util.Properties;
> 
>  import org.apache.lucene.benchmark.byTask.utils.Config;
> +import org.apache.lucene.util.IOUtils;
>  import org.apache.lucene.util.LuceneTestCase;
> -import org.junit.Ignore;
>  import org.junit.Test;
> 
>  public class EnwikiContentSourceTest extends LuceneTestCase { @@ -38,10
> +41,16 @@ public class EnwikiContentSourceTest ext
>        this.docs = docs;
>      }
> 
> -    @SuppressWarnings("deprecation") // fine for the characters used in this
> test
>      @Override
>      protected InputStream openInputStream() throws IOException {
> -      return new java.io.StringBufferInputStream(docs);
> +      // StringBufferInputStream would have been handy, but it is forbidden
> +      ByteArrayOutputStream baos = new ByteArrayOutputStream();
> +      OutputStreamWriter w = new OutputStreamWriter(baos,
> IOUtils.CHARSET_UTF_8);
> +      w.write(docs);
> +      w.close();
> +      byte[] byteArray = baos.toByteArray();
> +      baos.close();
> +      return new ByteArrayInputStream(byteArray);
>      }
> 
>    }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to