use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project iosched by google.
the class MockHttpClient method execute.
// This is the only one we actually use.
@Override
public HttpResponse execute(HttpUriRequest request, HttpContext context) {
requestExecuted = request;
StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), mStatusCode, "");
HttpResponse response = new BasicHttpResponse(statusLine);
response.setEntity(mResponseEntity);
return response;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project camel by apache.
the class HipchatComponentConsumerTest method sendInOnly.
@Test
public void sendInOnly() throws Exception {
result.expectedMessageCount(1);
String expectedResponse = "{\n" + " \"items\" : [\n" + " {\n" + " \"date\" : \"2015-01-19T22:07:11.030740+00:00\",\n" + " \"from\" : {\n" + " \"id\" : 1647095,\n" + " \"links\" : {\n" + " \"self\" : \"https://api.hipchat.com/v2/user/1647095\"\n" + " },\n" + " \"mention_name\" : \"notifier\",\n" + " \"name\" : \"Message Notifier\"\n" + " },\n" + " \"id\" : \"6567c6f7-7c1b-43cf-bed0-792b1d092919\",\n" + " \"mentions\" : [ ],\n" + " \"message\" : \"Unit test Alert\",\n" + " \"type\" : \"message\"\n" + " }\n" + " ],\n" + " \"links\" : {\n" + " \"self\" : \"https://api.hipchat.com/v2/user/%40ShreyasPurohit/history/latest\"\n" + " },\n" + " \"maxResults\" : 1,\n" + " \"startIndex\" : 0\n" + "}";
HttpEntity mockHttpEntity = mock(HttpEntity.class);
when(mockHttpEntity.getContent()).thenReturn(new ByteArrayInputStream(expectedResponse.getBytes(StandardCharsets.UTF_8)));
when(closeableHttpResponse.getEntity()).thenReturn(mockHttpEntity);
when(closeableHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
assertMockEndpointsSatisfied();
assertCommonResultExchange(result.getExchanges().get(0));
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project camel by apache.
the class HipchatComponentMultipleUsersTest method sendInOnlyMultipleUsers.
@Test
public void sendInOnlyMultipleUsers() throws Exception {
result.expectedMessageCount(2);
result.expectedHeaderValuesReceivedInAnyOrder(HipchatConstants.FROM_USER, Arrays.asList(new String[] { "@AUser", "@BUser" }));
final String expectedResponse = "{\n" + " \"items\" : [\n" + " {\n" + " \"date\" : \"2015-01-19T22:07:11.030740+00:00\",\n" + " \"from\" : {\n" + " \"id\" : 1647095,\n" + " \"links\" : {\n" + " \"self\" : \"https://api.hipchat.com/v2/user/1647095\"\n" + " },\n" + " \"mention_name\" : \"notifier\",\n" + " \"name\" : \"Message Notifier\"\n" + " },\n" + " \"id\" : \"6567c6f7-7c1b-43cf-bed0-792b1d092919\",\n" + " \"mentions\" : [ ],\n" + " \"message\" : \"Unit test Alert\",\n" + " \"type\" : \"message\"\n" + " }\n" + " ],\n" + " \"links\" : {\n" + " \"self\" : \"https://api.hipchat.com/v2/user/%40ShreyasPurohit/history/latest\"\n" + " },\n" + " \"maxResults\" : 1,\n" + " \"startIndex\" : 0\n" + "}";
HttpEntity mockHttpEntity = mock(HttpEntity.class);
when(mockHttpEntity.getContent()).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
return new ByteArrayInputStream(expectedResponse.getBytes(StandardCharsets.UTF_8));
}
});
when(closeableHttpResponse.getEntity()).thenReturn(mockHttpEntity);
when(closeableHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
assertMockEndpointsSatisfied();
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project robovm by robovm.
the class DefaultHttpResponseFactory method newHttpResponse.
// non-javadoc, see interface HttpResponseFactory
public HttpResponse newHttpResponse(final ProtocolVersion ver, final int status, HttpContext context) {
if (ver == null) {
throw new IllegalArgumentException("HTTP version may not be null");
}
final Locale loc = determineLocale(context);
final String reason = reasonCatalog.getReason(status, loc);
StatusLine statusline = new BasicStatusLine(ver, status, reason);
return new BasicHttpResponse(statusline, reasonCatalog, loc);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project gocd by gocd.
the class SslInfrastructureServiceTest method shouldInvalidateKeystore.
@Test
public void shouldInvalidateKeystore() throws Exception {
temporaryFolder.create();
File configFile = temporaryFolder.newFile();
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("https", 1, 2), 200, null));
when(httpResponse.getEntity()).thenReturn(new StringEntity(RegistrationJSONizer.toJson(createRegistration())));
when(agentRegistry.guidPresent()).thenReturn(true);
when(httpClient.execute(any(HttpRequestBase.class))).thenReturn(httpResponse);
when(agentRegistry.tokenPresent()).thenReturn(true);
shouldCreateSslInfrastructure();
sslInfrastructureService.registerIfNecessary(new AgentAutoRegistrationPropertiesImpl(configFile));
assertThat(GoAgentServerClientBuilder.AGENT_CERTIFICATE_FILE, exists());
verify(httpClient, times(1)).execute(any(HttpRequestBase.class));
sslInfrastructureService.registerIfNecessary(new AgentAutoRegistrationPropertiesImpl(configFile));
verify(httpClient, times(1)).execute(any(HttpRequestBase.class));
sslInfrastructureService.invalidateAgentCertificate();
sslInfrastructureService.registerIfNecessary(new AgentAutoRegistrationPropertiesImpl(configFile));
verify(httpClient, times(2)).execute(any(HttpRequestBase.class));
}
Aggregations