/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

  1. package com.atomist.spring;
  2. import org.junit.Test;
  3. import org.junit.runner.RunWith;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
  6. import org.springframework.test.context.junit4.SpringRunner;
  7. import org.springframework.test.web.servlet.MockMvc;
  8. import static org.hamcrest.Matchers.equalTo;
  9. import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
  10. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
  11. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
  12. @RunWith(SpringRunner.class)
  13. @WebMvcTest(SpringRestSeedController.class)
  14. public class SpringRestSeedControllerTests {
  15. @Autowired
  16. private MockMvc mockMvc;
  17. @Test
  18. public void shouldReturnGreeting() throws Exception {
  19. this.mockMvc.perform(get("/hello/Rod"))
  20. .andExpect(status().isOk())
  21. .andExpect(content().string(equalTo("Hello Rod!")));
  22. }
  23. @Test
  24. public void shouldNotFindGreetingElsewhere() throws Exception {
  25. this.mockMvc.perform(get("/hey/man"))
  26. .andExpect(status().isNotFound());
  27. }
  28. }