content: package com.epam.dsc2019.basic;
  
  import static org.hamcrest.MatcherAssert.assertThat;
  import static org.hamcrest.Matchers.containsString;
  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;
  
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.PropertySource;
  import org.springframework.http.MediaType;
  import org.springframework.test.context.ContextConfiguration;
  import org.springframework.test.context.junit4.SpringRunner;
  import org.springframework.test.context.web.WebAppConfiguration;
  import org.springframework.test.web.servlet.MockMvc;
  import org.springframework.test.web.servlet.MvcResult;
  import org.springframework.test.web.servlet.setup.MockMvcBuilders;
  import org.springframework.web.client.RestTemplate;
  import org.springframework.web.context.WebApplicationContext;
  
  @RunWith(SpringRunner.class)
  @WebAppConfiguration
  @ContextConfiguration(classes = BasicApplicationTest.TestConfiguration.class)
  public class BasicApplicationTest {
  
    private MockMvc mockMvc;
  
    @Autowired
    private WebApplicationContext applicationContext;
  
    @Before
    public void setUp() throws Exception {
      mockMvc = MockMvcBuilders.webAppContextSetup(applicationContext)
          .build();
    }
  
    @Test
    public void basicGreetingTest() throws Exception {
      final MvcResult result = mockMvc.perform(get("/greeting"))
          .andExpect(status().isOk())
          .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_PLAIN))
          .andReturn();
  
      final String responseContent = result.getResponse().getContentAsString();
  
      assertThat(responseContent, containsString("Hello from"));
    }
  
    @Configuration
    @ComponentScan(basePackageClasses = BasicGreetingController.class)
    @PropertySource("classpath:/test.properties")
    static class TestConfiguration {
  
      @Bean
      public RestTemplate restTemplate() {
        return new RestTemplate();
      }
    }
  }
  