FYI: the problem was that I executed my requests against the wrong class 
loader. Having changed the code from
>>
InputStream iStr = ClassLoader
                                .getSystemResourceAsStream(this.filePath1);
<<
... to...
>>
InputStream iStr = {class name}.class.getClassLoader()
                                .getResourceAsStream(this.filePath1);
<<
... makes it run like dream :-)

Thanks for your help,
Ciao,
Philipp

> -----Mensaje original-----
> De: Rossmanith, Philipp
> Enviado el: lunes, 14 de mayo de 2007 10:31
> Para: Maven Users List
> Asunto: RE: Problems with loading non-Java resources from classpath in
> JUnit tests
>
>
> > What is the content of "filePath1" ?
> It's a string containing the name of the properties file... (It is working
> in Eclipse, so I can exclude a typo or similar as the cause of the error.)
>
> Ciao,
> Philipp
>
>
> > -----Mensaje original-----
> > De: Jörg Schaible [mailto:[EMAIL PROTECTED]
> > Enviado el: lunes, 14 de mayo de 2007 10:13
> > Para: Maven Users List
> > Asunto: RE: Problems with loading non-Java resources from classpath in
> > JUnit tests
> >
>
> > What is the content of "filePath1" ?
> >
>
> > Rossmanith, Philipp wrote on Monday, May 14, 2007 10:00 AM:
> >
>
> > > Hi,
> > >
> > > My resource file (the properties file I am trying to load) is located
> > > under {root}src\test\resources. Compiling with Maven puts it under
> > > {root}\target\test-classes, along with the Java class files
> > > for the unit
> > > tests.
> > >
> > > I also tried to run the tests with the properties-file placed in
> > > {root}src\main\resources, but it didn't work, either.
> > >
> > > Any other suggestions?
> > >
> > > Thanks in advance,
> > > Ciao,
> > > Philipp
> > >
> > >> -----Mensaje original-----
> > >> De: Wayne Fay [mailto:[EMAIL PROTECTED]
> > >> Enviado el: domingo, 13 de mayo de 2007 23:36
> > >> Para: Maven Users List
> > >> Asunto: Re: Problems with loading non-Java resources from classpath
> > >> in JUnit tests
> > >>
> > >
> > >> Where is your resource file located in your source code tree?
> > >>
> > >
> > >> It should be under src/main/resources. I will assume it is under
> > >> src/main/java -- that's your problem.
> > >>
> > >
> > >> Wayne
> > >>
> > >
> > >> On 5/13/07, Rossmanith, Philipp <[EMAIL PROTECTED]>
> > >> wrote:
> > >>>
> > >>> Hi,
> > >>> I have a component that is loading resources/files from the
> > > classpath
> > >> and for which I have written a JUnit test. However, when I run the
> > >> tests with Maven from the command line, they fail - obviously due to
> > >> some classpath problems.*)
> > >>> My assumption was that target/test-classes would form part of the
> > >> classpath, which a test output with maven -X confirmed. **)
> > > The idea I
> > > got
> > >> was that once the resource file (here: a properties file) would be
> > >> found if it was contained in this folder. However, if I write out
> > >> the classpath programmatically from within the JUnit test, it
> > >> doesn't contain the folder.***)
> > >>> Please note that running the same test in Eclipse is working if I
> > > add
> > >> the test/resources folder as a source folder (with output in
> > >> target/test- classes).
> > >>> Now my question is: How can I make add these non-Java resources to
> > > the a
> > >> Maven classpath? Is there a way to configure the classpath
> > > that Maven
> > > is
> > >> looking at via the POM?
> > >>> Any help on this would be highly appreciated, as I already blew 2
> > >>> days on this. I'm using Maven 2.0.6 and JUnit 3.8.1 unit tests.
> > >>> Thanks in advance, Ciao, Philipp *) I get a NPE for an input stream
> > >>> i create via
> > >> ClassLoader.getSystemResourceAsStream(this.filePath1).
> > >>> **) From a file dump:
> > >>>>>
> > >>> [DEBUG] Adding to surefire test classpath: C:\Documents and
> > >> Settings\9prossma\.m2\repository\org\codehaus\plexus\plexus-
> > >> utils\1.1\plexus-utils-1.1.jar
> > >>> [DEBUG] Test Classpath :
> > >>> [DEBUG]   C:\Manchester\utilities\target\classes
> > >>> [DEBUG]   C:\Manchester\utilities\target\test-classes <<
> > >>> ***) System.out.println("Class path: " +
> > >> System.getProperty("java.class.path")):
> > >>>>>
> > >>> Class path: C:\Documents and
> > >> Settings\9prossma\.m2\repository\org\apache\maven\surefire\surefire-
> > >> api\2.0\surefire-api-2.0.jar;C:\Documents and
> > >> Settings\9prossma\.m2\repository\org\codehaus\plexus\plexus-
> > >> utils\1.1\plexus-utils-1.1.jar;C:\Doc
> > >>> uments and
> > >> Settings\9prossma\.m2\repository\org\apache\maven\surefire\surefire-
> > >> booter\2.0\surefire-booter-2.0.jar
> > >>> <<
> > >>>
> > >>> This e-mail may contain confidential or privileged information. Any
> > >>> unauthorised copying, use or distribution of this information is
> > >>> strictly prohibited.
> > >>>
> > >>>
> > > ---------------------------------------------------------------------
> > >>> 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]
> > >
> > >
> > > This e-mail may contain confidential or privileged
> > > information. Any unauthorised
> > > copying, use or distribution of this information is strictly
> > > prohibited.
> > >
> > > ---------------------------------------------------------------------
> > > 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]
>
>
> This e-mail may contain confidential or privileged information. Any
> unauthorised
> copying, use or distribution of this information is strictly prohibited.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


This e-mail may contain confidential or privileged information. Any unauthorised
copying, use or distribution of this information is strictly prohibited.

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

Reply via email to