Search in sources :

Example 1 with FetchHandler

use of com.thoughtworks.go.domain.FetchHandler in project gocd by gocd.

the class HttpServiceTest method shouldDownloadArtifact.

@Test
public void shouldDownloadArtifact() throws IOException {
    String url = "http://blah";
    FetchHandler fetchHandler = mock(FetchHandler.class);
    HttpGet mockGetMethod = mock(HttpGet.class);
    CloseableHttpResponse response = mock(CloseableHttpResponse.class);
    when(response.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
    when(httpClient.execute(mockGetMethod)).thenReturn(response);
    when(httpClientFactory.createGet(url)).thenReturn(mockGetMethod);
    service.download(url, fetchHandler);
    verify(httpClient).execute(mockGetMethod);
    verify(fetchHandler).handle(null);
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) FetchHandler(com.thoughtworks.go.domain.FetchHandler) BasicStatusLine(org.apache.http.message.BasicStatusLine) Test(org.junit.Test)

Aggregations

FetchHandler (com.thoughtworks.go.domain.FetchHandler)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1 BasicStatusLine (org.apache.http.message.BasicStatusLine)1 Test (org.junit.Test)1