Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/instrument/FakeTestDriver.java
41149 views
1
/*
2
* Copyright (c) 2003, 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
/*
26
* Copyright 2003 Wily Technology, Inc.
27
*/
28
29
/**
30
* Cheesy class to run all of our test cases in a hard-coded fashion.
31
* Will be replaced by Sun's iterator that uses the source decorations to figure out what to do.
32
*/
33
34
import java.lang.reflect.*;
35
36
public class FakeTestDriver {
37
38
private String[] fTestList = {
39
"javafake.lang.instrument.AddTransformerTest",
40
"javafake.lang.instrument.AppendToBootstrapClassPathTest",
41
"javafake.lang.instrument.AppendToClassPathTest",
42
"javafake.lang.instrument.GetAllLoadedClassesTest",
43
"javafake.lang.instrument.GetInitiatedClassesTest",
44
"javafake.lang.instrument.GetObjectSizeTest",
45
"javafake.lang.instrument.NoTransformerAddedTest",
46
"javafake.lang.instrument.NullTransformerAddTest",
47
"javafake.lang.instrument.RedefineClassesTests",
48
"javafake.lang.instrument.RemoveAbsentTransformerTest",
49
"javafake.lang.instrument.RemoveTransformerTest",
50
"javafake.lang.instrument.SingleTransformerTest",
51
"javafake.lang.instrument.TransformerManagementThreadAddTests",
52
"javafake.lang.instrument.TransformerManagementThreadRemoveTests",
53
"javafake.lang.instrument.TransformMethodTest",
54
};
55
56
public static void
57
main(String[] args) {
58
(new FakeTestDriver()).runSuppliedTests(args);
59
}
60
61
private
62
FakeTestDriver() {
63
}
64
65
private void
66
runAllTests() {
67
runSuppliedTests(fTestList);
68
}
69
70
private void
71
runSuppliedTests(String[] classnames) {
72
for (int x = 0; x < classnames.length; x++ ) {
73
loadAndRunOneTest(classnames[x]);
74
}
75
}
76
77
private void
78
loadAndRunOneTest(String classname) {
79
log("trying to run: " + classname);
80
81
Class testclass = loadOneTest(classname);
82
83
if ( testclass != null ) {
84
boolean result = runOneTest(testclass);
85
if ( result ) {
86
log(classname + " SUCCEEDED");
87
}
88
else {
89
log(classname + " FAILED");
90
}
91
}
92
else {
93
log(classname + " could not be loaded");
94
}
95
}
96
97
private Class
98
loadOneTest(String classname) {
99
Class result = null;
100
101
try {
102
result = Class.forName(classname);
103
}
104
catch (Throwable t) {
105
t.printStackTrace();
106
result = null;
107
}
108
return result;
109
}
110
111
private boolean
112
runOneTest(Class testclass) {
113
Method mainMethod = null;
114
115
try {
116
String[] forType = new String[0];
117
mainMethod = testclass.getMethod("main",
118
new Class[] {
119
forType.getClass()
120
});
121
}
122
catch (Throwable t) {
123
log(testclass.getName() + " is malformed");
124
t.printStackTrace();
125
return false;
126
}
127
128
try {
129
mainMethod.invoke(null, new Object[] {new String[] {testclass.getName()}});
130
return true;
131
}
132
catch (Throwable t) {
133
t.printStackTrace();
134
return false;
135
}
136
}
137
138
private void
139
log(String m) {
140
System.out.println(m);
141
}
142
}
143
144