* Configured Hiberante 5 correctly * Configured Git plugin correctly * Changed hibernate methods to comply with new method naming conventions * Removed and replaced deprecated properties * Updated Actuator test to use new response structure * Using random port in Mongo integration test, to avoid clashing with a potential instance using the mongo default port
36 lines
1.4 KiB
Java
36 lines
1.4 KiB
Java
package com.baeldung.intro;
|
|
|
|
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.http.MediaType;
|
|
import org.springframework.test.context.TestPropertySource;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import org.springframework.test.web.servlet.MockMvc;
|
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
@RunWith(SpringRunner.class)
|
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
|
@AutoConfigureMockMvc
|
|
public class AppLiveTest {
|
|
|
|
@Autowired
|
|
private MockMvc mvc;
|
|
|
|
@Test
|
|
public void getIndex() throws Exception {
|
|
mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().string(equalTo("Index Page")));
|
|
}
|
|
|
|
@Test
|
|
public void getLocal() throws Exception {
|
|
mvc.perform(MockMvcRequestBuilders.get("/local").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().string(equalTo("/local")));
|
|
}
|
|
|
|
} |