Here is my project structure: I have an xml file
that I need to use it with my junit test case
, I don't know why I can not get this file.
Even I mark the directory as test directory resources with intellij and there is no way.
Here is my method:
@Before
public void init() throws Exception {
xml = IOUtils.toString(
this.getClass().getResourceAsStream("reponse.xml"),
"UTF-8"
);
......
}
I'm getting always the same error trace:
java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:78)
at java.io.InputStreamReader.<init>(InputStreamReader.java:113)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1906)
at org.apache.commons.io.IOUtils.toString(IOUtils.java:778)
at org.apache.commons.io.IOUtils.toString(IOUtils.java:803)
at fr.gouv.crpcen.restitution.ParserServiceTest.init(ParserServiceTest.java:113)