01: /*
02: * ========================================================================
03: *
04: * Copyright 2001-2003 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: * ========================================================================
19: */
20: package org.apache.cactus.sample.servlet.unit;
21:
22: import java.io.IOException;
23: import java.io.PrintWriter;
24:
25: import org.apache.cactus.ServletTestCase;
26:
27: /**
28: * Test the HtppUnit integration.
29: *
30: * @version $Id: TestHttpUnitIntegration.java 238816 2004-02-29 16:36:46Z vmassol $
31: */
32: public class TestHttpUnitIntegration extends ServletTestCase {
33: /**
34: * Verify that the HttpUnit integration works.
35: *
36: * @exception IOException on test failure
37: */
38: public void testHttpUnitGetText() throws IOException {
39: PrintWriter pw = response.getWriter();
40:
41: pw.print("something to return for the test");
42: }
43:
44: /**
45: * Verify that HttpUnit integration works
46: *
47: * @param theResponse the response from the server side.
48: *
49: * @exception IOException on test failure
50: */
51: public void endHttpUnitGetText(
52: com.meterware.httpunit.WebResponse theResponse)
53: throws IOException {
54: String text = theResponse.getText();
55:
56: assertEquals("something to return for the test", text);
57: }
58:
59: //-------------------------------------------------------------------------
60:
61: /**
62: * Verify that we can set several headers in the response and
63: * assert them in endXXX().
64: */
65: public void testResponseAddHeadersHttpUnit() {
66: response.addHeader("X-Access-Header1", "value1");
67: response.addHeader("X-Access-Header2", "value2");
68: }
69:
70: /**
71: * Verify that we can set several headers in the response and
72: * assert them in endXXX().
73: *
74: * @param theResponse the response from the server side.
75: */
76: public void endResponseAddHeadersHttpUnit(
77: com.meterware.httpunit.WebResponse theResponse) {
78: String value1 = theResponse.getHeaderField("X-Access-Header1");
79: String value2 = theResponse.getHeaderField("X-Access-Header2");
80:
81: assertEquals("value1", value1);
82: assertEquals("value2", value2);
83: }
84:
85: }
|