use of org.apache.http.client.HttpClient in project intellij-community by JetBrains.
the class RedmineRepository method fetchProjects.
public List<RedmineProject> fetchProjects() throws Exception {
HttpClient client = getHttpClient();
// Download projects with pagination (IDEA-125056, IDEA-125157)
List<RedmineProject> allProjects = new ArrayList<>();
int offset = 0;
ProjectsWrapper wrapper;
do {
HttpGet method = new HttpGet(getProjectsUrl(offset, 50));
wrapper = client.execute(method, new GsonSingleObjectDeserializer<>(GSON, ProjectsWrapper.class));
offset += wrapper.getProjects().size();
allProjects.addAll(wrapper.getProjects());
} while (wrapper.getTotalCount() > allProjects.size() || wrapper.getProjects().isEmpty());
myProjects = allProjects;
return Collections.unmodifiableList(myProjects);
}
use of org.apache.http.client.HttpClient in project nhin-d by DirectProject.
the class HttpClientFactory method createHttpClient.
/**
* Creates an HttpClient with the default connection timeout and SO timeout.
* @return The HTTP client.
*/
public static HttpClient createHttpClient() {
final HttpClient client = new DefaultHttpClient(conMgr);
final HttpParams httpParams = client.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, DEFAULT_CON_TIMEOUT);
HttpConnectionParams.setSoTimeout(httpParams, DEFAULT_SO_TIMEOUT);
return client;
}
use of org.apache.http.client.HttpClient in project nhin-d by DirectProject.
the class HttpClientFactory method createHttpClient.
/**
* Creates an HttpClient with a specific connection timeout and SO timeout.
* @return The HTTP client.
*/
public static HttpClient createHttpClient(int conTimeOut, int soTimeout) {
final HttpClient client = new DefaultHttpClient(conMgr);
final HttpParams httpParams = client.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, conTimeOut);
HttpConnectionParams.setSoTimeout(httpParams, soTimeout);
return client;
}
use of org.apache.http.client.HttpClient in project nhin-d by DirectProject.
the class UsecuredServiceRequestBase_constructTest method testConstruct_validConstruction.
@Test
public void testConstruct_validConstruction() throws Exception {
HttpClient client = mock(HttpClient.class);
MockServiceRequest req = new MockServiceRequest(client, "http://service/svc", "Test");
assertNotNull(req);
assertEquals(client, req.httpClient);
assertEquals("Test", req.msg);
assertEquals("http://service/svc", req.serviceUrl);
}
use of org.apache.http.client.HttpClient in project nhin-d by DirectProject.
the class UnsecureServiceRequestBase_callTest method testCall_callWithNoReturnValue.
@Test
public void testCall_callWithNoReturnValue() throws Exception {
HttpClient mockClient = mock(HttpClient.class);
StatusLine statLine = mock(StatusLine.class);
when(statLine.getStatusCode()).thenReturn(204);
HttpResponse resp = mock(HttpResponse.class);
when(resp.getStatusLine()).thenReturn(statLine);
when(mockClient.execute((HttpUriRequest) any())).thenReturn(resp);
MockServiceRequest req = new MockServiceRequest(mockClient, "http://service/svc", "Test");
assertNull(req.call());
}
Aggregations