Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed HTTP unit test

The HTTP client was not being created before the tests. Thus several tests were throwing NullPointerExceptions. It broke as part of the move to httpclient 4.x.
  • Loading branch information...
commit f7d05f9bccc21a738f2423250f3caa74b0d7ac46 1 parent ce113ee
@roberttheiv roberttheiv authored
Showing with 12 additions and 9 deletions.
  1. +12 −9 test/unit/voldemort/store/http/HttpStoreTest.java
View
21 test/unit/voldemort/store/http/HttpStoreTest.java
@@ -66,6 +66,11 @@ public void setUp() throws Exception {
RequestFormatType.VOLDEMORT_V1,
node.getHttpPort());
server = context.getServer();
+
+ ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
+ 5000,
+ TimeUnit.MILLISECONDS);
+ httpClient = new DefaultHttpClient(connectionManager);
httpStore = ServerTestUtils.getHttpStore("users",
RequestFormatType.VOLDEMORT_V1,
node.getHttpPort(),
@@ -76,15 +81,15 @@ public void setUp() throws Exception {
ByteArray key = new ByteArray("test".getBytes());
RequestFormat requestFormat = new RequestFormatFactory().getRequestFormat(RequestFormatType.VOLDEMORT_V1);
- ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
- 5000,
- TimeUnit.MILLISECONDS);
-
- DefaultHttpClient client = new DefaultHttpClient(connectionManager);
- HttpParams clientParams = client.getParams();
+ HttpParams clientParams = httpClient.getParams();
HttpConnectionParams.setConnectionTimeout(clientParams, 5000);
- HttpStore badUrlHttpStore = new HttpStore("test", url, port, client, requestFormat, false);
+ HttpStore badUrlHttpStore = new HttpStore("test",
+ url,
+ port,
+ httpClient,
+ requestFormat,
+ false);
try {
badUrlHttpStore.put(key,
new Versioned<byte[]>("value".getBytes(), new VectorClock()),
@@ -102,8 +107,6 @@ public void setUp() throws Exception {
} catch(Exception e) {
assertTrue(e.getClass().equals(expected));
}
-
- client.getConnectionManager().shutdown();
}
public void testBadUrl() {
Please sign in to comment.
Something went wrong with that request. Please try again.