2

I'm developing a Rest Api using spring boot. I know that I can make all the integration tests using a 'test database' like H2 and spring boot is able to initialize sql scripts.

However, my application is accessing the database through procedures using an old home made library and I cannot refactor to JPA (unfortunately).

I do not think I can setup the database and procedures into H2 (because I'm using a non-standard database).

My question is: how can I test my endpoints in those conditions?

Thanks

pedrohreis
  • 1,030
  • 2
  • 14
  • 33
  • Did you try using Liquibase or Flyway to set up scripts that will be populate your test database and create stored procedures required by your library? – Mike Wojtyna Apr 07 '17 at 21:02
  • @MikeWojtyna, I do know if I'm losing anything, but I see 2 issues: 1 - I need definitions for the same table: in my .sql scripts and another in the liquibase xml 2 - I need to have the same implementation of the procedure twice (one for the metalanguage of the database and another for my 'dummy db'). The whole problem is because I'm using a non-standard database so some statements allowed there will fail on h2, for example. – pedrohreis Apr 07 '17 at 21:09
  • In your conditions it's ok to talk to real db to perform integration tests. What's stopping you from spinning up a new server in your test, perform http calls and verify? – phanin Apr 07 '17 at 22:44
  • @phani, yeah I agree with I can just talk to my dev db. I'm just trying to avoid some issues, like keep the database credentials within my application (in a test properties file); do not affect the real db itself; make my tests faster. I mean, it could be an 'overcare'... but I'm trying to keep good practices – pedrohreis Apr 08 '17 at 01:42
  • You can use Spring Profiles to have test-specific properties. Ref: http://stackoverflow.com/questions/32196451/environment-specific-application-properties-file-in-spring-boot-application – phanin Apr 10 '17 at 16:35

0 Answers0