title: MockMVC not working with server.context-path=/myRoot
body: <p>O. 
  I am using Spring boot server.context-path=/myRoot. 
  Then i have a @RestController that handles @RequestMapping("/some/path"). 
  In the controller unit test i am using MockMvc. </p>
  
  <pre><code>@Test
      public void shouldGetSuccessfulHttpResponseForBasket() throws Exception {
          //Given
          String requestURL = "/some/path";
          //When
          MvcResult result = getMockMvc().perform(get(requestURL))
          //Then
                  .andExpect(status().isOk());
          String content = result.getResponse().getContentAsString();
          assertNotEquals("Content should not be empty", "", content);
      }
  </code></pre>
  
  <p>So my problem is that content is comming empty. It's because my unit test doesn't use the server.context-path=/myRoot. 
  So if i use this URL "/myRoot/some/path" the http status is 400 because it doesn't find a matching handler. 
  If i use this URL "/some/path" the http status is 200 but content is empty (when it shouldn't).
  If i annotate my controller with @RequestMapping("/myRoot"), it works with this URL "/myRoot/some/path". But then my application won't work as i expect. In this last case i will have to use this URL "/myRoot/myRoot/some/path" in order to get a response from my service.</p>
  
  <p>So the ideal solution would be to get rid of server.context-path=/myRoot.
  This can't be done because the application depends on that property.
  Any ideas on how to solve this?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Update:</p>
  
  <p>This is my base class. My test class is extending this one.</p>
  
  <pre><code>/**
   * Sets up and gets the mvc test support available in the mock context.
   */
  public abstract class MvcTestCase {
  
      /** The spring mock web context. */
      @Autowired
      private WebApplicationContext webContext;
  
      /**
       * The service that creates a mock context to test against the front Controller.
       */
      private MockMvc mockMvc;
  
      /**
       * Sets up the service that creates a mock context to test against the front Controller.
       * 
       * @throws Exception thrown when set up fails.
       */
      @Before
      public void setupMockContext() throws Exception {
          mockMvc = MockMvcBuilders.webAppContextSetup(webContext)
                  .build();
      }
  
      /**
       * Gets the mock mvc test support.
       * 
       * @return The entry point for server-side Spring MVC test support.
       */
      public MockMvc getMockMvc() {
          return mockMvc;
      }
  
  }
  </code></pre>