3

I am learning spring-boot test and find this article,

4.Integration Testing with @DataJpaTest

How can I view the content of h2 database using the info below by configuring client tool such as intellij-idea's Tool > Database.

Or is there any better way to peek those information.

INFO 11276 --- [ main] o.s.j.d.e.EmbeddedDatabaseFactory : Starting embedded database: url='jdbc:h2:mem:094de3b8-72c0-4740-bdf6-5ae1a36ad9f4;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa'

Kevin Peters
  • 3,314
  • 1
  • 17
  • 38
teik
  • 508
  • 4
  • 26

1 Answers1

0

I don't know much about IntelliJ (because I love to use Eclipse), but in general you could access the h2 database like shown in this tutorial.

A small remaining obstacle in your case is that Spring Boot in combination with @DataJpaTest is initiating the database at the beginning of the tests and discards it after the tests complete. So there is "not really much time" to take a look into the database.

And depending on transactions, the flushing strategy and / or your manual flushing (EntityManager.flush()) it's not guaranteed to see all changes of your domain objects during the tests.

Kevin Peters
  • 3,314
  • 1
  • 17
  • 38