/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
- package com.atomist.spring;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
- import org.springframework.test.context.junit4.SpringRunner;
- import org.springframework.test.web.servlet.MockMvc;
- import static org.hamcrest.Matchers.equalTo;
- 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;
- @RunWith(SpringRunner.class)
- @WebMvcTest(SpringRestSeedController.class)
- public class SpringRestSeedControllerTests {
- @Autowired
- private MockMvc mockMvc;
- @Test
- public void shouldReturnGreeting() throws Exception {
- this.mockMvc.perform(get("/hello/Rod"))
- .andExpect(status().isOk())
- .andExpect(content().string(equalTo("Hello Rod!")));
- }
- @Test
- public void shouldNotFindGreetingElsewhere() throws Exception {
- this.mockMvc.perform(get("/hey/man"))
- .andExpect(status().isNotFound());
- }
- }