Fix 58 libcore tests that caught "expected" Exceptions but didn't fail()
There were no changes to code under test.
4 tests were fixed to not tolerate an Exception:
- libcore.java.util.CollectionsTest#test_CheckedMap_computeIfAbsent
In the case where a Map key is present, computeIfAbsent() should
not invoke the Function, so there is no return value that could
be expected to undergo a type check. The test was changed to
verify that the Function is not invoked.
- libcore.java.util.concurrent.CopyOnWriteArrayListTest#test_sort and
libcore.java.util.concurrent.CopyOnWriteArrayListTest#test_subList_sort
were sorting an already-sorted non-null list that contains no null
values. That logic was redundant and wouldn't have thrown.
- org.apache.harmony.security.tests.java.security.KeyStoreSpiTest#test_engineEntryInstanceOf
(the KeyStoreSpi documentation does not mention whether NPE is thrown;
the implementation comes from upstream and does not throw it).
54 tests were fixed by adding the missing
fail();
No attempt was made to make this failure message specific to the
exception that was expected.
Tests that weren't changed:
- SSLEngineTest.test_wrap_ByteBuffer_ByteBuffer_04() requires
investigation to determine the correct resolution.
A comment was added to the test linking to the corresponding bug.
- ThreadTest#testParkUntilWithUnderflowValue() and
OldNodeChangeEventTest.waitForEvent() were not touched since
it was not clear whether that it was relevent to the test whether
or not the exception was thrown.
- two cases in Files2Test#test_setPosixFilePermissions_NPE() are
left to a future CL
Test:
(croot; make vogar core-tests) \
&& git diff aosp/master --name-only | xargs vogar `cparg core-tests`
Change-Id: I1cd3220a06e331ff049b146b393f78879f07211a
31 files changed