PageRenderTime 26ms CodeModel.GetById 15ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/test/java/com/atomist/spring/SpringRestSeedControllerTests.java

https://bitbucket.org/jessitron/test-repo-1523562638244
Java | 35 lines | 28 code | 7 blank | 0 comment | 0 complexity | 8754a0a483d206623784aa7571571129 MD5 | raw file
 1package com.atomist.spring;
 2
 3import org.junit.Test;
 4import org.junit.runner.RunWith;
 5import org.springframework.beans.factory.annotation.Autowired;
 6import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
 7import org.springframework.test.context.junit4.SpringRunner;
 8import org.springframework.test.web.servlet.MockMvc;
 9
10import static org.hamcrest.Matchers.equalTo;
11import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
12import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
13import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
14
15@RunWith(SpringRunner.class)
16@WebMvcTest(SpringRestSeedController.class)
17public class SpringRestSeedControllerTests {
18
19	@Autowired
20	private MockMvc mockMvc;
21
22	@Test
23	public void shouldReturnGreeting() throws Exception {
24		this.mockMvc.perform(get("/hello/Rod"))
25				.andExpect(status().isOk())
26				.andExpect(content().string(equalTo("Hello Rod!")));
27	}
28
29	@Test
30	public void shouldNotFindGreetingElsewhere() throws Exception {
31		this.mockMvc.perform(get("/hey/man"))
32				.andExpect(status().isNotFound());
33	}
34
35}