use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project java-sdk by optimizely.
the class HttpProjectConfigManagerTest method testGetDatafileHttpResponse2XX.
@Test
@Ignore
public void testGetDatafileHttpResponse2XX() throws Exception {
String modifiedStamp = "Wed, 24 Apr 2019 07:07:07 GMT";
CloseableHttpResponse getResponse = new MyResponse(new ProtocolVersion("TEST", 0, 0), 200, "TEST");
getResponse.setEntity(new StringEntity(datafileString));
getResponse.setHeader(HttpHeaders.LAST_MODIFIED, modifiedStamp);
String datafile = projectConfigManager.getDatafileFromResponse(getResponse);
assertNotNull(datafile);
assertEquals("4", parseProjectConfig(datafile).getVersion());
// Confirm last modified time is set
assertEquals(modifiedStamp, projectConfigManager.getLastModified());
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project java-sdk by optimizely.
the class HttpProjectConfigManagerTest method testGetDatafileHttpResponse5XX.
@Test(expected = ClientProtocolException.class)
public void testGetDatafileHttpResponse5XX() throws Exception {
CloseableHttpResponse getResponse = new MyResponse(new ProtocolVersion("TEST", 0, 0), 500, "TEST");
getResponse.setEntity(new StringEntity(datafileString));
projectConfigManager.getDatafileFromResponse(getResponse);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project java-sdk by optimizely.
the class HttpProjectConfigManagerTest method testGetDatafileHttpResponse304.
@Test
public void testGetDatafileHttpResponse304() throws Exception {
CloseableHttpResponse getResponse = new MyResponse(new ProtocolVersion("TEST", 0, 0), 304, "TEST");
getResponse.setEntity(new StringEntity(datafileString));
String datafile = projectConfigManager.getDatafileFromResponse(getResponse);
assertNull(datafile);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project elasticsearch by elastic.
the class FailureTrackingResponseListenerTests method mockResponse.
private static Response mockResponse() {
ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
RequestLine requestLine = new BasicRequestLine("GET", "/", protocolVersion);
StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
HttpResponse httpResponse = new BasicHttpResponse(statusLine);
return new Response(requestLine, new HttpHost("localhost", 9200), httpResponse);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project elasticsearch by elastic.
the class HeapBufferedAsyncResponseConsumerTests method testResponseProcessing.
public void testResponseProcessing() throws Exception {
ContentDecoder contentDecoder = mock(ContentDecoder.class);
IOControl ioControl = mock(IOControl.class);
HttpContext httpContext = mock(HttpContext.class);
HeapBufferedAsyncResponseConsumer consumer = spy(new HeapBufferedAsyncResponseConsumer(TEST_BUFFER_LIMIT));
ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
HttpResponse httpResponse = new BasicHttpResponse(statusLine);
httpResponse.setEntity(new StringEntity("test", ContentType.TEXT_PLAIN));
//everything goes well
consumer.responseReceived(httpResponse);
consumer.consumeContent(contentDecoder, ioControl);
consumer.responseCompleted(httpContext);
verify(consumer).releaseResources();
verify(consumer).buildResult(httpContext);
assertTrue(consumer.isDone());
assertSame(httpResponse, consumer.getResult());
consumer.responseCompleted(httpContext);
verify(consumer, times(1)).releaseResources();
verify(consumer, times(1)).buildResult(httpContext);
}
Aggregations