* 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
0.6.6-post-fixes
lbsa71 2009-05-27 18:27:28 +00:00
parent 901fdca13b
commit 0787967f59
3 changed files with 44 additions and 6 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -3218,13 +3218,12 @@
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Client"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Servers.Base"/>
<Reference name="OpenSim.Server.Base"/>
<Reference name="OpenSim.Region.Communications.Local"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/>