001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.commons.pool; 019 020 import junit.framework.TestCase; 021 022 /** 023 * Unit tests for all {@link ObjectPoolFactory}. 024 * 025 * @author Sandy McArthur 026 * @version $Revision: 480413 $ $Date: 2006-11-29 00:16:05 -0500 (Wed, 29 Nov 2006) $ 027 */ 028 public abstract class TestObjectPoolFactory extends TestCase { 029 protected TestObjectPoolFactory(final String name) { 030 super(name); 031 } 032 033 /** 034 * @throws UnsupportedOperationException when this is unsupported by this PoolableObjectFactory type. 035 */ 036 protected ObjectPoolFactory makeFactory() throws UnsupportedOperationException { 037 return makeFactory(new MethodCallPoolableObjectFactory()); 038 } 039 040 /** 041 * @throws UnsupportedOperationException when this is unsupported by this PoolableObjectFactory type. 042 */ 043 protected abstract ObjectPoolFactory makeFactory(PoolableObjectFactory objectFactory) throws UnsupportedOperationException; 044 045 public void testCreatePool() throws Exception { 046 final ObjectPoolFactory factory; 047 try { 048 factory = makeFactory(); 049 } catch (UnsupportedOperationException uoe) { 050 return; 051 } 052 final ObjectPool pool = factory.createPool(); 053 pool.close(); 054 } 055 056 public void testToString() { 057 final ObjectPoolFactory factory; 058 try { 059 factory = makeFactory(); 060 } catch (UnsupportedOperationException uoe) { 061 return; 062 } 063 factory.toString(); 064 } 065 }