This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch POOL_2_X
in repository https://gitbox.apache.org/repos/asf/commons-pool.git
The following commit(s) were added to refs/heads/POOL_2_X by this push:
new 834e7659 Add TestGenericObjectPoolConfig
834e7659 is described below
commit 834e7659c1185a468fe0896ab75c42973aa64185
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Nov 24 15:39:55 2024 -0500
Add TestGenericObjectPoolConfig
---
.../pool2/impl/TestGenericObjectPoolConfig.java | 113 +++++++++++++++++++++
1 file changed, 113 insertions(+)
diff --git
a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolConfig.java
b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolConfig.java
new file mode 100644
index 00000000..3357557d
--- /dev/null
+++
b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolConfig.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.pool2.impl;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.time.Duration;
+import org.apache.commons.pool2.PooledObject;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link GenericObjectPoolConfig}.
+ */
+public class TestGenericObjectPoolConfig {
+
+ public final static class TestEvictionPolicy implements
EvictionPolicy<TestObject> {
+
+ @Override
+ public boolean evict(final EvictionConfig config, final
PooledObject<TestObject> underTest, final int idleCount) {
+ return false;
+ }
+
+ }
+
+ public final static class TestObject {
+ // empty
+ }
+
+ private GenericObjectPoolConfig<TestObject> config;
+
+ @BeforeEach
+ void beforeEach() {
+ config = new GenericObjectPoolConfig<>();
+ }
+
+ @Test
+ void testSetEvictionPolicy() {
+ final TestEvictionPolicy evictionPolicy = new TestEvictionPolicy();
+ config.setEvictionPolicy(evictionPolicy);
+ assertEquals(evictionPolicy, config.getEvictionPolicy());
+ }
+
+ @Test
+ void testSetEvictionPolicyClassName() {
+ config.setEvictionPolicyClassName(TestEvictionPolicy.class.getName());
+ assertEquals(TestEvictionPolicy.class.getName(),
config.getEvictionPolicyClassName());
+ }
+
+ @Test
+ void testSetEvictorShutdownTimeoutDuration() {
+ config.setEvictorShutdownTimeout(Duration.ofSeconds(10));
+ assertEquals(Duration.ofSeconds(10),
config.getEvictorShutdownTimeoutDuration());
+ }
+
+ @Test
+ void testSetEvictorShutdownTimeoutMillis() {
+ config.setEvictorShutdownTimeoutMillis(10_0000);
+ assertEquals(10_0000, config.getEvictorShutdownTimeoutMillis());
+ }
+
+ @Test
+ void testSetJmxNamePrefix() {
+ config.setJmxNamePrefix("prefix");
+ assertEquals("prefix", config.getJmxNamePrefix());
+ }
+
+ @Test
+ void testSetMaxWaitMillis() {
+ config.setMaxWaitMillis(10_0000);
+ assertEquals(10_0000, config.getMaxWaitMillis());
+ }
+
+ @Test
+ void testSetSoftMinEvictableIdleDuration() {
+ config.setSoftMinEvictableIdleDuration(Duration.ofSeconds(10));
+ assertEquals(Duration.ofSeconds(10),
config.getSoftMinEvictableIdleDuration());
+ }
+
+ @Test
+ void testSetSoftMinEvictableIdleTimeMillis() {
+ config.setSoftMinEvictableIdleTimeMillis(10_0000);
+ assertEquals(10_0000, config.getSoftMinEvictableIdleTimeMillis());
+ }
+
+ @Test
+ void testToString() {
+ assertFalse(config.toString().isEmpty());
+ }
+
+ @Test
+ void testToStringAppendFields() {
+ final StringBuilder builder = new StringBuilder();
+ config.toStringAppendFields(builder);
+ assertFalse(builder.toString().isEmpty());
+ }
+
+}