author | alundblad |
Wed, 26 Aug 2015 09:02:02 +0200 | |
changeset 32337 | c9d3ab9f601c |
parent 22448 | a85fbad9d687 |
permissions | -rw-r--r-- |
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
1 |
/* |
22448
a85fbad9d687
8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
ksrini
parents:
21505
diff
changeset
|
2 |
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
4 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
32337 | 7 |
* published by the Free Software Foundation. |
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
8 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
13 |
* accompanied this code). |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
14 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
18 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
21 |
* questions. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
22 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
23 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
24 |
package org.openjdk.tests.separate; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
25 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
26 |
import org.testng.ITestResult; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
27 |
import org.testng.annotations.AfterMethod; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
28 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
29 |
import java.lang.reflect.InvocationTargetException; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
30 |
import java.util.Arrays; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
31 |
import java.util.HashSet; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
32 |
import java.util.List; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
33 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
34 |
import static org.openjdk.tests.separate.SourceModel.Class; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
35 |
import static org.openjdk.tests.separate.SourceModel.*; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
36 |
import static org.testng.Assert.*; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
37 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
38 |
public class TestHarness { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
39 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
40 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
41 |
* Creates a per-thread persistent compiler object to allow as much |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
42 |
* sharing as possible, but still allows for parallel execution of tests. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
43 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
44 |
protected ThreadLocal<Compiler> compilerLocal = new ThreadLocal<Compiler>(){ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
45 |
protected synchronized Compiler initialValue() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
46 |
return new Compiler(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
47 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
48 |
}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
49 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
50 |
protected ThreadLocal<Boolean> verboseLocal = new ThreadLocal<Boolean>() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
51 |
protected synchronized Boolean initialValue() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
52 |
return Boolean.FALSE; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
53 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
54 |
}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
55 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
56 |
protected boolean verbose; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
57 |
protected boolean canUseCompilerCache; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
58 |
public static final String stdMethodName = SourceModel.stdMethodName; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
59 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
60 |
private TestHarness() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
61 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
62 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
63 |
protected TestHarness(boolean verbose, boolean canUseCompilerCache) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
64 |
this.verbose = verbose; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
65 |
this.canUseCompilerCache = canUseCompilerCache; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
66 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
67 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
68 |
public void setTestVerbose() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
69 |
verboseLocal.set(Boolean.TRUE); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
70 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
71 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
72 |
@AfterMethod |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
73 |
public void reset() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
74 |
if (!this.verbose) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
75 |
verboseLocal.set(Boolean.FALSE); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
76 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
77 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
78 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
79 |
public Compiler.Flags[] compilerFlags() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
80 |
HashSet<Compiler.Flags> flags = new HashSet<>(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
81 |
if (verboseLocal.get() == Boolean.TRUE) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
82 |
flags.add(Compiler.Flags.VERBOSE); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
83 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
84 |
if (this.canUseCompilerCache) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
85 |
flags.add(Compiler.Flags.USECACHE); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
86 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
87 |
return flags.toArray(new Compiler.Flags[0]); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
88 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
89 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
90 |
@AfterMethod |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
91 |
public void printError(ITestResult result) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
92 |
if (result.getStatus() == ITestResult.FAILURE) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
93 |
String clsName = result.getTestClass().getName(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
94 |
clsName = clsName.substring(clsName.lastIndexOf(".") + 1); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
95 |
System.out.println("Test " + clsName + "." + |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
96 |
result.getName() + " FAILED"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
97 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
98 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
99 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
100 |
private static final ConcreteMethod stdCM = ConcreteMethod.std("-1"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
101 |
private static final AbstractMethod stdAM = |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
102 |
new AbstractMethod("int", stdMethodName); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
103 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
104 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
105 |
* Returns a class which has a static method with the same name as |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
106 |
* 'method', whose body creates an new instance of 'specimen' and invokes |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
107 |
* 'method' upon it via an invokevirtual instruction with 'args' as |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
108 |
* function call parameters. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
109 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
110 |
* 'returns' is a dummy return value that need only match 'methods' |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
111 |
* return type (it is only used in the dummy class when compiling IV). |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
112 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
113 |
private Class invokeVirtualHarness( |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
114 |
Class specimen, ConcreteMethod method, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
115 |
String returns, String ... args) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
116 |
Method cm = new ConcreteMethod( |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
117 |
method.getReturnType(), method.getName(), |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
118 |
"return " + returns + ";", method.getElements()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
119 |
Class stub = new Class(specimen.getName(), cm); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
120 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
121 |
String params = toJoinedString(args, ", "); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
122 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
123 |
ConcreteMethod sm = new ConcreteMethod( |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
124 |
method.getReturnType(), method.getName(), |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
125 |
String.format("return (new %s()).%s(%s);", |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
126 |
specimen.getName(), method.getName(), params), |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
127 |
new AccessFlag("public"), new AccessFlag("static")); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
128 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
129 |
Class iv = new Class("IV_" + specimen.getName(), sm); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
130 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
131 |
iv.addCompilationDependency(stub); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
132 |
iv.addCompilationDependency(cm); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
133 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
134 |
return iv; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
135 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
136 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
137 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
138 |
* Returns a class which has a static method with the same name as |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
139 |
* 'method', whose body creates an new instance of 'specimen', casts it |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
140 |
* to 'iface' (including the type parameters) and invokes |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
141 |
* 'method' upon it via an invokeinterface instruction with 'args' as |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
142 |
* function call parameters. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
143 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
144 |
private Class invokeInterfaceHarness(Class specimen, Extends iface, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
145 |
AbstractMethod method, String ... args) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
146 |
Interface istub = new Interface( |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
147 |
iface.getType().getName(), iface.getType().getAccessFlags(), |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
148 |
iface.getType().getParameters(), |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
149 |
null, Arrays.asList((Method)method)); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
150 |
Class cstub = new Class(specimen.getName()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
151 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
152 |
String params = toJoinedString(args, ", "); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
153 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
154 |
ConcreteMethod sm = new ConcreteMethod( |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
155 |
"int", SourceModel.stdMethodName, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
156 |
String.format("return ((%s)(new %s())).%s(%s);", iface.toString(), |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
157 |
specimen.getName(), method.getName(), params), |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
158 |
new AccessFlag("public"), new AccessFlag("static")); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
159 |
sm.suppressWarnings(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
160 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
161 |
Class ii = new Class("II_" + specimen.getName() + "_" + |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
162 |
iface.getType().getName(), sm); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
163 |
ii.addCompilationDependency(istub); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
164 |
ii.addCompilationDependency(cstub); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
165 |
ii.addCompilationDependency(method); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
166 |
return ii; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
167 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
168 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
169 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
170 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
171 |
* Uses 'loader' to load class 'clzz', and calls the static method |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
172 |
* 'method'. If the return value does not equal 'value' (or if an |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
173 |
* exception is thrown), then a test failure is indicated. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
174 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
175 |
* If 'value' is null, then no equality check is performed -- the assertion |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
176 |
* fails only if an exception is thrown. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
177 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
178 |
protected void assertStaticCallEquals( |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
179 |
ClassLoader loader, Class clzz, String method, Object value) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
180 |
java.lang.Class<?> cls = null; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
181 |
try { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
182 |
cls = java.lang.Class.forName(clzz.getName(), true, loader); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
183 |
} catch (ClassNotFoundException e) {} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
184 |
assertNotNull(cls); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
185 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
186 |
java.lang.reflect.Method m = null; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
187 |
try { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
188 |
m = cls.getMethod(method); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
189 |
} catch (NoSuchMethodException e) {} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
190 |
assertNotNull(m); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
191 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
192 |
try { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
193 |
Object res = m.invoke(null); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
194 |
assertNotNull(res); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
195 |
if (value != null) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
196 |
assertEquals(res, value); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
197 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
198 |
} catch (InvocationTargetException | IllegalAccessException e) { |
21505 | 199 |
fail("Unexpected exception thrown: " + e.getCause(), e.getCause()); |
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
200 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
201 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
202 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
203 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
204 |
* Creates a class which calls target::method(args) via invokevirtual, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
205 |
* compiles and loads both the new class and 'target', and then invokes |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
206 |
* the method. If the returned value does not match 'value' then a |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
207 |
* test failure is indicated. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
208 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
209 |
public void assertInvokeVirtualEquals( |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
210 |
Object value, Class target, ConcreteMethod method, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
211 |
String returns, String ... args) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
212 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
213 |
Compiler compiler = compilerLocal.get(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
214 |
compiler.setFlags(compilerFlags()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
215 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
216 |
Class iv = invokeVirtualHarness(target, method, returns, args); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
217 |
ClassLoader loader = compiler.compile(iv, target); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
218 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
219 |
assertStaticCallEquals(loader, iv, method.getName(), value); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
220 |
compiler.cleanup(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
221 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
222 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
223 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
224 |
* Convenience method for above, which assumes stdMethodName, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
225 |
* a return type of 'int', and no arguments. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
226 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
227 |
public void assertInvokeVirtualEquals(int value, Class target) { |
21505 | 228 |
assertInvokeVirtualEquals(value, target, stdCM, "-1"); |
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
229 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
230 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
231 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
232 |
* Creates a class which calls target::method(args) via invokeinterface |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
233 |
* through 'iface', compiles and loads both it and 'target', and |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
234 |
* then invokes the method. If the returned value does not match |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
235 |
* 'value' then a test failure is indicated. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
236 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
237 |
public void assertInvokeInterfaceEquals(Object value, Class target, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
238 |
Extends iface, AbstractMethod method, String ... args) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
239 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
240 |
Compiler compiler = compilerLocal.get(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
241 |
compiler.setFlags(compilerFlags()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
242 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
243 |
Class ii = invokeInterfaceHarness(target, iface, method, args); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
244 |
ClassLoader loader = compiler.compile(ii, target); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
245 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
246 |
assertStaticCallEquals(loader, ii, method.getName(), value); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
247 |
compiler.cleanup(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
248 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
249 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
250 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
251 |
* Convenience method for above, which assumes stdMethodName, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
252 |
* a return type of 'int', and no arguments. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
253 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
254 |
public void assertInvokeInterfaceEquals( |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
255 |
int value, Class target, Interface iface) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
256 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
257 |
Compiler compiler = compilerLocal.get(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
258 |
compiler.setFlags(compilerFlags()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
259 |
|
21505 | 260 |
assertInvokeInterfaceEquals(value, target, new Extends(iface), stdAM); |
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
261 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
262 |
compiler.cleanup(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
263 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
264 |
|
21505 | 265 |
protected void assertInvokeInterfaceThrows(java.lang.Class<? extends Throwable> errorClass, |
266 |
Class target, Extends iface, AbstractMethod method, |
|
267 |
String... args) { |
|
268 |
try { |
|
269 |
assertInvokeInterfaceEquals(0, target, iface, method, args); |
|
270 |
fail("Expected exception: " + errorClass); |
|
271 |
} |
|
272 |
catch (AssertionError e) { |
|
273 |
Throwable cause = e.getCause(); |
|
274 |
if (cause == null) |
|
275 |
throw e; |
|
276 |
else if ((errorClass.isAssignableFrom(cause.getClass()))) { |
|
277 |
// this is success |
|
278 |
return; |
|
279 |
} |
|
280 |
else |
|
281 |
throw e; |
|
282 |
} |
|
283 |
} |
|
284 |
||
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
285 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
286 |
* Creates a class which calls target::method(args) via invokevirtual, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
287 |
* compiles and loads both the new class and 'target', and then invokes |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
288 |
* the method. If an exception of type 'exceptionType' is not thrown, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
289 |
* then a test failure is indicated. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
290 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
291 |
public void assertThrows(java.lang.Class<?> exceptionType, Class target, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
292 |
ConcreteMethod method, String returns, String ... args) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
293 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
294 |
Compiler compiler = compilerLocal.get(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
295 |
compiler.setFlags(compilerFlags()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
296 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
297 |
Class iv = invokeVirtualHarness(target, method, returns, args); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
298 |
ClassLoader loader = compiler.compile(iv, target); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
299 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
300 |
java.lang.Class<?> cls = null; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
301 |
try { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
302 |
cls = java.lang.Class.forName(iv.getName(), true, loader); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
303 |
} catch (ClassNotFoundException e) {} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
304 |
assertNotNull(cls); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
305 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
306 |
java.lang.reflect.Method m = null; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
307 |
try { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
308 |
m = cls.getMethod(method.getName()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
309 |
} catch (NoSuchMethodException e) {} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
310 |
assertNotNull(m); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
311 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
312 |
try { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
313 |
m.invoke(null); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
314 |
fail("Exception should have been thrown"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
315 |
} catch (InvocationTargetException | IllegalAccessException e) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
316 |
if (verboseLocal.get() == Boolean.TRUE) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
317 |
System.out.println(e.getCause()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
318 |
} |
21501
47605fc9fac0
8027220: DefaultMethodsTest: Change test to match spec
rfield
parents:
14870
diff
changeset
|
319 |
assertTrue(exceptionType.isAssignableFrom(e.getCause().getClass())); |
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
320 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
321 |
compiler.cleanup(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
322 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
323 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
324 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
325 |
* Convenience method for above, which assumes stdMethodName, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
326 |
* a return type of 'int', and no arguments. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
327 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
328 |
public void assertThrows(java.lang.Class<?> exceptionType, Class target) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
329 |
assertThrows(exceptionType, target, stdCM, "-1"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
330 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
331 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
332 |
private static <T> String toJoinedString(T[] a, String... p) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
333 |
return toJoinedString(Arrays.asList(a), p); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
334 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
335 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
336 |
private static <T> String toJoinedString(List<T> list, String... p) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
337 |
StringBuilder sb = new StringBuilder(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
338 |
String sep = ""; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
339 |
String init = ""; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
340 |
String end = ""; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
341 |
String empty = null; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
342 |
switch (p.length) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
343 |
case 4: |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
344 |
empty = p[3]; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
345 |
/*fall-through*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
346 |
case 3: |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
347 |
end = p[2]; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
348 |
/*fall-through*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
349 |
case 2: |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
350 |
init = p[1]; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
351 |
/*fall-through*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
352 |
case 1: |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
353 |
sep = p[0]; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
354 |
break; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
355 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
356 |
if (empty != null && list.isEmpty()) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
357 |
return empty; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
358 |
} else { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
359 |
sb.append(init); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
360 |
for (T x : list) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
361 |
if (sb.length() != init.length()) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
362 |
sb.append(sep); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
363 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
364 |
sb.append(x.toString()); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
365 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
366 |
sb.append(end); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
367 |
return sb.toString(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
368 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
369 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
370 |
} |