Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 02C5C10AF2 for ; Mon, 23 Feb 2015 17:01:32 +0000 (UTC) Received: (qmail 86909 invoked by uid 500); 23 Feb 2015 17:01:31 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 86771 invoked by uid 500); 23 Feb 2015 17:01:31 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 86759 invoked by uid 99); 23 Feb 2015 17:01:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Feb 2015 17:01:31 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 209.85.220.172 as permitted sender) Received: from [209.85.220.172] (HELO mail-vc0-f172.google.com) (209.85.220.172) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Feb 2015 17:01:26 +0000 Received: by mail-vc0-f172.google.com with SMTP id kv7so7811517vcb.3 for ; Mon, 23 Feb 2015 09:00:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=YEOL3zCPWtWVLkaoZ5KCn9nVp7DiDN0U3HN/wA2UnHU=; b=jYX8E+PHJcjNUu2Y/tRJtd9gRTQ5cuVsrAyJi2Ibgj6sFt3iUAEtuvk5n+f2YGXrtQ HcJYenZb0wQq/Ejf17GTcwsTJbd8nvUA1HE2Z9XSHg4AV8VOLzeYPC/oix0KGw9eDDwB D7T82mEMlKQhfmISbrf07/UQ95Q8VaaDYtRFZeAktXtVZIy6sL8RXa5+/fhpdJ2iiSG+ wwxfhgeI/u2Co8pfIF2BqSD1pg2gh90BvEJq33U/7/Aws3rQhiGlnSXDGa0lWSICpUfX TuoqmBj7IRibPBp3ZBZwgkRgX2E0lY2FdAmoZhHo67xitJc9X9/BagLUBfpPKiKV4IOa xA4A== MIME-Version: 1.0 X-Received: by 10.52.170.241 with SMTP id ap17mr11284911vdc.30.1424710821550; Mon, 23 Feb 2015 09:00:21 -0800 (PST) Received: by 10.52.36.130 with HTTP; Mon, 23 Feb 2015 09:00:21 -0800 (PST) In-Reply-To: References: <20150222204331.5615EAC0175@hades.apache.org> Date: Mon, 23 Feb 2015 17:00:21 +0000 Message-ID: Subject: Re: svn commit: r1661559 - /commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java From: sebb To: Commons Developers List Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On 23 February 2015 at 10:35, Benedikt Ritter wrote: > Hello Phil, > > 2015-02-22 21:43 GMT+01:00 : > >> Author: psteitz >> Date: Sun Feb 22 20:43:30 2015 >> New Revision: 1661559 >> >> URL: http://svn.apache.org/r1661559 >> Log: >> Added (disabled) tests for JIRA: DBCP-283 and DBCP-284. >> >> Modified: >> >> commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java >> >> Modified: >> commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java >> URL: >> http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1661559&r1=1661558&r2=1661559&view=diff >> >> ============================================================================== >> --- >> commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java >> (original) >> +++ >> commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java >> Sun Feb 22 20:43:30 2015 >> @@ -26,6 +26,7 @@ import static org.junit.Assert.fail; >> >> import java.lang.management.ManagementFactory; >> import java.util.ArrayList; >> +import java.util.HashSet; >> import java.util.List; >> import java.util.NoSuchElementException; >> import java.util.Random; >> @@ -2398,6 +2399,44 @@ public class TestGenericObjectPool exten >> >> Assert.assertEquals(1, factory.validateCounter); >> } >> + >> + /** >> + * Verifies that when a factory's makeObject produces instances that >> are not >> + * discernible by equals, the pool can handle them. >> + * >> + * JIRA: POOL-283 >> + */ >> + //@Test >> > > IMHO it's better to use the @Ignore annotation, because this way ignored > tests will at least show up in reports generated by maven. You can even add > a description why a test is ignored like this: > > @Ignore("See POOL-283 in JIRA") > +1 >> + public void testEqualsIndiscernible() throws Exception { >> + final HashSetFactory factory = new HashSetFactory(); >> + final GenericObjectPool> pool = new >> GenericObjectPool>( >> + factory, new GenericObjectPoolConfig()); >> + final HashSet s1 = pool.borrowObject(); >> + final HashSet s2 = pool.borrowObject(); >> + pool.returnObject(s1); >> + pool.returnObject(s2); >> + pool.close(); >> + } >> + >> + /** >> + * Verifies that when a borrowed object is mutated in a way that does >> not >> + * preserve equality and hashcode, the pool can recognized it on >> return. >> + * >> + * JIRA: POOL-284 >> + */ >> + //@Test >> + public void testMutable() throws Exception { >> + final HashSetFactory factory = new HashSetFactory(); >> + final GenericObjectPool> pool = new >> GenericObjectPool>( >> + factory, new GenericObjectPoolConfig()); >> + final HashSet s1 = pool.borrowObject(); >> + final HashSet s2 = pool.borrowObject(); >> + s1.add("One"); >> + s2.add("One"); >> + pool.returnObject(s1); >> + pool.returnObject(s2); >> + pool.close(); >> + } >> >> private static final class DummyFactory >> extends BasePooledObjectFactory { >> @@ -2410,7 +2449,23 @@ public class TestGenericObjectPool exten >> return new DefaultPooledObject(value); >> } >> } >> - >> + >> + /** >> + * Factory that creates HashSets. Note that this means >> + * 0) All instances are initially equal (not discernible by equals) >> + * 1) Instances are mutable and mutation can cause change in >> identity / hashcode. >> + */ >> + private static final class HashSetFactory >> + extends BasePooledObjectFactory> { >> + @Override >> + public HashSet create() throws Exception { >> + return new HashSet(); >> + } >> + @Override >> + public PooledObject> wrap(HashSet value) { >> + return new DefaultPooledObject>(value); >> + } >> + } >> >> private static class InvalidFactory >> extends BasePooledObjectFactory { >> >> >> > > > -- > http://people.apache.org/~britter/ > http://www.systemoutprintln.de/ > http://twitter.com/BenediktRitter > http://github.com/britter --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org