Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/management/openmbean/CompositeDataStringTest.java
41149 views
1
/*
2
* Copyright (c) 2008, 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
/*
25
* @test
26
* @bug 6610174
27
* @summary Test that CompositeDataSupport.toString() represents arrays correctly
28
* @author Eamonn McManus
29
*/
30
31
import javax.management.openmbean.ArrayType;
32
import javax.management.openmbean.CompositeData;
33
import javax.management.openmbean.CompositeDataSupport;
34
import javax.management.openmbean.CompositeType;
35
import javax.management.openmbean.OpenType;
36
import javax.management.openmbean.SimpleType;
37
38
public class CompositeDataStringTest {
39
public static void main(String[] args) throws Exception {
40
CompositeType basicCT = new CompositeType(
41
"basicCT", "basic CompositeType",
42
new String[] {"name", "value"},
43
new String[] {"name", "value"},
44
new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
45
CompositeType ct = new CompositeType(
46
"noddy", "descr",
47
new String[] {"strings", "ints", "cds"},
48
new String[] {"string array", "int array", "composite data array"},
49
new OpenType<?>[] {
50
ArrayType.getArrayType(SimpleType.STRING),
51
ArrayType.getPrimitiveArrayType(int[].class),
52
ArrayType.getArrayType(basicCT)
53
});
54
CompositeData basicCD1 = new CompositeDataSupport(
55
basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4});
56
CompositeData basicCD2 = new CompositeDataSupport(
57
basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9});
58
CompositeData cd = new CompositeDataSupport(
59
ct,
60
new String[] {"strings", "ints", "cds"},
61
new Object[] {
62
new String[] {"fred", "jim", "sheila"},
63
new int[] {2, 3, 5, 7},
64
new CompositeData[] {basicCD1, basicCD2}
65
});
66
String s = cd.toString();
67
System.out.println("CompositeDataSupport.toString(): " + s);
68
String[] expected = {
69
"fred, jim, sheila",
70
"2, 3, 5, 7",
71
"ceathar",
72
"naoi",
73
};
74
boolean ok = true;
75
for (String expect : expected) {
76
if (s.contains(expect))
77
System.out.println("OK: string contains <" + expect + ">");
78
else {
79
ok = false;
80
System.out.println("NOT OK: string does not contain <" +
81
expect + ">");
82
}
83
}
84
if (ok)
85
System.out.println("TEST PASSED");
86
else
87
throw new Exception("TEST FAILED: string did not contain expected substrings");
88
}
89
}
90
91