I am using JUnit 4, Java 8 and Gradle 1.12. I have a default json file that I need to download. My project has src/main/java/ (containing the project source), src/main/resources/ (empty), src/test/java/ (unit test source) and src/test/resources/ (downloadable json data file). The build.gradle file is in the root directory.
In my code, I have:
public class UnitTests extends JerseyTest { @Test public void test1() throws IOException { String json = UnitTests.readResource("/testData.json");
From what I'm reading, this should give me access to the resource file. However, I get a null pointer exception when trying to use the URL because calling getSystemResource() returns null.
How to access my resource files?
java junit4 gradle
kwiqsilver
source share