commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giovanni Azua <g...@imc.nl>
Subject question on copyProperties usage
Date Fri, 29 Feb 2008 09:19:31 GMT
hi all,

I have not been able to have the following test case pass under 1.7 and 1.8.

Here the list of trial-errors:
- Assigning to myMap property names starting upper case does not provide 
any error as I would expect it should i.e. IllegalArgumentException  
"Malformed property names provided in Map"

- Assigning proper property names i.e. "propertyA" I consistently get 
InvokationTargetException

TIA,
regards,
Giovanni

//------------------------------------------------------------------------
public void
testCopyProperties()
throws Exception
{
    @SuppressWarnings("unused")
    class SomeBean
    {
        //----------------------------------------------------------------
        public final double
        getPropertyA()
        {
            return thePropertyA;
        }

        //----------------------------------------------------------------
        public final void
        setPropertyA(double aPropertyA)
        {
            thePropertyA = aPropertyA;
        }

        //----------------------------------------------------------------
        public final double
        getPropertyB()
        {
            return thePropertyB;
        }

        //----------------------------------------------------------------
        public final void
        setPropertyB(double aPropertyB)
        {
            thePropertyB = aPropertyB;
        }

        //----------------------------------------------------------------
        /** (non-Javadoc)
         * @see java.lang.Object#toString()
         */
        @Override
        public String
        toString()
        {
            return "(" + getPropertyA() + ", " + getPropertyB() + ")";
        }

        //----------------------------------------------------------------
        // members
        //----------------------------------------------------------------
        private double thePropertyA;
        private double thePropertyB;
    }

    Object myBean = new SomeBean();

    String myExpected = "(1.0, 1.0)";

    Map<String, Object> myMap = new HashMap<String, Object>();
    myMap.put("propertyA", 1.0);
    myMap.put("propertyB", 1.0);

    BeanUtilsBean.getInstance().copyProperties(myBean, myMap);

    assertEquals("copyProperties method did not work as expected.",
        myExpected, myBean.toString());
}

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


Mime
View raw message