Browse Source

Get rid of Java 7 dependencies

pull/237/head
Patrik Helsing 9 years ago
parent
commit
ba7189c688
  1. 11
      json-path-assert/src/test/java/com/jayway/jsonpath/matchers/helpers/ResourceHelpers.java

11
json-path-assert/src/test/java/com/jayway/jsonpath/matchers/helpers/ResourceHelpers.java

@ -4,11 +4,8 @@ import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import static java.lang.ClassLoader.getSystemResource;
import static java.lang.ClassLoader.getSystemResourceAsStream;
@ -18,18 +15,16 @@ public class ResourceHelpers {
try {
return IOUtils.toString(getSystemResourceAsStream(resource));
} catch (IOException e) {
throw new AssertionError("Resource not found", e);
throw new AssertionError("Resource not found: " + e.getMessage());
}
}
public static File resourceAsFile(String resource) {
try {
URL systemResource = getSystemResource(resource);
URI uri = systemResource.toURI();
Path path = Paths.get(uri);
return path.toFile();
return new File(systemResource.toURI());
} catch (URISyntaxException e) {
throw new AssertionError("URI syntax error", e);
throw new AssertionError("URI syntax error:" + e.getMessage());
}
}
}

Loading…
Cancel
Save