{
String part1;
String part2;
String part3;
String reference;
Source source;
char[] buffer;
int length;
part1 = "Now is the time ";
part2 = "for all good men ";
part3 = "to come to the aid of the party";
reference = part1 + part2 + part3;
source = new InputStreamSource (new Stream (new ByteArrayInputStream (reference.getBytes (DEFAULT_CHARSET))), null);
buffer = new char[reference.length ()];
for (int i = 0; i < part1.length (); i++)
buffer[i] = (char)source.read ();
length = source.read (buffer, part1.length (), part2.length ());
assertTrue ("incorrect length", part2.length () == length);
length += part1.length ();
for (int i = 0; i < part3.length (); i++)
buffer[i + length] = (char)source.read ();
assertTrue ("string incorrect", reference.equals (new String (buffer)));
assertTrue ("extra character", -1 == source.read ());
source.close ();
}