Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove unused HttpStatusExtractorTest.

  • Loading branch information...
commit 7d855760d3a01944428a2628681f2aa1bc3fb170 1 parent dfcfe09
Hongli Lai authored August 03, 2011

Showing 1 changed file with 0 additions and 198 deletions. Show diff stats Hide diff stats

  1. 198  test/cxx/HttpStatusExtractorTest.cpp
198  test/cxx/HttpStatusExtractorTest.cpp
... ...
@@ -1,198 +0,0 @@
1  
-#include "TestSupport.h"
2  
-#include "HttpStatusExtractor.h"
3  
-
4  
-using namespace Passenger;
5  
-using namespace std;
6  
-
7  
-namespace tut {
8  
-	struct HttpStatusExtractorTest {
9  
-		HttpStatusExtractor ex;
10  
-	};
11  
-	
12  
-	DEFINE_TEST_GROUP(HttpStatusExtractorTest);
13  
-	
14  
-	/* TODO:
15  
-	 * "\r\n" in this test file should really be replaced with "\x0D\x0A".
16  
-	 * So far I haven't countered a platform on which "\r\n" is not equal
17  
-	 * to "\x0D\x0A" but the possibility that they're not equal exists.
18  
-	 */
19  
-	
20  
-	TEST_METHOD(1) {
21  
-		// Status defaults to "200 OK" and buffer is initially empty.
22  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
23  
-		ensure_equals(ex.getBuffer(), "");
24  
-	}
25  
-	
26  
-	TEST_METHOD(2) {
27  
-		// Test feeding an entire HTTP response (header + body)
28  
-		// in 1 pass. The first header is the status line.
29  
-		const char data[] =
30  
-			"Status: 201 OK\r\n"
31  
-			"Content-Type: text/html\r\n"
32  
-			"\r\n"
33  
-			"hello world!";
34  
-		ensure("Parsing completed.", ex.feed(data, sizeof(data) - 1));
35  
-		ensure_equals("Status was properly extracted.",
36  
-			ex.getStatusLine(), "201 OK\r\n");
37  
-		ensure_equals("All data that we've fed so far has been buffered.",
38  
-			ex.getBuffer(), data);
39  
-	}
40  
-	
41  
-	TEST_METHOD(3) {
42  
-		// Test feeding a single byte initially, and the
43  
-		// rest of the status line later.
44  
-		ensure("Parsing is not complete.", !ex.feed("S", 1));
45  
-		ensure_equals("Status line hasn't changed.",
46  
-			ex.getStatusLine(), "200 OK\r\n");
47  
-		ensure_equals("All data that we've fed so far has been buffered.",
48  
-			ex.getBuffer(), "S");
49  
-		
50  
-		const char data2[] = "tatus: 300 Abc\r\n";
51  
-		ensure("Parsing not yet complete.", !ex.feed(data2, sizeof(data2) - 1));
52  
-		
53  
-		// Parsing completes when full header has been fed.
54  
-		ensure("Parsing is complete.", ex.feed("\r\n", 2));
55  
-		ensure_equals("Status line recognized.",
56  
-			ex.getStatusLine(), "300 Abc\r\n");
57  
-		ensure_equals("All data that we've fed so far has been buffered.",
58  
-			ex.getBuffer(), "Status: 300 Abc\r\n\r\n");
59  
-	}
60  
-	
61  
-	TEST_METHOD(4) {
62  
-		// Test feeding an incomplete non-status line, which
63  
-		// is completed later. The status line is feeded later.
64  
-		const char data[] = "Content-Type: text/html";
65  
-		ensure(!ex.feed(data, sizeof(data) - 1));
66  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
67  
-		ensure_equals(ex.getBuffer(), data);
68  
-		
69  
-		const char data2[] = "\r\nStatus: 201 Hello\r\n\r\n";
70  
-		ensure(ex.feed(data2, sizeof(data2) - 1));
71  
-		ensure_equals(ex.getStatusLine(), "201 Hello\r\n");
72  
-		ensure_equals(ex.getBuffer(),
73  
-			"Content-Type: text/html\r\n"
74  
-			"Status: 201 Hello\r\n"
75  
-			"\r\n");
76  
-	}
77  
-	
78  
-	TEST_METHOD(5) {
79  
-		// Test feeding multiple complete lines, none of which
80  
-		// is the status line. The status line is feeded later.
81  
-		const char data[] =
82  
-			"Content-Type: text/html\r\n"
83  
-			"Foo: bar\r\n";
84  
-		ensure(!ex.feed(data, sizeof(data) - 1));
85  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
86  
-		ensure_equals(ex.getBuffer(), data);
87  
-		
88  
-		const char data2[] = "Status: 404 Not Found\r\n";
89  
-		ensure(!ex.feed(data2, sizeof(data2) - 1));
90  
-		
91  
-		// Parsing completes when full header has been fed.
92  
-		ensure(ex.feed("\r\n", 2));
93  
-		ensure_equals(ex.getStatusLine(), "404 Not Found\r\n");
94  
-		ensure_equals(ex.getBuffer(), string(data) + data2 + "\r\n");
95  
-	}
96  
-	
97  
-	TEST_METHOD(6) {
98  
-		// Test feeding multiple complete lines and a single incomplete line,
99  
-		// none of which is the status line. The header is completed
100  
-		// later, but without status line.
101  
-		const char data[] =
102  
-			"Content-Type: text/html\r\n"
103  
-			"Hello: world";
104  
-		ensure(!ex.feed(data, sizeof(data) - 1));
105  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
106  
-		ensure_equals(ex.getBuffer(), data);
107  
-		
108  
-		const char data2[] = "\r\n\r\nbody data";
109  
-		ensure(ex.feed(data2, sizeof(data2) - 1));
110  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
111  
-		ensure_equals(ex.getBuffer(), string(data) + data2);
112  
-	}
113  
-	
114  
-	TEST_METHOD(7) {
115  
-		// Test feeding an incomplete status line which is larger
116  
-		// than 3 bytes, which is completed later.
117  
-		const char data[] = "Status: 500 Internal Se";
118  
-		ensure(!ex.feed(data, sizeof(data) - 1));
119  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
120  
-		ensure_equals(ex.getBuffer(), data);
121  
-		
122  
-		const char data2[] = "rver Error\r\n\r\n";
123  
-		ensure(ex.feed(data2, sizeof(data2) - 1));
124  
-		ensure_equals(ex.getStatusLine(), "500 Internal Server Error\r\n");
125  
-		ensure_equals(ex.getBuffer(), string(data) + data2);
126  
-	}
127  
-	
128  
-	TEST_METHOD(8) {
129  
-		// Test feeding an entire HTTP response (header + body)
130  
-		// in 1 pass. There is a status line, but it is NOT the first
131  
-		// header.
132  
-		const char data[] =
133  
-			"Content-Type: text/html\r\n"
134  
-			"Status: 405 Testing\r\n"
135  
-			"Hello: world\r\n"
136  
-			"\r\n"
137  
-			"bla bla";
138  
-		ensure(ex.feed(data, sizeof(data) - 1));
139  
-		ensure_equals(ex.getStatusLine(), "405 Testing\r\n");
140  
-		ensure_equals(ex.getBuffer(), data);
141  
-	}
142  
-	
143  
-	TEST_METHOD(9) {
144  
-		// Test feeding multiple complete lines and a single incomplete
145  
-		// line. One of the complete lines is the status line, but it
146  
-		// is not the first line.
147  
-		// The response is completed later.
148  
-		const char data[] =
149  
-			"Content-Type: text/html\r\n"
150  
-			"Status: 100 Foo\r\n"
151  
-			"B";
152  
-		ensure(!ex.feed(data, sizeof(data) - 1));
153  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
154  
-		ensure_equals(ex.getBuffer(), data);
155  
-		
156  
-		const char data2[] = "la: bla\r\n\r\n";
157  
-		ensure(ex.feed(data2, sizeof(data2) - 1));
158  
-		ensure_equals(ex.getStatusLine(), "100 Foo\r\n");
159  
-		ensure_equals(ex.getBuffer(), string(data) + data2);
160  
-	}
161  
-	
162  
-	TEST_METHOD(10) {
163  
-		// Test feeding multiple complete lines and a single
164  
-		// incomplete status line. The response is completed
165  
-		// later
166  
-		const char data[] =
167  
-			"Content-Type: text/html\r\n"
168  
-			"Statu";
169  
-		ensure(!ex.feed(data, sizeof(data) - 1));
170  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
171  
-		ensure_equals(ex.getBuffer(), data);
172  
-		
173  
-		const char data2[] =
174  
-			"s: 202 Blabla\r\n"
175  
-			"Frobnicate: true\r\n"
176  
-			"\r\n";
177  
-		ensure(ex.feed(data2, sizeof(data2) - 1));
178  
-		ensure_equals(ex.getStatusLine(), "202 Blabla\r\n");
179  
-		ensure_equals(ex.getBuffer(), string(data) + data2);
180  
-	}
181  
-	
182  
-	TEST_METHOD(11) {
183  
-		// If the status in the HTTP data doesn't contain a status text,
184  
-		// then the status text is added.
185  
-		const char data[] = "Status: 200\r\n\r\n";
186  
-		ensure(ex.feed(data, sizeof(data) - 1));
187  
-		ensure_equals(ex.getStatusLine(), "200 OK\r\n");
188  
-	}
189  
-	
190  
-	TEST_METHOD(12) {
191  
-		// If the status in the HTTP data doesn't contain a status text,
192  
-		// and the status code is not recognized, then the status text
193  
-		// "Unknown Status Code" is added.
194  
-		const char data[] = "Status: 999\r\n\r\n";
195  
-		ensure(ex.feed(data, sizeof(data) - 1));
196  
-		ensure_equals(ex.getStatusLine(), "999 Unknown Status Code\r\n");
197  
-	}
198  
-}

0 notes on commit 7d85576

Please sign in to comment.
Something went wrong with that request. Please try again.