当前位置: 首页>>代码示例>>Java>>正文


Java ContentType.TEXT_PLAIN属性代码示例

本文整理汇总了Java中com.epam.reportportal.apache.http.entity.ContentType.TEXT_PLAIN属性的典型用法代码示例。如果您正苦于以下问题:Java ContentType.TEXT_PLAIN属性的具体用法?Java ContentType.TEXT_PLAIN怎么用?Java ContentType.TEXT_PLAIN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.epam.reportportal.apache.http.entity.ContentType的用法示例。


在下文中一共展示了ContentType.TEXT_PLAIN属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBasics

@Test
public void testBasics() throws Exception {
    final File tmpfile = File.createTempFile("testfile", ".txt");
    tmpfile.deleteOnExit();
    final FileEntity httpentity = new FileEntity(tmpfile, ContentType.TEXT_PLAIN);

    Assert.assertEquals(tmpfile.length(), httpentity.getContentLength());
    final InputStream content = httpentity.getContent();
    Assert.assertNotNull(content);
    content.close();
    Assert.assertTrue(httpentity.isRepeatable());
    Assert.assertFalse(httpentity.isStreaming());
    if (!tmpfile.delete()){
        Assert.fail("Failed to delete: "+tmpfile);
    }
}
 
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:16,代码来源:TestFileEntity.java

示例2: testBasics

@Test
public void testBasics() throws Exception {
    final String s = "Message content";
    final StringEntity httpentity = new StringEntity(s, ContentType.TEXT_PLAIN);

    final byte[] bytes = s.getBytes(Consts.ISO_8859_1.name());
    Assert.assertEquals(bytes.length, httpentity.getContentLength());
    Assert.assertNotNull(httpentity.getContent());
    Assert.assertTrue(httpentity.isRepeatable());
    Assert.assertFalse(httpentity.isStreaming());
}
 
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:11,代码来源:TestStringEntity.java

示例3: testIllegalConstructor

@Test
public void testIllegalConstructor() throws Exception {
    try {
        new FileEntity(null, ContentType.TEXT_PLAIN);
        Assert.fail("IllegalArgumentException should have been thrown");
    } catch (final IllegalArgumentException ex) {
        // expected
    }
}
 
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:9,代码来源:TestFileEntity.java

示例4: testWriteTo

@Test
public void testWriteTo() throws Exception {
    final File tmpfile = File.createTempFile("testfile", ".txt");
    tmpfile.deleteOnExit();

    final FileOutputStream outstream = new FileOutputStream(tmpfile);
    outstream.write(0);
    outstream.write(1);
    outstream.write(2);
    outstream.write(3);
    outstream.close();

    final FileEntity httpentity = new FileEntity(tmpfile, ContentType.TEXT_PLAIN);

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    httpentity.writeTo(out);
    final byte[] bytes = out.toByteArray();
    Assert.assertNotNull(bytes);
    Assert.assertEquals(tmpfile.length(), bytes.length);
    for (int i = 0; i < 4; i++) {
        Assert.assertEquals(i, bytes[i]);
    }
    if (!tmpfile.delete()){
        Assert.fail("Failed to delete: "+tmpfile);
    }

    try {
        httpentity.writeTo(null);
        Assert.fail("IllegalArgumentException should have been thrown");
    } catch (final IllegalArgumentException ex) {
        // expected
    }
}
 
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:33,代码来源:TestFileEntity.java

示例5: testBasics

@Test
public void testBasics() throws Exception {
    final String s = "Message content";
    final StringEntity httpentity = new StringEntity(s, ContentType.TEXT_PLAIN);
    httpentity.setContentEncoding(HTTP.IDENTITY_CODING);
    final HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity);

    Assert.assertEquals(httpentity.getContentLength(), wrapped.getContentLength());
    Assert.assertEquals(httpentity.getContentType(), wrapped.getContentType());
    Assert.assertEquals(httpentity.getContentEncoding(), wrapped.getContentEncoding());
    Assert.assertEquals(httpentity.isChunked(), wrapped.isChunked());
    Assert.assertEquals(httpentity.isRepeatable(), wrapped.isRepeatable());
    Assert.assertEquals(httpentity.isStreaming(), wrapped.isStreaming());
    Assert.assertNotNull(wrapped.getContent());
}
 
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:15,代码来源:TestHttpEntityWrapper.java

示例6: testBasic

@Test
public void testBasic() throws Exception {
    final String s = "some kind of text";
    final StringEntity e = new StringEntity(s, ContentType.TEXT_PLAIN);
    e.setChunked(false);
    final GzipCompressingEntity gzipe = new GzipCompressingEntity(e);
    Assert.assertTrue(gzipe.isChunked());
    Assert.assertEquals(-1, gzipe.getContentLength());
    Assert.assertNotNull(gzipe.getContentEncoding());
    Assert.assertEquals("gzip", gzipe.getContentEncoding().getValue());
}
 
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:11,代码来源:TestGZip.java

示例7: testCompressionDecompression

@Test
public void testCompressionDecompression() throws Exception {
    final StringEntity in = new StringEntity("some kind of text", ContentType.TEXT_PLAIN);
    final GzipCompressingEntity gzipe = new GzipCompressingEntity(in);
    final ByteArrayOutputStream buf = new ByteArrayOutputStream();
    gzipe.writeTo(buf);
    final ByteArrayEntity out = new ByteArrayEntity(buf.toByteArray());
    final GzipDecompressingEntity gunzipe = new GzipDecompressingEntity(out);
    Assert.assertEquals("some kind of text", EntityUtils.toString(gunzipe, Consts.ASCII));
}
 
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:10,代码来源:TestGZip.java


注:本文中的com.epam.reportportal.apache.http.entity.ContentType.TEXT_PLAIN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。