/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.io.input;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.io.Reader;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
 * JUnit Test Case for {@link BrokenReader}.
 */
@SuppressWarnings("ResultOfMethodCallIgnored")
public class BrokenReaderTest {

    private IOException exception;

    private Reader brokenReader;

    @BeforeEach
    public void setUp() {
        exception = new IOException("test exception");
        brokenReader = new BrokenReader(exception);
    }

    @Test
    public void testClose() {
        try {
            brokenReader.close();
            fail("Expected exception not thrown.");
        } catch (final IOException e) {
            assertEquals(exception, e);
        }
    }

    @Test
    public void testInstance() {
        assertNotNull(BrokenReader.INSTANCE);
    }

    @Test
    public void testMark() {
        try {
            brokenReader.mark(1);
            fail("Expected exception not thrown.");
        } catch (final IOException e) {
            assertEquals(exception, e);
        }
    }

    @Test
    public void testRead() {
        try {
            brokenReader.read();
            fail("Expected exception not thrown.");
        } catch (final IOException e) {
            assertEquals(exception, e);
        }

        try {
            brokenReader.read(new char[1]);
            fail("Expected exception not thrown.");
        } catch (final IOException e) {
            assertEquals(exception, e);
        }

        try {
            brokenReader.read(new char[1], 0, 1);
            fail("Expected exception not thrown.");
        } catch (final IOException e) {
            assertEquals(exception, e);
        }
    }

    @Test
    public void testReady() {
        try {
            brokenReader.ready();
            fail("Expected exception not thrown.");
        } catch (final IOException e) {
            assertEquals(exception, e);
        }
    }

    @Test
    public void testReset() {
        try {
            brokenReader.reset();
            fail("Expected exception not thrown.");
        } catch (final IOException e) {
            assertEquals(exception, e);
        }
    }

    @Test
    public void testSkip() {
        try {
            brokenReader.skip(1);
            fail("Expected exception not thrown.");
        } catch (final IOException e) {
            assertEquals(exception, e);
        }
    }

}

@@ -1004,20 +1004,28 @@
 ertions.
-fail
+assertThrows
 ;%0A%0Aimpor
@@ -1205,55 +1205,8 @@
  */%0A
-@SuppressWarnings(%22ResultOfMethodCallIgnored%22)%0A
 publ
@@ -1512,593 +1512,445 @@
     
-try %7B%0A            brokenReader.close();%0A            fail(%22Expected exception not thrown.%22);%0A        %7D catch (final IOException e) %7B%0A            assertEquals(exception, e);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testInstance() %7B%0A        assertNotNull(BrokenReader.INSTANCE);%0A    %7D%0A%0A    @Test%0A    public void testMark() %7B%0A        try %7B%0A            brokenReader.mark(1);%0A            fail(%22Expected exception not thrown.%22);%0A        %7D catch (final IOException e) %7B%0A            assertEquals(exception, e);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testRead() %7B%0A        try %7B%0A           
+assertEquals(exception, assertThrows(IOException.class, () -%3E brokenReader.close()));%0A    %7D%0A%0A    @Test%0A    public void testInstance() %7B%0A        assertNotNull(BrokenReader.INSTANCE);%0A    %7D%0A%0A    @Test%0A    public void testMark() %7B%0A        assertEquals(exception, assertThrows(IOException.class, () -%3E brokenReader.mark(1)));%0A    %7D%0A%0A    @Test%0A    public void testRead() %7B%0A        assertEquals(exception, assertThrows(IOException.class, () -%3E
  bro
@@ -1969,178 +1969,136 @@
 ad()
+))
 ;%0A    
+%7D%0A%0A
     
-    fail(%22Expected exception not thrown.%22);%0A        %7D catch (final IOException e) %7B%0A            assertEquals(exception, e);%0A        %7D%0A%0A        try %7B%0A           
+@Test%0A    public void testReadCharArray() %7B%0A        assertEquals(exception, assertThrows(IOException.class, () -%3E
  bro
@@ -2128,1068 +2128,605 @@
 %5B1%5D)
+))
 ;%0A    
+%7D%0A%0A
     
-    fail(%22Expected exception not thrown.%22);%0A        %7D catch (final IOException e) %7B%0A            assertEquals(exception, e);%0A        %7D%0A%0A        try %7B%0A            brokenReader.read(new char%5B1%5D, 0, 1);%0A            fail(%22Expected exception not thrown.%22);%0A        %7D catch (final IOException e) %7B%0A            assertEquals(exception, e);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testReady() %7B%0A        try %7B%0A            brokenReader.ready();%0A            fail(%22Expected exception not thrown.%22);%0A        %7D catch (final IOException e) %7B%0A            assertEquals(exception, e);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testReset() %7B%0A        try %7B%0A            brokenReader.reset();%0A            fail(%22Expected exception not thrown.%22);%0A        %7D catch (final IOException e) %7B%0A            assertEquals(exception, e);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testSkip() %7B%0A        try %7B%0A            brokenReader.skip(1);%0A            fail(%22Expected exception not thrown.%22);%0A        %7D catch (final IOException e) %7B%0A            assertEquals(exception, e);%0A        %7D
+@Test%0A    public void testReadCharArrayIndexed() %7B%0A        assertEquals(exception, assertThrows(IOException.class, () -%3E brokenReader.read(new char%5B1%5D, 0, 1)));%0A    %7D%0A%0A    @Test%0A    public void testReady() %7B%0A        assertEquals(exception, assertThrows(IOException.class, () -%3E brokenReader.ready()));%0A    %7D%0A%0A    @Test%0A    public void testReset() %7B%0A        assertEquals(exception, assertThrows(IOException.class, () -%3E brokenReader.reset()));%0A    %7D%0A%0A    @Test%0A    public void testSkip() %7B%0A        assertEquals(exception, assertThrows(IOException.class, () -%3E brokenReader.skip(1)));
 %0A   

Rewrite test using JUnit 5 APIs.