diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs | 10 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs | 37 | ||||
-rw-r--r-- | prebuild.xml | 3 |
3 files changed, 44 insertions, 6 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; | |||
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 | ||
diff --git a/prebuild.xml b/prebuild.xml index 884d4ed..e85bf84 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -3218,13 +3218,12 @@ | |||
3218 | <Reference name="OpenMetaverse.dll"/> | 3218 | <Reference name="OpenMetaverse.dll"/> |
3219 | <Reference name="OpenMetaverseTypes.dll"/> | 3219 | <Reference name="OpenMetaverseTypes.dll"/> |
3220 | <Reference name="OpenSim.Framework"/> | 3220 | <Reference name="OpenSim.Framework"/> |
3221 | <Reference name="OpenSim.Framework.Client"/> | ||
3222 | <Reference name="OpenSim.Framework.Communications"/> | 3221 | <Reference name="OpenSim.Framework.Communications"/> |
3223 | <Reference name="OpenSim.Framework.Servers"/> | 3222 | <Reference name="OpenSim.Framework.Servers"/> |
3224 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | 3223 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> |
3225 | <Reference name="OpenSim.Data"/> | 3224 | <Reference name="OpenSim.Data"/> |
3226 | <Reference name="OpenSim.Services.Interfaces"/> | 3225 | <Reference name="OpenSim.Services.Interfaces"/> |
3227 | <Reference name="OpenSim.Servers.Base"/> | 3226 | <Reference name="OpenSim.Server.Base"/> |
3228 | <Reference name="OpenSim.Region.Communications.Local"/> | 3227 | <Reference name="OpenSim.Region.Communications.Local"/> |
3229 | <Reference name="OpenSim.Region.Framework"/> | 3228 | <Reference name="OpenSim.Region.Framework"/> |
3230 | <Reference name="OpenSim.Region.CoreModules"/> | 3229 | <Reference name="OpenSim.Region.CoreModules"/> |