You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2013/11/01 10:06:06 UTC

svn commit: r1537857 - /commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java

Author: markt
Date: Fri Nov  1 09:06:06 2013
New Revision: 1537857

URL: http://svn.apache.org/r1537857
Log:
Fill a gap in the tests highlighted by the code coverage report.

Added:
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java   (with props)

Added: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java?rev=1537857&view=auto
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java (added)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java Fri Nov  1 09:06:06 2013
@@ -0,0 +1,76 @@
+/*
+ * 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.Assert.assertEquals;
+
+import org.apache.commons.pool2.BasePooledObjectFactory;
+import org.apache.commons.pool2.PooledObject;
+import org.junit.Test;
+
+public class TestPoolImplUtils {
+
+    @Test
+    public void testFactoryTypeSimple() {
+        Class<?> result = PoolImplUtils.getFactoryType(SimpleFactory.class);
+        assertEquals(String.class, result);
+    }
+
+    @Test
+    public void testFactoryTypeNotSimple() {
+        Class<?> result = PoolImplUtils.getFactoryType(NotSimpleFactory.class);
+        assertEquals(Long.class, result);
+    }
+
+    private static class SimpleFactory extends BasePooledObjectFactory<String> {
+        @Override
+        public String create() throws Exception {
+            return null;
+        }
+        @Override
+        public PooledObject<String> wrap(String obj) {
+            return null;
+        }
+    }
+
+    private abstract static class FactoryAB<A,B>
+            extends BasePooledObjectFactory<B> {
+    }
+
+    private abstract static class FactoryBA<A,B> extends FactoryAB<B,A> {
+    }
+
+    private abstract static class FactoryC<C> extends FactoryBA<C, String> {
+    }
+
+    private abstract static class FactoryDE<D,E> extends FactoryC<D>{
+    }
+
+    private abstract static class FactoryF<F> extends FactoryDE<Long,F>{
+    }
+
+    private static class NotSimpleFactory extends FactoryF<Integer> {
+        @Override
+        public Long create() throws Exception {
+            return null;
+        }
+        @Override
+        public PooledObject<Long> wrap(Long obj) {
+            return null;
+        }
+    }
+}

Propchange: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native