Properties.loadFromXML NullPointerException with jUnit

javirus

New Member
I have the problem with loading properties from xml inside jUnit test (the same code works well without jUnit):\[code\]public class InternetMapTest {private Properties properties;@Beforepublic void readProperties() {try {ClassLoader loader = ClassLoader.getSystemClassLoader();InputStream stream = loader.getResourceAsStream("analyse.properties.xml");properties.loadFromXML(stream);\[/code\]...if I run test, I get\[code\]java.lang.NullPointerException at xxx.yyy.zzz.analyse.tests.InternetMapTest.readProperties(InternetMapTest.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ... ... at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)\[/code\]Unfortunately, I can't identify the problem using this stack trace. First of all, I thought that the file was not found (it's located in /src/test/resources). But System.out.println(loader.getResource("analyse.properties.xml"));returns correct file path.Can somebody help, please?I use STS 2.9.1 with Maven (plugin version 2.3.1, as I think) and jUnit 4.10 under Ubuntu 12.04 amd64.Thank you in advance,Kind Regards.
 
Back
Top