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:

  1. maven copies resources target/test-classes
  2. 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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -