Skip to content

Commit

Permalink
DataHandleTest: allow for handles with unknown length
Browse files Browse the repository at this point in the history
Some handles don't know their length and instead return -1, this commit
adds an option to the length check to assure this.
  • Loading branch information
gab1one committed Oct 16, 2018
1 parent 2f54eed commit 8376a59
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/test/java/org/scijava/io/handle/DataHandleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void testEndianesSettings() throws IOException {
@Test
public void testReading() throws IOException {
try (final DataHandle<? extends Location> handle = createHandle()) {
checkBasicReadMethods(handle);
checkBasicReadMethods(handle, true);
checkEndiannessReading(handle);
}
}
Expand Down Expand Up @@ -168,13 +168,14 @@ public void populateData(final OutputStream out) throws IOException {
* Checks basic byte reading methods.
*
* @param handle the handle to test
* @param lengthKnown whether the length of the handle is know
* @throws IOException
*/
public <L extends Location> void checkBasicReadMethods(
final DataHandle<L> handle) throws IOException
final DataHandle<L> handle, boolean lengthKnown) throws IOException
{
assertEquals(0, handle.offset());
assertEquals(BYTES.length, handle.length());
assertEquals(lengthKnown ? BYTES.length : -1, handle.length());
assertEquals("UTF-8", handle.getEncoding());

// test read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testSmallBuffer() throws IOException {
new ReadBufferDataHandle(handle, 5))
{
// check with small buffersize
checkBasicReadMethods(bufferedHandle);
checkBasicReadMethods(bufferedHandle, true);
checkEndiannessReading(bufferedHandle);
}
}
Expand Down Expand Up @@ -127,7 +127,6 @@ public void testLargeRead() throws Exception {
}

@Test
@Ignore
@Override
public void testWriting() throws IOException {
// nothing to do here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,12 @@ public DataHandle<? extends Location> createHandle() {
}

@Test
@Ignore
@Override
public void testReading() throws IOException {
// nothing to do
}

@Test
@Ignore
@Override
public void checkSkip() throws IOException {
// nothing to do
Expand Down

0 comments on commit 8376a59

Please sign in to comment.