You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by vetalok <ve...@gmail.com> on 2007/12/18 20:21:13 UTC

Surefire can't find resource if forkMode=once

Hi all
I have maven 2.0.7 and the latest surefire plugin.
Surefire can't find resource if forkMode=once ( if forkMode=never it works)
Here is snip of code:
BaseStandaloneTest.class.getResource("/login.conf").toString();
Any ideas?
-- 
View this message in context: http://www.nabble.com/Surefire-can%27t-find-resource-if-forkMode%3Donce-tp14403769s177p14403769.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Surefire can't find resource if forkMode=once

Posted by vetalok <ve...@gmail.com>.
Developers have read my letter!
I have just run the test and it works!
New version of surefire has just been downloaded and the problem has gone
:))


vetalok wrote:
> 
> Thanks Jerome,
> I have tried this but the main problem is that 
> if (forkMode=once) {
> getResource() method does not looking for resources in    
> "test-clesses"  folder
> }else if (forkmode=never) {
> getResource() method  looking for resources in    
> "test-clesses"  folder - as I want
> }
> So the question is how can I  force surefire to search resources in
> "test-classes" folder if forkMode=once.
> 
> So it does not looking for resources in "test-classes" folder neither with
> getClass(), no with Thread.currentThread.getContextClassloader().
> 
> 
> Jerome Lacoste-2 wrote:
>> 
>> On Dec 18, 2007 8:21 PM, vetalok <ve...@gmail.com> wrote:
>>>
>>> Hi all
>>> I have maven 2.0.7 and the latest surefire plugin.
>>> Surefire can't find resource if forkMode=once ( if forkMode=never it
>>> works)
>>> Here is snip of code:
>>> BaseStandaloneTest.class.getResource("/login.conf").toString();
>> 
>> Class#getResource delegates to the class ClassLoader getResource method.
>> 
>> I.e. the above code is similar to:
>> 
>>   BaseStandaloneTest.class.getClassLoader().getResource()...
>> 
>> Try using the Context ClassLoader.
>> 
>> i.e.
>> 
>> Thread.currentThread().getContextClassLoader().getResource(....)
>> 
>> J
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Surefire-can%27t-find-resource-if-forkMode%3Donce-tp14403769s177p14412967.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Surefire can't find resource if forkMode=once

Posted by vetalok <ve...@gmail.com>.
Thanks Jerome,
I have tried this but the main problem is that 
if (forkMode=once) {
getResource() method does not looking for resources in    
"test-clesses"  folder
}else if (forkmode=never) {
getResource() method  looking for resources in    
"test-clesses"  folder - as I want
}
So the question is how can I  force surefire to search resources in
"test-classes" folder if forkMode=once.

So it does not looking for resources in "test-classes" folder neither with
getClass(), no with Thread.currentThread.getContextClassloader().


Jerome Lacoste-2 wrote:
> 
> On Dec 18, 2007 8:21 PM, vetalok <ve...@gmail.com> wrote:
>>
>> Hi all
>> I have maven 2.0.7 and the latest surefire plugin.
>> Surefire can't find resource if forkMode=once ( if forkMode=never it
>> works)
>> Here is snip of code:
>> BaseStandaloneTest.class.getResource("/login.conf").toString();
> 
> Class#getResource delegates to the class ClassLoader getResource method.
> 
> I.e. the above code is similar to:
> 
>   BaseStandaloneTest.class.getClassLoader().getResource()...
> 
> Try using the Context ClassLoader.
> 
> i.e.
> 
> Thread.currentThread().getContextClassLoader().getResource(....)
> 
> J
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Surefire-can%27t-find-resource-if-forkMode%3Donce-tp14403769s177p14412956.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Surefire can't find resource if forkMode=once

Posted by Jerome Lacoste <je...@gmail.com>.
On Dec 18, 2007 8:21 PM, vetalok <ve...@gmail.com> wrote:
>
> Hi all
> I have maven 2.0.7 and the latest surefire plugin.
> Surefire can't find resource if forkMode=once ( if forkMode=never it works)
> Here is snip of code:
> BaseStandaloneTest.class.getResource("/login.conf").toString();

Class#getResource delegates to the class ClassLoader getResource method.

I.e. the above code is similar to:

  BaseStandaloneTest.class.getClassLoader().getResource()...

Try using the Context ClassLoader.

i.e.

Thread.currentThread().getContextClassLoader().getResource(....)

J

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