Search in sources :

Example 1 with StringContent

use of eu.europeana.metis.network.StringHttpClient.StringContent in project metis-framework by europeana.

the class StringHttpClientTest method createResult.

@Test
void createResult() throws URISyntaxException, IOException {
    List<Closeable> closeables = new ArrayList<>();
    HttpEntity responseEntity = new BasicHttpEntity(new ByteArrayInputStream("content".getBytes()), ContentType.TEXT_PLAIN);
    final ContentRetriever contentRetriever = ContentRetriever.forNonCloseableContent(responseEntity == null ? InputStream::nullInputStream : responseEntity::getContent, closeables::add);
    StringContent actualContent = stringHttpClient.createResult(new URI("/resource/provided"), new URI("/resource/actual"), "text/plain", 7L, contentRetriever);
    assertEquals("content", actualContent.getContent());
    assertEquals("text/plain", actualContent.getContentType());
}
Also used : BasicHttpEntity(org.apache.hc.core5.http.io.entity.BasicHttpEntity) HttpEntity(org.apache.hc.core5.http.HttpEntity) ByteArrayInputStream(java.io.ByteArrayInputStream) Closeable(java.io.Closeable) ArrayList(java.util.ArrayList) StringContent(eu.europeana.metis.network.StringHttpClient.StringContent) BasicHttpEntity(org.apache.hc.core5.http.io.entity.BasicHttpEntity) URI(java.net.URI) ContentRetriever(eu.europeana.metis.network.AbstractHttpClient.ContentRetriever) Test(org.junit.jupiter.api.Test)

Example 2 with StringContent

use of eu.europeana.metis.network.StringHttpClient.StringContent in project metis-framework by europeana.

the class StringHttpClientTest method stringContent.

@Test
void stringContent() {
    StringContent stringContent = new StringContent("content", "text/plain");
    assertEquals("content", stringContent.getContent());
    assertEquals("text/plain", stringContent.getContentType());
}
Also used : StringContent(eu.europeana.metis.network.StringHttpClient.StringContent) Test(org.junit.jupiter.api.Test)

Aggregations

StringContent (eu.europeana.metis.network.StringHttpClient.StringContent)2 Test (org.junit.jupiter.api.Test)2 ContentRetriever (eu.europeana.metis.network.AbstractHttpClient.ContentRetriever)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Closeable (java.io.Closeable)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HttpEntity (org.apache.hc.core5.http.HttpEntity)1 BasicHttpEntity (org.apache.hc.core5.http.io.entity.BasicHttpEntity)1