Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 82030 invoked from network); 13 May 2009 22:44:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 May 2009 22:44:06 -0000 Received: (qmail 92126 invoked by uid 500); 13 May 2009 22:44:05 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 92018 invoked by uid 500); 13 May 2009 22:44:05 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 91849 invoked by uid 99); 13 May 2009 22:44:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2009 22:44:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2009 22:43:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6800823888A6; Wed, 13 May 2009 22:43:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r774574 - /commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java Date: Wed, 13 May 2009 22:43:35 -0000 To: commits@commons.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090513224335.6800823888A6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Wed May 13 22:43:34 2009 New Revision: 774574 URL: http://svn.apache.org/viewvc?rev=774574&view=rev Log: Add test case for POOL-135. There is a timing element so this may not fail on all machines. Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java?rev=774574&r1=774573&r2=774574&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java (original) +++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java Wed May 13 22:43:34 2009 @@ -516,6 +516,84 @@ } } + public void testMaxActiveUnderLoad() { + // Config + int numThreads = 199; // And main thread makes a round 200. + int numIter = 20; + int delay = 25; + int maxActive = 10; + + SimpleFactory factory = new SimpleFactory(); + factory.setMaxActive(maxActive); + pool.setFactory(factory); + pool.setMaxActive(maxActive); + pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); + pool.setTimeBetweenEvictionRunsMillis(-1); + + // Start threads to borrow objects + TestThread[] threads = new TestThread[numThreads]; + for(int i=0;i _maxActive + if (pool.getNumActive() > pool.getMaxActive()) { + throw new IllegalStateException("Too many active objects"); + } + try { + Thread.sleep(delay); + } catch(Exception e) { + // ignored + } + } catch (Exception e) { + // Shouldn't happen + e.printStackTrace(); + fail("Exception on borrow"); + } finally { + if (obj != null) { + try { + pool.returnObject(obj); + } catch (Exception e) { + // Ignore + } + } + } + } + + for(int i=0;i