camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r925739 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/util/IntrospectionSupport.java test/java/org/apache/camel/util/IntrospectionSupportTest.java test/java/org/apache/camel/util/jndi/ExampleBean.java
Date Sun, 21 Mar 2010 08:16:56 GMT
Author: davsclaus
Date: Sun Mar 21 08:16:56 2010
New Revision: 925739

URL: http://svn.apache.org/viewvc?rev=925739&view=rev
Log:
CAMEL-2561: Fixed Camel bean introspection to use English locale to avoid issues with foregin
languages in upper casing letters. Thanks to Christian Mueller for patch.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jndi/ExampleBean.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?rev=925739&r1=925738&r2=925739&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java Sun
Mar 21 08:16:56 2010
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
@@ -156,7 +157,7 @@ public final class IntrospectionSupport 
         ObjectHelper.notNull(target, "target");
         ObjectHelper.notNull(property, "property");
 
-        property = property.substring(0, 1).toUpperCase() + property.substring(1);
+        property = property.substring(0, 1).toUpperCase(Locale.ENGLISH) + property.substring(1);
 
         Class<?> clazz = target.getClass();
         Method method = getPropertyGetter(clazz, property);

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java?rev=925739&r1=925738&r2=925739&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java
Sun Mar 21 08:16:56 2010
@@ -19,6 +19,7 @@ package org.apache.camel.util;
 import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.camel.ContextTestSupport;
@@ -126,6 +127,28 @@ public class IntrospectionSupportTest ex
         Object name = IntrospectionSupport.getProperty(bean, "name");
         assertEquals("Claus", name);
     }
+    
+    public void testGetPropertyLocaleIndependend() throws Exception {
+        Locale oldLocale = Locale.getDefault();
+        Locale.setDefault(new Locale("tr", "TR"));
+        
+        try {
+            ExampleBean bean = new ExampleBean();
+            bean.setName("Claus");
+            bean.setPrice(10.0);
+            bean.setId("1");
+    
+            Object name = IntrospectionSupport.getProperty(bean, "name");
+            Object id = IntrospectionSupport.getProperty(bean, "id");
+            Object price = IntrospectionSupport.getProperty(bean, "price");
+            
+            assertEquals("Claus", name);
+            assertEquals(10.0, price);
+            assertEquals("1", id);
+        } finally {
+            Locale.setDefault(oldLocale);
+        }
+    }
 
     public void testGetPropertyGetter() throws Exception {
         ExampleBean bean = new ExampleBean();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jndi/ExampleBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/jndi/ExampleBean.java?rev=925739&r1=925738&r2=925739&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/jndi/ExampleBean.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/jndi/ExampleBean.java Sun Mar
21 08:16:56 2010
@@ -20,11 +20,12 @@ package org.apache.camel.util.jndi;
  * @version $Revision$
  */
 public class ExampleBean {
+    private String id;
     private String name;
     private double price;
 
     public String toString() {
-        return "ExampleBean[name: " + name + " price: " + price + "]";
+        return "ExampleBean[name: " + name + " price: " + price + " id: " + id + "]";
     }
 
     public String getName() {
@@ -42,4 +43,12 @@ public class ExampleBean {
     public void setPrice(double price) {
         this.price = price;
     }
-}
+    
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+}
\ No newline at end of file



Mime
View raw message