36511
|
1 |
|
|
2 |
import java.util.HashMap;
|
|
3 |
import java.util.Map;
|
|
4 |
import javax.management.openmbean.CompositeData;
|
|
5 |
import javax.management.openmbean.CompositeDataSupport;
|
|
6 |
import javax.management.openmbean.CompositeType;
|
|
7 |
import javax.management.openmbean.OpenType;
|
|
8 |
import javax.management.openmbean.SimpleType;
|
|
9 |
import sun.management.StackTraceElementCompositeData;
|
|
10 |
|
|
11 |
import org.testng.annotations.*;
|
|
12 |
import static org.testng.Assert.*;
|
|
13 |
|
|
14 |
/*
|
|
15 |
* @test
|
|
16 |
* @bug 8139587
|
|
17 |
* @summary Check backward compatibility of StackTraceElementCompositeData
|
44423
|
18 |
* @author Jaroslav Bachorik
|
|
19 |
*
|
36511
|
20 |
* @run testng CompatibilityTest
|
|
21 |
*/
|
|
22 |
|
|
23 |
public class CompatibilityTest {
|
|
24 |
private static CompositeType compositeTypeV6;
|
|
25 |
private static Map<String, Object> itemsV6;
|
|
26 |
private static CompositeData compositeDataV6;
|
|
27 |
|
|
28 |
@BeforeClass
|
|
29 |
public static void setup() throws Exception {
|
|
30 |
compositeTypeV6 = new CompositeType(
|
|
31 |
StackTraceElement.class.getName(),
|
|
32 |
"StackTraceElement",
|
|
33 |
new String[]{
|
|
34 |
"className", "methodName", "fileName", "nativeMethod", "lineNumber"
|
|
35 |
},
|
|
36 |
new String[]{
|
|
37 |
"className", "methodName", "fileName", "nativeMethod", "lineNumber"
|
|
38 |
},
|
|
39 |
new OpenType[]{
|
|
40 |
SimpleType.STRING,
|
|
41 |
SimpleType.STRING,
|
|
42 |
SimpleType.STRING,
|
|
43 |
SimpleType.BOOLEAN,
|
|
44 |
SimpleType.INTEGER
|
|
45 |
}
|
|
46 |
);
|
|
47 |
|
|
48 |
itemsV6 = new HashMap<>();
|
|
49 |
itemsV6.put("className", "MyClass");
|
|
50 |
itemsV6.put("methodName", "myMethod");
|
|
51 |
itemsV6.put("fileName", "MyClass.java");
|
|
52 |
itemsV6.put("nativeMethod", false);
|
|
53 |
itemsV6.put("lineNumber", 123);
|
|
54 |
|
|
55 |
compositeDataV6 = new CompositeDataSupport(compositeTypeV6, itemsV6);
|
|
56 |
}
|
|
57 |
|
|
58 |
@Test
|
|
59 |
public void testV6Compatibility() throws Exception {
|
|
60 |
StackTraceElement ste = StackTraceElementCompositeData.from(compositeDataV6);
|
|
61 |
|
|
62 |
assertNotNull(ste);
|
|
63 |
assertEquals(ste.getClassName(), "MyClass");
|
|
64 |
assertEquals(ste.getMethodName(), "myMethod");
|
|
65 |
assertEquals(ste.getFileName(), "MyClass.java");
|
|
66 |
assertEquals(ste.isNativeMethod(), false);
|
|
67 |
assertEquals(ste.getLineNumber(), 123);
|
|
68 |
|
|
69 |
assertNull(ste.getModuleName());
|
|
70 |
assertNull(ste.getModuleVersion());
|
|
71 |
}
|
44423
|
72 |
}
|
|
73 |
|