// create property
String pname = "file@" + testFile.getName();
Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
String update1String = "update#1";
long pos1 = 1024 * 1024;
// update 1
exv.update(new ByteArrayInputStream(update1String.getBytes()), update1String.length(), pos1);
// apply to the Property in another session and save
Session s1 = repository.login(credentials);
try
{
Node troot = s1.getRootNode().getNode(testRoot.getName());
byte[] s1Content = "__string_stream__".getBytes();
p = troot.setProperty(pname, new ByteArrayInputStream(s1Content));
BufferedInputStream exvStream = new BufferedInputStream(exv.getStream());
// fill the buffer from exv
exvStream.mark((int)exv.getLength() + 1);
while ((exvStream.read(new byte[2048])) >= 0)
{
}
exvStream.reset();
p.setValue(exv);
troot.save();
// check if we has the exv value
compareStream(exvStream, troot.getProperty(pname).getStream(), 0, pos1, update1String.length());
String update2String = "UPDATE#2";
long pos2 = (1024 * 1024) + 5;
// update 2
exv.update(new ByteArrayInputStream(update2String.getBytes()), update2String.length(), pos2);
// apply to the Property
p.setValue(exv);
// check the content from the first updated char to the last char of
// second update