> -----Original Message-----
> From: Ray Wenderlich [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, August 14, 2007 12:44 AM
> To: users@maven.apache.org
> Subject: Resources and JUnit
> 
> Hi all,
> 
> I am testing a class that is using a .properties file that I have
> placed in src\main\resources.  I am loading it via:
> 
> InputStream is =
> getClass().getClassLoader().getResourceAsStream("add.properties");
> 
> The .properties file gets copied to target\classes\add.properties, and
> when I create a package and run the class everything works fine.  The
> problem is if I try to run a junit test against the class, at that
> point the class cannot find the .properties file.
> 
> I ran mvn test with -X and got the following:
> 
> [DEBUG] Test Classpath :
> [DEBUG]   C:\Projects\Experiments\add-test\target\test-classes
> [DEBUG]   C:\Projects\Experiments\add-test\target\classes
> [DEBUG]   C:\Documents and
> Settings\rwenderlich\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar
> 
> I am using a basic POM I generated with the mvn archetype:create, so
> I'm using the default resources settings.  I am using Maven 2.0.8.
> 
> Any ideas what's going on here?  I've read the other forum postings on
> the subject and tried a bunch of different things to no avail.

What's the exact error you're getting in your code?  I'm doing something 
similar in my current project and it works just fine.  You're retrieving it 
from the classpath, and that directory's on the classpath, so it should work... 
 You do see the file in target/classes after the test goal runs, right?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to