summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2019-02-15 22:37:46 +0000
committerTobias Thierer <tobiast@google.com>2019-02-18 16:35:28 +0000
commit3aeb68a55c055261862498e22f34884fde9c164c (patch)
tree609bdbc3b60ea8eb0e11b7d0e0243cb1b20b87a4
parent233de2b7107880b2d3774d70941bde4c842769e5 (diff)
ConcurrentModificationException: Add test coverage for message, cause.
Adding such coverage for other exceptions is left to follow-up CLs. Test: atest CtsLibcoreTestCases:org.apache.harmony.tests.java.util.ConcurrentModificationExceptionTest Change-Id: I5c02571c63d5a2203b4aa0a49e4348304e40eca2
-rw-r--r--harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ConcurrentModificationExceptionTest.java17
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.