From 69328dca64e15d6acea74866555de7feb462db5b Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sun, 19 Mar 2017 13:38:40 -0700 Subject: Fixed most tests --- src/test/java/org/javacs/FindResource.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/java/org/javacs/FindResource.java (limited to 'src/test/java/org/javacs/FindResource.java') 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(); + } +} -- cgit v1.2.3