[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66157 
] 

Wim Deblauwe commented on MSUREFIRE-115:
----------------------------------------

I added 2 more tests, taking your suggestions into account.

{noformat}
public void testClassloading()
    {
        ClassLoader classLoader = getClass().getClassLoader();
                System.out.println( "classLoader: " + classLoader );
                URL resource = getClass().getResource( 
"/java/util/Date.betwixt" );
                System.out.println( "resource: " + resource );
        
                ClassLoader dateClassLoader = Date.class.getClassLoader();
                System.out.println( "dateClassLoader: " + dateClassLoader );
                
        URL dateResource = Date.class.getResource( "/java/util/Date.betwixt" );
                System.out.println( "dateResource: " + dateResource );
                assertNotNull( "the resource should not be null", dateResource 
);
                
    }

    public void testWithContextClassLoader()
    {
        ClassLoader contextClassLoader = 
Thread.currentThread().getContextClassLoader();
        System.out.println( "contextClassLoader: " + contextClassLoader );
        URL dateResource1 = contextClassLoader.getResource( 
"/java/util/Date.betwixt" );
        System.out.println( "dateResource1: " + dateResource1 );
        assertNotNull( "the resource1 should not be null", dateResource1 );
    }
    
    public void testWithSystemClassLoader()
    {
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println( "systemClassLoader: " + systemClassLoader );
        URL dateResource2 = systemClassLoader.getResource( 
"/java/util/Date.betwixt" );
        System.out.println( "dateResource2: " + dateResource2 );
        assertNotNull( "the resource2 should not be null", dateResource2 );

    }
{noformat}

And this is the output I get:
{noformat}
Running CLTest
classLoader: [EMAIL PROTECTED]
resource: file:/C:/javatests/surefire-test/target/classes/java/util/Date.betwixt
dateClassLoader: null
dateResource: null
contextClassLoader: [EMAIL PROTECTED]
dateResource1: null
systemClassLoader: [EMAIL PROTECTED]
dateResource2: null
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.11 sec <<< 
FAILURE!
{noformat}

According to what you say, the test with the context classloader should work 
but it does not.

> Classloading problem for getting a resource
> -------------------------------------------
>
>          Key: MSUREFIRE-115
>          URL: http://jira.codehaus.org/browse/MSUREFIRE-115
>      Project: Maven 2.x Surefire Plugin
>         Type: Bug

>     Versions: 2.1.3, 2.2
>  Environment: Maven 2.0.4
> Windows XP
>     Reporter: Wim Deblauwe
>     Priority: Blocker
>  Attachments: surefire-test.zip
>
>
> We are using Betwixt and some of our unit tests fail when run using
> surefire, but run fine in IntelliJ or Maven 1. Betwixt looks for
> descriptors with the name of the class + .betwixt to control how
> something is written out in XML. It uses the construct:
> myClass.getResource() to find the .betwixt file.
> E.g. com.mycomp.MyClass -> com/mycomp/MyClass.betwixt
> We have a betwixt file for the java.util.Date class. However, betwixt
> seems to be unable to pick it up when using surefire. I have created a
> small test that shows the problem and have attached it.
> I tried with version 2.2 using different configurations (never, once, 
> pertest) and with version 2.1.3 (default configuration)

-- 
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