3 import org.junit.jupiter.api.Test;
4 import org.springframework.beans.factory.annotation.Autowired;
5 import org.springframework.beans.factory.annotation.Value;
6 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
7 import org.springframework.boot.test.context.SpringBootTest;
8 import org.springframework.test.web.servlet.MockMvc;
10 import static de.juplo.demo.BackendVersionInterceptor.BACKEND_VERSION;
11 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
12 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
17 class DemoApplicationTests
20 @Value("${build.version}")
21 String projectVersion;
31 void getWelcomeResponseIsOkIfBackendHeaderIsNotSet(@Autowired MockMvc mvc) throws Exception
33 mvc.perform(get("/")).andExpect(status().isOk());
37 void getWelcomeResponseIsOkIfBackendHeaderDoesMatch(@Autowired MockMvc mvc) throws Exception
41 .header(BACKEND_VERSION, projectVersion))
42 .andExpect(status().isOk());
46 void getWelcomeResponseIsGoneIfBackendHeaderDoesNotMatch(@Autowired MockMvc mvc) throws Exception
50 .header(BACKEND_VERSION, "FOO"))
51 .andExpect(status().isGone());