You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by cr...@apache.org on 2004/02/15 05:28:19 UTC

cvs commit: jakarta-commons/beanutils/src/test/org/apache/commons/beanutils BeanUtilsTestCase.java DynaBeanUtilsTestCase.java

craigmcc    2004/02/14 20:28:19

  Modified:    beanutils/src/test/org/apache/commons/beanutils
                        BeanUtilsTestCase.java DynaBeanUtilsTestCase.java
  Log:
  Add some additional tests for null property values.
  
  Revision  Changes    Path
  1.28      +33 -4     jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/BeanUtilsTestCase.java
  
  Index: BeanUtilsTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/BeanUtilsTestCase.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- BeanUtilsTestCase.java	9 Oct 2003 20:40:07 -0000	1.27
  +++ BeanUtilsTestCase.java	15 Feb 2004 04:28:19 -0000	1.28
  @@ -752,6 +752,8 @@
   
           try {
   
  +            bean.setNullProperty("Non-null value");
  +
               HashMap map = new HashMap();
               map.put("booleanProperty", "false");
               // booleanSecond is left at true
  @@ -760,6 +762,7 @@
               // floatProperty is left at 123.0
               map.put("intProperty", "543");
               map.put("longProperty", "");
  +            map.put("nullProperty", null);
               map.put("shortProperty", "654");
               // stringProperty is left at "This is a string"
               map.put("writeOnlyProperty", "New writeOnlyProperty value");
  @@ -781,6 +784,8 @@
                            543, bean.getIntProperty());
               assertEquals("longProperty is 0",
                            (long) 0, bean.getLongProperty());
  +            assertNull("nullProperty is null",
  +                       bean.getNullProperty());
               assertEquals("shortProperty is 654",
                            (short) 654, bean.getShortProperty());
               assertEquals("stringProperty is \"This is a string\"",
  @@ -968,6 +973,18 @@
   
   
       /**
  +     * Test setting a null property value.
  +     */
  +    public void testSetPropertyNull() throws Exception {
  +
  +        bean.setNullProperty("non-null value");
  +        BeanUtils.setProperty(bean, "nullProperty", null);
  +        assertNull("nullProperty is null", bean.getNullProperty());
  +
  +    }
  +
  +
  +    /**
        * Test narrowing and widening conversions on short.
        */
       public void testSetPropertyShort() throws Exception {
  @@ -1208,6 +1225,18 @@
           assertNotNull(bean.getNested());
           assertEquals(0, bean.getIntProperty());
           assertEquals(4, bean.getNested().getIntProperty());
  +
  +    }
  +
  +
  +    /**
  +     * Test copying a null property value.
  +     */
  +    public void testCopyPropertyNull() throws Exception {
  +
  +        bean.setNullProperty("non-null value");
  +        BeanUtils.copyProperty(bean, "nullProperty", null);
  +        assertNull("nullProperty is null", bean.getNullProperty());
   
       }
   
  
  
  
  1.21      +32 -4     jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/DynaBeanUtilsTestCase.java
  
  Index: DynaBeanUtilsTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/DynaBeanUtilsTestCase.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DynaBeanUtilsTestCase.java	9 Oct 2003 20:40:07 -0000	1.20
  +++ DynaBeanUtilsTestCase.java	15 Feb 2004 04:28:19 -0000	1.21
  @@ -884,6 +884,8 @@
   
           try {
   
  +            bean.set("nullProperty", "non-null value");
  +
               HashMap map = new HashMap();
               map.put("booleanProperty", "false");
               // booleanSecond is left at true
  @@ -891,6 +893,7 @@
               // floatProperty is left at 123.0
               map.put("intProperty", "543");
               // longProperty is left at 321
  +            map.put("nullProperty", null);
               map.put("shortProperty", "654");
               // stringProperty is left at "This is a string"
   
  @@ -914,6 +917,7 @@
               Long longProperty = (Long) bean.get("longProperty");
               assertEquals("longProperty is 321",
                            (long) 321, longProperty.longValue());
  +            assertNull("nullProperty is null", bean.get("nullProperty"));
               Short shortProperty = (Short) bean.get("shortProperty");
               assertEquals("shortProperty is 654",
                            (short) 654, shortProperty.shortValue());
  @@ -986,6 +990,18 @@
   
   
       /**
  +     * Test setting a null property value.
  +     */
  +    public void testSetPropertyNull() throws Exception {
  +
  +        bean.set("nullProperty", "non-null value");
  +        BeanUtils.setProperty(bean, "nullProperty", null);
  +        assertNull("nullProperty is null", bean.get("nullProperty"));
  +
  +    }
  +
  +
  +    /**
        * Test narrowing and widening conversions on byte.
        */
       public void testCopyPropertyByte() throws Exception {
  @@ -1092,6 +1108,18 @@
           assertEquals((long) 123, ((Long) bean.get("longProperty")).longValue());
           BeanUtils.setProperty(bean, "longProperty", new Short((short) 123));
           assertEquals((long) 123, ((Long) bean.get("longProperty")).longValue());
  +
  +    }
  +
  +
  +    /**
  +     * Test copying a null property value.
  +     */
  +    public void testCopyPropertyNull() throws Exception {
  +
  +        bean.set("nullProperty", "non-null value");
  +        BeanUtils.copyProperty(bean, "nullProperty", null);
  +        assertNull("nullProperty is null", bean.get("nullProperty"));
   
       }
   
  
  
  

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