Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 58742 invoked from network); 16 Apr 2003 08:37:14 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 16 Apr 2003 08:37:14 -0000 Received: (qmail 8932 invoked by uid 97); 16 Apr 2003 08:39:20 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 8925 invoked from network); 16 Apr 2003 08:39:19 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 16 Apr 2003 08:39:19 -0000 Received: (qmail 56696 invoked by uid 500); 16 Apr 2003 08:36:37 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 56657 invoked by uid 500); 16 Apr 2003 08:36:37 -0000 Received: (qmail 56651 invoked from network); 16 Apr 2003 08:36:36 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 16 Apr 2003 08:36:36 -0000 Received: (qmail 80331 invoked by uid 1289); 16 Apr 2003 08:36:35 -0000 Date: 16 Apr 2003 08:36:35 -0000 Message-ID: <20030416083635.80330.qmail@icarus.apache.org> From: rdonkin@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/beanutils/src/test/org/apache/commons/beanutils ConvertUtilsTestCase.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N rdonkin 2003/04/16 01:36:35 Modified: beanutils/src/java/org/apache/commons/beanutils ConvertUtils.java beanutils/src/test/org/apache/commons/beanutils ConvertUtilsTestCase.java Log: Committed fix for bug #18918. This bug prevented converters from being correctly deregistered. Patch submitted by Eric Pugh. Revision Changes Path 1.14 +16 -16 jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ConvertUtils.java Index: ConvertUtils.java =================================================================== RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ConvertUtils.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ConvertUtils.java 3 Mar 2003 22:33:46 -0000 1.13 +++ ConvertUtils.java 16 Apr 2003 08:36:34 -0000 1.14 @@ -66,7 +66,7 @@ *

Utility methods for converting String scalar values to objects of the * specified Class, String arrays to arrays of the specified Class.

* - *

For more details, see ConvertUtilsBean which provides the + *

For more details, see ConvertUtilsBean which provides the * implementations for these methods.

* * @author Craig R. McClanahan @@ -191,7 +191,7 @@ * Integer.class instead */ public static void setDefaultInteger(int newDefaultInteger) { - ConvertUtilsBean.getInstance().setDefaultInteger(newDefaultInteger); + ConvertUtilsBean.getInstance().setDefaultInteger(newDefaultInteger); } @@ -240,7 +240,7 @@ * *

For more details see ConvertUtilsBean.

* - * @see ConvertUtilsBean#convert(Object) + * @see ConvertUtilsBean#convert(Object) */ public static String convert(Object value) { @@ -255,11 +255,11 @@ * *

For more details see ConvertUtilsBean.

* - * @see ConvertUtilsBean#convert(String, Class) + * @see ConvertUtilsBean#convert(String, Class) */ public static Object convert(String value, Class clazz) { - return ConvertUtilsBean.getInstance().convert(value, clazz); + return ConvertUtilsBean.getInstance().convert(value, clazz); } @@ -270,11 +270,11 @@ * *

For more details see ConvertUtilsBean.

* - * @see ConvertUtilsBean#convert(String[], Class) + * @see ConvertUtilsBean#convert(String[], Class) */ public static Object convert(String values[], Class clazz) { - return ConvertUtilsBean.getInstance().convert(values, clazz); + return ConvertUtilsBean.getInstance().convert(values, clazz); } @@ -285,7 +285,7 @@ * *

For more details see ConvertUtilsBean.

* - * @see ConvertUtilsBean#deregister() + * @see ConvertUtilsBean#deregister() */ public static void deregister() { @@ -300,11 +300,11 @@ * *

For more details see ConvertUtilsBean.

* - * @see ConvertUtilsBean#deregister(Class) + * @see ConvertUtilsBean#deregister(Class) */ public static void deregister(Class clazz) { - ConvertUtilsBean.getInstance().deregister(); + ConvertUtilsBean.getInstance().deregister(clazz); } @@ -316,7 +316,7 @@ * *

For more details see ConvertUtilsBean.

* - * @see ConvertUtilsBean#lookup(Class) + * @see ConvertUtilsBean#lookup(Class) */ public static Converter lookup(Class clazz) { @@ -331,7 +331,7 @@ * *

For more details see ConvertUtilsBean.

* - * @see ConvertUtilsBean#register(Converter, Class) + * @see ConvertUtilsBean#register(Converter, Class) */ public static void register(Converter converter, Class clazz) { 1.7 +44 -26 jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/ConvertUtilsTestCase.java Index: ConvertUtilsTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/ConvertUtilsTestCase.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ConvertUtilsTestCase.java 15 Mar 2003 11:38:11 -0000 1.6 +++ ConvertUtilsTestCase.java 16 Apr 2003 08:36:34 -0000 1.7 @@ -70,6 +70,7 @@ import junit.framework.TestCase; import junit.framework.Test; import junit.framework.TestSuite; +import org.apache.commons.beanutils.converters.BooleanConverter; /** @@ -582,66 +583,83 @@ } - + public void testSeparateConvertInstances() throws Exception { ConvertUtilsBean utilsOne = new ConvertUtilsBean(); ConvertUtilsBean utilsTwo = new ConvertUtilsBean(); - + // make sure that the test work ok before anything's changed Object value = utilsOne.convert("true", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals( - "Standard conversion failed (1)", - ((Boolean) value).booleanValue(), + "Standard conversion failed (1)", + ((Boolean) value).booleanValue(), true); - + value = utilsTwo.convert("true", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals( - "Standard conversion failed (2)", - ((Boolean) value).booleanValue(), + "Standard conversion failed (2)", + ((Boolean) value).booleanValue(), true); - + // now register a test - + utilsOne.register(new ThrowExceptionConverter(), Boolean.TYPE); try { - + utilsOne.convert("true", Boolean.TYPE); fail("Register converter failed."); - + } catch (PassTestException e) { /* This shows that the registration has worked */ } - + try { // nothing should have changed value = utilsTwo.convert("true", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals( "Standard conversion failed (3)", - ((Boolean) value).booleanValue(), + ((Boolean) value).booleanValue(), true); - - } catch (PassTestException e) { - // This is a failure since utilsTwo should still have - // standard converters registered + + } catch (PassTestException e) { + // This is a failure since utilsTwo should still have + // standard converters registered fail("Registering a converter for an instance should not effect another instance."); } - + // nothing we'll test deregister utilsOne.deregister(); value = utilsOne.convert("true", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals("Instance deregister failed.", ((Boolean) value).booleanValue(), true); - + value = utilsTwo.convert("true", Boolean.TYPE); assertTrue(value instanceof Boolean); assertEquals( - "Standard conversion failed (4)", - ((Boolean) value).booleanValue(), + "Standard conversion failed (4)", + ((Boolean) value).booleanValue(), + true); + } + + public void testDeregisteringSingleConverter() throws Exception { + ConvertUtils convertUtils = new ConvertUtils(); + + // make sure that the test work ok before anything's changed + Object + value = convertUtils.convert("true", Boolean.TYPE); + assertTrue(value instanceof Boolean); + assertEquals( + "Standard conversion failed (1)", + ((Boolean) value).booleanValue(), true); - } + // we'll test deregister + convertUtils.deregister(Boolean.TYPE); + assertNull("Converter should be null",convertUtils.lookup(Boolean.TYPE)); + + } // -------------------------------------------------------- Private Methods --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org