1 20 package org.apache.cactus.sample.servlet.unit; 21 22 import org.apache.cactus.ServletTestCase; 23 import org.apache.cactus.WebRequest; 24 import org.apache.cactus.WebResponse; 25 26 31 public class TestHttpHeaders extends ServletTestCase 32 { 33 40 public void beginSendMultivaluedHeader(WebRequest theRequest) 41 { 42 theRequest.addHeader("testheader", "value1"); 43 theRequest.addHeader("testheader", "value2"); 44 } 45 46 50 public void testSendMultivaluedHeader() 51 { 52 assertEquals("value1,value2", request.getHeader("testheader")); 78 79 82 95 } 96 97 99 105 public void beginSetContentTypeHeader(WebRequest theRequest) 106 { 107 theRequest.addHeader("Content-type", "text/xml"); 108 } 109 110 113 public void testSetContentTypeHeader() 114 { 115 assertEquals("text/xml", request.getContentType()); 116 } 117 118 120 124 public void testResponseAddHeaders() 125 { 126 response.addHeader("X-Test-Header1", "value1"); 127 response.addHeader("X-Test-Header2", "value2"); 128 } 129 130 136 public void endResponseAddHeaders(WebResponse theResponse) 137 { 138 String value1 = 139 theResponse.getConnection().getHeaderField("X-Test-Header1"); 140 String value2 = 141 theResponse.getConnection().getHeaderField("X-Test-Header2"); 142 143 assertEquals("value1", value1); 144 assertEquals("value2", value2); 145 } 146 147 } 148 | Popular Tags |