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/12 19:06:37 UTC

[commons-pool] branch master updated (3abe560 -> 43d7652)

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

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


    from 3abe560  Refactor test constants.
     new b6b0842  Sort members.
     new 43d7652  Add missing low-level tests.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/pool2/impl/TestPoolImplUtils.java      | 31 +++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

[commons-pool] 01/02: Sort members.

Posted by gg...@apache.org.
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

commit b6b084241ed4a8518a1c30b98e72e6353546669c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 12 15:00:03 2021 -0400

    Sort members.
---
 .../java/org/apache/commons/pool2/impl/TestPoolImplUtils.java     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
index 7fe08e2..3cf82f5 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
@@ -26,14 +26,10 @@ import org.junit.jupiter.api.Test;
 
 public class TestPoolImplUtils {
 
-    private static final Instant INSTANT_1 = Instant.ofEpochMilli(1);
-    private static final Instant INSTANT_0 = Instant.ofEpochMilli(0);
-
     @SuppressWarnings("unused")
     private abstract static class FactoryAB<A, B> extends BasePooledObjectFactory<B> {
         // empty by design
     }
-
     private abstract static class FactoryBA<A, B> extends FactoryAB<B, A> {
         // empty by design
     }
@@ -75,6 +71,10 @@ public class TestPoolImplUtils {
         }
     }
 
+    private static final Instant INSTANT_1 = Instant.ofEpochMilli(1);
+
+    private static final Instant INSTANT_0 = Instant.ofEpochMilli(0);
+
     @Test
     public void testFactoryTypeNotSimple() {
         final Class<?> result = PoolImplUtils.getFactoryType(NotSimpleFactory.class);

[commons-pool] 02/02: Add missing low-level tests.

Posted by gg...@apache.org.
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

commit 43d7652286da5d5359819a367beeb47b3ba91591
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 12 15:06:35 2021 -0400

    Add missing low-level tests.
---
 .../commons/pool2/impl/TestPoolImplUtils.java      | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
index 3cf82f5..844996a 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
@@ -18,7 +18,10 @@ package org.apache.commons.pool2.impl;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+import java.time.Duration;
 import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.pool2.BasePooledObjectFactory;
 import org.apache.commons.pool2.PooledObject;
@@ -30,6 +33,7 @@ public class TestPoolImplUtils {
     private abstract static class FactoryAB<A, B> extends BasePooledObjectFactory<B> {
         // empty by design
     }
+
     private abstract static class FactoryBA<A, B> extends FactoryAB<B, A> {
         // empty by design
     }
@@ -102,4 +106,25 @@ public class TestPoolImplUtils {
         assertEquals(INSTANT_1, PoolImplUtils.min(INSTANT_1, INSTANT_1));
         assertEquals(INSTANT_0, PoolImplUtils.min(INSTANT_0, INSTANT_0));
     }
+
+    @Test
+    public void testToChronoUnit() {
+        assertEquals(ChronoUnit.NANOS, PoolImplUtils.toChronoUnit(TimeUnit.NANOSECONDS));
+        assertEquals(ChronoUnit.MICROS, PoolImplUtils.toChronoUnit(TimeUnit.MICROSECONDS));
+        assertEquals(ChronoUnit.MILLIS, PoolImplUtils.toChronoUnit(TimeUnit.MILLISECONDS));
+        assertEquals(ChronoUnit.SECONDS, PoolImplUtils.toChronoUnit(TimeUnit.SECONDS));
+        assertEquals(ChronoUnit.MINUTES, PoolImplUtils.toChronoUnit(TimeUnit.MINUTES));
+        assertEquals(ChronoUnit.HOURS, PoolImplUtils.toChronoUnit(TimeUnit.HOURS));
+        assertEquals(ChronoUnit.DAYS, PoolImplUtils.toChronoUnit(TimeUnit.DAYS));
+    }
+
+    @Test
+    public void testToDuration() {
+        assertEquals(Duration.ZERO, PoolImplUtils.toDuration(0, TimeUnit.MILLISECONDS));
+        assertEquals(Duration.ofMillis(1), PoolImplUtils.toDuration(1, TimeUnit.MILLISECONDS));
+        for (TimeUnit tu : TimeUnit.values()) {
+            // All TimeUnit should be handled.
+            assertEquals(Duration.ZERO, PoolImplUtils.toDuration(0, tu));
+        }
+    }
 }