diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-02-18 19:51:38 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-02-18 19:51:38 +0000 |
commit | 505ad633296cd45757090c3e4f392dad640bf4e6 (patch) | |
tree | 765c6cd7d754525eecf9adf730280f509ec1897e /harmony-tests | |
parent | 3af45d9bad0c3e0b9efb693774294d6e550002f7 (diff) | |
parent | 3aeb68a55c055261862498e22f34884fde9c164c (diff) |
Merge "ConcurrentModificationException: Add test coverage for message, cause."
Diffstat (limited to 'harmony-tests')
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ConcurrentModificationExceptionTest.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ConcurrentModificationExceptionTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ConcurrentModificationExceptionTest.java index 2bbcd1e18a..cadb38f92a 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ConcurrentModificationExceptionTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ConcurrentModificationExceptionTest.java @@ -91,6 +91,23 @@ public class ConcurrentModificationExceptionTest extends fail("Failed to throw expected ConcurrentModificationException"); } + @SuppressWarnings("ThrowableNotThrown") + public void test_messageAndCause() { + Throwable cause = new Throwable("cause msg"); + assertMessageAndCause(null, null, new ConcurrentModificationException()); + assertMessageAndCause("msg", null, new ConcurrentModificationException("msg")); + assertMessageAndCause("msg", cause, new ConcurrentModificationException("msg", cause)); + assertMessageAndCause("msg", null, new ConcurrentModificationException("msg", null)); + assertMessageAndCause(null, null, new ConcurrentModificationException((Throwable) null)); + // cause.toString() is something like "java.lang.Throwable: cause msg" + assertMessageAndCause(cause.toString(), cause, new ConcurrentModificationException(cause)); + } + + private static void assertMessageAndCause(String message, Throwable cause, Exception e) { + assertEquals(message, e.getMessage()); + assertEquals(cause, e.getCause()); + } + /** * Sets up the fixture, for example, open a network connection. This method * is called before a test is executed. |