author | serb |
Wed, 03 Jun 2015 23:17:52 +0300 | |
changeset 31166 | 6448eff013a8 |
parent 25566 | ba387c302edd |
permissions | -rw-r--r-- |
25566 | 1 |
/* |
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
25566 | 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 |
*/ |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
23 |
|
25566 | 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; |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
29 |
|
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
30 |
/** |
25566 | 31 |
* @test |
32 |
* @bug 4058433 |
|
33 |
* @summary Tests the SwingContainer annotation |
|
34 |
* @author Sergey Malenkov |
|
35 |
*/ |
|
36 |
public class TestSwingContainer { |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
37 |
|
25566 | 38 |
public static void main(String[] args) throws Exception { |
39 |
test(X.class, null, null); |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
40 |
test(H.class, true, ""); |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
41 |
test(G.class, true, ""); |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
42 |
test(F.class, true, "method"); |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
43 |
test(E.class, false, ""); |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
44 |
test(D.class, false, ""); |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
45 |
test(C.class, true, ""); |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
46 |
test(B.class, false, "method"); |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
47 |
test(A.class, true, "method"); |
25566 | 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); |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
60 |
System.out.println("\t" + name + " = " + value); |
25566 | 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() |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
70 |
public static class H { |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
71 |
} |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
72 |
|
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
73 |
@SwingContainer(delegate = "") |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
74 |
public static class G { |
25566 | 75 |
} |
76 |
||
77 |
@SwingContainer(delegate = "method") |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
78 |
public static class F { |
25566 | 79 |
} |
80 |
||
81 |
@SwingContainer(false) |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
82 |
public static class E { |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
83 |
} |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
84 |
|
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
85 |
@SwingContainer(value = false, delegate = "") |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
86 |
public static class D { |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
87 |
} |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
88 |
|
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
89 |
@SwingContainer(value = true, delegate = "") |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
90 |
public static class C { |
25566 | 91 |
} |
92 |
||
93 |
@SwingContainer(value = false, delegate = "method") |
|
31166
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
94 |
public static class B { |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
95 |
} |
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
96 |
|
6448eff013a8
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
serb
parents:
25566
diff
changeset
|
97 |
@SwingContainer(value = true, delegate = "method") |
25566 | 98 |
public static class A { |
99 |
} |
|
100 |
} |