diff options
Diffstat (limited to 'OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs')
-rw-r--r-- | OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs index 593beae..26851d6 100644 --- a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs +++ b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs | |||
@@ -1,64 +1,64 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.IO; | 3 | using System.IO; |
4 | using System.Net; | 4 | using System.Net; |
5 | using System.Text; | 5 | using System.Text; |
6 | using System.Xml; | 6 | using System.Xml; |
7 | using System.Xml.Serialization; | 7 | using System.Xml.Serialization; |
8 | using NUnit.Framework; | 8 | using NUnit.Framework; |
9 | using OpenSim.Framework; | 9 | using OpenSim.Framework; |
10 | using OpenSim.Framework.Servers; | 10 | using OpenSim.Framework.Servers; |
11 | using OpenSim.Framework.Servers.HttpServer; | 11 | using OpenSim.Framework.Servers.HttpServer; |
12 | using OpenSim.Tests.Common.Mock; | 12 | using OpenSim.Tests.Common.Mock; |
13 | 13 | ||
14 | namespace OpenSim.Tests.Common.Setup | 14 | namespace OpenSim.Tests.Common.Setup |
15 | { | 15 | { |
16 | public class GetAssetStreamHandlerTestHelpers | 16 | public class GetAssetStreamHandlerTestHelpers |
17 | { | 17 | { |
18 | public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) | 18 | public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) |
19 | { | 19 | { |
20 | byte[] expected = BaseGetAssetStreamHandler.GetXml(asset); | 20 | byte[] expected = BaseGetAssetStreamHandler.GetXml(asset); |
21 | 21 | ||
22 | byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response); | 22 | byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response); |
23 | 23 | ||
24 | Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash."); | 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."); | 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."); | 26 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); |
27 | 27 | ||
28 | byte[] actual1 = handler.Handle("/assets/" + asset.ID + "/", null, null, response); | 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."); | 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."); | 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."); | 31 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); |
32 | } | 32 | } |
33 | 33 | ||
34 | public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) | 34 | public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) |
35 | { | 35 | { |
36 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash."); | 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."); | 37 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); |
38 | 38 | ||
39 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash."); | 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."); | 40 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); |
41 | } | 41 | } |
42 | 42 | ||
43 | public static AssetBase CreateCommonTestResources(out OSHttpResponse response) | 43 | public static AssetBase CreateCommonTestResources(out OSHttpResponse response) |
44 | { | 44 | { |
45 | AssetBase asset = CreateTestAsset(); | 45 | AssetBase asset = CreateTestAsset(); |
46 | response = new TestOSHttpResponse(); | 46 | response = new TestOSHttpResponse(); |
47 | return asset; | 47 | return asset; |
48 | } | 48 | } |
49 | 49 | ||
50 | public static AssetBase CreateTestAsset() | 50 | public static AssetBase CreateTestAsset() |
51 | { | 51 | { |
52 | byte[] expected = new byte[] { 1,2,3 }; | 52 | byte[] expected = new byte[] { 1,2,3 }; |
53 | AssetBase asset = new AssetBase( ); | 53 | AssetBase asset = new AssetBase( ); |
54 | asset.ID = Guid.NewGuid().ToString(); | 54 | asset.ID = Guid.NewGuid().ToString(); |
55 | asset.Data = expected; | 55 | asset.Data = expected; |
56 | return asset; | 56 | return asset; |
57 | } | 57 | } |
58 | 58 | ||
59 | public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler) | 59 | public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler) |
60 | { | 60 | { |
61 | Assert.AreEqual(BaseRequestHandlerTestHelper.EmptyByteArray, handler.Handle("/assets/" + Guid.NewGuid(), null, null, null), "Failed on bad guid."); | 61 | Assert.AreEqual(BaseRequestHandlerTestHelper.EmptyByteArray, handler.Handle("/assets/" + Guid.NewGuid(), null, null, null), "Failed on bad guid."); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | } | 64 | } |