craigmcc 01/09/03 10:34:36 Modified: beanutils/src/java/org/apache/commons/beanutils MappedPropertyDescriptor.java beanutils/src/test/org/apache/commons/beanutils PropertyUtilsTestCase.java TestBean.java Log: Correct property type returned by getMappedPropertyType() when it is not a String. Submitted by: Jan Sorensen <[EMAIL PROTECTED]> Revision Changes Path 1.2 +5 -5 jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java Index: MappedPropertyDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MappedPropertyDescriptor.java 2001/08/21 21:59:02 1.1 +++ MappedPropertyDescriptor.java 2001/09/03 17:34:36 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java,v 1.1 2001/08/21 21:59:02 craigmcc Exp $ - * $Revision: 1.1 $ - * $Date: 2001/08/21 21:59:02 $ + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java,v 1.2 2001/09/03 17:34:36 craigmcc Exp $ + * $Revision: 1.2 $ + * $Date: 2001/09/03 17:34:36 $ * * ==================================================================== * @@ -83,7 +83,7 @@ * * @author Rey François * @author Gregor Raıman - * @version $Revision: 1.1 $ $Date: 2001/08/21 21:59:02 $ + * @version $Revision: 1.2 $ $Date: 2001/09/03 17:34:36 $ */ public class MappedPropertyDescriptor extends PropertyDescriptor { @@ -331,7 +331,7 @@ throw new IntrospectionException ("type mismatch between mapped read and write methods"); } - mappedPropertyType = params[0]; + mappedPropertyType = params[1]; } } catch (IntrospectionException ex) { throw ex; 1.10 +26 -4 jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java Index: PropertyUtilsTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- PropertyUtilsTestCase.java 2001/08/21 23:05:08 1.9 +++ PropertyUtilsTestCase.java 2001/09/03 17:34:36 1.10 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java,v 1.9 2001/08/21 23:05:08 craigmcc Exp $ - * $Revision: 1.9 $ - * $Date: 2001/08/21 23:05:08 $ + * $Header: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java,v 1.10 2001/09/03 17:34:36 craigmcc Exp $ + * $Revision: 1.10 $ + * $Date: 2001/09/03 17:34:36 $ * * ==================================================================== * @@ -99,7 +99,7 @@ * </ul> * * @author Craig R. McClanahan - * @version $Revision: 1.9 $ $Date: 2001/08/21 23:05:08 $ + * @version $Revision: 1.10 $ $Date: 2001/09/03 17:34:36 $ */ public class PropertyUtilsTestCase extends TestCase { @@ -1624,6 +1624,28 @@ public void testGetWriteMethodPublicSubclass() { testGetWriteMethod(beanPublicSubclass, properties, TEST_BEAN_CLASS); + + } + + + /** + * Test the mappedPropertyType of MappedPropertyDescriptor. + */ + public void testMappedPropertyType() throws Exception { + + MappedPropertyDescriptor desc; + + // Check a String property + desc = (MappedPropertyDescriptor) + PropertyUtils.getPropertyDescriptor(bean, + "mappedProperty"); + assertEquals(String.class, desc.getMappedPropertyType()); + + // Check an int property + desc = (MappedPropertyDescriptor) + PropertyUtils.getPropertyDescriptor(bean, + "mappedIntProperty"); + assertEquals(Integer.TYPE, desc.getMappedPropertyType()); } 1.4 +25 -4 jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestBean.java Index: TestBean.java =================================================================== RCS file: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TestBean.java 2001/08/21 21:59:02 1.3 +++ TestBean.java 2001/09/03 17:34:36 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestBean.java,v 1.3 2001/08/21 21:59:02 craigmcc Exp $ - * $Revision: 1.3 $ - * $Date: 2001/08/21 21:59:02 $ + * $Header: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestBean.java,v 1.4 2001/09/03 17:34:36 craigmcc Exp $ + * $Revision: 1.4 $ + * $Date: 2001/09/03 17:34:36 $ * * ==================================================================== * @@ -70,7 +70,7 @@ * General purpose test bean for JUnit tests for the "beanutils" component. * * @author Craig R. McClanahan - * @version $Revision: 1.3 $ $Date: 2001/08/21 21:59:02 $ + * @version $Revision: 1.4 $ $Date: 2001/09/03 17:34:36 $ */ public class TestBean { @@ -208,6 +208,27 @@ public void setMappedProperty(String key, String value) { mappedProperty.put(key, value); + } + + + /** + * A mapped property that has String keys and int values. + */ + private HashMap mappedIntProperty = null; + + public int getMappedIntProperty(String key) { + // Create the map the very first time + if (mappedProperty == null) { + mappedProperty = new HashMap(); + mappedProperty.put("One", new Integer(1)); + mappedProperty.put("Two", new Integer(2)); + } + Integer x = (Integer) mappedIntProperty.get(key); + return ((x == null) ? 0 : x.intValue()); + } + + public void setMappedIntProperty(String key, int value) { + mappedIntProperty.put(key, new Integer(value)); }