Dear Tim,
It works for me under eclipse, but not under maven from command line. On my code what I use is to get the system property using:
System.getProperty("java.class.path");
Are you ussing Maven 1.x?, becuase on the following link:
http://maven.apache.org/guides/mini/guide-maven-classloading.html
There is a comment about a different behaviour when using Maven 1.x, I am using Maven 2.x
This is my output:
P:\ceb2b2000-commons\ceb2b2000-commons-io>mvn test
[INFO] Scanning for projects....
[INFO] -------------------------------------------------------------------------
---
[INFO] Building ceb2b2000-commons-io
[INFO] task-segment: [test]
[INFO] -------------------------------------------------------------------------
---
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: P:\ceb2b2000-commons\ceb2b2000-commons-io\targ
et\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.ceb2b2000.commons.io.TestFileUtils
System.getProperty("java.class.path")=
C:\Documents and Settings\dleal\.m2\repository\org\codehaus\plexus\plexus-archiv
er\1.0-alpha-7\plexus-archiver-1.0-alpha-7.jar;C:\Documents and Settings\dleal\.
m2\repository\org\apache\maven\surefire\surefire-api\2.3\surefire-api-2.3.jar;C:
\Documents and Settings\dleal\.m2\repository\org\codehaus\plexus\plexus-containe
r-default\1.0-alpha-8\plexus-container-default-1..0-alpha-8.jar;C:\Documents and
Settings\dleal\.m2\repository\org\codehaus\plexus\plexus-utils\1.1\plexus-utils-
1.1.jar;C:\Documents and Settings\dleal\.m2\repository\org\apache\maven\surefire
\surefire-booter\2.3\surefire-booter-2.3.jar;C:\Documents and Settings\dleal\.m2
\repository\classworlds\classworlds\1.1-alpha-2\classworlds-1.1-alpha-2.jar;C:\D
ocuments and Settings\dleal\.m2\repository\commons-lang\commons-lang\2.1\commons
-lang-2.1.jar;C:\Documents and Settings\dleal\.m2\repository\junit\junit\3.8..1\j
unit-3.8.1.jar
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Oct 23 15:36:26 CEST 2007
[INFO] Final Memory: 4M/7M
[INFO] ------------------------------------------------------------------------
P:\ceb2b2000-commons\ceb2b2000-commons-io>
----- Original Message ----
From: Tim Kettler <***@udo.edu>
To: Maven Users List <***@maven.apache.org>
Sent: Tuesday, October 23, 2007 3:07:48 PM
Subject: Re: How to configurate java.class.path property under a given test
Post by DavidDear 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.
Post by DavidSo 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
Post by DavidOn the
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-***@maven.apache.org
For additional commands, e-mail: users-***@maven.apache.org
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com