You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/08/13 13:20:20 UTC

[commons-pool] branch master updated: Reorg tests.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git


The following commit(s) were added to refs/heads/master by this push:
     new 8cf8d75  Reorg tests.
8cf8d75 is described below

commit 8cf8d7531515cc58a0b2e3b1fe8d05e1fd9772c0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Aug 13 09:20:18 2021 -0400

    Reorg tests.
---
 .../pool2/impl/TestDefaultPooledObject.java        | 26 +++++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObject.java b/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObject.java
index 49ae9fa..3c79044 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObject.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestDefaultPooledObject.java
@@ -28,6 +28,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import org.apache.commons.pool2.PooledObject;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -37,43 +38,46 @@ public class TestDefaultPooledObject {
 
     @Test
     public void testInitialStateActiveDuration() throws InterruptedException {
-        final DefaultPooledObject<Object> dpo = new DefaultPooledObject<>(new Object());
+        final PooledObject<Object> dpo = new DefaultPooledObject<>(new Object());
         // Sleep MUST be "long enough" to test that we are not returning a negative time.
+        // Need an API in Java 8 to get the clock granularity.
         Thread.sleep(200);
         assertFalse(dpo.getActiveDuration().isNegative());
         assertFalse(dpo.getActiveDuration().isZero());
+        assertThat(dpo.getActiveDuration(), lessThanOrEqualTo(dpo.getIdleDuration()));
+        // Depreacted
         assertThat(dpo.getActiveDuration().toMillis(), lessThanOrEqualTo(dpo.getActiveTimeMillis()));
         assertThat(dpo.getActiveDuration(), lessThanOrEqualTo(dpo.getActiveTime()));
-        //
-        assertThat(dpo.getActiveDuration(), lessThanOrEqualTo(dpo.getIdleDuration()));
+        assertThat(dpo.getActiveDuration(), lessThanOrEqualTo(dpo.getIdleTime()));
     }
 
     @Test
     public void testInitialStateIdleDuration() throws InterruptedException {
-        final DefaultPooledObject<Object> dpo = new DefaultPooledObject<>(new Object());
+        final PooledObject<Object> dpo = new DefaultPooledObject<>(new Object());
         // Sleep MUST be "long enough" to test that we are not returning a negative time.
         Thread.sleep(200);
         assertFalse(dpo.getIdleDuration().isNegative());
         assertFalse(dpo.getIdleDuration().isZero());
+        assertThat(dpo.getIdleDuration(), lessThanOrEqualTo(dpo.getActiveDuration()));
+        // Depreacted
         assertThat(dpo.getIdleDuration().toMillis(), lessThanOrEqualTo(dpo.getActiveTimeMillis()));
         assertThat(dpo.getIdleDuration(), lessThanOrEqualTo(dpo.getActiveTime()));
-        //
-        assertThat(dpo.getIdleDuration(), lessThanOrEqualTo(dpo.getActiveDuration()));
+        assertThat(dpo.getIdleDuration(), lessThanOrEqualTo(dpo.getIdleTime()));
     }
 
     @Test
     public void testInitialStateCreateInstant() throws InterruptedException {
-        final DefaultPooledObject<Object> dpo = new DefaultPooledObject<>(new Object());
-
-        // Instant vs. long
-        assertEquals(dpo.getCreateInstant().toEpochMilli(), dpo.getCreateTime());
+        final PooledObject<Object> dpo = new DefaultPooledObject<>(new Object());
 
         // Instant vs. Instant
         assertEquals(dpo.getCreateInstant(), dpo.getLastBorrowInstant());
         assertEquals(dpo.getCreateInstant(), dpo.getLastReturnInstant());
         assertEquals(dpo.getCreateInstant(), dpo.getLastUsedInstant());
 
-        // long vs. long
+        // Instant vs. long (deprecated)
+        assertEquals(dpo.getCreateInstant().toEpochMilli(), dpo.getCreateTime());
+
+        // long vs. long (deprecated)
         assertEquals(dpo.getCreateTime(), dpo.getLastBorrowTime());
         assertEquals(dpo.getCreateTime(), dpo.getLastReturnTime());
         assertEquals(dpo.getCreateTime(), dpo.getLastUsedTime());