svn commit: r390797 - in /jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite: TestCompositeKeyedObjectPoolFactory.java TestCompositeObjectPoolFactory.java

2006-04-02 Thread sandymac
Author: sandymac
Date: Sun Apr  2 00:00:47 2006
New Revision: 390797

URL: http://svn.apache.org/viewcvs?rev=390797view=rev
Log:
More unit tests.

Modified:

jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPoolFactory.java

jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPoolFactory.java

Modified: 
jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPoolFactory.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPoolFactory.java?rev=390797r1=390796r2=390797view=diff
==
--- 
jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPoolFactory.java
 (original)
+++ 
jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPoolFactory.java
 Sun Apr  2 00:00:47 2006
@@ -16,11 +16,17 @@
 
 package org.apache.commons.pool.composite;
 
-import org.apache.commons.pool.TestKeyedObjectPoolFactory;
-import org.apache.commons.pool.KeyedObjectPoolFactory;
-import org.apache.commons.pool.KeyedPoolableObjectFactory;
 import junit.framework.Test;
 import junit.framework.TestSuite;
+import org.apache.commons.pool.KeyedObjectPoolFactory;
+import org.apache.commons.pool.KeyedPoolableObjectFactory;
+import org.apache.commons.pool.MethodCallPoolableObjectFactory;
+import org.apache.commons.pool.PoolUtils;
+import org.apache.commons.pool.PoolableObjectFactory;
+import org.apache.commons.pool.TestKeyedObjectPoolFactory;
+import org.apache.commons.pool.impl.StackObjectPoolFactory;
+
+import java.util.Random;
 
 /**
  * Tests for [EMAIL PROTECTED] CompositeKeyedObjectPoolFactory}.
@@ -29,6 +35,8 @@
  * @version $Revision$ $Date$
  */
 public class TestCompositeKeyedObjectPoolFactory extends 
TestKeyedObjectPoolFactory {
+private final Random rnd = new Random();
+
 public TestCompositeKeyedObjectPoolFactory(final String name) {
 super(name);
 }
@@ -39,5 +47,99 @@
 
 protected KeyedObjectPoolFactory makeFactory(final 
KeyedPoolableObjectFactory objectFactory) throws UnsupportedOperationException {
 return new CompositeKeyedObjectPoolFactory(objectFactory);
+}
+
+public void testConstructors() throws Exception {
+CompositeKeyedObjectPoolFactory factory = new 
CompositeKeyedObjectPoolFactory(createObjectFactory());
+factory.createPool().close();
+
+try {
+new 
CompositeKeyedObjectPoolFactory((KeyedPoolableObjectFactory)null);
+fail();
+} catch (IllegalArgumentException iae) {
+// expected
+}
+
+try {
+new 
CompositeKeyedObjectPoolFactory((CompositeObjectPoolFactory)null);
+fail();
+} catch (IllegalArgumentException iae) {
+// expected
+}
+factory = new CompositeKeyedObjectPoolFactory(new 
CompositeObjectPoolFactory(new MethodCallPoolableObjectFactory()));
+factory.createPool().close();
+
+try {
+new CompositeKeyedObjectPoolFactory((PoolableObjectFactory)null);
+fail();
+} catch (IllegalArgumentException iae) {
+// expected
+}
+factory = new CompositeKeyedObjectPoolFactory(new 
MethodCallPoolableObjectFactory());
+factory.createPool().close();
+}
+
+public void testStaticCreatePool() {
+assertNotNull(CompositeKeyedObjectPoolFactory.createPool(new 
StackObjectPoolFactory()));
+try {
+CompositeKeyedObjectPoolFactory.createPool(null);
+fail();
+} catch (IllegalArgumentException iae) {
+// expected
+}
+}
+
+public void testFactory() {
+CompositeKeyedObjectPoolFactory factory = 
(CompositeKeyedObjectPoolFactory)makeFactory();
+try {
+factory.setFactory(null);
+fail();
+} catch (IllegalArgumentException iae) {
+// expected
+}
+
+factory.setFactory(new MethodCallPoolableObjectFactory());
+assertNotNull(factory.getFactory());
+assertNull(factory.getKeyedFactory());
+}
+
+public void testKeyedFactory() {
+CompositeKeyedObjectPoolFactory factory = 
(CompositeKeyedObjectPoolFactory)makeFactory();
+try {
+factory.setKeyedFactory(null);
+fail();
+} catch (IllegalArgumentException iae) {
+// expected
+}
+
+factory.setKeyedFactory(PoolUtils.adapt(new 
MethodCallPoolableObjectFactory()));
+assertNotNull(factory.getKeyedFactory());
+assertNull(factory.getFactory());
+}
+
+public void testClone() throws CloneNotSupportedException {
+CompositeKeyedObjectPoolFactory f1 = 

Re: svn commit: r390797 - in /jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite: TestCompositeKeyedObjectPoolFactory.java TestCompositeObjectPoolFactory.java

2006-04-02 Thread Sandy McArthur
FWIW: this commit put the trunk of pool over 90% test coverage
according to clover

On 4/2/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Author: sandymac
 Date: Sun Apr  2 00:00:47 2006
 New Revision: 390797

 URL: http://svn.apache.org/viewcvs?rev=390797view=rev
 Log:
 More unit tests.

 Modified:
 
 jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPoolFactory.java
 
 jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPoolFactory.java

 Modified: 
 jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPoolFactory.java
 URL: 
 http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPoolFactory.java?rev=390797r1=390796r2=390797view=diff

--
Sandy McArthur

He who dares not offend cannot be honest.
- Thomas Paine

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: svn commit: r390797 - in /jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite: TestCompositeKeyedObjectPoolFactory.java TestCompositeObjectPoolFactory.java

2006-04-02 Thread robert burrell donkin
On Sun, 2006-04-02 at 04:04 -0400, Sandy McArthur wrote:
 FWIW: this commit put the trunk of pool over 90% test coverage
 according to clover

excellent :)

- robet


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]