aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs
diff options
context:
space:
mode:
authorlbsa712009-05-13 17:11:53 +0000
committerlbsa712009-05-13 17:11:53 +0000
commit40e95cab02b125a6c9ec7e90cab94c94b201f021 (patch)
tree6c77dce02a24ee061cf936f95faca13b41759fbe /OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs
parentDisabling WebFetchInventoryDescendents CAPs for the time being as it (diff)
downloadopensim-SC_OLD-40e95cab02b125a6c9ec7e90cab94c94b201f021.zip
opensim-SC_OLD-40e95cab02b125a6c9ec7e90cab94c94b201f021.tar.gz
opensim-SC_OLD-40e95cab02b125a6c9ec7e90cab94c94b201f021.tar.bz2
opensim-SC_OLD-40e95cab02b125a6c9ec7e90cab94c94b201f021.tar.xz
* Added some more tests to the GetAssetStreamHandlers
Diffstat (limited to 'OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs')
-rw-r--r--OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs
new file mode 100644
index 0000000..593beae
--- /dev/null
+++ b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs
@@ -0,0 +1,64 @@
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Net;
5using System.Text;
6using System.Xml;
7using System.Xml.Serialization;
8using NUnit.Framework;
9using OpenSim.Framework;
10using OpenSim.Framework.Servers;
11using OpenSim.Framework.Servers.HttpServer;
12using OpenSim.Tests.Common.Mock;
13
14namespace OpenSim.Tests.Common.Setup
15{
16 public class GetAssetStreamHandlerTestHelpers
17 {
18 public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
19 {
20 byte[] expected = BaseGetAssetStreamHandler.GetXml(asset);
21
22 byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response);
23
24 Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash.");
25 Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash.");
26 // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
27
28 byte[] actual1 = handler.Handle("/assets/" + asset.ID + "/", null, null, response);
29 Assert.Greater(actual1.Length, 10, "Too short xml on fetching xml with trailing slash.");
30 Assert.AreEqual(expected, actual1, "Failed on fetching xml with trailing slash.");
31 // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
32 }
33
34 public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
35 {
36 Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash.");
37 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
38
39 Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash.");
40 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
41 }
42
43 public static AssetBase CreateCommonTestResources(out OSHttpResponse response)
44 {
45 AssetBase asset = CreateTestAsset();
46 response = new TestOSHttpResponse();
47 return asset;
48 }
49
50 public static AssetBase CreateTestAsset()
51 {
52 byte[] expected = new byte[] { 1,2,3 };
53 AssetBase asset = new AssetBase( );
54 asset.ID = Guid.NewGuid().ToString();
55 asset.Data = expected;
56 return asset;
57 }
58
59 public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler)
60 {
61 Assert.AreEqual(BaseRequestHandlerTestHelper.EmptyByteArray, handler.Handle("/assets/" + Guid.NewGuid(), null, null, null), "Failed on bad guid.");
62 }
63 }
64}