title: I/O error on GET request for unkown host in Junit test case
body: <p>I am writing the Junit test cases for method which uses the rest template, below is the method.</p>
  
  <pre><code>public Student getStudent(Integer studId) throws Exception {
          RestTemplate restTemplate = new RestTemplate(
                          utility.setAuthenticationParameters(
                                  "test", "test"));
          String url=https://dev.test.res.com/student;
              HttpHeaders headers = new HttpHeaders();
          HttpEntity&lt;String&gt; entity = new HttpEntity&lt;&gt;(headers);
          url =url+"?"+studId;
          Map&lt;String, String&gt; params = new HashMap&lt;&gt;();
          params.put("studId", studId);
          ResponseEntity&lt;String&gt; response = restTemplate.exchange(url,
                              HttpMethod.GET, entity, String.class, params);
      }
  </code></pre>
  
  <p>Junit test cases for the above method I have written using mockito framework</p>
  
  <pre><code>import static org.junit.Assert.*;
  
  import java.io.IOException;
  import java.net.URI;
  import java.text.ParseException;
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.xml.datatype.DatatypeConfigurationException;
  
  import junit.framework.Assert;
  
  import org.codehaus.jackson.JsonGenerationException;
  import org.codehaus.jackson.map.JsonMappingException;
  import org.codehaus.jackson.map.ObjectMapper;
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.mockito.InjectMocks;
  import org.mockito.Mock;
  import org.mockito.Mockito;
  import org.mockito.MockitoAnnotations;
  import org.mockito.runners.MockitoJUnitRunner;
  import org.springframework.boot.test.IntegrationTest;
  import org.springframework.http.HttpEntity;
  import org.springframework.http.HttpHeaders;
  import org.springframework.http.HttpMethod;
  import org.springframework.http.MediaType;
  import org.springframework.http.ResponseEntity;
  import org.springframework.http.client.ClientHttpRequest;
  import org.springframework.http.client.ClientHttpRequestFactory;
  import org.springframework.http.client.ClientHttpResponse;
  import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
  import org.springframework.mock.http.client.MockClientHttpRequest;
  import org.springframework.test.context.ContextConfiguration;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  import org.springframework.test.context.web.WebAppConfiguration;
  import org.springframework.test.web.client.MockRestServiceServer;
  import org.springframework.web.client.RestTemplate;
  
  
  @RunWith(MockitoJUnitRunner.class)
  @ContextConfiguration(classes = {ConfigData.class})
  public class StudentClientTest {
  
      @Mock
      RestTemplate restTemplate;
  
      @Mock
      ClientHttpRequestFactory requestFactory;
  
      @Mock
      ClientHttpRequest request;
  
      @Mock
      MockClientHttpRequest mockClientHttpRequest;
  
      @Mock
      ClientHttpResponse response;
  
      @Mock
      ResponseEntity&lt;String&gt; responseEntory;
  
      private MockRestServiceServer mockServer;
  
  
      @InjectMocks
      private StudentClient studentClient= new StudentClient();
  
  
  
      @Before
      public void setUp() {
          MockitoAnnotations.initMocks(this);
  
      }
  
  
      @Test
      public void getStudentTest() throws Exception{
  
  
  
          String uri = "https://dev.test.res.com/student?";
  
          Integer studId=100;
          uri=uri+studId;
  
          Mockito.when(restTemplate.exchange(Mockito.contains(uri),Mockito.eq(HttpMethod.GET),Mockito.isA(HttpEntity.class), Mockito.eq(String.class),Mockito.isNotNull())).thenReturn(responseEntory);
          assertNotNull(studentClient.getStudent(100));
  }
  
  
  }
  </code></pre>
  
  <p>I/O error on GET request for "<a href="https://dev.test.res.com/student?studId=100" rel="nofollow">https://dev.test.res.com/student?studId=100</a>": nested exception is java.net.UnknownHostException: dev.test.res.com</p>
  
  <p>I have mocked the object but still is failing with exception</p>