在seam测试中更改persistence.xml

时间:2012-01-19 13:30:13

标签: hibernate unit-testing seam testng

在我们的生产和开发中,我们针对MSSQL数据库进行开发。

但是当我们运行测试时,我们希望将它与HSQL数据库进行对比。

更改DS文件以使其针对HSQL运行没有问题,但是persitence.xml中的旧dialcet仍然是MSSQL方言,那么如何将其更改为HSQL方言?

// Trind

1 个答案:

答案 0 :(得分:1)

您可以使用资源和测试资源过滤。

<filters>
    <filter>src/main/filters/dev.filter.properties</filter>
    <filter>src/test/filters/dev.filter.properties</filter>
</filters>
<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>
<testResources>
    <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
    </testResource>
</testResources>

在dev.filter.properties文件中定义一个hibernate.dialect属性,并使其在主目录和测试目录中不同。

然后使用test和main中的persistence.xml文件。

http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

http://maven.apache.org/plugins/maven-resources-plugin/testResources-mojo.html

相关问题