You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/09/12 21:32:46 UTC

[commons-io] 02/02: Fix test on Java > 8

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit f984567112e03d4b6e420597b8bbb9db2c70230c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 12 14:32:39 2022 -0700

    Fix test on Java > 8
---
 .../org/apache/commons/io/function/IOIteratorAdapterTest.java  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/function/IOIteratorAdapterTest.java b/src/test/java/org/apache/commons/io/function/IOIteratorAdapterTest.java
index d4fa89e3..b298d72e 100644
--- a/src/test/java/org/apache/commons/io/function/IOIteratorAdapterTest.java
+++ b/src/test/java/org/apache/commons/io/function/IOIteratorAdapterTest.java
@@ -28,6 +28,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.commons.lang3.JavaVersion;
+import org.apache.commons.lang3.SystemUtils;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -49,7 +51,6 @@ public class IOIteratorAdapterTest {
 
     @Test
     public void testAdapt() throws IOException {
-        iterator = IOIteratorAdapter.adapt(newPathList().iterator());
         assertEquals(TestConstants.ABS_PATH_A, iterator.next());
     }
 
@@ -80,9 +81,14 @@ public class IOIteratorAdapterTest {
 
     @Test
     public void testRemove() throws IOException {
-        assertThrows(IllegalStateException.class, iterator::remove);
+        final Class<? extends Exception> exClass = SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_1_8) ? IllegalStateException.class
+            : UnsupportedOperationException.class;
+        assertThrows(exClass, iterator::remove);
+        assertThrows(exClass, iterator::remove);
         iterator.next();
         assertThrows(UnsupportedOperationException.class, iterator::remove);
+        assertThrows(UnsupportedOperationException.class, iterator::remove);
+
     }
 
 }