lundi 9 novembre 2015

How can I get a test resource from another module

I want to re-use an sql script from the test resources of the database module in my in-memory test in the pizza module, but I can't get the script from the classpath.

My directory structure looks like this:

(I left most of the files/directories out for brevity)

|   pom.xml
|   
|           
+---database
|   |   pom.xml
|   |   
|   \---src
|       \---test
|           \---resources
|               \---db
|                   \---migration
|                       \---hsqldb
|                               V1__create_schema.sql
|                               V2__config_data.sql
|                               V3__user_data.sql
|                               
+---pizza
|   |   pom.xml
|   |   
|   \---src
|       +---main
|       |   +---java
|       |   |   \---com
|       |   |       \---example
|       |   |           +---domain
|       |   |           |       DoStuff.java
|       |   |                   
|       |   \---resources
|       |       |   applicationContext.xml
|       |               
|       \---test
|           +---java
|           |   \---com
|           |       \---example
|           |               DoStuffTest.java
|           |                   
|           \---resources
|                   insert-test-data.sql
|                   test-applicationContext.xml
|                   test-in-memory-database.xml
|                   
\---poms
    |   pom.xml
    |   
    \---parent
            pom.xml

Now, I would like test-applicationContext in the pizza module to create an in-memory database from the V1__create_schema.sql script in the database module, so I can run tests against it. I put this into my test-applicationContext.xml:

<jdbc:embedded-database id="dataSource" type="HSQL">
    <jdbc:script location="classpath:V1__create_schema.sql"/>
    <jdbc:script location="insert-test-data.sql"/>
</jdbc:embedded-database>

... but it can't find V1__create_schema.sql on my classpath. I have tried many different ways of reaching it, including maven-remote-resources-plugin, without luck.

How would I go about getting hold of that resource?

... or maybe I'm using the wrong approach?

Aucun commentaire:

Enregistrer un commentaire