You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2006/06/08 14:57:28 UTC

svn commit: r412738 - in /jakarta/httpcomponents/httpcore/trunk/src: java/org/apache/http/protocol/ test/org/apache/http/ test/org/apache/http/protocol/

Author: olegk
Date: Thu Jun  8 05:57:28 2006
New Revision: 412738

URL: http://svn.apache.org/viewvc?rev=412738&view=rev
Log:
[HTTPCORE-1] Added test cases for o.a.http.protocol classes. Some minor bug fixes.

Added:
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestAllProtocol.java   (with props)
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java   (with props)
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java   (with props)
Modified:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestTargetHost.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseConnControl.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseServer.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestAll.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpExceptions.java

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestTargetHost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestTargetHost.java?rev=412738&r1=412737&r2=412738&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestTargetHost.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestTargetHost.java Thu Jun  8 05:57:28 2006
@@ -68,7 +68,8 @@
             }
             String virtualhost = HttpProtocolParams.getVirtualHost(request.getParams());
             if (virtualhost != null) {
-                targethost = new HttpHost(virtualhost, targethost.getPort());
+                targethost = new HttpHost(virtualhost, 
+                        targethost.getPort(), targethost.getScheme());
             }
             request.addHeader(new GeneratedHeader(HTTP.TARGET_HOST, targethost.toHostString()));
         }

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseConnControl.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseConnControl.java?rev=412738&r1=412737&r2=412738&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseConnControl.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseConnControl.java Thu Jun  8 05:57:28 2006
@@ -90,9 +90,11 @@
         }
         // Drop connection if requested by the client
         HttpRequest request = (HttpRequest) context.getAttribute(HttpContext.HTTP_REQUEST);
-        Header header = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        if (header != null) {
-        	response.setHeader(new GeneratedHeader(HTTP.CONN_DIRECTIVE, header.getValue()));
+        if (request != null) {
+            Header header = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
+            if (header != null) {
+                response.setHeader(new GeneratedHeader(HTTP.CONN_DIRECTIVE, header.getValue()));
+            }
         }
     }
     

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseServer.java?rev=412738&r1=412737&r2=412738&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseServer.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseServer.java Thu Jun  8 05:57:28 2006
@@ -61,7 +61,7 @@
             String s = (String) response.getParams().getParameter(
                     HttpProtocolParams.ORIGIN_SERVER);
             if (s != null) {
-                response.setHeader(new GeneratedHeader(HTTP.SERVER_DIRECTIVE, s)); 
+                response.addHeader(new GeneratedHeader(HTTP.SERVER_DIRECTIVE, s)); 
             }
         }
     }

Modified: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestAll.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestAll.java?rev=412738&r1=412737&r2=412738&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestAll.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestAll.java Thu Jun  8 05:57:28 2006
@@ -32,6 +32,7 @@
 import org.apache.http.impl.TestAllImpl;
 import org.apache.http.impl.entity.TestAllEntityImpl;
 import org.apache.http.io.TestAllIO;
+import org.apache.http.protocol.TestAllProtocol;
 import org.apache.http.util.TestAllUtil;
 
 import junit.framework.*;
@@ -62,6 +63,8 @@
         suite.addTest(TestAllEntity.suite());
         suite.addTest(TestAllImpl.suite());
         suite.addTest(TestAllEntityImpl.suite());
+        
+        suite.addTest(TestAllProtocol.suite());
         
         return suite;
     }

Modified: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpExceptions.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpExceptions.java?rev=412738&r1=412737&r2=412738&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpExceptions.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpExceptions.java Thu Jun  8 05:57:28 2006
@@ -70,6 +70,8 @@
         new ConnectionClosedException("Oppsie");
         new MethodNotSupportedException("Oppsie");
         new MethodNotSupportedException("Oppsie", cause);
+        new UnsupportedHttpVersionException();
+        new UnsupportedHttpVersionException("Oppsie");
     }
             
 }

Added: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestAllProtocol.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestAllProtocol.java?rev=412738&view=auto
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestAllProtocol.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestAllProtocol.java Thu Jun  8 05:57:28 2006
@@ -0,0 +1,51 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ * ====================================================================
+ *
+ *  Copyright 1999-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.protocol;
+
+import junit.framework.*;
+
+public class TestAllProtocol extends TestCase {
+
+    public TestAllProtocol(String testName) {
+        super(testName);
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite();
+        suite.addTest(TestHttpExecutionContext.suite());
+        suite.addTest(TestStandardInterceptors.suite());
+        return suite;
+    }
+
+    public static void main(String args[]) {
+        String[] testCaseName = { TestAllProtocol.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);
+    }
+
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestAllProtocol.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestAllProtocol.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestAllProtocol.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java?rev=412738&view=auto
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java Thu Jun  8 05:57:28 2006
@@ -0,0 +1,110 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ * ====================================================================
+ *
+ *  Copyright 1999-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.protocol;
+
+import junit.framework.*;
+
+public class TestHttpExecutionContext extends TestCase {
+
+    // ------------------------------------------------------------ Constructor
+    public TestHttpExecutionContext(String testName) {
+        super(testName);
+    }
+
+    // ------------------------------------------------------------------- Main
+    public static void main(String args[]) {
+        String[] testCaseName = { TestHttpExecutionContext.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);
+    }
+
+    // ------------------------------------------------------- TestCase Methods
+
+    public static Test suite() {
+        return new TestSuite(TestHttpExecutionContext.class);
+    }
+
+    public void testContextOperations() {
+        HttpExecutionContext parentContext = new HttpExecutionContext(null); 
+        HttpExecutionContext currentContext = new HttpExecutionContext(parentContext); 
+
+        parentContext.setAttribute("param1", "1");
+        parentContext.setAttribute("param2", "2");
+        currentContext.setAttribute("param3", "3");
+        currentContext.setAttribute("param2", "4");
+        
+        assertEquals("1", parentContext.getAttribute("param1"));
+        assertEquals("2", parentContext.getAttribute("param2"));
+        assertEquals(null, parentContext.getAttribute("param3"));
+        
+        assertEquals("1", currentContext.getAttribute("param1"));
+        assertEquals("4", currentContext.getAttribute("param2"));
+        assertEquals("3", currentContext.getAttribute("param3"));
+        assertEquals(null, currentContext.getAttribute("param4"));
+        
+        currentContext.removeAttribute("param1");
+        currentContext.removeAttribute("param2");
+        currentContext.removeAttribute("param3");
+        currentContext.removeAttribute("param4");
+
+        assertEquals("1", currentContext.getAttribute("param1"));
+        assertEquals("2", currentContext.getAttribute("param2"));
+        assertEquals(null, currentContext.getAttribute("param3"));
+        assertEquals(null, currentContext.getAttribute("param4"));
+    }
+
+    public void testEmptyContextOperations() {
+        HttpExecutionContext currentContext = new HttpExecutionContext(null); 
+        assertEquals(null, currentContext.getAttribute("param1"));
+        currentContext.removeAttribute("param1");
+        assertEquals(null, currentContext.getAttribute("param1"));
+    }
+
+    public void testContextInvalidInput() throws Exception {
+        HttpExecutionContext currentContext = new HttpExecutionContext(null); 
+        try {
+            currentContext.setAttribute(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        try {
+            currentContext.getAttribute(null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        try {
+            currentContext.removeAttribute(null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+    
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestHttpExecutionContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java?rev=412738&view=auto
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java Thu Jun  8 05:57:28 2006
@@ -0,0 +1,840 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ * 
+ * ====================================================================
+ *
+ *  Copyright 1999-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.protocol;
+
+import org.apache.http.Header;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolException;
+import org.apache.http.RequestLine;
+import org.apache.http.Scheme;
+import org.apache.http.StatusLine;
+import org.apache.http.entity.BasicHttpEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.io.PlainSocketFactory;
+import org.apache.http.message.BasicHttpEntityEnclosingRequest;
+import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.params.HttpProtocolParams;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public class TestStandardInterceptors extends TestCase {
+
+    public TestStandardInterceptors(String testName) {
+        super(testName);
+    }
+
+    public static void main(String args[]) {
+        String[] testCaseName = { TestStandardInterceptors.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestStandardInterceptors.class);
+    }
+
+    public void testRequestConnControlGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        RequestConnControl interceptor = new RequestConnControl();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNotNull(header);
+        assertEquals(HTTP.CONN_KEEP_ALIVE, header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+    
+    public void testRequestConnControlCustom() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        Header myheader = new Header(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
+        request.addHeader(myheader);
+        RequestConnControl interceptor = new RequestConnControl();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNotNull(header);
+        assertEquals(HTTP.CONN_CLOSE, header.getValue());
+        assertTrue(header == myheader);
+    }
+    
+    public void testRequestConnControlInvalidInput() throws Exception {
+        RequestConnControl interceptor = new RequestConnControl();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+    
+    public void testRequestContentProtocolException() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request1 = new BasicHttpEntityEnclosingRequest("POST", "/");
+        request1.addHeader(new Header(HTTP.TRANSFER_ENCODING, "chunked"));
+        BasicHttpRequest request2 = new BasicHttpEntityEnclosingRequest("POST", "/");
+        request2.addHeader(new Header(HTTP.CONTENT_LEN, "12"));
+
+        RequestContent interceptor = new RequestContent();
+        try {
+            interceptor.process(request1, context);
+            fail("ProtocolException should have been thrown");
+        } catch (ProtocolException ex) {
+            // expected
+        }
+        try {
+            interceptor.process(request2, context);
+            fail("ProtocolException should have been thrown");
+        } catch (ProtocolException ex) {
+            // expected
+        }
+   }
+    
+    public void testRequestContentNullEntity() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+
+        RequestContent interceptor = new RequestContent();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNotNull(header);
+        assertEquals("0", header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+        assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
+   }
+    
+    public void testRequestContentEntityContentLengthDelimitedHTTP11() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+        String s = "whatever";
+        StringEntity entity = new StringEntity(s, "US-ASCII");
+        request.setEntity(entity);
+
+        RequestContent interceptor = new RequestContent();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNotNull(header);
+        assertEquals(s.length(), Integer.parseInt(header.getValue()));
+        assertTrue(header instanceof GeneratedHeader);
+        assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
+   }
+    
+    public void testRequestContentEntityChunkedHTTP11() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+        String s = "whatever";
+        StringEntity entity = new StringEntity(s, "US-ASCII");
+        entity.setChunked(true);
+        request.setEntity(entity);
+
+        RequestContent interceptor = new RequestContent();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.TRANSFER_ENCODING);
+        assertNotNull(header);
+        assertEquals("chunked", header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+        assertNull(request.getFirstHeader(HTTP.CONTENT_LEN));
+   }
+    
+    public void testRequestContentEntityUnknownLengthHTTP11() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+        BasicHttpEntity entity = new BasicHttpEntity();
+        entity.setContentLength(-1);
+        entity.setChunked(false);
+        request.setEntity(entity);
+
+        RequestContent interceptor = new RequestContent();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.TRANSFER_ENCODING);
+        assertNotNull(header);
+        assertEquals("chunked", header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+        assertNull(request.getFirstHeader(HTTP.CONTENT_LEN));
+    }
+
+    public void testRequestContentEntityChunkedHTTP10() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
+                new RequestLine("POST", "/", HttpVersion.HTTP_1_0));
+        String s = "whatever";
+        StringEntity entity = new StringEntity(s, "US-ASCII");
+        entity.setChunked(true);
+        request.setEntity(entity);
+
+        RequestContent interceptor = new RequestContent();
+        try {
+            interceptor.process(request, context);
+            fail("ProtocolException should have been thrown");
+        } catch (ProtocolException ex) {
+            // expected
+        }
+    }
+    
+    public void testRequestContentTypeAndEncoding() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+        BasicHttpEntity entity = new BasicHttpEntity();
+        entity.setContentType("whatever");
+        entity.setContentEncoding("whatever");
+        request.setEntity(entity);
+
+        RequestContent interceptor = new RequestContent();
+        interceptor.process(request, context);
+        Header h1 = request.getFirstHeader(HTTP.CONTENT_TYPE);
+        assertNotNull(h1);
+        assertEquals("whatever", h1.getValue());
+        Header h2 = request.getFirstHeader(HTTP.CONTENT_ENCODING);
+        assertNotNull(h2);
+        assertEquals("whatever", h2.getValue());
+    }
+    
+    public void testRequestContentNullTypeAndEncoding() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+        BasicHttpEntity entity = new BasicHttpEntity();
+        request.setEntity(entity);
+
+        RequestContent interceptor = new RequestContent();
+        interceptor.process(request, context);
+        assertNull(request.getFirstHeader(HTTP.CONTENT_TYPE));
+        assertNull(request.getFirstHeader(HTTP.CONTENT_ENCODING));
+    }
+    
+    public void testRequestContentEntityUnknownLengthHTTP10() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
+                new RequestLine("POST", "/", HttpVersion.HTTP_1_0));
+        BasicHttpEntity entity = new BasicHttpEntity();
+        entity.setContentLength(-1);
+        entity.setChunked(false);
+        request.setEntity(entity);
+
+        RequestContent interceptor = new RequestContent();
+        try {
+            interceptor.process(request, context);
+            fail("ProtocolException should have been thrown");
+        } catch (ProtocolException ex) {
+            // expected
+        }
+   }
+
+    public void testRequestContentInvalidInput() throws Exception {
+        RequestContent interceptor = new RequestContent();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+    
+    public void testRequestContentIgnoreNonenclosingRequests() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("POST", "/");
+        RequestContent interceptor = new RequestContent();
+        interceptor.process(request, context);
+        assertEquals(0, request.getAllHeaders().length);
+    }
+
+   public void testRequestExpectContinueGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+        String s = "whatever";
+        StringEntity entity = new StringEntity(s, "US-ASCII");
+        request.setEntity(entity);
+        request.getParams().setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, true);
+        RequestExpectContinue interceptor = new RequestExpectContinue();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
+        assertNotNull(header);
+        assertEquals(HTTP.EXPECT_CONTINUE, header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+
+    public void testRequestExpectContinueNotGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+        String s = "whatever";
+        StringEntity entity = new StringEntity(s, "US-ASCII");
+        request.setEntity(entity);
+        request.getParams().setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
+        RequestExpectContinue interceptor = new RequestExpectContinue();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
+        assertNull(header);
+    }
+
+    public void testRequestExpectContinueHTTP10() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
+                new RequestLine("POST", "/", HttpVersion.HTTP_1_0));
+        String s = "whatever";
+        StringEntity entity = new StringEntity(s, "US-ASCII");
+        request.setEntity(entity);
+        request.getParams().setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, true);
+        RequestExpectContinue interceptor = new RequestExpectContinue();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
+        assertNull(header);
+    }
+
+    public void testRequestExpectContinueZeroContent() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+        String s = "";
+        StringEntity entity = new StringEntity(s, "US-ASCII");
+        request.setEntity(entity);
+        request.getParams().setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, true);
+        RequestExpectContinue interceptor = new RequestExpectContinue();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
+        assertNull(header);
+    }
+
+    public void testRequestExpectContinueInvalidInput() throws Exception {
+        RequestExpectContinue interceptor = new RequestExpectContinue();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+
+    public void testRequestExpectContinueIgnoreNonenclosingRequests() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("POST", "/");
+        RequestExpectContinue interceptor = new RequestExpectContinue();
+        interceptor.process(request, context);
+        assertEquals(0, request.getAllHeaders().length);
+    }
+
+    public void testRequestTargetHostGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
+        HttpHost host = new HttpHost("somehost", 8080, http);
+        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        RequestTargetHost interceptor = new RequestTargetHost();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.TARGET_HOST);
+        assertNotNull(header);
+        assertEquals("somehost:8080", header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+
+    public void testRequestTargetHostNotGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
+        HttpHost host = new HttpHost("somehost", 8080, http);
+        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        request.addHeader(new Header(HTTP.TARGET_HOST, "whatever"));
+        RequestTargetHost interceptor = new RequestTargetHost();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.TARGET_HOST);
+        assertNotNull(header);
+        assertEquals("whatever", header.getValue());
+        assertFalse(header instanceof GeneratedHeader);
+    }
+
+    public void testRequestTargetHostMissingHost() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        RequestTargetHost interceptor = new RequestTargetHost();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.TARGET_HOST);
+        assertNull(header);
+    }
+
+    public void testRequestTargetHostVirtualHost() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
+        HttpHost host = new HttpHost("somehost", 8080, http);
+        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        request.getParams().setParameter(HttpProtocolParams.VIRTUAL_HOST, "whatever");
+        RequestTargetHost interceptor = new RequestTargetHost();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.TARGET_HOST);
+        assertNotNull(header);
+        assertEquals("whatever:8080", header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+
+    public void testRequestTargetHostInvalidInput() throws Exception {
+        RequestTargetHost interceptor = new RequestTargetHost();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        try {
+            interceptor.process(new BasicHttpRequest("GET", "/"), null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+
+    public void testRequestUserAgentGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        request.getParams().setParameter(HttpProtocolParams.USER_AGENT, "some agent");
+        RequestUserAgent interceptor = new RequestUserAgent();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.USER_AGENT);
+        assertNotNull(header);
+        assertEquals("some agent", header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+
+    public void testRequestUserAgentNotGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        request.getParams().setParameter(HttpProtocolParams.USER_AGENT, "some agent");
+        request.addHeader(new Header(HTTP.USER_AGENT, "whatever"));
+        RequestUserAgent interceptor = new RequestUserAgent();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.USER_AGENT);
+        assertNotNull(header);
+        assertEquals("whatever", header.getValue());
+        assertFalse(header instanceof GeneratedHeader);
+    }
+
+    public void testRequestUserAgentMissingUserAgent() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        RequestUserAgent interceptor = new RequestUserAgent();
+        interceptor.process(request, context);
+        Header header = request.getFirstHeader(HTTP.USER_AGENT);
+        assertNull(header);
+    }
+    
+    public void testRequestUserAgentInvalidInput() throws Exception {
+        RequestUserAgent interceptor = new RequestUserAgent();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+
+    public void testResponseConnControlNoEntity() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNull(header);
+    }
+    
+    public void testResponseConnControlEntityContentLength() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        StringEntity entity = new StringEntity("whatever");
+        response.setEntity(entity);
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNull(header);
+    }
+    
+    public void testResponseConnControlEntityUnknownContentLength() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        request.addHeader(new Header(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE));
+        context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+        BasicHttpResponse response = new BasicHttpResponse();
+        BasicHttpEntity entity = new BasicHttpEntity();
+        response.setEntity(entity);
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNotNull(header);
+        assertEquals(HTTP.CONN_CLOSE, header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+    
+    public void testResponseConnControlEntityChunked() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        BasicHttpEntity entity = new BasicHttpEntity();
+        entity.setChunked(true);
+        response.setEntity(entity);
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNull(header);
+    }
+    
+    public void testResponseConnControlEntityUnknownContentLengthHTTP10() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        request.addHeader(new Header(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE));
+        context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+
+        BasicHttpResponse response = new BasicHttpResponse(
+                new StatusLine(HttpVersion.HTTP_1_0, HttpStatus.SC_OK));
+        BasicHttpEntity entity = new BasicHttpEntity();
+        response.setEntity(entity);
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNotNull(header);
+        assertEquals(HTTP.CONN_CLOSE, header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+
+    public void testResponseConnControlClientRequest() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        request.addHeader(new Header(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE));
+        context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+
+        BasicHttpResponse response = new BasicHttpResponse();
+        StringEntity entity = new StringEntity("whatever");
+        response.setEntity(entity);
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNotNull(header);
+        assertEquals(HTTP.CONN_KEEP_ALIVE, header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+    
+    public void testResponseConnControlClientRequest2() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+
+        BasicHttpResponse response = new BasicHttpResponse();
+        StringEntity entity = new StringEntity("whatever");
+        response.setEntity(entity);
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNull(header);
+    }
+
+    public void testResponseConnControlStatusCode() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
+        request.addHeader(new Header(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE));
+        context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+
+        ResponseConnControl interceptor = new ResponseConnControl();
+
+        int [] statusCodes = new int[] { 
+                HttpStatus.SC_BAD_REQUEST, 
+                HttpStatus.SC_REQUEST_TIMEOUT, 
+                HttpStatus.SC_LENGTH_REQUIRED,
+                HttpStatus.SC_REQUEST_TOO_LONG,
+                HttpStatus.SC_REQUEST_URI_TOO_LONG,
+                HttpStatus.SC_INTERNAL_SERVER_ERROR,
+                HttpStatus.SC_SERVICE_UNAVAILABLE,
+                HttpStatus.SC_NOT_IMPLEMENTED };
+        
+        for (int i = 0; i < statusCodes.length; i++) {
+            BasicHttpResponse response = new BasicHttpResponse(
+                    new StatusLine(HttpVersion.HTTP_1_1, statusCodes[i]));
+            interceptor.process(response, context);
+            Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+            assertNotNull(header);
+            assertEquals(HTTP.CONN_CLOSE, header.getValue());
+            assertTrue(header instanceof GeneratedHeader);
+        }
+        
+    }
+
+    public void testResponseConnControlHostInvalidInput() throws Exception {
+        ResponseConnControl interceptor = new ResponseConnControl();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        try {
+            interceptor.process(new BasicHttpResponse(), null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+
+    public void testResponseContentNoEntity() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNotNull(header);
+        assertEquals("0", header.getValue());
+        assertTrue(header instanceof GeneratedHeader);
+    }
+    
+    public void testResponseContentStatusNoContent() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        response.setStatusCode(HttpStatus.SC_NO_CONTENT);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNull(header);
+    }
+    
+    public void testResponseContentStatusResetContent() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        response.setStatusCode(HttpStatus.SC_RESET_CONTENT);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNull(header);
+    }
+
+    public void testResponseContentStatusNotModified() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        response.setStatusCode(HttpStatus.SC_NOT_MODIFIED);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNull(header);
+    }
+
+    public void testResponseContentEntityChunked() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        BasicHttpEntity entity = new BasicHttpEntity();
+        entity.setChunked(true);
+        response.setEntity(entity);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
+        assertNotNull(h1);
+        assertEquals(HTTP.CHUNK_CODING, h1.getValue());
+        assertTrue(h1 instanceof GeneratedHeader);
+        Header h2 = response.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNull(h2);
+    }
+    
+    public void testResponseContentEntityContentLenghtDelimited() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        BasicHttpEntity entity = new BasicHttpEntity();
+        entity.setContentLength (10);
+        response.setEntity(entity);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNotNull(h1);
+        assertEquals("10", h1.getValue());
+        assertTrue(h1 instanceof GeneratedHeader);
+        Header h2 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
+        assertNull(h2);
+    }
+    
+    public void testResponseContentEntityUnknownContentLength() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        BasicHttpEntity entity = new BasicHttpEntity();
+        response.setEntity(entity);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
+        assertNull(h1);
+        Header h2 = response.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNull(h2);
+    }
+    
+    public void testResponseContentEntityChunkedHTTP10() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse(
+                new StatusLine(HttpVersion.HTTP_1_0, HttpStatus.SC_OK));
+        BasicHttpEntity entity = new BasicHttpEntity();
+        entity.setChunked(true);
+        response.setEntity(entity);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
+        assertNull(h1);
+        Header h2 = response.getFirstHeader(HTTP.CONTENT_LEN);
+        assertNull(h2);
+    }
+
+    public void testResponseContentEntityNoContentTypeAndEncoding() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        BasicHttpEntity entity = new BasicHttpEntity();
+        response.setEntity(entity);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.CONTENT_TYPE);
+        assertNull(h1);
+        Header h2 = response.getFirstHeader(HTTP.CONTENT_ENCODING);
+        assertNull(h2);
+    }
+        
+    public void testResponseContentEntityContentTypeAndEncoding() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        BasicHttpEntity entity = new BasicHttpEntity();
+        entity.setContentEncoding("whatever");
+        entity.setContentType("whatever");
+        response.setEntity(entity);
+        ResponseContent interceptor = new ResponseContent();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.CONTENT_TYPE);
+        assertNotNull(h1);
+        assertEquals("whatever", h1.getValue());
+        Header h2 = response.getFirstHeader(HTTP.CONTENT_ENCODING);
+        assertNotNull(h2);
+        assertEquals("whatever", h2.getValue());
+    }
+
+    public void testResponseContentInvalidInput() throws Exception {
+        ResponseContent interceptor = new ResponseContent();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+        
+    public void testResponseContentInvalidResponseState() throws Exception {
+        ResponseContent interceptor = new ResponseContent();
+        HttpContext context = new HttpExecutionContext(null);
+        try {
+            BasicHttpResponse response = new BasicHttpResponse();
+            response.addHeader(new Header(HTTP.CONTENT_LEN, "10"));
+            interceptor.process(response, context);
+            fail("ProtocolException should have been thrown");
+        } catch (ProtocolException ex) {
+            // expected
+        }
+        try {
+            BasicHttpResponse response = new BasicHttpResponse();
+            response.addHeader(new Header(HTTP.TRANSFER_ENCODING, "stuff"));
+            interceptor.process(response, context);
+            fail("ProtocolException should have been thrown");
+        } catch (ProtocolException ex) {
+            // expected
+        }
+    }
+
+    public void testResponseDateGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        ResponseDate interceptor = new ResponseDate();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.DATE_DIRECTIVE);
+        assertNotNull(h1);
+        interceptor.process(response, context);
+        Header h2 = response.getFirstHeader(HTTP.DATE_DIRECTIVE);
+        assertNotNull(h2);
+    }
+        
+    public void testResponseDateNotGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        response.setStatusCode(199);
+        ResponseDate interceptor = new ResponseDate();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.DATE_DIRECTIVE);
+        assertNull(h1);
+    }
+        
+    public void testResponseDateInvalidInput() throws Exception {
+        ResponseDate interceptor = new ResponseDate();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+            
+    public void testResponseServerGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        response.getParams().setParameter(HttpProtocolParams.ORIGIN_SERVER, "some server");
+        ResponseServer interceptor = new ResponseServer();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.SERVER_DIRECTIVE);
+        assertNotNull(h1);
+        assertEquals("some server", h1.getValue());
+        assertTrue(h1 instanceof GeneratedHeader);
+    }
+        
+    public void testResponseServerNotGenerated() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        response.getParams().setParameter(HttpProtocolParams.ORIGIN_SERVER, "some server");
+        response.addHeader(new Header(HTTP.SERVER_DIRECTIVE, "whatever"));
+        ResponseServer interceptor = new ResponseServer();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.SERVER_DIRECTIVE);
+        assertNotNull(h1);
+        assertEquals("whatever", h1.getValue());
+        assertFalse(h1 instanceof GeneratedHeader);
+    }
+        
+    public void testResponseServerMissing() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
+        BasicHttpResponse response = new BasicHttpResponse();
+        ResponseServer interceptor = new ResponseServer();
+        interceptor.process(response, context);
+        Header h1 = response.getFirstHeader(HTTP.SERVER_DIRECTIVE);
+        assertNull(h1);
+    }
+        
+    public void testResponseServerInvalidInput() throws Exception {
+        ResponseServer interceptor = new ResponseServer();
+        try {
+            interceptor.process(null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+
+}
\ No newline at end of file

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain