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 18:56:22 UTC

[commons-pool] branch master updated: Refactor test constants.

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 3abe560  Refactor test constants.
3abe560 is described below

commit 3abe560d284f64ee0444b782bab3e4794d9a445c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 12 14:56:20 2021 -0400

    Refactor test constants.
---
 .../commons/pool2/impl/TestPoolImplUtils.java      | 23 +++++++++++-----------
 1 file changed, 11 insertions(+), 12 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 3abaa20..7fe08e2 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
@@ -26,6 +26,9 @@ 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
@@ -86,21 +89,17 @@ public class TestPoolImplUtils {
 
     @Test
     public void testMaxInstants() {
-        final Instant instant0 = Instant.ofEpochMilli(0);
-        final Instant instant1 = Instant.ofEpochMilli(1);
-        assertEquals(instant1, PoolImplUtils.max(instant0, instant1));
-        assertEquals(instant1, PoolImplUtils.max(instant1, instant0));
-        assertEquals(instant1, PoolImplUtils.max(instant1, instant1));
-        assertEquals(instant0, PoolImplUtils.max(instant0, instant0));
+        assertEquals(INSTANT_1, PoolImplUtils.max(INSTANT_0, INSTANT_1));
+        assertEquals(INSTANT_1, PoolImplUtils.max(INSTANT_1, INSTANT_0));
+        assertEquals(INSTANT_1, PoolImplUtils.max(INSTANT_1, INSTANT_1));
+        assertEquals(INSTANT_0, PoolImplUtils.max(INSTANT_0, INSTANT_0));
     }
 
     @Test
     public void testMinInstants() {
-        final Instant instant0 = Instant.ofEpochMilli(0);
-        final Instant instant1 = Instant.ofEpochMilli(1);
-        assertEquals(instant0, PoolImplUtils.min(instant0, instant1));
-        assertEquals(instant0, PoolImplUtils.min(instant1, instant0));
-        assertEquals(instant1, PoolImplUtils.min(instant1, instant1));
-        assertEquals(instant0, PoolImplUtils.min(instant0, instant0));
+        assertEquals(INSTANT_0, PoolImplUtils.min(INSTANT_0, INSTANT_1));
+        assertEquals(INSTANT_0, PoolImplUtils.min(INSTANT_1, INSTANT_0));
+        assertEquals(INSTANT_1, PoolImplUtils.min(INSTANT_1, INSTANT_1));
+        assertEquals(INSTANT_0, PoolImplUtils.min(INSTANT_0, INSTANT_0));
     }
 }