#4 MockOutputStream needs to return byte[ ]

closed-fixed
None
5
2002-07-08
2002-04-21
Dale King
No

The getContents method of MockOutputStream is taking
the bytes that have been written and converting that
to a string using the platform default encoding. This
is the only way to access what has been written.

This is plain wrong. It should be returning the
contents as a byte array. The data written may be
binary data, not textual data. The conversion to a
String will differ from one platform as you are using
the platform default encoding. On Windows the
conversion from bytes to String is not even lossless.
There are certain characters in the range 0x80 to 0x9F
do not exist in the platform and will get mapped to
\uFFFD. None of the bytes in that range gets mapped to
the a character of the same value.

A method to get the data as a byte array needs to be
provided either instead of or in addition to a method
to get it as text. If you provide a means to get it as
text it should be overloaded to also accept an
encoding parameter. But the string methods are really
unnecessary as you can create a String from the byte
array easily.

Discussion

  • Steve Freeman

    Steve Freeman - 2002-07-08
    • assigned_to: nobody --> smgf
    • status: open --> closed-fixed
     
  • Steve Freeman

    Steve Freeman - 2002-07-08

    Logged In: YES
    user_id=123464

    Fixed and released to CVS

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks