Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/Introspector/Test6447751.java
41149 views
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 6447751
27
* @summary Tests automatic search for customizers
28
* @author Sergey Malenkov
29
*/
30
31
import java.awt.Component;
32
import java.beans.Customizer;
33
import java.beans.Introspector;
34
import java.beans.IntrospectionException;
35
import java.beans.SimpleBeanInfo;
36
import java.beans.BeanDescriptor;
37
import java.beans.PropertyChangeListener;
38
39
public class Test6447751 {
40
41
public static void main(String[] args) {
42
test(Manual.class, AutomaticCustomizer.class);
43
test(Illegal.class, null);
44
test(Automatic.class, AutomaticCustomizer.class);
45
}
46
47
private static void test(Class<?> type, Class<?> expected) {
48
Class<?> actual;
49
try {
50
actual = Introspector.getBeanInfo(type).getBeanDescriptor().getCustomizerClass();
51
}
52
catch (IntrospectionException exception) {
53
throw new Error("unexpected error", exception);
54
}
55
if (actual != expected) {
56
StringBuilder sb = new StringBuilder();
57
sb.append("bean ").append(type).append(": ");
58
if (expected != null) {
59
sb.append("expected ").append(expected);
60
if (actual != null) {
61
sb.append(", but ");
62
}
63
}
64
if (actual != null) {
65
sb.append("found ").append(actual);
66
}
67
throw new Error(sb.toString());
68
}
69
}
70
71
public static class Automatic {
72
}
73
public static class AutomaticCustomizer extends Component implements Customizer {
74
public void setObject(Object bean) {
75
throw new UnsupportedOperationException();
76
}
77
}
78
79
public static class Illegal {
80
}
81
public static class IllegalCustomizer implements Customizer {
82
public void setObject(Object bean) {
83
throw new UnsupportedOperationException();
84
}
85
public void addPropertyChangeListener(PropertyChangeListener listener) {
86
throw new UnsupportedOperationException();
87
}
88
public void removePropertyChangeListener(PropertyChangeListener listener) {
89
throw new UnsupportedOperationException();
90
}
91
}
92
93
public static class Manual {
94
}
95
public static class ManualBeanInfo extends SimpleBeanInfo {
96
public BeanDescriptor getBeanDescriptor() {
97
return new BeanDescriptor(Manual.class, AutomaticCustomizer.class);
98
}
99
}
100
}
101
102