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