summaryrefslogtreecommitdiff
path: root/src/test/java/org/javacs/FindResource.java
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2017-03-19 13:38:40 -0700
committerGeorge Fraser <george@fivetran.com>2017-03-19 13:38:40 -0700
commit69328dca64e15d6acea74866555de7feb462db5b (patch)
treef4e882432695eacdeb0b32545575c56ad6e6d84e /src/test/java/org/javacs/FindResource.java
parent139784693f4bef6078fdc58e7ce17a9416e1a6c8 (diff)
downloadjava-language-server-69328dca64e15d6acea74866555de7feb462db5b.zip
Fixed most tests
Diffstat (limited to 'src/test/java/org/javacs/FindResource.java')
-rw-r--r--src/test/java/org/javacs/FindResource.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/java/org/javacs/FindResource.java b/src/test/java/org/javacs/FindResource.java
new file mode 100644
index 0000000..355223a
--- /dev/null
+++ b/src/test/java/org/javacs/FindResource.java
@@ -0,0 +1,24 @@
+package org.javacs;
+
+import java.io.File;
+import java.net.URI;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * Represents a java source on the system resource path.
+ */
+public class FindResource {
+ public static URI uri(String resourcePath) {
+ if (resourcePath.startsWith("/"))
+ resourcePath = resourcePath.substring(1);
+
+ Path path = Paths.get("./src/test/resources").resolve(resourcePath).normalize();
+ File file = path.toFile();
+
+ if (!file.exists())
+ throw new RuntimeException(file + " does not exist");
+
+ return file.toURI();
+ }
+}