RevBlob id = tr.blob(data);
tr.branch("master").commit().add("A", id).create();
tr.packAndPrune();
assertTrue("has blob", wc.has(id));
ObjectLoader ol = wc.open(id);
assertNotNull("created loader", ol);
assertEquals(type, ol.getType());
assertEquals(data.length, ol.getSize());
assertTrue("is large", ol.isLarge());
try {
ol.getCachedBytes();
fail("Should have thrown LargeObjectException");
} catch (LargeObjectException tooBig) {
assertEquals(MessageFormat.format(
JGitText.get().largeObjectException, id.name()), tooBig
.getMessage());
}
ObjectStream in = ol.openStream();
assertNotNull("have stream", in);
assertEquals(type, in.getType());
assertEquals(data.length, in.getSize());
byte[] data2 = new byte[data.length];
IO.readFully(in, data2, 0, data.length);