Example usage for org.apache.http.entity FileEntity getContentType

List of usage examples for org.apache.http.entity FileEntity getContentType

Introduction

In this page you can find the example usage for org.apache.http.entity FileEntity getContentType.

Prototype

public Header getContentType() 

Source Link

Usage

From source file:io.cloudslang.content.httpclient.build.EntityBuilderTest.java

@Test
public void buildEntityWithFile() throws Exception {
    ContentType parsedContentType = ContentType.parse(CONTENT_TYPE);
    final String fileName = "testFile.txt";
    PowerMockito.whenNew(File.class).withArguments(fileName).thenReturn(fileMock);
    PowerMockito.when(fileMock.exists()).thenReturn(true);

    HttpEntity httpEntity = entityBuilder.setFilePath(fileName).setContentType(parsedContentType).buildEntity();
    assertThat(httpEntity, instanceOf(FileEntity.class));
    FileEntity fileEntity = (FileEntity) httpEntity;
    assertEquals(CONTENT_TYPE, fileEntity.getContentType().getValue());
}

From source file:org.ellis.yun.search.test.httpclient.HttpClientTest.java

@Test
@SuppressWarnings("deprecation")
public void testFileEntity() throws Exception {
    File file = new File("src/test/resources/README.txt");
    FileEntity entity = new FileEntity(file, "text/plain; charset=\"UTF-8\"");
    System.out.println(entity.getContentLength() + "");
    System.out.println(entity.getContentType() + "");
    String content = parseEntity(entity);
    System.out.println(content);/*from   ww  w . ja v  a 2  s. c om*/
}