I'm not a surefire expert, this is just from taking a quick look at the source:
However you run Surefire (forked or not, with child delegation or
not), the system classloader will not contain your test code. In
forked mode, it will only contain surefire and your testing framework.
Surefire itself will create an isolated classloader that contains your
test code and its dependencies and run your tests from that
classloader.

If you expect your code to work in anything but a basic Java
application, do not depend on the system classloader. And
unfortunately, surefire is not a basic app.

tom

On 12/25/06, Wendy Smoak <[EMAIL PROTECTED]> wrote:
On 12/24/06, Benson Margulies <[EMAIL PROTECTED]> wrote:

> I have a class that calls ClassLoader.getSystemResourceAsStream to
> retrieve an XML file. All is well when running the live code, and even
> when running JUnit from Eclipse. From surefire, the XML file is not
> found.
>
> I sense that I'm missing something about class paths, but I can't find
> anything really apposite in the documentation.

I can reproduce it, but I can't explain it.

According to the Surefire docs [1], tests normally run in an isolated
classloader.

However, setting childDelegation=true, which supposedly "makes tests
run using the standard classloader delegation instead of the default
Maven isolated classloader" didn't help matters.

With src/main/resources/temp.properties, running from Surefire,
   ClassLoader.getSystemResourceAsStream("temp.properties");
returns null while
   this.getClass().getClassLoader().getResourceAsStream("temp.properties");
doesn't.

In IDEA, neither one returns null (and the tests pass.)

Here's a sample project if you want to play with it:
http://people.apache.org/~wsmoak/maven/system-resource-1.0-SNAPSHOT-src.zip

[1] http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html

--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to