Skip to content

Commit 61caea1

Browse files
committed
Fix compiler warnings
Access static methods on the class that define them
1 parent 73c1a31 commit 61caea1

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/test/java/org/apache/commons/io/IOUtilsTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
import org.junit.jupiter.params.ParameterizedTest;
9797
import org.junit.jupiter.params.provider.Arguments;
9898
import org.junit.jupiter.params.provider.MethodSource;
99+
import org.mockito.ArgumentMatchers;
99100
import org.mockito.MockedStatic;
100101
import org.mockito.Mockito;
101102

@@ -1731,17 +1732,19 @@ void testToByteArray_String() throws Exception {
17311732
}
17321733

17331734
@Test
1734-
void testToByteArray_ThrowsIOExceptionOnHugeStream() {
1735-
try (MockedStatic<IOUtils> utils = Mockito.mockStatic(IOUtils.class, Mockito.CALLS_REAL_METHODS)) {
1735+
void testToByteArray_ThrowsIOExceptionOnHugeStream() throws IOException {
1736+
try (MockedStatic<IOUtils> utils = Mockito.mockStatic(IOUtils.class, Mockito.CALLS_REAL_METHODS);
1737+
UnsynchronizedByteArrayOutputStream mockOutputStream = mock(UnsynchronizedByteArrayOutputStream.class)) {
17361738
// Prepare the mocks
1737-
final UnsynchronizedByteArrayOutputStream mockOutputStream = mock(UnsynchronizedByteArrayOutputStream.class);
1738-
utils.when(() -> IOUtils.copyToOutputStream(Mockito.any(InputStream.class), Mockito.anyLong(), Mockito.anyInt())).thenReturn(mockOutputStream);
1739+
utils.when(() -> IOUtils.copyToOutputStream(ArgumentMatchers.any(InputStream.class), ArgumentMatchers.anyLong(), ArgumentMatchers.anyInt()))
1740+
.thenReturn(mockOutputStream);
17391741
when(mockOutputStream.size()).thenReturn(IOUtils.SOFT_MAX_ARRAY_LENGTH + 1);
17401742
// Test and check
1741-
final InputStream mockInputStream = mock(InputStream.class);
1742-
final IOException exception = assertThrows(IOException.class, () -> IOUtils.toByteArray(mockInputStream));
1743-
assertTrue(exception.getMessage().contains(String.format("%,d", IOUtils.SOFT_MAX_ARRAY_LENGTH)),
1744-
"Exception message does not contain the maximum length");
1743+
try (InputStream mockInputStream = mock(InputStream.class)) {
1744+
final IOException exception = assertThrows(IOException.class, () -> IOUtils.toByteArray(mockInputStream));
1745+
assertTrue(exception.getMessage().contains(String.format("%,d", IOUtils.SOFT_MAX_ARRAY_LENGTH)),
1746+
"Exception message does not contain the maximum length");
1747+
}
17451748
}
17461749
}
17471750

0 commit comments

Comments
 (0)