I'm trying to access the H2-Console during a WebIntegrationTest in debug mode. However, I noticed that Spring Boot is blocking the H2-console when I'm debugging the test. It seems as soon as a breakpoint is reached, the H2-console is blocked as well. I'm working with Spring Boot 1.3.1.RELEASE.
Each breakpoint in the following test causes to block the H2-console. In breakpoint 1, the login page appears. I then press to login button but nothing happens until I let continue the test to the next breakpoint. In breakpoint 2, I'm logged in and can execute a query. But only when I'm going to the next breakpoint, the query results appear.
@Test
public void whenGetById_thenCorrectId() throws InterruptedException {
// do some stuff
// breakpoint 1
Thread.sleep(1000);
// breakpoint 2
Thread.sleep(1000);
// breakpoint 3
}
The WebIntegrationTest ist configured as follows:
@ActiveProfiles("local,unittest")
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyApplication.class)
@WebIntegrationTest({"spring.h2.console.enabled=true", "server.port=8080"})
public class MyResourceTest {
How can I decouple the H2-in-memory DB from the debug mode?
Accessing the H2 Console By default, the H2 console is not enabled in Spring. Then, after starting the application, we can navigate to http://localhost:8080/h2-console, which will present us with a login page. The web console has an auto-complete feature that suggests SQL keywords.
H2 Console: By default, the console view of the H2 database is disabled. Before accessing the H2 database, we must enable it by using the following property. Once we have enabled the H2 console, now we can access the H2 console in the browser by invoking the URL http://localhost:8082/h2-console.
Breakpoint can be configured to suspend the whole VM or only a single thread. In IntelliJ you can set this via right-click on the respective breakpoint. My breakpoints were configured to suspend the whole VM and so each breakpoint also blocked to access the H2-Console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With