1 /* Reattore HTTP Server 2 3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 $Id: TestHttpParserFull.java,v 1.4 2003/01/21 22:43:13 michaelh Exp $ 20 */ 21 22 package test.juju.reattore.protocol.http.impl; 23 24 import junit.framework.*; 25 import juju.reattore.protocol.http.HttpParser; 26 import juju.reattore.io.impl.ByteSourceSink; 27 28 public class TestHttpParserFull 29 extends HttpParserBase { 30 31 private static final String REQ1 = 32 "GET /%7Emichaelh/ HTTP/1.0\r\n" 33 + "User-Agent: Wget/1.8.2\r\n" 34 + "Host: localhost:8080\r\n" 35 + "Accept: */*\r\n" 36 + "Connection: Keep-Alive\r\n" 37 + "\r\n"; 38 39 private static final String RESP1 = 40 "HTTP/1.1 200 OK\r\n" 41 + "Date: Mon, 06 Jan 2003 01:47:30 GMT\r\n" 42 + "Server: Apache/2.0.43 (Unix)\r\n" 43 + "Last-Modified: Tue, 24 Dec 2002 06:27:10 GMT\r\n" 44 + "ETag: \"79e8a-1ae-772d8b80\"\r\n" 45 + "Accept-Ranges: bytes\r\n" 46 + "Content-Length: 430\r\n" 47 + "Keep-Alive: timeout=15, max=100\r\n" 48 + "Connection: Keep-Alive\r\n" 49 + "Content-Type: text/html; charset=ISO-8859-1\r\n" 50 + "\r\n" 51 + "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n" 52 + "<html>\n" 53 + "<head>\n" 54 + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n" 55 + "</head>\n" 56 + "<body bgcolor=\"white\">\n" 57 + "\n" 58 + "<h1>\n" 59 + "The Homepage.</h1>\n" 60 + "Yeah. Small beginnings, eh.\n" 61 + "<ul>\n" 62 + "<li><a href=\"/michaelh/\">Michael's</a></li>\n" 63 + "<li><a href=\"/tracyh/\">Tracy's</a></li>\n" 64 + "<li><a href=\"/simonm/\">Simon's</a></li>\n" 65 + "<li><a href=\"/mark/\">Mark's</a></li>\n" 66 + "</ul>\n" 67 + "<hr>\n" 68 + "</body>\n" 69 + "</Html>\n"; 70 71 private static final String RESP1_BODY = 72 "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n" 73 + "<html>\n" 74 + "<head>\n" 75 + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n" 76 + "</head>\n" 77 + "<body bgcolor=\"white\">\n" 78 + "\n" 79 + "<h1>\n" 80 + "The Homepage.</h1>\n" 81 + "Yeah. Small beginnings, eh.\n" 82 + "<ul>\n" 83 + "<li><a href=\"/michaelh/\">Michael's</a></li>\n" 84 + "<li><a href=\"/tracyh/\">Tracy's</a></li>\n" 85 + "<li><a href=\"/simonm/\">Simon's</a></li>\n" 86 + "<li><a href=\"/mark/\">Mark's</a></li>\n" 87 + "</ul>\n" 88 + "<hr>\n" 89 + "</body>\n" 90 + "</Html>\n"; 91 92 protected void setUp() { 93 assertEquals(430, RESP1_BODY.length()); 94 } 95 96 public void testEmpty() { 97 } 98 99 // public void testParseRequest() { 100 // } 101 // add(REQ); 102 103 // assertTrue(pa.areHeadersAvailable()); 104 // assertTrue(pa.isBodyAvailable()); 105 106 // assertEquals("GET /%7Emichaelh/ HTTP/1.0", getHeader(0)); 107 // assertEquals("", getBody()); 108 // } 109 110 // public void testParseResponse() { 111 // add(RESP); 112 113 // assertTrue(pa.areHeadersAvailable()); 114 // assertTrue(pa.isBodyAvailable()); 115 116 // assertEquals("HTTP/1.1 200 OK", getHeader(0)); 117 // assertEquals(RESP_BODY, getBody()); 118 // } 119 120 // public void testContentLength() { 121 // add(RESP.substring(0, RESP.length() - 1)); 122 123 // assertTrue(pa.areHeadersAvailable()); 124 // assertTrue(pa.isBodyAvailable() == false); 125 // } 126 127 // public void testNoContentLength() { 128 // add("GET /\r\n\r\nThis is the body.\n"); 129 130 // assertTrue(pa.areHeadersAvailable()); 131 // assertTrue(pa.isBodyAvailable()); 132 133 // assertEquals("This is the body.\n", getBody()); 134 // } 135 136 public static Test suite() { 137 return new TestSuite(TestHttpParserFull.class); 138 } 139 }

This page was automatically generated by Maven