* Fix unit tests so that they correctly handle 404 missing asset response

* I didn't think there were tests in this area - my bad
0.6.6-post-fixes
Justin Clarke Casey 2009-06-05 17:03:44 +00:00
parent 593942b195
commit 87097f2484
3 changed files with 14 additions and 9 deletions

View File

@ -94,9 +94,11 @@ namespace OpenSim.Framework.Servers.Tests
public void TestHandleFetchMissingAsset()
{
IAssetCache assetCache = new TestAssetCache();
CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(assetCache);
CachedGetAssetStreamHandler handler;
OSHttpResponse response;
AssetBase asset = CreateTestEnvironment(out handler, out response);
GetAssetStreamHandlerTestHelpers.BaseFetchMissingAsset(handler);
GetAssetStreamHandlerTestHelpers.BaseFetchMissingAsset(handler, response);
}
[Test]

View File

@ -94,10 +94,11 @@ namespace OpenSim.Framework.Servers.Tests
[Test]
public void TestHandleFetchMissingAsset()
{
IAssetDataPlugin assetDataPlugin = new TestAssetDataPlugin();
GetAssetStreamHandler handler = new GetAssetStreamHandler(assetDataPlugin);
GetAssetStreamHandler handler;
OSHttpResponse response;
AssetBase asset = CreateTestEnvironment(out handler, out response);
GetAssetStreamHandlerTestHelpers.BaseFetchMissingAsset(handler);
GetAssetStreamHandlerTestHelpers.BaseFetchMissingAsset(handler, response);
}
[Test]

View File

@ -80,8 +80,7 @@ namespace OpenSim.Tests.Common.Setup
public static void BaseFetchExistingAssetMetaDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
{
XmlSerializer xs =
new XmlSerializer(typeof(AssetMetadata));
XmlSerializer xs = new XmlSerializer(typeof(AssetMetadata));
byte[] expected = ServerUtils.SerializeResult(xs, asset.Metadata);
@ -112,9 +111,12 @@ namespace OpenSim.Tests.Common.Setup
return asset;
}
public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler)
public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler, OSHttpResponse response)
{
Assert.AreEqual(BaseRequestHandlerTestHelper.EmptyByteArray, handler.Handle("/assets/" + Guid.NewGuid(), null, null, null), "Failed on bad guid.");
Assert.AreEqual(
BaseRequestHandlerTestHelper.EmptyByteArray,
handler.Handle("/assets/" + Guid.NewGuid(), null, null, response), "Failed on bad guid.");
Assert.AreEqual((int)HttpStatusCode.NotFound, response.StatusCode, "Response code wrong in BaseFetchMissingAsset");
}
}
}