You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by David <ac...@yahoo.es> on 2007/10/23 12:43:58 UTC

How to configurate java.class.path property under a given test

Dear members,

I have a method that find a file on classpath and I want to check that it works fine. My testing class works fine under Eclipse, for example but under mave it doesn't work properly. The reason is that during the testing process I assume there is at least a directory location on classpath, but under maven the java.class.path, contains only jar files. So I can't check if some file exist on some directory of my classpath. I would need for my test, just the "." directory, but I don't find the way to add this information before the test start.

On the 

I have seen other posts about this problem, but without any real good solution, for example:
http://www.mail-archive.com/users@maven.apache.org/msg47276.html

On surefire documentation:
http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html

probably using properly one of the following properties: environmentVariables, jvm, could be solved, but I don't figure out how to deal with this.

Thanks,

David

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to configurate java.class.path property under a given test

Posted by Tim Kettler <ti...@udo.edu>.
David schrieb:
> Dear members,
> 
> I have a method that find a file on classpath and I want to check that it works fine. My testing class works fine
> under Eclipse, for example but under mave it doesn't work properly. The reason is that during the testing process I
> assume there is at least a directory location on classpath, but under maven the java.class.path, contains only jar files.

That's not true. This is from one of my projects:

[DEBUG]   (f) classpathElements = [
/home/tik/Develop/wallabystreet/mtn4java/target/classes,
/home/tik/Develop/wallabystreet/mtn4java/target/test-classes,
/home/tik/.m2/repository/org/codehaus/plexus/plexus-utils/1.4.1/plexus-utils-1.4.1.jar,
/home/tik/.m2/repository/net/sf/oval/oval/1.0/oval-1.0.jar,
/home/tik/.m2/repository/org/testng/testng/5.1/testng-5.1-jdk15.jar
]

The classes and test-classes directories are on the classpath.

> So I can't check if some file exist on some directory of my classpath. I would need for my test, just the "." directory,
> but I don't find the way to add this information before the test start.

In fact, it's not good to access resources in the classpath directly via
the file system. You should access them as resources via the
classloader. See this thread [1] for an example.

-Tim

[1]
http://www.nabble.com/Problems-with-loading-non-Java-resources-from-classpath-in-JUnit--tests-tf3734983s177.html#a10605055

> 
> On the 
> 
> I have seen other posts about this problem, but without any real good solution, for example:
> http://www.mail-archive.com/users@maven.apache.org/msg47276.html
> 
> On surefire documentation:
> http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html
> 
> probably using properly one of the following properties: environmentVariables, jvm, could be solved, but I don't figure out how to deal with this.
> 
> Thanks,
> 
> David
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org