hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r411092 - in /jakarta/httpcomponents/httpcore/trunk/src: java/org/apache/http/util/HeaderUtils.java test/org/apache/http/util/TestHeaderUtils.java
Date Fri, 02 Jun 2006 08:44:43 GMT
Author: olegk
Date: Fri Jun  2 01:44:43 2006
New Revision: 411092

URL: http://svn.apache.org/viewvc?rev=411092&view=rev
Log:
Cleaned up test cases for HeaderUtils

Modified:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/util/TestHeaderUtils.java

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java?rev=411092&r1=411091&r2=411092&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java Fri
Jun  2 01:44:43 2006
@@ -91,6 +91,9 @@
      */
     public static Header[] parseHeaders(final HttpDataReceiver datareceiver) 
             throws HttpException, IOException {
+        if (datareceiver == null) {
+            throw new IllegalArgumentException("HTTP data receiver may not be null");
+        }
         ArrayList headerLines = new ArrayList();
 
         CharArrayBuffer current = null;

Modified: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/util/TestHeaderUtils.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/util/TestHeaderUtils.java?rev=411092&r1=411091&r2=411092&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/util/TestHeaderUtils.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/util/TestHeaderUtils.java
Fri Jun  2 01:44:43 2006
@@ -61,53 +61,15 @@
         return new TestSuite(TestHeaderUtils.class);
     }
 
-    public void testBasicConstructor() {
-        Header header = new Header("name", "value");
-        assertEquals("name", header.getName()); 
-        assertEquals("value", header.getValue()); 
-    }
-    
-    public void testBasicConstructorNullValue() {
-        Header header = new Header("name", null);
-        assertEquals("name", header.getName()); 
-        assertEquals(null, header.getValue()); 
-    }
-    
-    public void testInvalidName() {
+    public void testInvalidInput() throws Exception {
         try {
-            new Header(null, null);
+            HeaderUtils.parseHeaders(null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
-            //expected
+            // expected
         }
     }
     
-    public void testToString() {
-        Header header1 = new Header("name1", "value1");
-        assertEquals("name1: value1", header1.toString());
-        Header header2 = new Header("name2", null);
-        assertEquals("name2: ", header2.toString());
-    }
-    
-    public void testHeaderElements() {
-        Header header = new Header("name", "element1 = value1, element2; param1 = value1,
element3");
-        HeaderElement[] elements = header.getElements(); 
-        assertNotNull(elements); 
-        assertEquals(3, elements.length); 
-        assertEquals("element1", elements[0].getName()); 
-        assertEquals("value1", elements[0].getValue()); 
-        assertEquals("element2", elements[1].getName()); 
-        assertEquals(null, elements[1].getValue()); 
-        assertEquals("element3", elements[2].getName()); 
-        assertEquals(null, elements[2].getValue()); 
-        assertEquals(1, elements[1].getParameters().length); 
-        
-        header = new Header("name", null);
-        elements = header.getElements();
-        assertNotNull(elements); 
-        assertEquals(0, elements.length); 
-    }    
-        
     public void testBasicHeaderParsing() throws Exception {
         String s = 
             "header1: stuff\r\n" + 



Mime
View raw message