* 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:
Mher Baghinyan
2018-04-02 09:56:55 +04:00
committed by Grzegorz Piwowarek
parent b34473ebbb
commit 19fb7ef5a2
7 changed files with 133 additions and 0 deletions

View File

@@ -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());
}
}