|
20 | 20 | */
|
21 | 21 | public class ResourceUtil {
|
22 | 22 |
|
23 |
| - public enum P2Repositories { |
24 |
| - ECLIPSE_342("e342"), ECLIPSE_352("e352"), ECLIPSE_OXYGEN( |
25 |
| - "https:////download.eclipse.org/releases/oxygen/"), ECLIPSE_LATEST( |
26 |
| - "https:////download.eclipse.org/releases/2020-12/"); |
27 |
| - |
28 |
| - private final String path; |
29 |
| - |
30 |
| - P2Repositories(String path) { |
31 |
| - this.path = path; |
32 |
| - } |
33 |
| - |
34 |
| - public URI getResolvedLocation() throws IllegalStateException { |
35 |
| - if (path.startsWith("https:") || path.startsWith("http:")) { |
36 |
| - return URI.create(path); |
37 |
| - } |
38 |
| - return resolveTestResource("repositories/" + path).toURI(); |
39 |
| - } |
40 |
| - |
41 |
| - @Override |
42 |
| - public String toString() { |
43 |
| - return getResolvedLocation().toString(); |
44 |
| - } |
45 |
| - } |
46 |
| - |
47 |
| - public static File resolveTestResource(String pathRelativeToProjectRoot) throws IllegalStateException { |
48 |
| - File resolvedFile = new File(pathRelativeToProjectRoot).getAbsoluteFile(); |
49 |
| - |
50 |
| - if (!resolvedFile.canRead()) { |
51 |
| - throw new IllegalStateException( |
52 |
| - "Test resource \"" + pathRelativeToProjectRoot + "\" is not available; " + workingDirMessage()); |
53 |
| - } |
54 |
| - return resolvedFile; |
55 |
| - } |
56 |
| - |
57 |
| - private static String workingDirMessage() { |
58 |
| - return "(working directory is \"" + new File(".").getAbsolutePath() + "\")"; |
59 |
| - } |
| 23 | + public enum P2Repositories { |
| 24 | + ECLIPSE_342("e342"), ECLIPSE_352("e352"), ECLIPSE_OXYGEN("https:////download.eclipse.org/releases/oxygen/"), |
| 25 | + ECLIPSE_LATEST("https:////download.eclipse.org/releases/2021-12/"); |
| 26 | + |
| 27 | + private final String path; |
| 28 | + |
| 29 | + P2Repositories(String path) { |
| 30 | + this.path = path; |
| 31 | + } |
| 32 | + |
| 33 | + public URI getResolvedLocation() throws IllegalStateException { |
| 34 | + if (path.startsWith("https:") || path.startsWith("http:")) { |
| 35 | + return URI.create(path); |
| 36 | + } |
| 37 | + return resolveTestResource("repositories/" + path).toURI(); |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public String toString() { |
| 42 | + return getResolvedLocation().toString(); |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + public static File resolveTestResource(String pathRelativeToProjectRoot) throws IllegalStateException { |
| 47 | + File resolvedFile = new File(pathRelativeToProjectRoot).getAbsoluteFile(); |
| 48 | + |
| 49 | + if (!resolvedFile.canRead()) { |
| 50 | + throw new IllegalStateException( |
| 51 | + "Test resource \"" + pathRelativeToProjectRoot + "\" is not available; " + workingDirMessage()); |
| 52 | + } |
| 53 | + return resolvedFile; |
| 54 | + } |
| 55 | + |
| 56 | + private static String workingDirMessage() { |
| 57 | + return "(working directory is \"" + new File(".").getAbsolutePath() + "\")"; |
| 58 | + } |
60 | 59 | }
|
0 commit comments