Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2A0CA7F1D for ; Mon, 18 Jul 2011 19:54:06 +0000 (UTC) Received: (qmail 81676 invoked by uid 500); 18 Jul 2011 19:54:05 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 81496 invoked by uid 500); 18 Jul 2011 19:54:05 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 81488 invoked by uid 99); 18 Jul 2011 19:54:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jul 2011 19:54:04 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 209.85.220.171 as permitted sender) Received: from [209.85.220.171] (HELO mail-vx0-f171.google.com) (209.85.220.171) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jul 2011 19:53:58 +0000 Received: by vxh11 with SMTP id 11so2953449vxh.30 for ; Mon, 18 Jul 2011 12:53:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=3mwbuxq6+Ez1BSm0eUkUkCBice+qzsdXq708DWwv+98=; b=CAFaF4wpSsxVfXrXQ/nSkSkPhtdYYnRtpZJ+Ay4EUT0MwQYgcel0WjR7M2R8x7fD9T vaHmztDu0yyM1M8mdOc6uMQ+NFP0fASvcuVTVgckNXfEkGWDuK3XYBDXaZbt//txPZcd u3y/8rwCgE6iMxxRbsr0wS9ATJm1mm9f02m3I= MIME-Version: 1.0 Received: by 10.220.148.8 with SMTP id n8mr1835431vcv.135.1311018817007; Mon, 18 Jul 2011 12:53:37 -0700 (PDT) Received: by 10.220.162.85 with HTTP; Mon, 18 Jul 2011 12:53:36 -0700 (PDT) In-Reply-To: References: <20110718145115.5A0CE23889B2@eris.apache.org> Date: Mon, 18 Jul 2011 20:53:36 +0100 Message-ID: Subject: Re: svn commit: r1147907 - /commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java From: sebb To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 18 July 2011 18:19, Gary Gregory wrote: > On Mon, Jul 18, 2011 at 1:11 PM, sebb wrote: > >> On 18 July 2011 15:51, =A0 wrote: >> > Author: ggregory >> > Date: Mon Jul 18 14:51:14 2011 >> > New Revision: 1147907 >> > >> > URL: http://svn.apache.org/viewvc?rev=3D1147907&view=3Drev >> > Log: >> > Tests https://issues.apache.org/jira/browse/IO-277 (@Ignore'd). Port t= o >> JUnit 4. >> > >> > Modified: >> > >> =A0commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/Rea= derInputStreamTest.java >> > >> > Modified: >> commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/Reader= InputStreamTest.java >> > URL: >> http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/a= pache/commons/io/input/ReaderInputStreamTest.java?rev=3D1147907&r1=3D114790= 6&r2=3D1147907&view=3Ddiff >> > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> > --- >> commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/Reader= InputStreamTest.java >> (original) >> > +++ >> commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/Reader= InputStreamTest.java >> Mon Jul 18 14:51:14 2011 >> > @@ -16,13 +16,19 @@ >> > =A0*/ >> > =A0package org.apache.commons.io.input; >> > >> > +import static org.junit.Assert.assertEquals; >> > +import static org.junit.Assert.assertTrue; >> > + >> > +import java.io.CharArrayReader; >> > =A0import java.io.IOException; >> > =A0import java.io.StringReader; >> > +import java.nio.charset.Charset; >> > =A0import java.util.Random; >> > >> > -import junit.framework.TestCase; >> > +import org.junit.Ignore; >> > +import org.junit.Test; >> > >> > -public class ReaderInputStreamTest extends TestCase { >> > +public class ReaderInputStreamTest { >> > =A0 =A0 private static final String TEST_STRING =3D "\u00e0 peine arri= v\u00e9s >> nous entr\u00e2mes dans sa chambre"; >> > =A0 =A0 private static final String LARGE_TEST_STRING; >> > >> > @@ -73,29 +79,61 @@ public class ReaderInputStreamTest exten >> > =A0 =A0 =A0 =A0 } >> > =A0 =A0 } >> > >> > + =A0 =A0@Test >> > =A0 =A0 public void testUTF8WithSingleByteRead() throws IOException { >> > =A0 =A0 =A0 =A0 testWithSingleByteRead(TEST_STRING, "UTF-8"); >> > =A0 =A0 } >> > >> > + =A0 =A0@Test >> > =A0 =A0 public void testLargeUTF8WithSingleByteRead() throws IOExcepti= on { >> > =A0 =A0 =A0 =A0 testWithSingleByteRead(LARGE_TEST_STRING, "UTF-8"); >> > =A0 =A0 } >> > >> > + =A0 =A0@Test >> > =A0 =A0 public void testUTF8WithBufferedRead() throws IOException { >> > =A0 =A0 =A0 =A0 testWithBufferedRead(TEST_STRING, "UTF-8"); >> > =A0 =A0 } >> > >> > + =A0 =A0@Test >> > =A0 =A0 public void testLargeUTF8WithBufferedRead() throws IOException= { >> > =A0 =A0 =A0 =A0 testWithBufferedRead(LARGE_TEST_STRING, "UTF-8"); >> > =A0 =A0 } >> > >> > + =A0 =A0@Test >> > =A0 =A0 public void testUTF16WithSingleByteRead() throws IOException { >> > =A0 =A0 =A0 =A0 testWithSingleByteRead(TEST_STRING, "UTF-16"); >> > =A0 =A0 } >> > >> > + =A0 =A0@Test >> > =A0 =A0 public void testReadZero() throws Exception { >> > =A0 =A0 =A0 =A0 ReaderInputStream r =3D new ReaderInputStream(new >> StringReader("test")); >> > =A0 =A0 =A0 =A0 byte[] bytes =3D new byte[30]; >> > =A0 =A0 =A0 =A0 assertEquals(0, r.read(bytes, 0, 0)); >> > =A0 =A0 } >> > + >> > + =A0 =A0/** >> > + =A0 =A0 * Tests https://issues.apache.org/jira/browse/IO-277 >> > + =A0 =A0 * >> > + =A0 =A0 * @throws IOException >> > + =A0 =A0 */ >> > + =A0 =A0@Test >> > + =A0 =A0@Ignore >> > + =A0 =A0public void testCharsetMismatchInfiniteLoop() throws IOExcept= ion { >> > + =A0 =A0 =A0 =A0// Input is UTF-8 bytes: 0xE0 0xB2 0xA0 >> > + =A0 =A0 =A0 =A0byte[] input =3D new byte[] { (byte) 0xE0, (byte) 0xB= 2, (byte) >> 0xA0 }; >> > + =A0 =A0 =A0 =A0char[] inputChars =3D new char[] { (char) 0xE0, (char= ) 0xB2, >> (char) 0xA0 }; >> > + =A0 =A0 =A0 =A0System.out.println("Input: " + new String(input, >> Charset.forName("UTF-8"))); >> >> This does not compile on Java 1.5, because the ctor is 1.6+. >> >> Could use >> >> System.out.println("Input: " + new String(input, "UTF-8")); >> >> instead, but tests should not have unnecessary output. >> >> I suggest deleting "input" and the println statement. >> > > Good catch, thank you Sebb. In SVN now. Actually it was Continuum that alerted me to the issue ... > > Gary > > >> >> > + >> > + =A0 =A0 =A0 =A0// Charset charset =3D Charset.forName("UTF-8"); // w= orks >> > + =A0 =A0 =A0 =A0Charset charset =3D Charset.forName("ASCII"); // infi= nite loop >> > + >> > + =A0 =A0 =A0 =A0ReaderInputStream stream =3D new ReaderInputStream(ne= w >> CharArrayReader(inputChars), charset); >> > + =A0 =A0 =A0 =A0try { >> > + =A0 =A0 =A0 =A0 =A0 =A0while (stream.read() !=3D -1) { >> > + =A0 =A0 =A0 =A0 =A0 =A0} >> > + =A0 =A0 =A0 =A0} finally { >> > + =A0 =A0 =A0 =A0 =A0 =A0stream.close(); >> > + =A0 =A0 =A0 =A0} >> > + >> > + =A0 =A0} >> > =A0} >> > >> > >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> For additional commands, e-mail: dev-help@commons.apache.org >> >> > > > -- > Thank you, > Gary > > http://garygregory.wordpress.com/ > http://garygregory.com/ > http://people.apache.org/~ggregory/ > http://twitter.com/GaryGregory > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org