Sorry, I must be dense, but I do not understand how that thread helps me...
I've tried this code:

        InputStream xml =
getClass().getClassLoader().getResourceAsStream("/data/" + fileName);
            return new FlatXmlDataSet(xml);

But now Eclipse cannot find the files... and neither can Maven.

My original data xml files are under CodsWebTesting/test/data directory.  I
use maven to copy them into 'target\test-classes\data' directory - but
maven is not finding it there when I run mvn test...   There's not much I
can do abut the structure of the CodsWebTesting project at this point...

How could I convince maven to look for these XML files in
/target/test-classes/data dir or some other dir under /target ?

Thanks,
James






                                                                       
             "Wayne Fay"                                               
             <[EMAIL PROTECTED]                                         
             om>                                                        To
                                       "Maven Users List"              
             09/26/2007 02:47          <[email protected]>        
             PM                                                         cc
                                                                       
                                                                   Subject
             Please respond to         Re: Resource relative paths in test
               "Maven Users            cases...                        
                   List"                                               
             <[EMAIL PROTECTED]                                         
                  he.org>                                              
                                                                       
                                                                       
                                                                       




This comes up pretty frequently. In the future, try searching the
archives first...

Here's a search query with a few hits from the last 3 mos:
http://www.nabble.com/forum/Search.jtp?query=classloader+getclass&local=y&forum=178&daterange=4&startdate=&enddate=


Wayne

On 9/26/07, Insitu <[EMAIL PROTECTED]> wrote:
> James Depaul <[EMAIL PROTECTED]> writes:
>
> > Hello -
> >
> > I'm working on maven-izing a project that's composed of three modules.
I
> > have the POMs configured with proper dependencies.  Compile all works
now
> > and now I'm tying to execute the Test Cases and have some problems - it
has
> > to do with how Maven resolves the resource locations...
> >
> > The test cases are using DBUNIT framework to insert data into the db
before
> > running.  Inside the getDataSet() method in test case I need to create
an
> > InputStream to the XML file that contains the test data for the run.
The
> > code implementation that I have that works perfectly in Eclipse is
this:
> >
> >     protected IDataSet getDataSet() throws Exception {
> >         String fileName = "cods_user_auth-seed.xml"; // data file
> >         URL rootPath = UserAdminUserTest.class.getResource("/data/" +
> > fileName);   // root path location + specific location of the file
> >         System.out.println("rootPath=" + rootPath);
> >         return new FlatXmlDataSet(
> >                 new FileInputStream(rootPath.getFile())); // get the
file
> > as InputStream
> >     }
> >
>
> This assumes  "cods_user_auth-seed.xml" is located at
> "src/test/resources":
>
>     InputStream xml =
>     getClass().getClassLoader().getResourceAsStream("/data/" +
>       fileName);
>     return new FlatXmlDataSet(xml);
>
> HTH
> --
> OQube < software engineering \ génie logiciel >
> Arnaud Bailly, Dr.
> \web> http://www.oqube.com
>
>
> ---------------------------------------------------------------------
> 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