You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/05/04 20:02:27 UTC

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

Author: sebb
Date: Fri May  4 18:02:27 2012
New Revision: 1334103

URL: http://svn.apache.org/viewvc?rev=1334103&view=rev
Log:
Add specific test for null factory
TODO causes tearDown error

Modified:
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1334103&r1=1334102&r2=1334103&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Fri May  4 18:02:27 2012
@@ -1111,6 +1111,14 @@ public class TestGenericKeyedObjectPool 
         pool.close();
     }
 
+    @Test(expected=IllegalArgumentException.class)
+    public void testConstructorNullFactory() {
+        // add dummy assert (won't be invoked because of IAE) to avoid "unused" warning
+        assertNotNull(new GenericKeyedObjectPool<String,String>(null));
+        // TODO this currently causes tearDown to report an error
+        // Looks like GKOP needs to call close() on its parent before throwing IAE
+    }
+
     @Test(timeout=60000)
     public void testExceptionOnPassivateDuringReturn() throws Exception {
         SimpleFactory<String> factory = new SimpleFactory<String>();



Re: svn commit: r1334103 - /commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java

Posted by Mark Thomas <ma...@apache.org>.
On 05/05/2012 11:22, sebb AT ASF wrote:
> On 4 May 2012 19:05, sebb AT ASF <se...@apache.org> wrote:
>> The following change to the GKOP ctor seems to fix the problem:
>>
>>
>>        if (factory == null) {
>>            this.close(); // <============= close the parent
>>            throw new IllegalArgumentException("factory may not be null");
>>        }
>>
>> Not 100% sure if that is the correct fix - perhaps tearDown() needs to
>> be adjusted?
> 
> I've fixed GOP and GKOP to call jmxUnregister() instead.
> Hope that's OK; it fixes the remaining test errors.

Looks good to me.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1334103 - /commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java

Posted by sebb AT ASF <se...@apache.org>.
On 4 May 2012 19:05, sebb AT ASF <se...@apache.org> wrote:
> The following change to the GKOP ctor seems to fix the problem:
>
>
>        if (factory == null) {
>            this.close(); // <============= close the parent
>            throw new IllegalArgumentException("factory may not be null");
>        }
>
> Not 100% sure if that is the correct fix - perhaps tearDown() needs to
> be adjusted?

I've fixed GOP and GKOP to call jmxUnregister() instead.
Hope that's OK; it fixes the remaining test errors.

> On 4 May 2012 19:02,  <se...@apache.org> wrote:
>> Author: sebb
>> Date: Fri May  4 18:02:27 2012
>> New Revision: 1334103
>>
>> URL: http://svn.apache.org/viewvc?rev=1334103&view=rev
>> Log:
>> Add specific test for null factory
>> TODO causes tearDown error
>>
>> Modified:
>>    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
>>
>> Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
>> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1334103&r1=1334102&r2=1334103&view=diff
>> ==============================================================================
>> --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
>> +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Fri May  4 18:02:27 2012
>> @@ -1111,6 +1111,14 @@ public class TestGenericKeyedObjectPool
>>         pool.close();
>>     }
>>
>> +    @Test(expected=IllegalArgumentException.class)
>> +    public void testConstructorNullFactory() {
>> +        // add dummy assert (won't be invoked because of IAE) to avoid "unused" warning
>> +        assertNotNull(new GenericKeyedObjectPool<String,String>(null));
>> +        // TODO this currently causes tearDown to report an error
>> +        // Looks like GKOP needs to call close() on its parent before throwing IAE
>> +    }
>> +
>>     @Test(timeout=60000)
>>     public void testExceptionOnPassivateDuringReturn() throws Exception {
>>         SimpleFactory<String> factory = new SimpleFactory<String>();
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1334103 - /commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java

Posted by sebb AT ASF <se...@apache.org>.
The following change to the GKOP ctor seems to fix the problem:


        if (factory == null) {
            this.close(); // <============= close the parent
            throw new IllegalArgumentException("factory may not be null");
        }

Not 100% sure if that is the correct fix - perhaps tearDown() needs to
be adjusted?

On 4 May 2012 19:02,  <se...@apache.org> wrote:
> Author: sebb
> Date: Fri May  4 18:02:27 2012
> New Revision: 1334103
>
> URL: http://svn.apache.org/viewvc?rev=1334103&view=rev
> Log:
> Add specific test for null factory
> TODO causes tearDown error
>
> Modified:
>    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
>
> Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1334103&r1=1334102&r2=1334103&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
> +++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Fri May  4 18:02:27 2012
> @@ -1111,6 +1111,14 @@ public class TestGenericKeyedObjectPool
>         pool.close();
>     }
>
> +    @Test(expected=IllegalArgumentException.class)
> +    public void testConstructorNullFactory() {
> +        // add dummy assert (won't be invoked because of IAE) to avoid "unused" warning
> +        assertNotNull(new GenericKeyedObjectPool<String,String>(null));
> +        // TODO this currently causes tearDown to report an error
> +        // Looks like GKOP needs to call close() on its parent before throwing IAE
> +    }
> +
>     @Test(timeout=60000)
>     public void testExceptionOnPassivateDuringReturn() throws Exception {
>         SimpleFactory<String> factory = new SimpleFactory<String>();
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org