use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project incubator-skywalking by apache.
the class StateInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
ServiceManager.INSTANCE.boot();
stateInterceptor = new StateInterceptor();
setResponseInterceptor = new SetResponseInterceptor();
processResponseInterceptor = new ProcessResponseInterceptor();
PowerMockito.mock(HttpHost.class);
when(statusLine.getStatusCode()).thenReturn(200);
when(httpResponse.getStatusLine()).thenReturn(statusLine);
when(httpHost.getHostName()).thenReturn("127.0.0.1");
when(httpHost.getSchemeName()).thenReturn("http");
when(request.getOriginal()).thenReturn(httpRequest);
when(httpRequest.getRequestLine()).thenReturn(new RequestLine() {
@Override
public String getMethod() {
return "GET";
}
@Override
public ProtocolVersion getProtocolVersion() {
return new ProtocolVersion("http", 1, 1);
}
@Override
public String getUri() {
return "http://127.0.0.1:8080/test-web/httpasync";
}
});
when(httpHost.getPort()).thenReturn(8080);
allArguments = new Object[] { request };
argumentsType = new Class[] { request.getClass() };
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project incubator-skywalking by apache.
the class TestException method setUp.
@Before
public void setUp() throws Exception {
ServiceManager.INSTANCE.boot();
stateInterceptor = new StateInterceptor();
setResponseInterceptor = new SetResponseInterceptor();
processResponseInterceptor = new ProcessResponseInterceptor();
PowerMockito.mock(HttpHost.class);
when(statusLine.getStatusCode()).thenReturn(200);
when(httpResponse.getStatusLine()).thenReturn(statusLine);
when(httpHost.getHostName()).thenReturn("127.0.0.1");
when(httpHost.getSchemeName()).thenReturn("http");
when(request.getOriginal()).thenReturn(httpRequest);
when(httpRequest.getRequestLine()).thenReturn(new RequestLine() {
@Override
public String getMethod() {
return "GET";
}
@Override
public ProtocolVersion getProtocolVersion() {
return new ProtocolVersion("http", 1, 1);
}
@Override
public String getUri() {
return "http://127.0.0.1:8080/test-web/httpasync";
}
});
when(httpHost.getPort()).thenReturn(8080);
allArguments = new Object[] { request };
setResponseInterceptorArguments = new Object[] { httpResponse };
argumentsType = new Class[] { request.getClass() };
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project opencast by opencast.
the class HttpNotificationWorkflowOperationHandlerTest method testNotificationFailedAfterOneTry.
@Test
public void testNotificationFailedAfterOneTry() throws Exception {
client = EasyMock.createNiceMock(TrustedHttpClient.class);
HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_NOT_FOUND, ""));
EasyMock.expect(client.execute((HttpPut) EasyMock.anyObject(), EasyMock.anyInt(), EasyMock.anyInt())).andReturn(response);
EasyMock.replay(client);
// set up service
operationHandler = new HttpNotificationWorkflowOperationHandler();
// operation configuration
Map<String, String> configurations = new HashMap<String, String>();
configurations.put(HttpNotificationWorkflowOperationHandler.OPT_URL_PATH, "http://127.0.0.1:9");
configurations.put(HttpNotificationWorkflowOperationHandler.OPT_NOTIFICATION_SUBJECT, "test");
configurations.put(HttpNotificationWorkflowOperationHandler.OPT_MAX_RETRY, "0");
configurations.put(HttpNotificationWorkflowOperationHandler.OPT_TIMEOUT, Integer.toString(10));
// run the operation handler
try {
getWorkflowOperationResult(mp, configurations);
Assert.fail("Operation handler should have thrown an exception!");
} catch (WorkflowOperationException e) {
Assert.assertTrue("Exception thrown as expected by the operation handler", true);
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project ecf by eclipse.
the class HttpClientRetrieveFileTransfer method getResponseCode.
public int getResponseCode() {
if (responseCode != -1)
return responseCode;
ProtocolVersion version = getMethod.getProtocolVersion();
if (version == null) {
responseCode = -1;
httpVersion = 1;
return responseCode;
}
httpVersion = version.getMinor();
responseCode = httpResponse.getStatusLine().getStatusCode();
return responseCode;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.ProtocolVersion in project spring-cloud-netflix by spring-cloud.
the class HttpClientStatusCodeExceptionTest method getResponse.
@Test
public void getResponse() throws Exception {
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
doReturn(new Locale("en")).when(response).getLocale();
Header foo = new BasicHeader("foo", "bar");
Header[] headers = new Header[] { foo };
doReturn(headers).when(response).getAllHeaders();
StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("http", 1, 1), 200, "Success");
doReturn(statusLine).when(response).getStatusLine();
BasicHttpEntity entity = new BasicHttpEntity();
entity.setContent(new ByteArrayInputStream("foo".getBytes()));
entity.setContentLength(3);
doReturn(entity).when(response).getEntity();
HttpEntity copiedEntity = HttpClientUtils.createEntity(response);
HttpClientStatusCodeException ex = new HttpClientStatusCodeException("service", response, copiedEntity, new URI("http://service.com"));
assertEquals("en", ex.getResponse().getLocale().toString());
assertArrayEquals(headers, ex.getResponse().getAllHeaders());
assertEquals("Success", ex.getResponse().getStatusLine().getReasonPhrase());
assertEquals(200, ex.getResponse().getStatusLine().getStatusCode());
assertEquals("http", ex.getResponse().getStatusLine().getProtocolVersion().getProtocol());
assertEquals(1, ex.getResponse().getStatusLine().getProtocolVersion().getMajor());
assertEquals(1, ex.getResponse().getStatusLine().getProtocolVersion().getMinor());
assertEquals("foo", EntityUtils.toString(ex.getResponse().getEntity()));
verify(response, times(1)).close();
}
Aggregations