You should ask this on the commons user list:
http://commons.apache.org/beanutils/mail-lists.html
...but the reason is because you have used the wrong names for keys in
your Map - the first character should be lower case (so "properyA" and
"propertyB") - this is the java beans spec
If you change the key names then it works.
Niall
On Fri, Feb 29, 2008 at 8:27 AM, Giovanni Azua <[EMAIL PROTECTED]> wrote:
> hi,
>
> Sorry for the of-topic but given that BeanUtils is heavily used in
> Struts, can anyone suggest why this test does not pass neither in 1.7
> nor 1.8? alternative way using BeanUtils? I had to end up implementing
> my own Reflection-based copyProperties ...
>
>
> //------------------------------------------------------------------------
> public void
> testCopyProperties()
> throws Exception
> {
> 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 = 0;
> private double thePropertyB = 0;
> }
>
> 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("BeanUtilsBean.copyProperties did not work as
> expected",
> myExpected, myBean.toString());
> }
>
> TIA,
> regards,
> Giovanni
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]