Permalink
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...
roberttheiv committed Jan 5, 2012
1 parent ce113ee commit f7d05f9bccc21a738f2423250f3caa74b0d7ac46
Showing with 12 additions and 9 deletions.
  1. +12 −9 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() {

0 comments on commit f7d05f9

Please sign in to comment.