Author: niallp Date: Thu May 24 07:31:50 2007 New Revision: 541308 URL: http://svn.apache.org/viewvc?view=rev&rev=541308 Log: BEANUTILS-87 - Package scope implementation of a public interface for mapped property fails. Adding a test case to prove that this has been resolved (running the test with BeanUtils 1.7.0 failed, but passes with current BeanUtils trunk) - fixed by changes to MappedPropertyDescriptor associated with BEANUTILS-6)
Added: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira87TestCase.java (with props) jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira87BeanFactory.java (with props) Added: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira87TestCase.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira87TestCase.java?view=auto&rev=541308 ============================================================================== --- jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira87TestCase.java (added) +++ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira87TestCase.java Thu May 24 07:31:50 2007 @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.beanutils.bugs; + +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils.bugs.other.Jira87BeanFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Test case for Jiar issue# BEANUTILS-87. + * <p /> + * See https://issues.apache.org/jira/browse/BEANUTILS-87 + * <p /> + * In BeanUtils 1.7.0 a "package friendly" implementation + * of a public interface with defined a "mapped property" + * caused an [EMAIL PROTECTED] IllegalAccessException} to be thrown by + * PropertyUtils's getMappedProperty method. + * <p /> + * This test case demonstrates the issue. + * + * @version $Revision$ $Date$ + */ +public class Jira87TestCase extends TestCase { + + private Log log = LogFactory.getLog(Jira87TestCase.class); + + /** + * Create a test case with the specified name. + * + * @param name The name of the test + */ + public Jira87TestCase(String name) { + super(name); + } + + /** + * Run the Test. + * + * @param args Arguments + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + + /** + * Create a test suite for this test. + * + * @return a test suite + */ + public static Test suite() { + return (new TestSuite(Jira87TestCase.class)); + } + + /** + * Set up. + * + * @throws java.lang.Exception + */ + protected void setUp() throws Exception { + super.setUp(); + } + + /** + * Tear Down. + * + * @throws java.lang.Exception + */ + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Interface definition with a mapped property + */ + public void testJira87() { + + Jira87BeanFactory.PublicMappedInterface bean = Jira87BeanFactory.createMappedPropertyBean(); + try { + // N.B. The test impl. returns the key value + assertEquals("foo", PropertyUtils.getMappedProperty(bean, "value(foo)")); + } catch (Throwable t) { + log.error("ERROR " + t, t); + fail("Threw exception: " + t); + } + } +} Propchange: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira87TestCase.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira87TestCase.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Added: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira87BeanFactory.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira87BeanFactory.java?view=auto&rev=541308 ============================================================================== --- jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira87BeanFactory.java (added) +++ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira87BeanFactory.java Thu May 24 07:31:50 2007 @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.beanutils.bugs.other; + +import org.apache.commons.beanutils.bugs.Jira87TestCase; + +/** + * Factory which creates beans for [EMAIL PROTECTED] Jira87TestCase}. + * + * @version $Revision$ $Date$ + */ +public class Jira87BeanFactory { + + /** + * Factory method which creates beans bean with mapped method. + * + * @return The the mapped property bean instance + */ + public static PublicMappedInterface createMappedPropertyBean() { + return new PackageMappedImpl(); + } + + /* =================== Public interface with Mapped Property ========================= */ + /** + * Public interface with a mapped property. + */ + public interface PublicMappedInterface { + + /** + * Mapped Property method + * @param key The key of the mapped value + * @return The value + */ + Object getValue(String key); + + } + + /* =============== Package Friendly implementation of public interface =============== */ + static class PackageMappedImpl implements PublicMappedInterface { + + /** + * This implementation returns the key value. + * + * @param key The key of the mapped value + * @return The key value + */ + public Object getValue(String key) { + return key; + } + + } + +} Propchange: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira87BeanFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira87BeanFactory.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]