[ 
https://issues.apache.org/jira/browse/IO-158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12599421#action_12599421
 ] 

hoju edited comment on IO-158 at 5/23/08 9:42 AM:
---------------------------------------------------------

FYI,

I ran org.openide.util.io.ReaderInputStream against the tests in 
org.apache.tools.ant.util.ReaderInputStreamTest (on JDK 1.5.0_15).  It fails 
only the testReadZero() test with the message "expected:<3> but was:<2>".

Below is a copy of said test for quick reference.  Is the test assertion 
correct?  If it is, is this just an esoteric edge case that Ant required, for 
some special reason, or something fundamental that must be accounted for by any 
ReaderInputStream implementation, not just the one in Ant?

{code:title=o.a.tools.ant.util.ReaderInputStreamTest.testReadZero()|borderStyle=solid}
    public void testReadZero() throws Exception
    {
        ReaderInputStream r = new ReaderInputStream(
            new StringReader("abc"));
        byte[] bytes = new byte[30];
        // First read in zero bytes
        r.read(bytes, 0, 0);
        // Now read in the string
        int readin = r.read(bytes, 0, 10);
        // Make sure that the counts are the same
        assertEquals("abc".getBytes().length, readin);
    }
{code}

      was (Author: hoju):
    FYI,

I ran org.openide.util.io.ReaderInputStream against the tests in 
org.apache.tools.ant.util.ReaderInputStreamTest (on JDK 1.5.0_15).  It fails 
only the testReadZero() test with the message "expected:<3> but was:<2>".  
Below is a copy of said test for quick reference.  Is the test assertion 
correct?  If it is, is this just an esoteric edge case that Ant required, for 
some special reason, or something fundamental that must be accounted for by any 
ReaderInputStream implementation, not just the one in Ant?

    public void testReadZero() throws Exception
    {
        ReaderInputStream r = new ReaderInputStream(
            new StringReader("abc"));
        byte[] bytes = new byte[30];
        // First read in zero bytes
        r.read(bytes, 0, 0);
        // Now read in the string
        int readin = r.read(bytes, 0, 10);
        // Make sure that the counts are the same
        assertEquals("abc".getBytes().length, readin);
    }
  
> ReaderInputStream implementation
> --------------------------------
>
>                 Key: IO-158
>                 URL: https://issues.apache.org/jira/browse/IO-158
>             Project: Commons IO
>          Issue Type: Wish
>            Reporter: Andreas Veithen
>            Priority: Minor
>
> The standard Java class InputStreamReader converts a Reader into an 
> InputStream. In some cases it is necessary to do the reverse, i.e. to convert 
> a Reader into an InputStream. Several frameworks and libraries have their own 
> implementation of this functionality (google for "ReaderInputStream"). Among 
> these are at least four Apache projects: Ant, iBatis, James and XMLBeans. 
> Commons IO would be a good place to share a common implementation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to