[ 
http://jira.codehaus.org/browse/SUREFIRE-368?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Brett Porter moved MNG-3264 to SUREFIRE-368:
--------------------------------------------

    Affects Version/s:     (was: 2.0.7)
          Component/s:     (was: Errors)
                  Key: SUREFIRE-368  (was: MNG-3264)
              Project: Maven Surefire  (was: Maven 2)

> Property java.class.path modified by the user, it is not taken into account 
> by ClassLoader
> ------------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-368
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-368
>             Project: Maven Surefire
>          Issue Type: Bug
>            Reporter: David Leal
>             Fix For: 2.4
>
>         Attachments: FileUtils.java, TestFileUtils2.java
>
>
> I have a simple class that just find a file on classpath, i.e.:
> public final class FileUtils extends org.apache.commons.io.FileUtils {
>     public static File findFileInClasspath(String fileName)
>             throws UnsupportedEncodingException, FileNotFoundException {
>         return findFileInClasspath(fileName, FileUtils.LATIN_CODE);
>     }
>   
>     public static File findFileInClasspath(String fileName, String encoding)
>             throws UnsupportedEncodingException, FileNotFoundException {
>         URL url = FileUtils.class.getClassLoader().getResource(fileName);
>         if (url == null) {
>             throw new FileNotFoundException(fileName);
>         }
>         String file = URLDecoder.decode(url.getFile(), encoding);
>         return new File(file);
>     }
> }
> I would like to test this method, without leaving a testing file on 
> test/resources, so I want to use at valid location on classpath, so I 
> configurate the pluggin:
> <plugins>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-surefire-plugin</artifactId>
>         <configuration>
>           <forkMode>once</forkMode>
>           <systemProperties>
>             <property>
>               <name>java.class.path</name>
>               <value>${user.dir}</value>
>             </property>
>           </systemProperties>
>         </configuration>
>       </plugin>
>     </plugins>
> Note: if I add the variable: ${maven.test.classpath} its value is not 
> translated into the corresponding value.
> On my testing process I look on the property variable: java.class.path in 
> effect its point into: ${user.dir} but the testing method still fails. Under 
> Eclipse the same test, doesn't fail.
> Under Maven the test for some reason it fails even the on the java.class.path 
> there is directory (that's the condition I need in order to run the test).
> On the atached file you can find the source and testing file.
> I now it is possible to desing a different test using a resource file for 
> this purpose, but I am very suprise about this behavour. It open for me the 
> question about: How really the user control de classpath during the testing 
> process.
> After running the testing file I get:
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running com.ceb2b2000.commons.io.TestFileUtils2
> 30-oct-2007 0:25:34 com.ceb2b2000.commons.io.TestFileUtils2 
> findDirectoryOnClass
> path
> INFO: classpath = P:\ceb2b2000-commons\ceb2b2000-commons-io
> <<< FAILURE!
> Results :
> Tests in error:
>   testFindFileInClasspath(com.ceb2b2000.commons.io.TestFileUtils2)
> Tests run: 4, Failures: 0, Errors: 3, Skipped: 0

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to