01: /*
02: * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/test/org/apache/commons/httpclient/TestHeader.java,v 1.6 2004/02/22 18:08:49 olegk Exp $
03: * $Revision: 480424 $
04: * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
05: * ====================================================================
06: *
07: * Licensed to the Apache Software Foundation (ASF) under one or more
08: * contributor license agreements. See the NOTICE file distributed with
09: * this work for additional information regarding copyright ownership.
10: * The ASF licenses this file to You under the Apache License, Version 2.0
11: * (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software
17: * distributed under the License is distributed on an "AS IS" BASIS,
18: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19: * See the License for the specific language governing permissions and
20: * limitations under the License.
21: * ====================================================================
22: *
23: * This software consists of voluntary contributions made by many
24: * individuals on behalf of the Apache Software Foundation. For more
25: * information on the Apache Software Foundation, please see
26: * <http://www.apache.org/>.
27: *
28: * [Additional notices, if required by prior licensing conditions]
29: *
30: */
31:
32: package org.apache.commons.httpclient;
33:
34: import junit.framework.*;
35:
36: /**
37: * Simple tests for {@link NameValuePair}.
38: *
39: * @author Rodney Waldhoff
40: * @version $Id: TestHeader.java 480424 2006-11-29 05:56:49Z bayard $
41: */
42: public class TestHeader extends TestNVP {
43:
44: // ------------------------------------------------------------ Constructor
45: public TestHeader(String testName) {
46: super (testName);
47: }
48:
49: // ------------------------------------------------------------------- Main
50: public static void main(String args[]) {
51: String[] testCaseName = { TestHeader.class.getName() };
52: junit.textui.TestRunner.main(testCaseName);
53: }
54:
55: // ------------------------------------------------------- TestCase Methods
56:
57: public static Test suite() {
58: return new TestSuite(TestHeader.class);
59: }
60:
61: // ------------------------------------------------------ Protected Methods
62:
63: protected NameValuePair makePair() {
64: return new Header();
65: }
66:
67: protected NameValuePair makePair(String name, String value) {
68: return new Header(name, value);
69: }
70:
71: // ----------------------------------------------------------- Test Methods
72:
73: public void testToExternalFormNull() {
74: Header header = (Header) makePair();
75: assertEquals(": \r\n", header.toExternalForm());
76: }
77:
78: public void testToExternalFormNullName() {
79: Header header = (Header) makePair(null, "value");
80: assertEquals(": value\r\n", header.toExternalForm());
81: }
82:
83: public void testToExternalFormNullValue() {
84: Header header = (Header) makePair("name", null);
85: assertEquals("name: \r\n", header.toExternalForm());
86: }
87:
88: public void testToExternalForm() {
89: Header header = (Header) makePair("a", "b");
90: assertEquals("a: b\r\n", header.toExternalForm());
91: }
92:
93: public void testEqualToNVP() {
94: NameValuePair header = makePair("a", "b");
95: NameValuePair pair = new NameValuePair("a", "b");
96: assertTrue(header.equals(pair));
97: assertTrue(pair.equals(header));
98: }
99: }
|