Re: junit tests and resources
Yes, the call simply returns null. It really doesn't make much sense. When I run maven with the -X option I can see the path being included, but when I try to access the resource, I get null. WM --- Dion Gillard [EMAIL PROTECTED] wrote: The resources aren't on the system classloader? On Thu, 17 Jun 2004 12:39:04 -0700 (PDT), Webb Morris [EMAIL PROTECTED] wrote: I have set up some resources for my unit tests in the unittest/resources area of my project.xml. These resources are being correctly copied to the target/test-classes directory. However, when I try to access these resources using: ClassLoader.getSystemResourceAsStream(myresource) The resource can not be found. Any ideas? WM __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: junit tests and resources
In case anyone is following this thread or finds it while solving their own problem in the future, here is what I ended up having to do: InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(testResource); Apparently there are some weird things going on with the JUnit ClassLoader. Also, if you are attempting to access a resource in the root directory (directly under test-classes) then be sure to prefix your resource with a / (i.e. /text.xml). Thanks to those who tried to help! WM --- Webb Morris [EMAIL PROTECTED] wrote: Yes, the call simply returns null. It really doesn't make much sense. When I run maven with the -X option I can see the path being included, but when I try to access the resource, I get null. WM --- Dion Gillard [EMAIL PROTECTED] wrote: The resources aren't on the system classloader? On Thu, 17 Jun 2004 12:39:04 -0700 (PDT), Webb Morris [EMAIL PROTECTED] wrote: I have set up some resources for my unit tests in the unittest/resources area of my project.xml. These resources are being correctly copied to the target/test-classes directory. However, when I try to access these resources using: ClassLoader.getSystemResourceAsStream(myresource) The resource can not be found. Any ideas? WM __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: junit tests and resources
SomeTest.class.getResourceAsStream (or getClass().getResourceAsStream()) would work just as effectively. This is how I would do it whether I was using Maven or not. This is not a weird thing - Maven doesn't shove everything onto the system classloader, it builds up its own. - Brett On Fri, 18 Jun 2004 11:49:13 -0700 (PDT), Webb Morris [EMAIL PROTECTED] wrote: In case anyone is following this thread or finds it while solving their own problem in the future, here is what I ended up having to do: InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(testResource); Apparently there are some weird things going on with the JUnit ClassLoader. Also, if you are attempting to access a resource in the root directory (directly under test-classes) then be sure to prefix your resource with a / (i.e. /text.xml). Thanks to those who tried to help! WM --- Webb Morris [EMAIL PROTECTED] wrote: Yes, the call simply returns null. It really doesn't make much sense. When I run maven with the -X option I can see the path being included, but when I try to access the resource, I get null. WM --- Dion Gillard [EMAIL PROTECTED] wrote: The resources aren't on the system classloader? On Thu, 17 Jun 2004 12:39:04 -0700 (PDT), Webb Morris [EMAIL PROTECTED] wrote: I have set up some resources for my unit tests in the unittest/resources area of my project.xml. These resources are being correctly copied to the target/test-classes directory. However, when I try to access these resources using: ClassLoader.getSystemResourceAsStream(myresource) The resource can not be found. Any ideas? WM __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
junit tests and resources
I have set up some resources for my unit tests in the unittest/resources area of my project.xml. These resources are being correctly copied to the target/test-classes directory. However, when I try to access these resources using: ClassLoader.getSystemResourceAsStream(myresource) The resource can not be found. Any ideas? WM __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: junit tests and resources
The resources aren't on the system classloader? On Thu, 17 Jun 2004 12:39:04 -0700 (PDT), Webb Morris [EMAIL PROTECTED] wrote: I have set up some resources for my unit tests in the unittest/resources area of my project.xml. These resources are being correctly copied to the target/test-classes directory. However, when I try to access these resources using: ClassLoader.getSystemResourceAsStream(myresource) The resource can not be found. Any ideas? WM __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]