aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorlbsa712009-05-27 18:27:28 +0000
committerlbsa712009-05-27 18:27:28 +0000
commit0787967f599aaf75a69231bf78be878fc2f5de3a (patch)
treed1475ebfc0e48490b72e24d5eecc8b281d0fa85e /OpenSim
parentFrom: Chris Yeoh <cyeoh@au1.ibm.com> (diff)
downloadopensim-SC_OLD-0787967f599aaf75a69231bf78be878fc2f5de3a.zip
opensim-SC_OLD-0787967f599aaf75a69231bf78be878fc2f5de3a.tar.gz
opensim-SC_OLD-0787967f599aaf75a69231bf78be878fc2f5de3a.tar.bz2
opensim-SC_OLD-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 '')
-rw-r--r--OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs10
-rw-r--r--OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs37
2 files changed, 43 insertions, 4 deletions
diff --git a/OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs b/OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs
index bc0b0b6..cf19468 100644
--- a/OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs
+++ b/OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs
@@ -109,6 +109,16 @@ namespace OpenSim.Framework.Servers.Tests
109 GetAssetStreamHandlerTestHelpers.BaseFetchExistingAssetDataTest(asset, handler, response); 109 GetAssetStreamHandlerTestHelpers.BaseFetchExistingAssetDataTest(asset, handler, response);
110 } 110 }
111 111
112 //[Test]
113 //public void TestHandleFetchExistingAssetMetaData()
114 //{
115 // CachedGetAssetStreamHandler handler;
116 // OSHttpResponse response;
117 // AssetBase asset = CreateTestEnvironment(out handler, out response);
118
119 // GetAssetStreamHandlerTestHelpers.BaseFetchExistingAssetMetaDataTest(asset, handler, response);
120 //}
121
112 private static AssetBase CreateTestEnvironment(out CachedGetAssetStreamHandler handler, out OSHttpResponse response) 122 private static AssetBase CreateTestEnvironment(out CachedGetAssetStreamHandler handler, out OSHttpResponse response)
113 { 123 {
114 AssetBase asset = GetAssetStreamHandlerTestHelpers.CreateCommonTestResources(out response); 124 AssetBase asset = GetAssetStreamHandlerTestHelpers.CreateCommonTestResources(out response);
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;
33using System.Xml; 33using System.Xml;
34using System.Xml.Serialization; 34using System.Xml.Serialization;
35using NUnit.Framework; 35using NUnit.Framework;
36using OpenMetaverse;
36using OpenSim.Framework; 37using OpenSim.Framework;
37using OpenSim.Framework.Servers; 38using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer; 39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Server.Base;
39using OpenSim.Tests.Common.Mock; 41using OpenSim.Tests.Common.Mock;
40 42
41namespace OpenSim.Tests.Common.Setup 43namespace 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