commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r332503 - in /jakarta/commons/proper/beanutils/trunk/src: java/org/apache/commons/beanutils/ test/org/apache/commons/beanutils/
Date Fri, 11 Nov 2005 09:55:23 GMT
Author: niallp
Date: Fri Nov 11 01:55:13 2005
New Revision: 332503

URL: http://svn.apache.org/viewcvs?rev=332503&view=rev
Log:
Fix for Bug 27760 - MappedPropertyDescriptor doesn't recognize boolean property accessor,
reported by Chris Audley 

Modified:
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java
    jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestBean.java
    jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestCase.java

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java?rev=332503&r1=332502&r2=332503&view=diff
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/MappedPropertyDescriptor.java
Fri Nov 11 01:55:13 2005
@@ -100,8 +100,13 @@
         
         // Look for mapped read method and matching write method
         try {
-            mappedReadMethod = getMethod(beanClass, "get" + base,
-                    stringClassArray);
+            try {
+                mappedReadMethod = getMethod(beanClass, "get" + base,
+                        stringClassArray);
+            } catch (IntrospectionException e) {
+                mappedReadMethod = getMethod(beanClass, "is" + base,
+                        stringClassArray);
+            }
             Class params[] = { String.class, mappedReadMethod.getReturnType() };
             mappedWriteMethod = getMethod(beanClass, "set" + base, params);
         } catch (IntrospectionException e) {

Modified: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestBean.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestBean.java?rev=332503&r1=332502&r2=332503&view=diff
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestBean.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestBean.java
Fri Nov 11 01:55:13 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Copyright 2001-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,6 +39,14 @@
 
     public void setMapproperty(String key, String value) {	
         map.put(key, value);
+    }
+
+    public boolean isMappedBoolean(String key) {
+        return ((Boolean)map.get(key)).booleanValue();
+    }
+
+    public void setMappedBoolean(String key, boolean value) {	
+        map.put(key, (value ? Boolean.TRUE : Boolean.FALSE));
     }
 
     protected String getProtectedMapped(String key) {

Modified: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestCase.java?rev=332503&r1=332502&r2=332503&view=diff
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestCase.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/MappedPropertyTestCase.java
Fri Nov 11 01:55:13 2005
@@ -90,6 +90,22 @@
     }
 
     /**
+     * Test boolean "is" method name
+     */
+    public void testBooleanMapped() {
+        String property = "mappedBoolean";
+        Class clazz = MappedPropertyTestBean.class;
+        try {
+            MappedPropertyDescriptor desc 
+                = new MappedPropertyDescriptor(property, clazz);
+            assertNotNull("Getter is missing", desc.getMappedReadMethod());
+            assertNotNull("Setter is missing", desc.getMappedWriteMethod());
+        } catch (Exception ex) {
+            fail("Property '" + property + "' Not Found in " + clazz.getName() + ": " + ex);
+        }
+    }
+
+    /**
      * Test invalid method name
      */
     public void testNotFound() {



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


Mime
View raw message