Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/test/functional/VM_Test/src/j9vm/runner/AllTestsInJar.java
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2018 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
package j9vm.runner;
23
import java.util.*;
24
import java.util.zip.*;
25
import java.io.*;
26
27
public class AllTestsInJar implements java.util.Enumeration {
28
boolean entryReady;
29
String testName;
30
ZipFile zipFile;
31
Enumeration zipFileEntries;
32
33
public boolean isValidTestName(String testName) {
34
if (!testName.startsWith("j9vm.test.")) {
35
return false;
36
}
37
if (!testName.endsWith("Test")) {
38
return false;
39
}
40
return true;
41
}
42
43
public boolean hasMoreElements(){
44
if (entryReady) return true;
45
while (!entryReady) {
46
if (!zipFileEntries.hasMoreElements()) {
47
return false;
48
}
49
testName = ((ZipEntry)zipFileEntries.nextElement()).getName();
50
if (testName.endsWith(".class")) {
51
testName = testName.substring(0, testName.length() - ".class".length());
52
testName = testName.replace('/','.');
53
entryReady = isValidTestName(testName);
54
}
55
}
56
return true;
57
}
58
public Object nextElement(){
59
if (!hasMoreElements()) throw new NoSuchElementException();
60
entryReady = false;
61
return testName;
62
}
63
64
public AllTestsInJar(String jarFileName) throws IOException {
65
entryReady = false;
66
testName = null;
67
zipFile = new ZipFile(jarFileName);
68
zipFileEntries = zipFile.entries();
69
}
70
71
public void finalize() {
72
try {
73
zipFile.close();
74
} catch (Exception e) {
75
}
76
}
77
78
}
79
80