[prev in list] [next in list] [prev in thread] [next in thread]
List: httpcomponents-commits
Subject: svn commit: r327598 -
From: olegk () apache ! org
Date: 2005-10-21 22:41:20
Message-ID: 20051021224121.61041.qmail () minotaur ! apache ! org
[Download RAW message or body]
Author: olegk
Date: Fri Oct 21 15:41:11 2005
New Revision: 327598
URL: http://svn.apache.org/viewcvs?rev=327598&view=rev
Log:
More test coverage
Modified:
jakarta/httpclient/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java
Modified: jakarta/httpclient/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java?rev=327598&r1=327597&r2=327598&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java \
(original)
+++ jakarta/httpclient/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java \
Fri Oct 21 15:41:11 2005 @@ -231,5 +231,60 @@
// expected
}
}
-
+
+ public void testInputStreamEntity() throws Exception {
+ byte[] bytes = "Message content".getBytes("ISO-8859-1");
+ InputStream instream = new ByteArrayInputStream(bytes);
+ InputStreamEntity httpentity = new InputStreamEntity(instream, \
bytes.length); + httpentity.setContentType("text/plain");
+ httpentity.setContentEncoding("identity");
+ httpentity.setChunked(false);
+
+ assertEquals(bytes.length, httpentity.getContentLength());
+ assertEquals("text/plain", httpentity.getContentType());
+ assertEquals("identity", httpentity.getContentEncoding());
+ assertEquals(instream, httpentity.getContent());
+ assertNotNull(httpentity.getContent());
+ assertFalse(httpentity.isChunked());
+ assertFalse(httpentity.isRepeatable());
+ }
+
+ public void testInputStreamEntityIllegalConstructor() throws Exception {
+ try {
+ new InputStreamEntity(null, 0);
+ fail("IllegalArgumentException should have been thrown");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ }
+
+ public void testInputStreamyEntityWriteTo() throws Exception {
+ byte[] bytes = "Message content".getBytes("ISO-8859-1");
+ InputStream instream = new ByteArrayInputStream(bytes);
+ InputStreamEntity httpentity = new InputStreamEntity(instream, 7);
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ assertTrue(httpentity.writeTo(out));
+ byte[] bytes2 = out.toByteArray();
+ assertNotNull(bytes2);
+ assertEquals(7, bytes2.length);
+ String s = new String(bytes2, "ISO-8859-1");
+ assertEquals("Message", s);
+
+ instream = new ByteArrayInputStream(bytes);
+ httpentity = new InputStreamEntity(instream, 20);
+ out = new ByteArrayOutputStream();
+ assertTrue(httpentity.writeTo(out));
+ bytes2 = out.toByteArray();
+ assertNotNull(bytes2);
+ assertEquals(bytes.length, bytes2.length);
+
+ try {
+ httpentity.writeTo(null);
+ fail("IllegalArgumentException should have been thrown");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ }
+
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic