Connect to in memory Hsql (hypersonic) database with DatabaseManager while debugging tests

给你一囗甜甜゛ 提交于 2019-12-07 12:22:46

问题


I would like to connect to an in-memory HSQL database instance using the hsql DatabaseManager (or the swing version, it doesn't matter) while debugging tests in my IDE (Intellij IDEA 11.1.2).

I have tried as was suggested by this answer, but every time I do so the DatabaseManager process/thread (I don't know which) starts and freezes. If kill/force quit it, the debug session also dies.

How can I do this without the DatabaseManager freezing?


回答1:


Your Spring/JUnit is starting the database in in-process mode.

Your options would be:

  1. Either starting hsqldb in server mode
  2. Or starting the DBmanager from your application
  3. Or make your breakpoint stop only the current thread, then your databasemanager will not freeze



回答2:


Please also check if your breakpoint halts all threads. Most debuggers have a setting for this. You can change this setting for this breakpoint to only halt the JUnit test. See also here:

Does a breakpoint halt all threads?




回答3:


I think there are two answers to this question.

  1. The answer given by Eugenio Cuevas in his comment if you would like to start DatabaseManager in a separate process/thread from your tests.
  2. Adding the call to DatabaseManager.main() inside one of your tests if you are running in in-process mode. Make sure you pause execution (i.e., prompt for user input) right after the line where DatabaseManager.main() is called so that the test does not keep executing. See here for the code to start the DatabaseManager.


来源:https://stackoverflow.com/questions/11435654/connect-to-in-memory-hsql-hypersonic-database-with-databasemanager-while-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!