1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.http.entity;
29
30 import org.apache.http.Header;
31 import org.apache.http.message.BasicHeader;
32 import org.apache.http.protocol.HTTP;
33 import org.junit.Assert;
34 import org.junit.Test;
35
36
37
38
39
40 public class TestAbstractHttpEntity {
41
42 @Test
43 public void testContentType() throws Exception {
44 final BasicHttpEntity httpentity = new BasicHttpEntity();
45 httpentity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "blah"));
46 Assert.assertEquals(HTTP.CONTENT_TYPE, httpentity.getContentType().getName());
47 Assert.assertEquals("blah", httpentity.getContentType().getValue());
48
49 httpentity.setContentType("blah");
50 Assert.assertEquals(HTTP.CONTENT_TYPE, httpentity.getContentType().getName());
51 Assert.assertEquals("blah", httpentity.getContentType().getValue());
52
53 httpentity.setContentType((Header)null);
54 Assert.assertNull(httpentity.getContentType());
55 httpentity.setContentType((String)null);
56 Assert.assertNull(httpentity.getContentType());
57 }
58
59 @Test
60 public void testContentEncoding() throws Exception {
61 final BasicHttpEntity httpentity = new BasicHttpEntity();
62 httpentity.setContentEncoding(new BasicHeader(HTTP.CONTENT_ENCODING, "gzip"));
63 Assert.assertEquals(HTTP.CONTENT_ENCODING, httpentity.getContentEncoding().getName());
64 Assert.assertEquals("gzip", httpentity.getContentEncoding().getValue());
65
66 httpentity.setContentEncoding("gzip");
67 Assert.assertEquals(HTTP.CONTENT_ENCODING, httpentity.getContentEncoding().getName());
68 Assert.assertEquals("gzip", httpentity.getContentEncoding().getValue());
69
70 httpentity.setContentEncoding((Header)null);
71 Assert.assertNull(httpentity.getContentEncoding());
72 httpentity.setContentEncoding((String)null);
73 Assert.assertNull(httpentity.getContentEncoding());
74 }
75
76 @Test
77 public void testChunkingFlag() throws Exception {
78 final BasicHttpEntity httpentity = new BasicHttpEntity();
79 Assert.assertFalse(httpentity.isChunked());
80 httpentity.setChunked(true);
81 Assert.assertTrue(httpentity.isChunked());
82 }
83
84 }