commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ville Autio <au...@inbox.com>
Subject [beanutils] BeanUtils.copyProperties and null values
Date Thu, 18 Oct 2012 09:58:37 GMT
I wonder what's the idea with this? Is this a bug or a feature? Using 1.8.3.

public class BeanUtilsTest {

    @Test
    public void testCopyProperties() throws Exception {

        SomeBean bean = new SomeBean();
        assertNull(bean.getId());

        BeanUtils.copyProperties(bean, new SomeBean());
        assertNull(bean.getId()); // Fails because bean.getId() returns 0.
    }

    public static class SomeBean {

        private Long id;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }
    }
}

____________________________________________________________
Publish your photos in seconds for FREE
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4



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


Mime
View raw message