Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/beans/Introspector/Test7192955.java
47964 views
1
/*
2
* Copyright (c) 2012, 2013, 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 7192955 8000183
27
* @summary Tests that all properties are bound
28
* @author Sergey Malenkov
29
*/
30
31
import java.beans.IntrospectionException;
32
import java.beans.Introspector;
33
import java.beans.PropertyChangeListener;
34
import java.beans.PropertyDescriptor;
35
import java.util.List;
36
37
public class Test7192955 {
38
39
public static void main(String[] args) throws IntrospectionException {
40
if (!BeanUtils.findPropertyDescriptor(MyBean.class, "test").isBound()) {
41
throw new Error("a simple property is not bound");
42
}
43
if (!BeanUtils.findPropertyDescriptor(MyBean.class, "list").isBound()) {
44
throw new Error("a generic property is not bound");
45
}
46
if (!BeanUtils.findPropertyDescriptor(MyBean.class, "readOnly").isBound()) {
47
throw new Error("a read-only property is not bound");
48
}
49
PropertyDescriptor[] pds = Introspector.getBeanInfo(MyBean.class, BaseBean.class).getPropertyDescriptors();
50
for (PropertyDescriptor pd : pds) {
51
if (pd.getName().equals("test") && pd.isBound()) {
52
throw new Error("a simple property is bound without superclass");
53
}
54
}
55
}
56
57
public static class BaseBean {
58
59
private List<String> list;
60
61
public List<String> getList() {
62
return this.list;
63
}
64
65
public void setList(List<String> list) {
66
this.list = list;
67
}
68
69
public void addPropertyChangeListener(PropertyChangeListener listener) {
70
}
71
72
public void removePropertyChangeListener(PropertyChangeListener listener) {
73
}
74
75
public List<String> getReadOnly() {
76
return this.list;
77
}
78
}
79
80
public static class MyBean extends BaseBean {
81
82
private String test;
83
84
public String getTest() {
85
return this.test;
86
}
87
88
public void setTest(String test) {
89
this.test = test;
90
}
91
}
92
}
93
94