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
    }


When I run in Eclipse, the rootPath that gets resolved is this:  >>>>>
rootPath=file:/C:/workspaces/maersk/cods/CodsWebTesting/bin/data/cods_user_auth-seed.xml

When I run in maven, the rootPath resolves to this (which is not found):
>>>>>
rootPath=file:/C:/workspaces/maersk/cods/target/test-classes/com/ibm/cods/web/data/service/adminuseradmin/
data/cods_user_auth-seed.xml

I know this is probably a Java resource question, but could someone
recommend a uniform way I can use to retrieve the resource/file that will
resolve equally well in Eclipse and in Maven2?  I'm sooo close...

Thanks,
James

Reply via email to