diff options
author | UbitUmarov | 2015-09-01 14:54:35 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-01 14:54:35 +0100 |
commit | 371c9dd2af01a2e7422ec901ee1f80757284a78c (patch) | |
tree | 058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Framework/Servers/Tests | |
parent | remove lixo (diff) | |
parent | dont change camera on crossings (diff) | |
download | opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2 opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz |
bad merge?
Diffstat (limited to 'OpenSim/Framework/Servers/Tests')
-rw-r--r-- | OpenSim/Framework/Servers/Tests/OSHttpTests.cs | 326 |
1 files changed, 325 insertions, 1 deletions
diff --git a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs index 5c0e0df..e13551c 100644 --- a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs +++ b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs | |||
@@ -41,7 +41,331 @@ namespace OpenSim.Framework.Servers.Tests | |||
41 | { | 41 | { |
42 | [TestFixture] | 42 | [TestFixture] |
43 | public class OSHttpTests : OpenSimTestCase | 43 | public class OSHttpTests : OpenSimTestCase |
44 | <<<<<<< HEAD | ||
44 | { | 45 | { |
46 | ======= | ||
47 | { | ||
48 | // we need an IHttpClientContext for our tests | ||
49 | public class TestHttpClientContext: IHttpClientContext | ||
50 | { | ||
51 | private bool _secured; | ||
52 | public bool IsSecured | ||
53 | { | ||
54 | get { return _secured; } | ||
55 | } | ||
56 | public bool Secured | ||
57 | { | ||
58 | get { return _secured; } | ||
59 | } | ||
60 | |||
61 | public TestHttpClientContext(bool secured) | ||
62 | { | ||
63 | _secured = secured; | ||
64 | } | ||
65 | |||
66 | public void Disconnect(SocketError error) {} | ||
67 | public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body) {} | ||
68 | public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) {} | ||
69 | public void Respond(string body) {} | ||
70 | public void Send(byte[] buffer) {} | ||
71 | public void Send(byte[] buffer, int offset, int size) {} | ||
72 | public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {} | ||
73 | public void Close() { } | ||
74 | public bool EndWhenDone { get { return false;} set { return;}} | ||
75 | |||
76 | public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing() | ||
77 | { | ||
78 | return new HTTPNetworkContext(); | ||
79 | } | ||
80 | |||
81 | public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { }; | ||
82 | /// <summary> | ||
83 | /// A request have been received in the context. | ||
84 | /// </summary> | ||
85 | public event EventHandler<RequestEventArgs> RequestReceived = delegate { }; | ||
86 | |||
87 | public bool CanSend { get { return true; } } | ||
88 | public string RemoteEndPoint { get { return ""; } } | ||
89 | public string RemoteEndPointAddress { get { return ""; } } | ||
90 | public string RemoteEndPointPort { get { return ""; } } | ||
91 | } | ||
92 | |||
93 | public class TestHttpRequest: IHttpRequest | ||
94 | { | ||
95 | private string _uriPath; | ||
96 | public bool BodyIsComplete | ||
97 | { | ||
98 | get { return true; } | ||
99 | } | ||
100 | public string[] AcceptTypes | ||
101 | { | ||
102 | get {return _acceptTypes; } | ||
103 | } | ||
104 | private string[] _acceptTypes; | ||
105 | public Stream Body | ||
106 | { | ||
107 | get { return _body; } | ||
108 | set { _body = value;} | ||
109 | } | ||
110 | private Stream _body; | ||
111 | public ConnectionType Connection | ||
112 | { | ||
113 | get { return _connection; } | ||
114 | set { _connection = value; } | ||
115 | } | ||
116 | private ConnectionType _connection; | ||
117 | public int ContentLength | ||
118 | { | ||
119 | get { return _contentLength; } | ||
120 | set { _contentLength = value; } | ||
121 | } | ||
122 | private int _contentLength; | ||
123 | public NameValueCollection Headers | ||
124 | { | ||
125 | get { return _headers; } | ||
126 | } | ||
127 | private NameValueCollection _headers = new NameValueCollection(); | ||
128 | public string HttpVersion | ||
129 | { | ||
130 | get { return _httpVersion; } | ||
131 | set { _httpVersion = value; } | ||
132 | } | ||
133 | private string _httpVersion = null; | ||
134 | public string Method | ||
135 | { | ||
136 | get { return _method; } | ||
137 | set { _method = value; } | ||
138 | } | ||
139 | private string _method = null; | ||
140 | public HttpInput QueryString | ||
141 | { | ||
142 | get { return _queryString; } | ||
143 | } | ||
144 | private HttpInput _queryString = null; | ||
145 | public Uri Uri | ||
146 | { | ||
147 | get { return _uri; } | ||
148 | set { _uri = value; } | ||
149 | } | ||
150 | private Uri _uri = null; | ||
151 | public string[] UriParts | ||
152 | { | ||
153 | get { return _uri.Segments; } | ||
154 | } | ||
155 | public HttpParam Param | ||
156 | { | ||
157 | get { return null; } | ||
158 | } | ||
159 | public HttpForm Form | ||
160 | { | ||
161 | get { return null; } | ||
162 | } | ||
163 | public bool IsAjax | ||
164 | { | ||
165 | get { return false; } | ||
166 | } | ||
167 | public RequestCookies Cookies | ||
168 | { | ||
169 | get { return null; } | ||
170 | } | ||
171 | |||
172 | public TestHttpRequest() {} | ||
173 | |||
174 | public TestHttpRequest(string contentEncoding, string contentType, string userAgent, | ||
175 | string remoteAddr, string remotePort, string[] acceptTypes, | ||
176 | ConnectionType connectionType, int contentLength, Uri uri) | ||
177 | { | ||
178 | _headers["content-encoding"] = contentEncoding; | ||
179 | _headers["content-type"] = contentType; | ||
180 | _headers["user-agent"] = userAgent; | ||
181 | _headers["remote_addr"] = remoteAddr; | ||
182 | _headers["remote_port"] = remotePort; | ||
183 | |||
184 | _acceptTypes = acceptTypes; | ||
185 | _connection = connectionType; | ||
186 | _contentLength = contentLength; | ||
187 | _uri = uri; | ||
188 | } | ||
189 | |||
190 | public void DecodeBody(FormDecoderProvider providers) {} | ||
191 | public void SetCookies(RequestCookies cookies) {} | ||
192 | public void AddHeader(string name, string value) | ||
193 | { | ||
194 | _headers.Add(name, value); | ||
195 | } | ||
196 | public int AddToBody(byte[] bytes, int offset, int length) | ||
197 | { | ||
198 | return 0; | ||
199 | } | ||
200 | public void Clear() {} | ||
201 | |||
202 | public object Clone() | ||
203 | { | ||
204 | TestHttpRequest clone = new TestHttpRequest(); | ||
205 | clone._acceptTypes = _acceptTypes; | ||
206 | clone._connection = _connection; | ||
207 | clone._contentLength = _contentLength; | ||
208 | clone._uri = _uri; | ||
209 | clone._headers = new NameValueCollection(_headers); | ||
210 | |||
211 | return clone; | ||
212 | } | ||
213 | public IHttpResponse CreateResponse(IHttpClientContext context) | ||
214 | { | ||
215 | return new HttpResponse(context, this); | ||
216 | } | ||
217 | /// <summary> | ||
218 | /// Path and query (will be merged with the host header) and put in Uri | ||
219 | /// </summary> | ||
220 | /// <see cref="Uri"/> | ||
221 | public string UriPath | ||
222 | { | ||
223 | get { return _uriPath; } | ||
224 | set | ||
225 | { | ||
226 | _uriPath = value; | ||
227 | |||
228 | } | ||
229 | } | ||
230 | |||
231 | } | ||
232 | |||
233 | public class TestHttpResponse: IHttpResponse | ||
234 | { | ||
235 | public Stream Body | ||
236 | { | ||
237 | get { return _body; } | ||
238 | |||
239 | set { _body = value; } | ||
240 | } | ||
241 | private Stream _body; | ||
242 | |||
243 | public string ProtocolVersion | ||
244 | { | ||
245 | get { return _protocolVersion; } | ||
246 | set { _protocolVersion = value; } | ||
247 | } | ||
248 | private string _protocolVersion; | ||
249 | |||
250 | public bool Chunked | ||
251 | { | ||
252 | get { return _chunked; } | ||
253 | |||
254 | set { _chunked = value; } | ||
255 | } | ||
256 | private bool _chunked; | ||
257 | |||
258 | public ConnectionType Connection | ||
259 | { | ||
260 | get { return _connection; } | ||
261 | |||
262 | set { _connection = value; } | ||
263 | } | ||
264 | private ConnectionType _connection; | ||
265 | |||
266 | public Encoding Encoding | ||
267 | { | ||
268 | get { return _encoding; } | ||
269 | |||
270 | set { _encoding = value; } | ||
271 | } | ||
272 | private Encoding _encoding; | ||
273 | |||
274 | public int KeepAlive | ||
275 | { | ||
276 | get { return _keepAlive; } | ||
277 | |||
278 | set { _keepAlive = value; } | ||
279 | } | ||
280 | private int _keepAlive; | ||
281 | |||
282 | public HttpStatusCode Status | ||
283 | { | ||
284 | get { return _status; } | ||
285 | |||
286 | set { _status = value; } | ||
287 | } | ||
288 | private HttpStatusCode _status; | ||
289 | |||
290 | public string Reason | ||
291 | { | ||
292 | get { return _reason; } | ||
293 | |||
294 | set { _reason = value; } | ||
295 | } | ||
296 | private string _reason; | ||
297 | |||
298 | public long ContentLength | ||
299 | { | ||
300 | get { return _contentLength; } | ||
301 | |||
302 | set { _contentLength = value; } | ||
303 | } | ||
304 | private long _contentLength; | ||
305 | |||
306 | public string ContentType | ||
307 | { | ||
308 | get { return _contentType; } | ||
309 | |||
310 | set { _contentType = value; } | ||
311 | } | ||
312 | private string _contentType; | ||
313 | |||
314 | public bool HeadersSent | ||
315 | { | ||
316 | get { return _headersSent; } | ||
317 | } | ||
318 | private bool _headersSent; | ||
319 | |||
320 | public bool Sent | ||
321 | { | ||
322 | get { return _sent; } | ||
323 | } | ||
324 | private bool _sent; | ||
325 | |||
326 | public ResponseCookies Cookies | ||
327 | { | ||
328 | get { return _cookies; } | ||
329 | } | ||
330 | private ResponseCookies _cookies = null; | ||
331 | |||
332 | public TestHttpResponse() | ||
333 | { | ||
334 | _headersSent = false; | ||
335 | _sent = false; | ||
336 | } | ||
337 | |||
338 | public void AddHeader(string name, string value) {} | ||
339 | public void Send() | ||
340 | { | ||
341 | if (!_headersSent) SendHeaders(); | ||
342 | if (_sent) throw new InvalidOperationException("stuff already sent"); | ||
343 | _sent = true; | ||
344 | } | ||
345 | |||
346 | public void SendBody(byte[] buffer, int offset, int count) | ||
347 | { | ||
348 | if (!_headersSent) SendHeaders(); | ||
349 | _sent = true; | ||
350 | } | ||
351 | public void SendBody(byte[] buffer) | ||
352 | { | ||
353 | if (!_headersSent) SendHeaders(); | ||
354 | _sent = true; | ||
355 | } | ||
356 | |||
357 | public void SendHeaders() | ||
358 | { | ||
359 | if (_headersSent) throw new InvalidOperationException("headers already sent"); | ||
360 | _headersSent = true; | ||
361 | } | ||
362 | |||
363 | public void Redirect(Uri uri) {} | ||
364 | public void Redirect(string url) {} | ||
365 | } | ||
366 | |||
367 | |||
368 | >>>>>>> avn/ubitvar | ||
45 | public OSHttpRequest req0; | 369 | public OSHttpRequest req0; |
46 | public OSHttpRequest req1; | 370 | public OSHttpRequest req1; |
47 | 371 | ||
@@ -113,4 +437,4 @@ namespace OpenSim.Framework.Servers.Tests | |||
113 | Assert.That(rsp0.ContentType, Is.EqualTo("text/xml")); | 437 | Assert.That(rsp0.ContentType, Is.EqualTo("text/xml")); |
114 | } | 438 | } |
115 | } | 439 | } |
116 | } \ No newline at end of file | 440 | } |