It seems that calling getResourceAsStream() off of getClass() does not return the resource. It's unfortunately that the Class class has a getResourceAsStream() method if it's not going to actually work.
So...
InputStream input = getClass().getResourceAsStream("./test.properties")returns null.
If you use ResourceBundle to fetch "test" - it works.
I thought that was odd. I made a mention to my friend and he suggested that I need to be asking the ClassLoader to fetch the resource, not the class.
So...
InputStream input = getClass().getClassLoader().getResourceAsStream("./test.properties")returns the resource.
Now - I am executing this from a GroovyTestCase instance. I do not know the reason for this. But either way, it's frustrating.
2 comments:
Thanks for this little post! Helped me out
Got the same problem, thanks for the hint.
Post a Comment