aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/junit/runners/model/TestTimedOutException.java
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2016-12-14 11:49:43 +0000
committerPaul Duffin <paulduffin@google.com>2016-12-20 15:52:52 +0000
commitaeb93fc33cae3aadbb9b46083350ad2dc9aea645 (patch)
treeb316db7dee11d1aeee3510562e036fd41705b8b5 /src/main/java/org/junit/runners/model/TestTimedOutException.java
parent26401927b83770db45f00706ccc589955644c6c2 (diff)
downloadjunit-aeb93fc33cae3aadbb9b46083350ad2dc9aea645.tar.gz
Upgrade to JUnit 4.12
The license has changed from Common Public License v1.0 to Eclipse Public License v1.0. This will not compile as it is because it is intended to be built against Hamcrest 1.3 or later but it is being built against Hamcrest 1.1. A follow on patch will fix the compilation errors so that it builds against Hamcrest 1.1. That allows Hamcrest to be upgraded separately. The patch can be reverted once Hamcrest has been upgraded. There are also some Android specific issues that will also be fixed in follow on patches. Bug: 33613916 Test: make checkbuild Change-Id: Ic2c983a030399e3ace1a14927cb143fbd8307b4f
Diffstat (limited to 'src/main/java/org/junit/runners/model/TestTimedOutException.java')
-rw-r--r--src/main/java/org/junit/runners/model/TestTimedOutException.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/org/junit/runners/model/TestTimedOutException.java b/src/main/java/org/junit/runners/model/TestTimedOutException.java
new file mode 100644
index 0000000..60e1a8a
--- /dev/null
+++ b/src/main/java/org/junit/runners/model/TestTimedOutException.java
@@ -0,0 +1,44 @@
+package org.junit.runners.model;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Exception thrown when a test fails on timeout.
+ *
+ * @since 4.12
+ *
+ */
+public class TestTimedOutException extends Exception {
+
+ private static final long serialVersionUID = 31935685163547539L;
+
+ private final TimeUnit timeUnit;
+ private final long timeout;
+
+ /**
+ * Creates exception with a standard message "test timed out after [timeout] [timeUnit]"
+ *
+ * @param timeout the amount of time passed before the test was interrupted
+ * @param timeUnit the time unit for the timeout value
+ */
+ public TestTimedOutException(long timeout, TimeUnit timeUnit) {
+ super(String.format("test timed out after %d %s",
+ timeout, timeUnit.name().toLowerCase()));
+ this.timeUnit = timeUnit;
+ this.timeout = timeout;
+ }
+
+ /**
+ * Gets the time passed before the test was interrupted
+ */
+ public long getTimeout() {
+ return timeout;
+ }
+
+ /**
+ * Gets the time unit for the timeout value
+ */
+ public TimeUnit getTimeUnit() {
+ return timeUnit;
+ }
+}