// create property, prepare the data to be readed
String pname = "file@" + testFile.getName();
Property p = testRoot.setProperty(pname, new ByteArrayInputStream("short message".getBytes()));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
// read zero bytes
exv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// from begin
long res = exv.read(baos, 0, 0);
assertEquals("Zero bytes must be read", 0, res);
assertEquals("Zero bytes must be read", 0, baos.size());
// from middle
baos = new ByteArrayOutputStream();
res = exv.read(baos, 0, 5);
assertEquals("Zero bytes must be read", 0, res);
assertEquals("Zero bytes must be read", 0, baos.size());
// out of end
try
{
exv.read(baos, 0, exv.getLength() + 10);
fail("The out-of-range exception should be thrown");
}
catch (IOException e)
{
// ok