diff options
author | lbsa71 | 2009-05-27 18:27:28 +0000 |
---|---|---|
committer | lbsa71 | 2009-05-27 18:27:28 +0000 |
commit | 0787967f599aaf75a69231bf78be878fc2f5de3a (patch) | |
tree | d1475ebfc0e48490b72e24d5eecc8b281d0fa85e /OpenSim/Tests | |
parent | From: Chris Yeoh <cyeoh@au1.ibm.com> (diff) | |
download | opensim-SC-0787967f599aaf75a69231bf78be878fc2f5de3a.zip opensim-SC-0787967f599aaf75a69231bf78be878fc2f5de3a.tar.gz opensim-SC-0787967f599aaf75a69231bf78be878fc2f5de3a.tar.bz2 opensim-SC-0787967f599aaf75a69231bf78be878fc2f5de3a.tar.xz |
* So, giving up on my efforts to de-duplicate the asset handlers. I'll just service commit my current state, then start over and this time concentrating only on the new handlers.
* Fixed some erroneous refs in Tests.Common
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r-- | OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs index 5fc3547..138b690 100644 --- a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs +++ b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs | |||
@@ -33,15 +33,19 @@ using System.Text; | |||
33 | using System.Xml; | 33 | using System.Xml; |
34 | using System.Xml.Serialization; | 34 | using System.Xml.Serialization; |
35 | using NUnit.Framework; | 35 | using NUnit.Framework; |
36 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
38 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenSim.Server.Base; | ||
39 | using OpenSim.Tests.Common.Mock; | 41 | using OpenSim.Tests.Common.Mock; |
40 | 42 | ||
41 | namespace OpenSim.Tests.Common.Setup | 43 | namespace OpenSim.Tests.Common.Setup |
42 | { | 44 | { |
43 | public class GetAssetStreamHandlerTestHelpers | 45 | public class GetAssetStreamHandlerTestHelpers |
44 | { | 46 | { |
47 | private const string EXPECTED_CONTENT_TYPE = "application/x-metaverse-callingcard"; | ||
48 | |||
45 | public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) | 49 | public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) |
46 | { | 50 | { |
47 | byte[] expected = BaseGetAssetStreamHandler.GetXml(asset); | 51 | byte[] expected = BaseGetAssetStreamHandler.GetXml(asset); |
@@ -49,12 +53,17 @@ namespace OpenSim.Tests.Common.Setup | |||
49 | byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response); | 53 | byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response); |
50 | 54 | ||
51 | Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash."); | 55 | Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash."); |
52 | Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash."); | 56 | Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash."); |
53 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); | 57 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); |
54 | 58 | ||
55 | byte[] actual1 = handler.Handle("/assets/" + asset.ID + "/", null, null, response); | 59 | actual = handler.Handle("/assets/" + asset.ID + "/", null, null, response); |
56 | Assert.Greater(actual1.Length, 10, "Too short xml on fetching xml with trailing slash."); | 60 | Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with trailing slash."); |
57 | Assert.AreEqual(expected, actual1, "Failed on fetching xml with trailing slash."); | 61 | Assert.AreEqual(expected, actual, "Failed on fetching xml with trailing slash."); |
62 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); | ||
63 | |||
64 | actual = handler.Handle("/assets/" + asset.ID + "/badData", null, null, response); | ||
65 | Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with bad trailing data."); | ||
66 | Assert.AreEqual(expected, actual, "Failed on fetching xml with bad trailing trailing slash."); | ||
58 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); | 67 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); |
59 | } | 68 | } |
60 | 69 | ||
@@ -62,9 +71,27 @@ namespace OpenSim.Tests.Common.Setup | |||
62 | { | 71 | { |
63 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash."); | 72 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash."); |
64 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); | 73 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); |
74 | Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch."); | ||
65 | 75 | ||
66 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash."); | 76 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash."); |
67 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); | 77 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); |
78 | Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch."); | ||
79 | } | ||
80 | |||
81 | public static void BaseFetchExistingAssetMetaDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) | ||
82 | { | ||
83 | XmlSerializer xs = | ||
84 | new XmlSerializer(typeof(AssetMetadata)); | ||
85 | |||
86 | byte[] expected = ServerUtils.SerializeResult(xs, asset.Metadata); | ||
87 | |||
88 | Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata", null, null, response), "Failed on fetching data without trailing slash."); | ||
89 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); | ||
90 | Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch."); | ||
91 | |||
92 | Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata/", null, null, response), "Failed on fetching data with trailing slash."); | ||
93 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); | ||
94 | Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch."); | ||
68 | } | 95 | } |
69 | 96 | ||
70 | public static AssetBase CreateCommonTestResources(out OSHttpResponse response) | 97 | public static AssetBase CreateCommonTestResources(out OSHttpResponse response) |
@@ -80,6 +107,8 @@ namespace OpenSim.Tests.Common.Setup | |||
80 | AssetBase asset = new AssetBase( ); | 107 | AssetBase asset = new AssetBase( ); |
81 | asset.ID = Guid.NewGuid().ToString(); | 108 | asset.ID = Guid.NewGuid().ToString(); |
82 | asset.Data = expected; | 109 | asset.Data = expected; |
110 | asset.Type = 2; | ||
111 | |||
83 | return asset; | 112 | return asset; |
84 | } | 113 | } |
85 | 114 | ||