001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/test/java/org/apache/http/message/TestRequestLine.java $
003: * $Revision: 604625 $
004: * $Date: 2007-12-16 15:11:11 +0100 (Sun, 16 Dec 2007) $
005: * ====================================================================
006: * Licensed to the Apache Software Foundation (ASF) under one
007: * or more contributor license agreements. See the NOTICE file
008: * distributed with this work for additional information
009: * regarding copyright ownership. The ASF licenses this file
010: * to you under the Apache License, Version 2.0 (the
011: * "License"); you may not use this file except in compliance
012: * with the License. You may obtain a copy of the License at
013: *
014: * http://www.apache.org/licenses/LICENSE-2.0
015: *
016: * Unless required by applicable law or agreed to in writing,
017: * software distributed under the License is distributed on an
018: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
019: * KIND, either express or implied. See the License for the
020: * specific language governing permissions and limitations
021: * under the License.
022: * ====================================================================
023: *
024: * This software consists of voluntary contributions made by many
025: * individuals on behalf of the Apache Software Foundation. For more
026: * information on the Apache Software Foundation, please see
027: * <http://www.apache.org/>.
028: *
029: */
030:
031: package org.apache.http.message;
032:
033: import junit.framework.Test;
034: import junit.framework.TestCase;
035: import junit.framework.TestSuite;
036:
037: import org.apache.http.HttpVersion;
038: import org.apache.http.RequestLine;
039:
040: /**
041: * Simple tests for {@link RequestLine}.
042: *
043: * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
044: *
045: * @version $Revision: 604625 $
046: */
047: public class TestRequestLine extends TestCase {
048:
049: // ------------------------------------------------------------ Constructor
050: public TestRequestLine(String testName) {
051: super (testName);
052: }
053:
054: // ------------------------------------------------------------------- Main
055: public static void main(String args[]) {
056: String[] testCaseName = { TestRequestLine.class.getName() };
057: junit.textui.TestRunner.main(testCaseName);
058: }
059:
060: // ------------------------------------------------------- TestCase Methods
061:
062: public static Test suite() {
063: return new TestSuite(TestRequestLine.class);
064: }
065:
066: public void testConstructor() {
067: RequestLine requestline = new BasicRequestLine("GET", "/stuff",
068: HttpVersion.HTTP_1_1);
069: assertEquals("GET", requestline.getMethod());
070: assertEquals("/stuff", requestline.getUri());
071: assertEquals(HttpVersion.HTTP_1_1, requestline
072: .getProtocolVersion());
073: }
074:
075: public void testConstructorInvalidInput() {
076: try {
077: new BasicRequestLine(null, "/stuff", HttpVersion.HTTP_1_1);
078: fail("IllegalArgumentException should have been thrown");
079: } catch (IllegalArgumentException e) { /* expected */
080: }
081: try {
082: new BasicRequestLine("GET", null, HttpVersion.HTTP_1_1);
083: fail("IllegalArgumentException should have been thrown");
084: } catch (IllegalArgumentException e) { /* expected */
085: }
086: try {
087: new BasicRequestLine("GET", "/stuff", (HttpVersion) null);
088: fail("IllegalArgumentException should have been thrown");
089: } catch (IllegalArgumentException e) { /* expected */
090: }
091: }
092:
093: public void testCloning() throws Exception {
094: BasicRequestLine orig = new BasicRequestLine("GET", "/stuff",
095: HttpVersion.HTTP_1_1);
096: BasicRequestLine clone = (BasicRequestLine) orig.clone();
097: assertEquals(orig.getMethod(), clone.getMethod());
098: assertEquals(orig.getUri(), clone.getUri());
099: assertEquals(orig.getProtocolVersion(), clone
100: .getProtocolVersion());
101: }
102:
103: }
|