Joakim Erdfelt a écrit :
Johnny Ruiz wrote:I had this problem before, I solved it by not relying on the System ClassLoader. (BTW: Surefire Isolates the test's ClassLoaders from the Maven ClassLoaders).c_inconnu3 wrote:And 2 properties files in src/test/resources/ and src/test/resources/a/b/c/.When I run "m2 test" the following always returns null: InputStream inputStream = ClassLoader.getSystemResourceAsStream("a/b/c/myTest.properties"); System.out.println("**** " + inputStream); // nullinputStream = ClassLoader.getSystemResourceAsStream("myTest.properties");System.out.println("**** " + inputStream); // nullUse the same ClassLoader that the TestCase was loaded via. Change it from ... InputStream inputStream = ClassLoader.getSystemResourceAsStream("a/b/c/myTest.properties"); to ... InputStream inputStream =this.getClass().getClassLoader().getSystemResourceAsStream("a/b/c/myTest.properties");This subtle change helped me. If that works, I'll explain why. ;-) /* Joakim Erdfelt */ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Thanks for this great help, i was going mad... :-) This works :* this.getClass().getClassLoader().getResourceAsStream("a/b/c/myTest.properties");
This DOES NOT works :
* ClassLoader.getSystemResourceAsStream("a/b/c/myTest.properties");
*
this.getClass().getClassLoader().getSystemResourceAsStream("a/b/c/myTest.properties");
<quote> If that works, I'll explain why. ;-) </quote> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
