Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/Introspector/4058433/TestSwingContainer.java
41152 views
1
/*
2
* Copyright (c) 2014, 2015, 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
import java.beans.BeanDescriptor;
25
import java.beans.BeanInfo;
26
import java.beans.Introspector;
27
import java.util.Objects;
28
import javax.swing.SwingContainer;
29
30
/**
31
* @test
32
* @bug 4058433
33
* @summary Tests the SwingContainer annotation
34
* @author Sergey Malenkov
35
*/
36
public class TestSwingContainer {
37
38
public static void main(String[] args) throws Exception {
39
test(X.class, null, null);
40
test(H.class, true, "");
41
test(G.class, true, "");
42
test(F.class, true, "method");
43
test(E.class, false, "");
44
test(D.class, false, "");
45
test(C.class, true, "");
46
test(B.class, false, "method");
47
test(A.class, true, "method");
48
}
49
50
private static void test(Class<?> type, Object iC, Object cD) throws Exception {
51
System.out.println(type);
52
BeanInfo info = Introspector.getBeanInfo(type);
53
BeanDescriptor bd = info.getBeanDescriptor();
54
test(bd, "isContainer", iC);
55
test(bd, "containerDelegate", cD);
56
}
57
58
private static void test(BeanDescriptor bd, String name, Object expected) {
59
Object value = bd.getValue(name);
60
System.out.println("\t" + name + " = " + value);
61
if (!Objects.equals(value, expected)) {
62
throw new Error(name + ": expected = " + expected + "; actual = " + value);
63
}
64
}
65
66
public static class X {
67
}
68
69
@SwingContainer()
70
public static class H {
71
}
72
73
@SwingContainer(delegate = "")
74
public static class G {
75
}
76
77
@SwingContainer(delegate = "method")
78
public static class F {
79
}
80
81
@SwingContainer(false)
82
public static class E {
83
}
84
85
@SwingContainer(value = false, delegate = "")
86
public static class D {
87
}
88
89
@SwingContainer(value = true, delegate = "")
90
public static class C {
91
}
92
93
@SwingContainer(value = false, delegate = "method")
94
public static class B {
95
}
96
97
@SwingContainer(value = true, delegate = "method")
98
public static class A {
99
}
100
}
101
102