Skip to content

Commit

Permalink
Simpler config for IT HTTP client
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Nov 15, 2013
1 parent 9fe1e47 commit 280e503
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Expand Up @@ -18,7 +18,6 @@

import static java.lang.Integer.MAX_VALUE;
import static java.lang.Integer.parseInt;
import static java.util.concurrent.TimeUnit.SECONDS;
import static javax.ws.rs.core.Response.Status.CREATED;
import static javax.ws.rs.core.Response.Status.OK;
import static org.fcrepo.http.commons.test.util.TestHelpers.parseTriples;
Expand All @@ -37,7 +36,6 @@
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import org.junit.Before;
import org.junit.runner.RunWith;
Expand All @@ -64,16 +62,12 @@ public void setLogger() {
protected static final String serverAddress = "http://" + HOSTNAME + ":" +
SERVER_PORT + "/";

protected final PoolingHttpClientConnectionManager connectionManager =
new PoolingHttpClientConnectionManager();

protected static HttpClient client;

public AbstractResourceIT() {
connectionManager.closeIdleConnections(3, SECONDS);
final HttpClientBuilder b =
HttpClientBuilder.create().setMaxConnPerRoute(5).setMaxConnTotal(
MAX_VALUE).setConnectionManager(connectionManager);
HttpClientBuilder.create().setMaxConnPerRoute(MAX_VALUE)
.setMaxConnTotal(MAX_VALUE);
client = b.build();
}

Expand Down Expand Up @@ -150,7 +144,11 @@ protected HttpResponse createObject(final String pid) throws IOException {
}

protected HttpResponse createDatastream(final String pid, final String dsid, final String content) throws IOException {
final HttpResponse response = client.execute(postDSMethod(pid, dsid, content));
logger.trace(
"Attempting to create datastream for object: {} at datastream ID: {}",
pid, dsid);
final HttpResponse response =
client.execute(postDSMethod(pid, dsid, content));
assertEquals(CREATED.getStatusCode(), response.getStatusLine().getStatusCode());
return response;
}
Expand Down
Expand Up @@ -33,6 +33,7 @@
import static javax.ws.rs.core.Response.Status.OK;
import static nu.validator.htmlparser.common.DoctypeExpectation.NO_DOCTYPE_ERRORS;
import static nu.validator.htmlparser.common.XmlViolationPolicy.ALLOW;
import static org.apache.http.impl.client.cache.CacheConfig.DEFAULT;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
import static org.fcrepo.jcr.FedoraJcrTypes.ROOT;
import static org.fcrepo.kernel.RdfLexicon.DC_TITLE;
Expand Down Expand Up @@ -639,7 +640,7 @@ public void testGetProjectedNode() throws Exception {
@Test
public void testDescribeRdfCached() throws RepositoryException, IOException {
final CloseableHttpClient specialClient =
CachingHttpClientBuilder.create().build();
CachingHttpClientBuilder.create().setCacheConfig(DEFAULT).build();
final String pid = "FedoraObjectsRdfTest2";
final String path = "" + pid;
specialClient.execute(new HttpPost(serverAddress + path));
Expand Down

0 comments on commit 280e503

Please sign in to comment.