Updated Branches: refs/heads/master 5c4bcca2f -> ac00999cc
Fixed issue with the test. When test generated a zero length file it would still try to random access read it. Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/ac00999c Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/ac00999c Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/ac00999c Branch: refs/heads/master Commit: ac00999cce0071f11d421da90a44012801f0f229 Parents: 5c4bcca Author: Aaron McCurry <[email protected]> Authored: Mon Jul 29 09:21:36 2013 -0400 Committer: Aaron McCurry <[email protected]> Committed: Mon Jul 29 09:21:36 2013 -0400 ---------------------------------------------------------------------- .../store/blockcache/BlockDirectoryTest.java | 34 +++++++++----------- 1 file changed, 16 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ac00999c/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryTest.java ---------------------------------------------------------------------- diff --git a/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryTest.java b/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryTest.java index f2ef236..7702b97 100644 --- a/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryTest.java +++ b/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryTest.java @@ -24,10 +24,6 @@ import java.io.IOException; import java.util.Map; import java.util.Random; -import javax.jws.Oneway; - -import org.apache.blur.store.blockcache.BlockDirectory; -import org.apache.blur.store.blockcache.Cache; import org.apache.blur.store.buffer.BufferStore; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; @@ -172,21 +168,23 @@ public class BlockDirectoryTest { IndexInput hdfsInput = hdfs.openInput(name, IOContext.DEFAULT); assertEquals(fsInput.length(), hdfsInput.length()); int fileLength = (int) fsInput.length(); - for (int i = 0; i < reads; i++) { - byte[] fsBuf = new byte[random.nextInt(Math.min(MAX_BUFFER_SIZE - MIN_BUFFER_SIZE, fileLength)) + MIN_BUFFER_SIZE]; - byte[] hdfsBuf = new byte[fsBuf.length]; - int offset = random.nextInt(fsBuf.length); - int length = random.nextInt(fsBuf.length - offset); - int pos = random.nextInt(fileLength - length); - fsInput.seek(pos); - fsInput.readBytes(fsBuf, offset, length); - hdfsInput.seek(pos); - hdfsInput.readBytes(hdfsBuf, offset, length); - for (int f = offset; f < length; f++) { - if (fsBuf[f] != hdfsBuf[f]) { - fail(Long.toString(seed) + " read [" + i + "]"); + if (fileLength != 0) { + for (int i = 0; i < reads; i++) { + byte[] fsBuf = new byte[random.nextInt(Math.min(MAX_BUFFER_SIZE - MIN_BUFFER_SIZE, fileLength)) + MIN_BUFFER_SIZE]; + byte[] hdfsBuf = new byte[fsBuf.length]; + int offset = random.nextInt(fsBuf.length); + int length = random.nextInt(fsBuf.length - offset); + int pos = random.nextInt(fileLength - length); + fsInput.seek(pos); + fsInput.readBytes(fsBuf, offset, length); + hdfsInput.seek(pos); + hdfsInput.readBytes(hdfsBuf, offset, length); + for (int f = offset; f < length; f++) { + if (fsBuf[f] != hdfsBuf[f]) { + fail(Long.toString(seed) + " read [" + i + "]"); + } } - } + } } fsInput.close(); hdfsInput.close();
