當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。