commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject [46/50] [abbrv] commons-pool git commit: Add starter TravisCI configuration. Will pick up Travis profile from new parent module when released.
Date Sun, 12 Mar 2017 19:48:16 GMT
Add starter TravisCI configuration. Will pick up Travis profile from new parent module when
released.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/pool/trunk@1770094 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/commons-pool/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-pool/commit/fe494538
Tree: http://git-wip-us.apache.org/repos/asf/commons-pool/tree/fe494538
Diff: http://git-wip-us.apache.org/repos/asf/commons-pool/diff/fe494538

Branch: refs/heads/master
Commit: fe4945387e2fbc9ba2a9ac4eb7c1fa1d50f40310
Parents: 505842e
Author: Gary D. Gregory <ggregory@apache.org>
Authored: Thu Nov 17 00:02:16 2016 +0000
Committer: Gary D. Gregory <ggregory@apache.org>
Committed: Thu Nov 17 00:02:16 2016 +0000

----------------------------------------------------------------------
 .travis.yml                                     | 24 ++++++
 .../java/org/apache/commons/pool2/PoolTest.java | 80 ++++++++++++++++++++
 2 files changed, 104 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-pool/blob/fe494538/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..fc2a03a
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,24 @@
+# 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.
+
+language: java
+sudo: false
+
+jdk:
+  - openjdk7
+  - oraclejdk8
+
+after_success:
+  - mvn clean cobertura:cobertura coveralls:report

http://git-wip-us.apache.org/repos/asf/commons-pool/blob/fe494538/src/test/java/org/apache/commons/pool2/PoolTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/pool2/PoolTest.java b/src/test/java/org/apache/commons/pool2/PoolTest.java
new file mode 100644
index 0000000..e22e70b
--- /dev/null
+++ b/src/test/java/org/apache/commons/pool2/PoolTest.java
@@ -0,0 +1,80 @@
+package org.apache.commons.pool2;
+
+import static org.junit.Assert.assertFalse;
+
+import org.apache.commons.pool2.impl.DefaultPooledObject;
+import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class PoolTest {
+    private static final CharSequence COMMONS_POOL_EVICTIONS_TIMER_THREAD_NAME = "commons-pool-EvictionTimer";
+    private static final long EVICTION_PERIOD_IN_MILLIS = 100;
+
+    private static class Foo {
+    }
+
+    private static class PooledFooFactory implements PooledObjectFactory<Foo> {
+        private static final long VALIDATION_WAIT_IN_MILLIS = 1000;
+
+        @Override
+        public PooledObject<Foo> makeObject() throws Exception {
+            return new DefaultPooledObject<Foo>(new Foo());
+        }
+
+        @Override
+        public void destroyObject(PooledObject<Foo> pooledObject) throws Exception
{
+        }
+
+        @Override
+        public boolean validateObject(PooledObject<Foo> pooledObject) {
+            try {
+                Thread.sleep(VALIDATION_WAIT_IN_MILLIS);
+            } catch (final InterruptedException e) {
+                Thread.interrupted();
+            }
+            return false;
+        }
+
+        @Override
+        public void activateObject(PooledObject<Foo> pooledObject) throws Exception
{
+        }
+
+        @Override
+        public void passivateObject(PooledObject<Foo> pooledObject) throws Exception
{
+        }
+    }
+
+    @Test
+    public void testPool() throws Exception {
+        final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
+        poolConfig.setTestWhileIdle(true /* testWhileIdle */);
+        final PooledFooFactory pooledFooFactory = new PooledFooFactory();
+        GenericObjectPool<Foo> pool = null;
+        try {
+            pool = new GenericObjectPool<Foo>(pooledFooFactory, poolConfig);
+            pool.setTimeBetweenEvictionRunsMillis(EVICTION_PERIOD_IN_MILLIS);
+            pool.addObject();
+            try {
+                Thread.sleep(EVICTION_PERIOD_IN_MILLIS);
+            } catch (final InterruptedException e) {
+                Thread.interrupted();
+            }
+        } finally {
+            if (pool != null) {
+                pool.close();
+            }
+        }
+        final Thread[] threads = new Thread[Thread.activeCount()];
+        Thread.enumerate(threads);
+        for (final Thread thread : threads) {
+            if (thread == null) {
+                continue;
+            }
+            final String name = thread.getName();
+            assertFalse(name, name.contains(COMMONS_POOL_EVICTIONS_TIMER_THREAD_NAME));
+        }
+    }
+}
\ No newline at end of file


Mime
View raw message