harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Liang <richard.lian...@gmail.com>
Subject [classlib][luni] Compatibility: Default buf size of BufferedOutputStream
Date Thu, 17 Aug 2006 02:16:26 GMT
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.

    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 = new java.io.ByteArrayInputStream(baos.toByteArray());
            assertEquals("Bytes not written after flush", 500, 
            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

View raw message