1 /*
2  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 6976577
27  * @summary Tests public methods in non-public beans
28  * @author Sergey Malenkov
29  */
30 
31 import test.Accessor;
32 
33 import java.beans.EventSetDescriptor;
34 import java.beans.IndexedPropertyDescriptor;
35 import java.beans.PropertyDescriptor;
36 import java.lang.reflect.Method;
37 
38 public class Test6976577 {
39 
main(String[] args)40     public static void main(String[] args) throws Exception {
41         Class<?> bt = Accessor.getBeanType();
42         Class<?> lt = Accessor.getListenerType();
43 
44         // test PropertyDescriptor
45         PropertyDescriptor pd = new PropertyDescriptor("boolean", bt);
46         test(pd.getReadMethod());
47         test(pd.getWriteMethod());
48 
49         // test IndexedPropertyDescriptor
50         IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt);
51         test(ipd.getReadMethod());
52         test(ipd.getWriteMethod());
53         test(ipd.getIndexedReadMethod());
54         test(ipd.getIndexedWriteMethod());
55 
56         // test EventSetDescriptor
57         EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process");
58         test(esd.getAddListenerMethod());
59         test(esd.getRemoveListenerMethod());
60         test(esd.getGetListenerMethod());
61         test(esd.getListenerMethods());
62     }
63 
test(Method... methods)64     private static void test(Method... methods) {
65         for (Method method : methods) {
66             if (method == null) {
67                 throw new Error("public method is not found");
68             }
69         }
70     }
71 }
72