Skip to content

Commit 8376a59

Browse files
committed
DataHandleTest: allow for handles with unknown length
Some handles don't know their length and instead return -1, this commit adds an option to the length check to assure this.
1 parent 2f54eed commit 8376a59

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/test/java/org/scijava/io/handle/DataHandleTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void testEndianesSettings() throws IOException {
113113
@Test
114114
public void testReading() throws IOException {
115115
try (final DataHandle<? extends Location> handle = createHandle()) {
116-
checkBasicReadMethods(handle);
116+
checkBasicReadMethods(handle, true);
117117
checkEndiannessReading(handle);
118118
}
119119
}
@@ -168,13 +168,14 @@ public void populateData(final OutputStream out) throws IOException {
168168
* Checks basic byte reading methods.
169169
*
170170
* @param handle the handle to test
171+
* @param lengthKnown whether the length of the handle is know
171172
* @throws IOException
172173
*/
173174
public <L extends Location> void checkBasicReadMethods(
174-
final DataHandle<L> handle) throws IOException
175+
final DataHandle<L> handle, boolean lengthKnown) throws IOException
175176
{
176177
assertEquals(0, handle.offset());
177-
assertEquals(BYTES.length, handle.length());
178+
assertEquals(lengthKnown ? BYTES.length : -1, handle.length());
178179
assertEquals("UTF-8", handle.getEncoding());
179180

180181
// test read()

src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void testSmallBuffer() throws IOException {
6464
new ReadBufferDataHandle(handle, 5))
6565
{
6666
// check with small buffersize
67-
checkBasicReadMethods(bufferedHandle);
67+
checkBasicReadMethods(bufferedHandle, true);
6868
checkEndiannessReading(bufferedHandle);
6969
}
7070
}
@@ -127,7 +127,6 @@ public void testLargeRead() throws Exception {
127127
}
128128

129129
@Test
130-
@Ignore
131130
@Override
132131
public void testWriting() throws IOException {
133132
// nothing to do here

src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ public DataHandle<? extends Location> createHandle() {
6464
}
6565

6666
@Test
67-
@Ignore
6867
@Override
6968
public void testReading() throws IOException {
7069
// nothing to do
7170
}
7271

7372
@Test
74-
@Ignore
7573
@Override
7674
public void checkSkip() throws IOException {
7775
// nothing to do

0 commit comments

Comments
 (0)