You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/08/29 11:48:43 UTC

DO NOT REPLY [Bug 12152] New: - Combined property access ( b.mapped(bar/foo) ) throws excception

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12152>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12152

Combined property access ( b.mapped(bar/foo) ) throws excception

           Summary: Combined property access ( b.mapped(bar/foo) ) throws
                    excception
           Product: Commons
           Version: 1.4 Final
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: Bean Utilities
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: vnesek@yahoo.com


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;
	}

}

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>