title: Spring Test MockMvc perform request on external URL
body: <p>I'm trying to perform a POST request on URL outside the current context, and it looks like Spring cannot understand it.</p>
  
  <p>Test code:</p>
  
  <pre><code>        String content = mvc
              .perform(post("http://some-external-url.com:8080/somepath)
                      .header("Authorization", authorization)
                      .contentType(MediaType.APPLICATION_FORM_URLENCODED)
                      .param("username", username)
                      .param("password", password)
              .andExpect(status().isOk())
              .andReturn().getResponse().getContentAsString();
  </code></pre>
  
  <p>Works like a charm on current context.  But remote service cannot be reached at all. It seems like "<a href="http://some-external-url.com:8080" rel="noreferrer">http://some-external-url.com:8080</a>" part is ignored.</p>
  
  <p>Mock creation code:</p>
  
  <pre><code>mvc = MockMvcBuilders.webAppContextSetup(context).build();
  </code></pre>
  
  <p>Is there any way to make it work? Because using standard Java HttpUrlConnection class is a huge pain.</p>