Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
1.4
-
None
-
None
-
None
-
Operating System: other
Platform: Other
-
12152
Description
Combined property access ( b.mapped(bar/foo) ) in beanutils 1.4.1
throws excception. It used to work in 1.3. I think changes related
to supporting '.' in keys for mapped access are cousing it.
There was 1 error:
1) testA_B_Mapped(org.apache.commons.beanutils.test.CombinedPropertyAccessTest)
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at org.apache.commons.beanutils.PropertyUtils.getMappedProperty
(PropertyUtils.java:617)
at org.apache.commons.beanutils.PropertyUtils.getMappedProperty
(PropertyUtils.java:555)
at org.apache.commons.beanutils.PropertyUtils.getNestedProperty
(PropertyUtils.java:747)
at org.apache.commons.beanutils.PropertyUtils.getProperty
(PropertyUtils.java:780)
at
org.apache.commons.beanutils.test.CombinedPropertyAccessTest.testA_B_Mapped
(CombinedPropertyAccessTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at org.apache.commons.beanutils.test.CombinedPropertyAccessTest.main
(CombinedPropertyAccessTest.java:31)
Following are a two classes and JUnit test case:
package org.apache.commons.beanutils.test;
import junit.framework.TestCase;
import org.apache.commons.beanutils.PropertyUtils;
/**
- Tests combined property access.
- @author Vjekoslav Nesek
*/
public class CombinedPropertyAccessTest extends TestCase {
/**
- Constructor for CombinedPropertyAccessTest.
- @param test
*/
public CombinedPropertyAccessTest(String test) { super(test); }
public void testA_B_Mapped() throws Exception
{ A a = new A(); B b = new B(); a.setB(b); assertEquals(PropertyUtils.getProperty(a, "b.mapped (bar/foo)"), "bar/foo"); }public static void main(String[] args)
{ junit.textui.TestRunner.run(CombinedPropertyAccessTest.class); }}
package org.apache.commons.beanutils.test;
public class A {
private B b;
/**
- Returns the b.
- @return B
*/
public B getB() { return b; }
/**
- Sets the b.
- @param b The b to set
*/
public void setB(B b) { this.b = b; }
}
package org.apache.commons.beanutils.test;
public class B {
public void setMapped(String key, Object value) {
}
public Object getMapped(String key)
{ return key; }}