commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r628158 - in /commons/proper/beanutils/trunk: pom.xml src/java/org/apache/commons/beanutils/locale/LocaleConvertUtilsBean.java src/test/org/apache/commons/beanutils/locale/LocaleConvertUtilsTestCase.java
Date Fri, 15 Feb 2008 20:14:21 GMT
Author: niallp
Date: Fri Feb 15 12:14:20 2008
New Revision: 628158

URL: http://svn.apache.org/viewvc?rev=628158&view=rev
Log:
Fix for BEANUTILS-306 - LocaleConvertUtilsBean.convert throws NPE on null Locale when debug
logging is enabled
(NOTE: change surefire plugin configuration logging level to "DEBUG" in pom.xml to test this
is fixed)

Modified:
    commons/proper/beanutils/trunk/pom.xml
    commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/locale/LocaleConvertUtilsBean.java
    commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/locale/LocaleConvertUtilsTestCase.java

Modified: commons/proper/beanutils/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/pom.xml?rev=628158&r1=628157&r2=628158&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/pom.xml (original)
+++ commons/proper/beanutils/trunk/pom.xml Fri Feb 15 12:14:20 2008
@@ -180,6 +180,23 @@
                 -->
                 <exclude>**/*MemoryTestCase.java</exclude>
               </excludes>
+
+              <!-- Configure Logging -->
+              <systemProperties>
+                  <property>
+                      <name>org.apache.commons.logging.LogFactory</name>
+                      <value>org.apache.commons.logging.impl.LogFactoryImpl</value>
+                  </property>
+                  <property>
+                      <name>org.apache.commons.logging.Log</name>
+                      <value>org.apache.commons.logging.impl.SimpleLog</value>
+                  </property>
+                  <property>
+                      <name>org.apache.commons.logging.simplelog.defaultlog</name>
+                      <value>WARN</value>
+                  </property>
+              </systemProperties>
+
           </configuration>
         </plugin>
         <plugin>

Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/locale/LocaleConvertUtilsBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/locale/LocaleConvertUtilsBean.java?rev=628158&r1=628157&r2=628158&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/locale/LocaleConvertUtilsBean.java
(original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/locale/LocaleConvertUtilsBean.java
Fri Feb 15 12:14:20 2008
@@ -263,7 +263,7 @@
 
         if (log.isDebugEnabled()) {
             log.debug("Convert string " + value + " to class " +
-                    clazz.getName() + " using " + locale.toString() +
+                    clazz.getName() + " using " + locale +
                     " locale and " + pattern + " pattern");
         }
 
@@ -333,7 +333,7 @@
         }
         if (log.isDebugEnabled()) {
             log.debug("Convert String[" + values.length + "] to class " +
-                    type.getName() + "[] using " + locale.toString() +
+                    type.getName() + "[] using " + locale +
                     " locale and " + pattern + " pattern");
         }
 

Modified: commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/locale/LocaleConvertUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/locale/LocaleConvertUtilsTestCase.java?rev=628158&r1=628157&r2=628158&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/locale/LocaleConvertUtilsTestCase.java
(original)
+++ commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/locale/LocaleConvertUtilsTestCase.java
Fri Feb 15 12:14:20 2008
@@ -23,6 +23,7 @@
 import java.sql.Timestamp;
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
+import java.util.Locale;
 
 import junit.framework.TestCase;
 import junit.framework.Test;
@@ -593,6 +594,39 @@
                 stringArray.getClass());
         checkStringArray(value, stringArray2);
 
+    }
+
+    /**
+     * Test conversion of a String using a Locale and pattern.
+     */
+    public void testConvertStringLocaleNull() {
+        Object result = null;
+        try {
+            result = LocaleConvertUtils.convert("123", Integer.class, (Locale)null, "#,###");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("Threw: " + e);
+        }
+        assertNotNull("Null Result", result);
+        assertEquals("Integer Type", Integer.class, result.getClass());
+        assertEquals("Integer Value", new Integer(123), result);
+    }
+
+    /**
+     * Test conversion of a String array using a Locale and pattern.
+     */
+    public void testConvertStringArrayLocaleNull() {
+        Object result = null;
+        try {
+            result = LocaleConvertUtils.convert(new String[] {"123"}, Integer[].class, (Locale)null,
"#,###");
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("Threw: " + e);
+        }
+        assertNotNull("Null Result", result);
+        assertEquals("Integer Array Type", Integer[].class, result.getClass());
+        assertEquals("Integer Array Length", 1, ((Integer[])result).length);
+        assertEquals("Integer Array Value", new Integer(123), ((Integer[])result)[0]);
     }
 
 



Mime
View raw message