java - Properties.loadFromXML NullPointerException with jUnit -


i have problem loading properties xml inside junit test (the same code works without junit):

public class internetmaptest { private properties properties; @before public void readproperties() { try { classloader loader = classloader.getsystemclassloader(); inputstream stream = loader.getresourceasstream("analyse.properties.xml"); properties.loadfromxml(stream); 

...

if run test, get

java.lang.nullpointerexception @ xxx.yyy.zzz.analyse.tests.internetmaptest.readproperties(internetmaptest.java:27) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ... ... @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:197) 

unfortunately, can't identify problem using stack trace. first of all, thought file not found (it's located in /src/test/resources). system.out.println(loader.getresource("analyse.properties.xml")); returns correct file path.

can help, please?

i use sts 2.9.1 maven (plugin version 2.3.1, think) , junit 4.10 under ubuntu 12.04 amd64.

thank in advance, kind regards.

variable "properties" may null, have create before calling loading function.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

c++ - Accessing inactive union member and undefined behavior? -

php - Get uncommon values from two or more arrays -