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 cb5e9289 Format tweaks, Javadoc. remove default code.
cb5e9289 is described below
commit cb5e9289d6ed1f92b46dc61bbb8bb43861f70eb3
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Apr 21 13:04:24 2022 -0400
Format tweaks, Javadoc. remove default code.
---
src/test/java/org/apache/commons/pool2/PoolTest.java | 2 ++
src/test/java/org/apache/commons/pool2/VisitTracker.java | 16 ++++++++++++++--
.../org/apache/commons/pool2/VisitTrackerFactory.java | 5 ++---
.../apache/commons/pool2/impl/TestGenericObjectPool.java | 14 ++++++++++++++
4 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/src/test/java/org/apache/commons/pool2/PoolTest.java
b/src/test/java/org/apache/commons/pool2/PoolTest.java
index 99e2c3e7..6dac8a13 100644
--- a/src/test/java/org/apache/commons/pool2/PoolTest.java
+++ b/src/test/java/org/apache/commons/pool2/PoolTest.java
@@ -31,8 +31,10 @@ import org.junit.jupiter.api.Test;
@Disabled
public class PoolTest {
+
private static class Foo {
}
+
private static class PooledFooFactory implements PooledObjectFactory<Foo,
RuntimeException> {
private static final long VALIDATION_WAIT_IN_MILLIS = 1000;
diff --git a/src/test/java/org/apache/commons/pool2/VisitTracker.java
b/src/test/java/org/apache/commons/pool2/VisitTracker.java
index 2fbed31b..2dbd4b79 100644
--- a/src/test/java/org/apache/commons/pool2/VisitTracker.java
+++ b/src/test/java/org/apache/commons/pool2/VisitTracker.java
@@ -17,11 +17,12 @@
package org.apache.commons.pool2;
/**
- * Test pooled object class. Keeps track of how many times it has been
- * validated, activated, passivated.
+ * Test pooled object class. Keeps track of how many times it has been
validated, activated, passivated.
*
+ * @param <K> The key type.
*/
public class VisitTracker<K> {
+
private int validateCount;
private int activateCount;
private int passivateCount;
@@ -50,42 +51,53 @@ public class VisitTracker<K> {
}
activateCount++;
}
+
public void destroy() {
destroyed = true;
}
+
private void fail(final String message) {
throw new IllegalStateException(message);
}
+
public int getActivateCount() {
return activateCount;
}
+
public int getId() {
return id;
}
+
public K getKey() {
return key;
}
+
public int getPassivateCount() {
return passivateCount;
}
+
public int getValidateCount() {
return validateCount;
}
+
public boolean isDestroyed() {
return destroyed;
}
+
public void passivate() {
if (destroyed) {
fail("attempted to passivate a destroyed object");
}
passivateCount++;
}
+
public void reset() {
validateCount = 0;
activateCount = 0;
passivateCount = 0;
destroyed = false;
}
+
@Override
public String toString() {
return "Key: " + key + " id: " + id;
diff --git a/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java
b/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java
index 94497a82..78121ef1 100644
--- a/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java
+++ b/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java
@@ -22,13 +22,12 @@ import org.apache.commons.pool2.impl.DefaultPooledObject;
/**
* Factory that creates VisitTracker instances. Used to test Evictor runs.
*
+ * @param <K> The VisitTracker key type.
*/
public class VisitTrackerFactory<K>
implements PooledObjectFactory<VisitTracker<K>, RuntimeException>,
KeyedPooledObjectFactory<K, VisitTracker<K>, RuntimeException> {
- private int nextId;
- public VisitTrackerFactory() {
- }
+ private int nextId;
@Override
public void activateObject(final K key, final
PooledObject<VisitTracker<K>> ref) {
diff --git
a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
index afb7dae6..47081ced 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
@@ -272,10 +272,12 @@ public class TestGenericObjectPool extends
TestBaseObjectPool {
public SimpleFactory(final boolean valid) {
this(valid,valid);
}
+
public SimpleFactory(final boolean evalid, final boolean ovalid) {
evenValid = evalid;
oddValid = ovalid;
}
+
@Override
public void activateObject(final PooledObject<String> obj) throws
Exception {
final boolean hurl;
@@ -292,6 +294,7 @@ public class TestGenericObjectPool extends
TestBaseObjectPool {
throw new Exception();
}
}
+
@Override
public void destroyObject(final PooledObject<String> obj) throws
Exception {
final long waitLatency;
@@ -310,18 +313,23 @@ public class TestGenericObjectPool extends
TestBaseObjectPool {
throw new Exception();
}
}
+
private void doWait(final long latency) {
Waiter.sleepQuietly(latency);
}
+
public synchronized int getMakeCounter() {
return makeCounter;
}
+
public synchronized boolean isThrowExceptionOnActivate() {
return exceptionOnActivate;
}
+
public synchronized boolean isValidationEnabled() {
return enableValidation;
}
+
@Override
public PooledObject<String> makeObject() {
final long waitLatency;
@@ -342,6 +350,7 @@ public class TestGenericObjectPool extends
TestBaseObjectPool {
}
return new DefaultPooledObject<>(String.valueOf(counter));
}
+
@Override
public void passivateObject(final PooledObject<String> obj) throws
Exception {
final boolean hurl;
@@ -352,18 +361,23 @@ public class TestGenericObjectPool extends
TestBaseObjectPool {
throw new Exception();
}
}
+
public synchronized void setDestroyLatency(final long destroyLatency) {
this.destroyLatency = destroyLatency;
}
+
public synchronized void setEvenValid(final boolean valid) {
evenValid = valid;
}
+
public synchronized void setMakeLatency(final long makeLatency) {
this.makeLatency = makeLatency;
}
+
public synchronized void setMaxTotal(final int maxTotal) {
this.maxTotal = maxTotal;
}
+
public synchronized void setOddValid(final boolean valid) {
oddValid = valid;
}