From 0787967f599aaf75a69231bf78be878fc2f5de3a Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Wed, 27 May 2009 18:27:28 +0000
Subject: * 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
---
.../Tests/CachedGetAssetStreamHandlerTests.cs | 10 ++++++
.../Setup/GetAssetStreamHandlerTestHelpers.cs | 37 +++++++++++++++++++---
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
GetAssetStreamHandlerTestHelpers.BaseFetchExistingAssetDataTest(asset, handler, response);
}
+ //[Test]
+ //public void TestHandleFetchExistingAssetMetaData()
+ //{
+ // CachedGetAssetStreamHandler handler;
+ // OSHttpResponse response;
+ // AssetBase asset = CreateTestEnvironment(out handler, out response);
+
+ // GetAssetStreamHandlerTestHelpers.BaseFetchExistingAssetMetaDataTest(asset, handler, response);
+ //}
+
private static AssetBase CreateTestEnvironment(out CachedGetAssetStreamHandler handler, out OSHttpResponse response)
{
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;
using System.Xml;
using System.Xml.Serialization;
using NUnit.Framework;
+using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Server.Base;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Tests.Common.Setup
{
public class GetAssetStreamHandlerTestHelpers
{
+ private const string EXPECTED_CONTENT_TYPE = "application/x-metaverse-callingcard";
+
public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
{
byte[] expected = BaseGetAssetStreamHandler.GetXml(asset);
@@ -49,12 +53,17 @@ namespace OpenSim.Tests.Common.Setup
byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response);
Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash.");
- Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash.");
+ Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash.");
// Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
- byte[] actual1 = handler.Handle("/assets/" + asset.ID + "/", null, null, response);
- Assert.Greater(actual1.Length, 10, "Too short xml on fetching xml with trailing slash.");
- Assert.AreEqual(expected, actual1, "Failed on fetching xml with trailing slash.");
+ actual = handler.Handle("/assets/" + asset.ID + "/", null, null, response);
+ Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with trailing slash.");
+ Assert.AreEqual(expected, actual, "Failed on fetching xml with trailing slash.");
+ // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
+
+ actual = handler.Handle("/assets/" + asset.ID + "/badData", null, null, response);
+ Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with bad trailing data.");
+ Assert.AreEqual(expected, actual, "Failed on fetching xml with bad trailing trailing slash.");
// Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
}
@@ -62,9 +71,27 @@ namespace OpenSim.Tests.Common.Setup
{
Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash.");
Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
+ Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");
Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash.");
Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
+ Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
+ }
+
+ public static void BaseFetchExistingAssetMetaDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
+ {
+ XmlSerializer xs =
+ new XmlSerializer(typeof(AssetMetadata));
+
+ byte[] expected = ServerUtils.SerializeResult(xs, asset.Metadata);
+
+ Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata", null, null, response), "Failed on fetching data without trailing slash.");
+ Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
+ Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");
+
+ Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata/", null, null, response), "Failed on fetching data with trailing slash.");
+ Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
+ Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
}
public static AssetBase CreateCommonTestResources(out OSHttpResponse response)
@@ -80,6 +107,8 @@ namespace OpenSim.Tests.Common.Setup
AssetBase asset = new AssetBase( );
asset.ID = Guid.NewGuid().ToString();
asset.Data = expected;
+ asset.Type = 2;
+
return asset;
}
diff --git a/prebuild.xml b/prebuild.xml
index 884d4ed..e85bf84 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3218,13 +3218,12 @@
-
-
+
--
cgit v1.1