Java – using developer HSQLDB in spring rest integration testing

I want to do an integration test of spring MVC rest service The purpose of this test is mainly to test the rest part, not the whole application This means that I want to use HSQLDB instead of the main database of PostgreSQL

I finally found this blog and its sample application, which is very close to my needs: http://johndobie.blogspot.fr/2012/04/unit-and-integration-tests-with-maven.html It uses the Maven plug - in to start Tomcat and start integration testing

My only question is: how can I test with a special ApplicationContext, just as I do simple unit tests?

If I understand correctly, the integration test uses the same war file as the actual application This means that war uses the production web XML, which calls the production ApplicationContext. XML using the real database XML (we use attribute placeholders for some parameters, but not for hibernate dialects)

So my question is: is there any way to use test web XML or at least one test ApplicationContext XML for integration testing?

thank you.

Solution

If you really want to use the same war for testing and production:

>For spring > 3.1: you can use a profile, see the example here: http://spring.io/blog/2011/02/11/spring-framework-3-1-m1-released/ >Or for older spring versions, the spring configurator in the Apache cocoon project: http://cocoon.apache.org/subprojects/configuration/spring-configurator/index.html >If it's just a data source, as a third possibility, you can configure the data source in Tomcat and reference it through JNDI

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>