Bael 1625 (#3831)
* shutdown boot app * test the ctx.close() * application shutdown test * BAEL-1625 * /shutdown endpoint test * bring back the closeApplication * @Ignore shutdown endpoint test
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
b34473ebbb
commit
19fb7ef5a2
@@ -0,0 +1,43 @@
|
||||
package com.baeldung.shutdown;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class)
|
||||
@AutoConfigureMockMvc
|
||||
public class ShutdownApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext wac;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void givenBootApp_whenShutdownEndpoint_thenExit() throws Exception {
|
||||
|
||||
mockMvc.perform(
|
||||
post("/shutdown"))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user