harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stepan Mishura" <stepan.mish...@gmail.com>
Subject Re: [classlib][luni] Compatibility: Default buf size of BufferedOutputStream
Date Thu, 17 Aug 2006 08:03:09 GMT
On 8/17/06, Richard Liang  wrote:

> Hello All,
>
> One test case tests.api.java.io.BufferedOutputStreamTest.test_write$BII
> fails on RI (passes on Harmony) because the default buf size between RI
> and Harmony are different. The default buf size is not specified in the
> Java Specification.  If we can detect what the default buf size of RI is
> by some test cases, shall we use the same default buf size as RI? Any
> comments? Thanks a lot.


At first glance, the test is wrong - it shouldn't rely on default buffer
size and it should explicitly specify what the buffer size is by using:
BufferedOutputStream(OutputStream out, int size)
    Parameters:
        out - the underlying output stream.
        size - the buffer size.

Thanks,
Stepan.


>    public void test_write$BII() {
>        // Test for method void java.io.BufferedOutputStream.write(byte
> [], int,
>        // int)
>        try {
>            os = new java.io.BufferedOutputStream(
>                    baos = new java.io.ByteArrayOutputStream());
>            os.write(fileString.getBytes(), 0, 500);
>            bais = new java.io.ByteArrayInputStream(baos.toByteArray());
>            assertEquals("Bytes written, not buffered", 0,
> bais.available());
>            os.flush();
>            bais = new java.io.ByteArrayInputStream(baos.toByteArray());
>            assertEquals("Bytes not written after flush", 500,
> bais.available());
>            os.write(fileString.getBytes(), 500, 513);
>            bais = new java.io.ByteArrayInputStream(baos.toByteArray());
>            assertTrue("Bytes not written when buffer full",
>                    bais.available() >= 1000);
>            byte[] wbytes = new byte[1013];
>            bais.read(wbytes, 0, 1013);
>            assertTrue("Incorrect bytes written",
> fileString.substring(0, 1013)
>                    .equals(new String(wbytes, 0, wbytes.length)));
>        } catch (java.io.IOException e) {
>            fail("Flush test failed");
>        }
>
>    }
>
> --
> Richard Liang
> China Software Development Lab, IBM
>
>
------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message