01: /*
02: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/test/java/org/apache/http/impl/TestBasicRequest.java $
03: * $Revision: 576073 $
04: * $Date: 2007-09-16 12:53:13 +0200 (Sun, 16 Sep 2007) $
05: * ====================================================================
06: * Licensed to the Apache Software Foundation (ASF) under one
07: * or more contributor license agreements. See the NOTICE file
08: * distributed with this work for additional information
09: * regarding copyright ownership. The ASF licenses this file
10: * to you under the Apache License, Version 2.0 (the
11: * "License"); you may not use this file except in compliance
12: * with 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,
17: * software distributed under the License is distributed on an
18: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19: * KIND, either express or implied. See the License for the
20: * specific language governing permissions and limitations
21: * under the License.
22: * ====================================================================
23: *
24: * This software consists of voluntary contributions made by many
25: * individuals on behalf of the Apache Software Foundation. For more
26: * information on the Apache Software Foundation, please see
27: * <http://www.apache.org/>.
28: *
29: */
30:
31: package org.apache.http.impl;
32:
33: import junit.framework.Test;
34: import junit.framework.TestCase;
35: import junit.framework.TestSuite;
36:
37: import org.apache.http.HttpRequest;
38: import org.apache.http.HttpVersion;
39: import org.apache.http.message.BasicHttpRequest;
40: import org.apache.http.params.CoreProtocolPNames;
41:
42: public class TestBasicRequest extends TestCase {
43:
44: public TestBasicRequest(String testName) {
45: super (testName);
46: }
47:
48: // ------------------------------------------------------- TestCase Methods
49:
50: public static Test suite() {
51: return new TestSuite(TestBasicRequest.class);
52: }
53:
54: // ------------------------------------------------------------------- Main
55: public static void main(String args[]) {
56: String[] testCaseName = { TestBasicRequest.class.getName() };
57: junit.textui.TestRunner.main(testCaseName);
58: }
59:
60: public void testConstructor() throws Exception {
61: new BasicHttpRequest("GET", "/stuff");
62: new BasicHttpRequest("GET", "/stuff", HttpVersion.HTTP_1_1);
63: try {
64: new BasicHttpRequest(null, "/stuff");
65: fail("IllegalArgumentException should have been thrown");
66: } catch (IllegalArgumentException ex) {
67: // expected
68: }
69: try {
70: new BasicHttpRequest("GET", null);
71: fail("IllegalArgumentException should have been thrown");
72: } catch (IllegalArgumentException ex) {
73: // expected
74: }
75: }
76:
77: public void testRequestLine() throws Exception {
78: HttpRequest request = new BasicHttpRequest("GET", "/stuff");
79: request.getParams().setParameter(
80: CoreProtocolPNames.PROTOCOL_VERSION,
81: HttpVersion.HTTP_1_0);
82: assertEquals("GET", request.getRequestLine().getMethod());
83: assertEquals("/stuff", request.getRequestLine().getUri());
84: assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine()
85: .getProtocolVersion());
86: }
87:
88: public void testRequestLine2() throws Exception {
89: HttpRequest request = new BasicHttpRequest("GET", "/stuff",
90: HttpVersion.HTTP_1_0);
91: assertEquals("GET", request.getRequestLine().getMethod());
92: assertEquals("/stuff", request.getRequestLine().getUri());
93: assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine()
94: .getProtocolVersion());
95: }
96:
97: }
|