From 9de55e6a769ad3f0cd642d30a6523dd433a05dc8 Mon Sep 17 00:00:00 2001 From: Gabriel Einsdorf Date: Tue, 16 Oct 2018 11:30:16 +0200 Subject: [PATCH] DataHandleTest: make checkLength in testReading optional Some handles don't know their length, so we need an option to skip the the length check. --- src/test/java/org/scijava/io/handle/DataHandleTest.java | 9 ++++++--- .../org/scijava/io/handle/ReadBufferDataHandleTest.java | 3 +-- .../org/scijava/io/handle/WriteBufferDataHandleTest.java | 2 -- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/scijava/io/handle/DataHandleTest.java b/src/test/java/org/scijava/io/handle/DataHandleTest.java index 7c38e3e1a..f2b7d5a16 100644 --- a/src/test/java/org/scijava/io/handle/DataHandleTest.java +++ b/src/test/java/org/scijava/io/handle/DataHandleTest.java @@ -113,7 +113,7 @@ public void testEndianesSettings() throws IOException { @Test public void testReading() throws IOException { try (final DataHandle handle = createHandle()) { - checkBasicReadMethods(handle); + checkBasicReadMethods(handle, true); checkEndiannessReading(handle); } } @@ -168,13 +168,16 @@ public void populateData(final OutputStream out) throws IOException { * Checks basic byte reading methods. * * @param handle the handle to test + * @param checkLength whether to check the total length of the handle * @throws IOException */ public void checkBasicReadMethods( - final DataHandle handle) throws IOException + final DataHandle handle, boolean checkLength) throws IOException { assertEquals(0, handle.offset()); - assertEquals(BYTES.length, handle.length()); + if (checkLength) { + assertEquals(BYTES.length, handle.length()); + } assertEquals("UTF-8", handle.getEncoding()); // test read() diff --git a/src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java b/src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java index e7cb332f2..9f05bd38b 100644 --- a/src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java +++ b/src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java @@ -64,7 +64,7 @@ public void testSmallBuffer() throws IOException { new ReadBufferDataHandle(handle, 5)) { // check with small buffersize - checkBasicReadMethods(bufferedHandle); + checkBasicReadMethods(bufferedHandle, true); checkEndiannessReading(bufferedHandle); } } @@ -127,7 +127,6 @@ public void testLargeRead() throws Exception { } @Test - @Ignore @Override public void testWriting() throws IOException { // nothing to do here diff --git a/src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java b/src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java index 40f035e3a..6ea468872 100644 --- a/src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java +++ b/src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java @@ -64,14 +64,12 @@ public DataHandle createHandle() { } @Test - @Ignore @Override public void testReading() throws IOException { // nothing to do } @Test - @Ignore @Override public void checkSkip() throws IOException { // nothing to do