commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/beanutils/src/test/org/apache/commons/beanutils ConvertUtilsTestCase.java
Date Sat, 15 Jun 2002 21:14:34 GMT
craigmcc    2002/06/15 14:14:34

  Modified:    beanutils/src/java/org/apache/commons/beanutils/converters
                        BooleanConverter.java
               beanutils/src/test/org/apache/commons/beanutils
                        ConvertUtilsTestCase.java
  Log:
  Make BooleanConverter accept "y" and "n" for String->Boolean conversions.
  
  Thanks for the patch!
  
  PR: Bugzilla #9582
  Submitted by:	Tomas Viberg <tomas at viberg.nu>
  
  Revision  Changes    Path
  1.4       +6 -4      jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java
  
  Index: BooleanConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BooleanConverter.java	29 Apr 2002 16:32:44 -0000	1.3
  +++ BooleanConverter.java	15 Jun 2002 21:14:34 -0000	1.4
  @@ -151,11 +151,13 @@
           try {
               String stringValue = (String) value;
               if (stringValue.equalsIgnoreCase("yes") ||
  +                stringValue.equalsIgnoreCase("y") ||
                   stringValue.equalsIgnoreCase("true") ||
                   stringValue.equalsIgnoreCase("on") ||
                   stringValue.equalsIgnoreCase("1")) {
                   return (Boolean.TRUE);
               } else if (stringValue.equalsIgnoreCase("no") ||
  +                       stringValue.equalsIgnoreCase("n") ||
                          stringValue.equalsIgnoreCase("false") ||
                          stringValue.equalsIgnoreCase("off") ||
                          stringValue.equalsIgnoreCase("0")) {
  
  
  
  1.3       +20 -4     jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/ConvertUtilsTestCase.java
  
  Index: ConvertUtilsTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/ConvertUtilsTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConvertUtilsTestCase.java	15 Jun 2002 20:39:44 -0000	1.2
  +++ ConvertUtilsTestCase.java	15 Jun 2002 21:14:34 -0000	1.3
  @@ -310,6 +310,14 @@
           assertTrue(value instanceof Boolean);
           assertEquals(((Boolean) value).booleanValue(), true);
   
  +        value = ConvertUtils.convert("y", Boolean.TYPE);
  +        assertTrue(value instanceof Boolean);
  +        assertEquals(((Boolean) value).booleanValue(), true);
  +
  +        value = ConvertUtils.convert("y", Boolean.class);
  +        assertTrue(value instanceof Boolean);
  +        assertEquals(((Boolean) value).booleanValue(), true);
  +
           value = ConvertUtils.convert("on", Boolean.TYPE);
           assertTrue(value instanceof Boolean);
           assertEquals(((Boolean) value).booleanValue(), true);
  @@ -331,6 +339,14 @@
           assertEquals(((Boolean) value).booleanValue(), false);
   
           value = ConvertUtils.convert("no", Boolean.class);
  +        assertTrue(value instanceof Boolean);
  +        assertEquals(((Boolean) value).booleanValue(), false);
  +
  +        value = ConvertUtils.convert("n", Boolean.TYPE);
  +        assertTrue(value instanceof Boolean);
  +        assertEquals(((Boolean) value).booleanValue(), false);
  +
  +        value = ConvertUtils.convert("n", Boolean.class);
           assertTrue(value instanceof Boolean);
           assertEquals(((Boolean) value).booleanValue(), false);
   
  
  
  

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


Mime
View raw message