This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new 0a1b0f46a [LANG-1832] Improve test coverage for
ObjectUtils.wait(Duration) (#1756)
0a1b0f46a is described below
commit 0a1b0f46a75c9913be9dcfad037230170d24af6b
Author: Maksym Korshun <[email protected]>
AuthorDate: Mon Jul 27 17:26:02 2026 +0200
[LANG-1832] Improve test coverage for ObjectUtils.wait(Duration) (#1756)
* [LANG-1832] Improve test coverage for ObjectUtils.wait(Duration)
* fix: add final keyword for local variables to follow style convention
* Clean up testWaitDuration method
Refactor testWaitDuration to remove unnecessary lines.
---------
Co-authored-by: Gary Gregory <[email protected]>
---
src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
index 8b2584e6d..a7fa2542b 100644
--- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
@@ -889,7 +889,15 @@ void testToString_Supplier_Supplier() {
}
@Test
- void testWaitDuration() {
+ void testWaitDuration() throws InterruptedException {
+ final Object lock = new Object();
+ final long start = System.nanoTime();
+ synchronized (lock) {
+ ObjectUtils.wait(lock, Duration.ofMillis(100));
+ }
+ final long elapsed = System.nanoTime() - start;
+ assertTrue(elapsed >= Duration.ofMillis(100).toNanos());
+ assertThrows(IllegalArgumentException.class, () ->
ObjectUtils.wait(new Object(), Duration.ofSeconds(-10)));
assertThrows(IllegalMonitorStateException.class, () ->
ObjectUtils.wait(new Object(), Duration.ZERO));
}