@Test
public void testCloseAll() {

    TestCloseable[] closeablesWithoutException = TestCloseable.createCloseables(false, false, false);
    try {
        Utils.closeAll(closeablesWithoutException);
        TestCloseable.checkClosed(closeablesWithoutException);
    } catch (IOException e) {
        fail("Unexpected exception: " + e);
    }
    TestCloseable[] closeablesWithException = TestCloseable.createCloseables(true, true, true);
    try {
        Utils.closeAll(closeablesWithException);
        fail("Expected exception not thrown");
    } catch (IOException e) {
        TestCloseable.checkClosed(closeablesWithException);
        TestCloseable.checkException(e, closeablesWithException);
    }
    TestCloseable[] singleExceptionCloseables = TestCloseable.createCloseables(false, true, false);
    try {
        Utils.closeAll(singleExceptionCloseables);
        fail("Expected exception not thrown");
    } catch (IOException e) {
        TestCloseable.checkClosed(singleExceptionCloseables);
        TestCloseable.checkException(e, singleExceptionCloseables[1]);
    }
    TestCloseable[] mixedCloseables = TestCloseable.createCloseables(false, true, false, true, true);
    try {
        Utils.closeAll(mixedCloseables);
        fail("Expected exception not thrown");
    } catch (IOException e) {
        TestCloseable.checkClosed(mixedCloseables);
        TestCloseable.checkException(e, mixedCloseables[1], mixedCloseables[3], mixedCloseables[4]);
    }
}