2
* $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpStatus.java,v 1.2.2.2 2004/05/02 11:19:58 olegk Exp $
4
* $Date: 2004/05/02 11:19:58 $
5
* ====================================================================
7
* Copyright 1999-2004 The Apache Software Foundation
9
* Licensed under the Apache License, Version 2.0 (the "License");
10
* you may not use this file except in compliance with the License.
11
* You may obtain a copy of the License at
13
* http://www.apache.org/licenses/LICENSE-2.0
15
* Unless required by applicable law or agreed to in writing, software
16
* distributed under the License is distributed on an "AS IS" BASIS,
17
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
* See the License for the specific language governing permissions and
19
* limitations under the License.
20
* ====================================================================
22
* This software consists of voluntary contributions made by many
23
* individuals on behalf of the Apache Software Foundation. For more
24
* information on the Apache Software Foundation, please see
25
* <http://www.apache.org/>.
27
* [Additional notices, if required by prior licensing conditions]
31
package org.apache.commons.httpclient;
33
import junit.framework.*;
34
import java.lang.reflect.*;
38
* Unit tests for {@link HttpStatus}
40
* @author Sean C. Sullivan
41
* @version $Id: TestHttpStatus.java,v 1.2.2.2 2004/05/02 11:19:58 olegk Exp $
43
public class TestHttpStatus extends TestCase {
45
// ------------------------------------------------------------ Constructor
46
public TestHttpStatus(String testName) {
50
// ------------------------------------------------------------------- Main
51
public static void main(String args[]) {
52
String[] testCaseName = { TestHttpStatus.class.getName() };
53
junit.textui.TestRunner.main(testCaseName);
56
// ------------------------------------------------------- TestCase Methods
58
public static Test suite() {
59
return new TestSuite(TestHttpStatus.class);
63
// ----------------------------------------------------------- Test Methods
65
public void testStatusText() throws IllegalAccessException {
66
Field[] publicFields = HttpStatus.class.getFields();
68
assertTrue( publicFields != null );
70
assertTrue( publicFields.length > 0 );
72
for (int i = 0; i < publicFields.length; i++)
74
final Field f = publicFields[i];
76
final int modifiers = f.getModifiers();
78
if ( (f.getType() == int.class)
79
&& Modifier.isPublic(modifiers)
80
&& Modifier.isFinal(modifiers)
81
&& Modifier.isStatic(modifiers) )
83
final int iValue = f.getInt(null);
84
final String text = HttpStatus.getStatusText(iValue);
86
assertTrue( "text is null for HttpStatus." + f.getName(),
89
assertTrue( text.length() > 0 );
95
public void testStatusTextNegative() throws Exception {
97
HttpStatus.getStatusText(-1);
98
fail("IllegalArgumentException must have been thrown");
99
} catch (IllegalArgumentException expected) {
103
public void testStatusTextAll() throws Exception {
104
for (int i = 0; i < 600; i++) {
105
HttpStatus.getStatusText(i);