java - Change property file located in src/test/resources -
i'm exploring apache common configuration , want make test read/write properties from/to xml file located in src/test/resources test. far, i'm reading no problems cannot write file. if change location of file scr/test/resources location in file system (example: c:/test), works fine. can please me ?
edit
here had tried far:
@test public void test() throws configurationexception { //first data.xml located in src/test/resources xmlconfiguration config = new xmlconfiguration("data.xml"); list<object> rows = config.getlist("user.username"); system.out.println(rows); //this not working config.setproperty("user.username", "fromtest"); config.save(); // second data.xml in different location xmlconfiguration config = new xmlconfiguration("c:/temp/data.xml"); list<object> rows = config.getlist("user.username"); system.out.println(rows); //this works config.setproperty("user.username", "fromtest"); config.save(); }
thanks.
well, don't provide insight running context, src/test/resources path, guess work maven. if true, happens:
- maven copies resources target/test-classes
- the test method operates on copied resources, target/test-classes/data.xml
if check file, works. looked @ source file, not file read code.
the difference second test, c:/temp/data.xml, former relative path, while latter absolute, , not under maven's scope.
Comments
Post a Comment