use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project herd by FINRAOS.
the class DataBridgeWebClientTest method testGetBusinessObjectDataStorageFilesCreateResponse200ValidResponseHttpResponseThrowsExceptionOnClose.
@Test
public void testGetBusinessObjectDataStorageFilesCreateResponse200ValidResponseHttpResponseThrowsExceptionOnClose() throws Exception {
CloseableHttpResponse httpResponse = new MockCloseableHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "testReasonPhrase"), true);
httpResponse.setEntity(new StringEntity(xmlHelper.objectToXml(new BusinessObjectDataStorageFilesCreateResponse())));
executeWithoutLogging(DataBridgeWebClient.class, () -> {
BusinessObjectDataStorageFilesCreateResponse businessObjectDataStorageFilesCreateResponse = dataBridgeWebClient.getBusinessObjectDataStorageFilesCreateResponse(httpResponse);
assertNotNull("businessObjectDataStorageFilesCreateResponse", businessObjectDataStorageFilesCreateResponse);
});
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project herd by FINRAOS.
the class DownloaderWebClientTest method testGetBusinessObjectDataAssertNoAuthorizationHeaderWhenNoSsl.
@Test
public void testGetBusinessObjectDataAssertNoAuthorizationHeaderWhenNoSsl() throws Exception {
HttpClientOperations mockHttpClientOperations = mock(HttpClientOperations.class);
HttpClientOperations originalHttpClientOperations = (HttpClientOperations) ReflectionTestUtils.getField(downloaderWebClient, "httpClientOperations");
ReflectionTestUtils.setField(downloaderWebClient, "httpClientOperations", mockHttpClientOperations);
try {
CloseableHttpResponse closeableHttpResponse = mock(CloseableHttpResponse.class);
when(mockHttpClientOperations.execute(any(), any())).thenReturn(closeableHttpResponse);
when(closeableHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
when(closeableHttpResponse.getEntity()).thenReturn(new StringEntity(xmlHelper.objectToXml(new BusinessObjectData())));
DownloaderInputManifestDto manifest = new DownloaderInputManifestDto();
downloaderWebClient.getRegServerAccessParamsDto().setUseSsl(false);
downloaderWebClient.getBusinessObjectData(manifest);
verify(mockHttpClientOperations).execute(any(), argThat(httpUriRequest -> httpUriRequest.getFirstHeader("Authorization") == null));
} finally {
ReflectionTestUtils.setField(downloaderWebClient, "httpClientOperations", originalHttpClientOperations);
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project herd by FINRAOS.
the class DownloaderWebClientTest method testGetBusinessObjectDataAssertNamespaceOptional.
@Test
public void testGetBusinessObjectDataAssertNamespaceOptional() throws Exception {
HttpClientOperations mockHttpClientOperations = mock(HttpClientOperations.class);
HttpClientOperations originalHttpClientOperations = (HttpClientOperations) ReflectionTestUtils.getField(downloaderWebClient, "httpClientOperations");
ReflectionTestUtils.setField(downloaderWebClient, "httpClientOperations", mockHttpClientOperations);
try {
String expectedHttpMethod = "GET";
String expectedUri = "https://testWebServiceHostname:1234/herd-app/rest/businessObjectData" + "/businessObjectDefinitionNames/businessObjectDefinitionName/businessObjectFormatUsages/businessObjectFormatUsage" + "/businessObjectFormatFileTypes/businessObjectFormatFileType?partitionKey=partitionKey&partitionValue=partitionValue&" + "businessObjectFormatVersion=0&businessObjectDataVersion=1";
CloseableHttpResponse closeableHttpResponse = mock(CloseableHttpResponse.class);
when(mockHttpClientOperations.execute(any(), any())).thenReturn(closeableHttpResponse);
when(closeableHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
BusinessObjectData expectedBusinessObjectData = new BusinessObjectData();
expectedBusinessObjectData.setId(1234);
StringEntity httpEntity = new StringEntity(xmlHelper.objectToXml(expectedBusinessObjectData));
when(closeableHttpResponse.getEntity()).thenReturn(httpEntity);
DownloaderInputManifestDto manifest = new DownloaderInputManifestDto();
manifest.setBusinessObjectDefinitionName("businessObjectDefinitionName");
manifest.setBusinessObjectFormatUsage("businessObjectFormatUsage");
manifest.setBusinessObjectFormatFileType("businessObjectFormatFileType");
manifest.setBusinessObjectFormatVersion("0");
manifest.setPartitionKey("partitionKey");
manifest.setPartitionValue("partitionValue");
manifest.setBusinessObjectDataVersion("1");
assertEquals(expectedBusinessObjectData.getId(), downloaderWebClient.getBusinessObjectData(manifest).getId());
verify(mockHttpClientOperations).execute(any(), argThat(httpUriRequest -> Objects.equal(expectedHttpMethod, httpUriRequest.getMethod()) && Objects.equal(expectedUri, httpUriRequest.getURI().toString())));
} finally {
ReflectionTestUtils.setField(downloaderWebClient, "httpClientOperations", originalHttpClientOperations);
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project scribejava by scribejava.
the class OauthAsyncCompletionHandlerTest method shouldReleaseLatchOnCancel.
@Test
public void shouldReleaseLatchOnCancel() throws Exception {
handler = new OAuthAsyncCompletionHandler<>(callback, ALL_GOOD_RESPONSE_CONVERTER);
final HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("4", 1, 1), 200, "ok"));
final BasicHttpEntity entity = new BasicHttpEntity();
entity.setContent(new ByteArrayInputStream(new byte[0]));
response.setEntity(entity);
handler.cancelled();
assertNull(callback.getResponse());
assertNotNull(callback.getThrowable());
assertTrue(callback.getThrowable() instanceof CancellationException);
// verify latch is released
try {
handler.getResult();
fail();
} catch (ExecutionException expected) {
// expected
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicStatusLine in project scribejava by scribejava.
the class OauthAsyncCompletionHandlerTest method shouldReleaseLatchOnSuccess.
@Test
public void shouldReleaseLatchOnSuccess() throws Exception {
handler = new OAuthAsyncCompletionHandler<>(callback, ALL_GOOD_RESPONSE_CONVERTER);
final HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("4", 1, 1), 200, "ok"));
final BasicHttpEntity entity = new BasicHttpEntity();
entity.setContent(new ByteArrayInputStream(new byte[0]));
response.setEntity(entity);
handler.completed(response);
assertNotNull(callback.getResponse());
assertNull(callback.getThrowable());
// verify latch is released
assertEquals("All good", handler.getResult());
}
Aggregations