List of usage examples for org.eclipse.jgit.errors LargeObjectException LargeObjectException
public LargeObjectException()
From source file:org.gitective.tests.BlobUtilsTest.java
License:Open Source License
/** * Test getting blob content with object load that throws a * {@link LargeObjectException}//from w ww . j av a 2 s . co m * * @throws Exception */ @Test public void largeLoader() throws Exception { add("test.txt", "content"); final AtomicReference<AbbreviatedObjectId> blob = new AtomicReference<AbbreviatedObjectId>(); CommitDiffFilter diffs = new CommitDiffFilter() { public boolean include(RevCommit commit, Collection<DiffEntry> diffs) { blob.set(diffs.iterator().next().getNewId()); return true; } }; new CommitFinder(testRepo).setFilter(diffs).find(); assertNotNull(blob.get()); Repository repo = new FileRepository(testRepo) { public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException { final ObjectLoader loader = super.open(objectId, typeHint); return new ObjectLoader() { public ObjectStream openStream() throws MissingObjectException, IOException { return loader.openStream(); } public int getType() { return loader.getType(); } public long getSize() { return loader.getSize(); } public byte[] getCachedBytes() throws LargeObjectException { throw new LargeObjectException(); } }; } }; assertEquals("content", BlobUtils.getContent(repo, blob.get().toObjectId())); }