Search in sources :

Example 1 with RequestFormat

use of voldemort.client.protocol.RequestFormat in project voldemort by voldemort.

the class HttpStoreTest method testBadUrlOrPort.

public <T extends Exception> void testBadUrlOrPort(String url, int port, Class<T> expected) {
    ByteArray key = new ByteArray("test".getBytes());
    RequestFormat requestFormat = new RequestFormatFactory().getRequestFormat(RequestFormatType.VOLDEMORT_V1);
    HttpParams clientParams = httpClient.getParams();
    HttpConnectionParams.setConnectionTimeout(clientParams, 5000);
    HttpStore badUrlHttpStore = new HttpStore("test", url, port, httpClient, requestFormat, false);
    try {
        badUrlHttpStore.put(key, new Versioned<byte[]>("value".getBytes(), new VectorClock()), null);
    } catch (Exception e) {
        assertTrue(e.getClass().equals(expected));
    }
    try {
        badUrlHttpStore.get(key, null);
    } catch (Exception e) {
        assertTrue(e.getClass().equals(expected));
    }
    try {
        badUrlHttpStore.delete(key, new VectorClock());
    } catch (Exception e) {
        assertTrue(e.getClass().equals(expected));
    }
}
Also used : RequestFormatFactory(voldemort.client.protocol.RequestFormatFactory) HttpParams(org.apache.http.params.HttpParams) RequestFormat(voldemort.client.protocol.RequestFormat) VectorClock(voldemort.versioning.VectorClock) ByteArray(voldemort.utils.ByteArray) UnreachableStoreException(voldemort.store.UnreachableStoreException)

Aggregations

HttpParams (org.apache.http.params.HttpParams)1 RequestFormat (voldemort.client.protocol.RequestFormat)1 RequestFormatFactory (voldemort.client.protocol.RequestFormatFactory)1 UnreachableStoreException (voldemort.store.UnreachableStoreException)1 ByteArray (voldemort.utils.ByteArray)1 VectorClock (voldemort.versioning.VectorClock)1