Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unit testing an old JEE web app with native PLSQL queries

User_C85SZFeb 5 2021

Hello
Straight to the point: how would you tackle adding a unit test framework to an old and big JEE web app (Java 5) which is using native SQL queries instead of Hibernate?
The app relies on a PL/SQL database with what I guess should be considered as a medium-sized database (a dump weighs about 60GB).
The app runs Hibernate. If it was properly made, I guess it would fully use Hibernate. By that, I mean that all the CRUD operations would be written in criteria, HQL or JPQL.
Adding JUnit, power mock/mockito, and some embedded DB scripts like an h2 or SQLite would be very easy and we could do unit tests on everything.
Thing is, more than half of the CRUD operations are written in native PL/SQL queries, so Hibernate in the app is used only for the sole purpose of mapping...
Unit testing turns out to be a nightmare where an embedded DB won't work because some PL/SQL queries won't be compatible... And I see no easy solution. Importing and managing database dumps for each feature, to run the unit tests, sounds really awful
To me, the only solution to have a complete unit test environment would be to rewrite all the queries into HQL/criteria so that unit tests could run on isolated embedded databases scripts right?

Comments
Post Details
Added on Feb 5 2021
1 comment
129 views