2013-12-31 16:40:21 +08:00
|
|
|
package sample.data.jpa;
|
2013-04-24 17:02:07 +08:00
|
|
|
|
2013-08-03 01:12:17 +08:00
|
|
|
import org.junit.Before;
|
2013-04-24 17:02:07 +08:00
|
|
|
import org.junit.Test;
|
2013-10-03 03:07:04 +08:00
|
|
|
import org.junit.runner.RunWith;
|
2013-08-03 01:12:17 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2013-11-28 22:35:36 +08:00
|
|
|
import org.springframework.boot.test.SpringApplicationConfiguration;
|
2013-10-03 03:07:04 +08:00
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
import org.springframework.test.context.web.WebAppConfiguration;
|
2013-08-03 01:12:17 +08:00
|
|
|
import org.springframework.test.web.servlet.MockMvc;
|
|
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
|
|
import org.springframework.web.context.WebApplicationContext;
|
2013-04-24 17:02:07 +08:00
|
|
|
|
2014-01-22 06:37:18 +08:00
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
|
2013-04-24 17:02:07 +08:00
|
|
|
/**
|
2013-08-03 01:12:17 +08:00
|
|
|
* Integration test to run the application.
|
2014-07-03 05:43:43 +08:00
|
|
|
*
|
2013-08-03 01:12:17 +08:00
|
|
|
* @author Oliver Gierke
|
2013-04-24 17:02:07 +08:00
|
|
|
*/
|
2013-10-03 03:07:04 +08:00
|
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
2013-11-28 22:35:36 +08:00
|
|
|
@SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
|
2013-10-03 03:07:04 +08:00
|
|
|
@WebAppConfiguration
|
2013-11-16 15:42:40 +08:00
|
|
|
@ActiveProfiles("scratch")
|
|
|
|
// Separate profile for web tests to avoid clashing databases
|
2013-10-03 03:07:04 +08:00
|
|
|
public class SampleDataJpaApplicationTests {
|
2013-04-24 17:02:07 +08:00
|
|
|
|
2013-08-03 01:12:17 +08:00
|
|
|
@Autowired
|
|
|
|
private WebApplicationContext context;
|
2013-04-24 17:02:07 +08:00
|
|
|
|
2013-08-03 01:12:17 +08:00
|
|
|
private MockMvc mvc;
|
2013-04-24 17:02:07 +08:00
|
|
|
|
2013-08-03 01:12:17 +08:00
|
|
|
@Before
|
|
|
|
public void setUp() {
|
|
|
|
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
2013-04-24 17:02:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testHome() throws Exception {
|
|
|
|
|
2013-08-03 01:12:17 +08:00
|
|
|
this.mvc.perform(get("/")).andExpect(status().isOk())
|
|
|
|
.andExpect(content().string("Bath"));
|
2013-04-24 17:02:07 +08:00
|
|
|
}
|
|
|
|
}
|