Author: ggregory
Date: Wed Jun  1 06:07:14 2016
New Revision: 1746394

URL: http://svn.apache.org/viewvc?rev=1746394&view=rev
Log:
[BEANUTILS-474] FluentPropertyBeanIntrospector does not use the same naming 
algorithm as DefaultBeanIntrospector.

Modified:
    
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospector.java
    
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospectorTestCase.java

Modified: 
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospector.java
URL: 
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospector.java?rev=1746394&r1=1746393&r2=1746394&view=diff
==============================================================================
--- 
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospector.java
 (original)
+++ 
commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospector.java
 Wed Jun  1 06:07:14 2016
@@ -17,6 +17,7 @@
 package org.apache.commons.beanutils;
 
 import java.beans.IntrospectionException;
+import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.lang.reflect.Method;
 import java.util.Locale;
@@ -159,8 +160,7 @@ public class FluentPropertyBeanIntrospec
     private String propertyName(final Method m) {
         final String methodName = m.getName().substring(
                 getWriteMethodPrefix().length());
-        return (methodName.length() > 1) ? Character.toLowerCase(methodName
-                .charAt(0)) + methodName.substring(1) : methodName
+        return (methodName.length() > 1) ? 
Introspector.decapitalize(methodName) : methodName
                 .toLowerCase(Locale.ENGLISH);
     }
 

Modified: 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospectorTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospectorTestCase.java?rev=1746394&r1=1746393&r2=1746394&view=diff
==============================================================================
--- 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospectorTestCase.java
 (original)
+++ 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/FluentPropertyBeanIntrospectorTestCase.java
 Wed Jun  1 06:07:14 2016
@@ -18,6 +18,7 @@ package org.apache.commons.beanutils;
 
 import java.beans.IntrospectionException;
 import java.beans.PropertyDescriptor;
+import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -93,4 +94,36 @@ public class FluentPropertyBeanIntrospec
         assertNotNull("No write method for fluentGetProperty",
                 pd.getWriteMethod());
     }
+
+    public void testIntrospectionCaps() throws Exception {
+           final PropertyUtilsBean pu = new PropertyUtilsBean();
+
+        final FluentPropertyBeanIntrospector introspector = new 
FluentPropertyBeanIntrospector();
+
+           pu.addBeanIntrospector(introspector);
+
+           final Map<String, PropertyDescriptor> props = createDescriptorMap(
+                       pu.getPropertyDescriptors(CapsBean.class));
+
+           PropertyDescriptor aDescriptor = fetchDescriptor(props, "URI");
+
+           assertNotNull("missing property", aDescriptor);
+
+           assertNotNull("No read method for uri", 
aDescriptor.getReadMethod());
+           assertNotNull("No write method for uri", 
aDescriptor.getWriteMethod());
+
+           assertNull("Should not find mis-capitalized property", 
props.get("uRI"));
+    }
+
+       public static final class CapsBean {
+               private URI mURI;
+
+               public URI getURI() {
+                       return mURI;
+               }
+
+               public void setURI(final URI theURI) {
+                       mURI = theURI;
+               }
+       }
 }


Reply via email to