harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vijay Yellapragada <yell...@earthlink.net>
Subject Re: [classlib][luni] Compatibility: Default buf size of BufferedOutputStream
Date Thu, 17 Aug 2006 07:01:07 GMT
Hi,

Buffer Size is definitely implementation dependent.

The test should be re done so that it doesn't assume the size of the buffer.

A simple way to structure the test would be :-

- Create a Sub class of BufferedOutputStream.
- Since count and buf have protected access in BufferedOutputStream, 
subclassing will allow us to get access to those values.

Once you have the sub class it is now straight forward to determine the 
default size of the buffer and the test becomes much simpler in fact...

Hope that helps..

Thanks,
Vijay

Andrew Zhang wrote:
> I think it's implementation detail. Any default buffer size is 
> acceptable as
> long as complying with spec.
>
> Of course, if  Harmony's default size is equal with RI's by accident, 
> it's
> good. :)
>
> So the problem is test, not implementation code. I suggest modify the 
> test
> even if we "fix" our default size in the code.
>
> And if some applications are heaviliy dependent on the default size and
> refuse to fix their code, I guess they won't become popular. :) 
> Applications
> can take the advantage of the default size, but not to be dependent on 
> them.
> :)
>
> On 8/17/06, Richard Liang <richard.liangyx@gmail.com> 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.
>>
>>    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
View raw message