View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.beanutils2.bugs;
18  
19  import static org.junit.jupiter.api.Assertions.assertEquals;
20  
21  import org.apache.commons.beanutils2.PropertyUtils;
22  import org.apache.commons.beanutils2.bugs.other.Jira87BeanFactory;
23  import org.apache.commons.logging.Log;
24  import org.apache.commons.logging.LogFactory;
25  import org.junit.jupiter.api.AfterEach;
26  import org.junit.jupiter.api.BeforeEach;
27  import org.junit.jupiter.api.Test;
28  
29  /**
30   * Test case for Jiar issue# BEANUTILS-87.
31   *
32   * <p>
33   * In BeanUtils 1.7.0 a "package friendly" implementation of a public interface with defined a "mapped property" caused an {@link IllegalAccessException} to be
34   * thrown by PropertyUtils's getMappedProperty method.
35   *
36   * <p>
37   * This test case demonstrates the issue.
38   *
39   * @see <a href="https://issues.apache.org/jira/browse/BEANUTILS-87">https://issues.apache.org/jira/browse/BEANUTILS-87</a>
40   */
41  public class Jira87Test {
42  
43      private static final Log LOG = LogFactory.getLog(Jira87Test.class);
44  
45      /**
46       * Sets up.
47       *
48       * @throws Exception
49       */
50      @BeforeEach
51      protected void setUp() throws Exception {
52      }
53  
54      /**
55       * Tear Down.
56       *
57       * @throws Exception
58       */
59      @AfterEach
60      protected void tearDown() throws Exception {
61      }
62  
63      /**
64       * Interface definition with a mapped property
65       */
66      @Test
67      public void testJira87() throws Exception {
68  
69          final Jira87BeanFactory.PublicMappedInterface bean = Jira87BeanFactory.createMappedPropertyBean();
70          // The test impl. returns the key value
71          assertEquals("foo", PropertyUtils.getMappedProperty(bean, "value(foo)"));
72      }
73  }