use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project TaEmCasa by Dionen.
the class BasicNetworkTest method serverError_enableRetries.
@Test
public void serverError_enableRetries() throws Exception {
for (int i = 500; i <= 599; i++) {
MockHttpStack mockHttpStack = new MockHttpStack();
BasicHttpResponse fakeResponse = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), i, "");
mockHttpStack.setResponseToReturn(fakeResponse);
BasicNetwork httpNetwork = new BasicNetwork(mockHttpStack, new ByteArrayPool(4096));
Request<String> request = buildRequest();
request.setRetryPolicy(mMockRetryPolicy);
request.setShouldRetryServerErrors(true);
doThrow(new VolleyError()).when(mMockRetryPolicy).retry(any(VolleyError.class));
try {
httpNetwork.performRequest(request);
} catch (VolleyError e) {
// expected
}
// should retry all 500 errors
verify(mMockRetryPolicy).retry(any(ServerError.class));
reset(mMockRetryPolicy);
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project jmeter-plugins-manager by undera.
the class HttpRetryStrategyTest method testFlow.
@Test
public void testFlow() throws Exception {
HttpRetryStrategy strategy = new HttpRetryStrategy();
HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
assertFalse(strategy.retryRequest(response, 1, null));
strategy = new HttpRetryStrategy(2, 3333);
response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, ""));
assertTrue(strategy.retryRequest(response, 1, null));
assertFalse(strategy.retryRequest(response, 4, null));
assertEquals(2, strategy.getMaxRetries());
assertEquals(3333, strategy.getRetryInterval());
try {
new HttpRetryStrategy(-1, 2222);
fail();
} catch (IllegalArgumentException ex) {
assertEquals("MaxRetries must be greater than 1", ex.getMessage());
}
try {
new HttpRetryStrategy(2, -1);
fail();
} catch (IllegalArgumentException ex) {
assertEquals("Retry interval must be greater than 1", ex.getMessage());
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project android-uploader by nightscout.
the class RestV1UploaderTest method setUpExecuteCaptor.
public void setUpExecuteCaptor(int status) throws IOException {
captor = ArgumentCaptor.forClass(HttpUriRequest.class);
HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("mock", 1, 2), status, ""));
response.setEntity(new StringEntity(""));
when(mockHttpClient.execute(captor.capture())).thenReturn(response);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project k-9 by k9mail.
the class WebDavStoreTest method createOkPropfindResponse.
// TODO: Replace XML with actual XML from an Exchange server
private BasicHttpResponse createOkPropfindResponse() throws UnsupportedEncodingException {
BasicHttpResponse okPropfindResponse = createOkResponse();
HttpEntity propfindResponseEntity = new StringEntity("" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<D:multistatus xmlns:D=\"DAV:\" xmlns:e=\"urn:schemas:httpmail:\">\n" + " <D:response><e:inbox>http://example.org/Exchange/user/Inbox</e:inbox></D:response>\n" + "</D:multistatus>");
okPropfindResponse.setEntity(propfindResponseEntity);
return okPropfindResponse;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project k-9 by k9mail.
the class WebDavStoreTest method createOkSearchResponse.
// TODO: Replace XML with actual XML from an Exchange server
private BasicHttpResponse createOkSearchResponse() throws UnsupportedEncodingException {
BasicHttpResponse okSearchResponse = createOkResponse();
HttpEntity searchResponseEntity = new StringEntity("" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + " <D:multistatus xmlns:D=\"DAV:\"\n" + " xmlns:R=\"http://example.org/propschema\">\n" + " <D:response>" + " <D:propstat>\n" + " <uid>Inbox</uid>" + " <href>http://example.org/Exchange/user/Inbox</href>\n" + " </D:propstat></D:response>\n" + " <D:response>" + " <D:propstat>\n" + " <uid>Drafts</uid>" + " <href>http://example.org/Exchange/user/Drafts</href>\n" + " </D:propstat></D:response>\n" + " <D:response>" + " <D:propstat>\n" + " <uid>Folder2</uid>" + " <href>http://example.org/Exchange/user/Folder2</href>\n" + " </D:propstat></D:response>\n" + " </D:multistatus>");
okSearchResponse.setEntity(searchResponseEntity);
return okSearchResponse;
}
Aggregations