Stop iar save failing on corrupt assets
Not ideal since one will still have to watch out for big 'corrupt asset' messages in the log, but better than an outright fail0.6.8-post-fixes
parent
cbe1cc1bc8
commit
bb92ba97c6
|
@ -26,10 +26,13 @@
|
|||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.SyntaxHelpers;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
|
||||
|
@ -38,16 +41,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
|||
[TestFixture]
|
||||
public class UuidGathererTests
|
||||
{
|
||||
protected UuidGatherer m_ug;
|
||||
protected IAssetService m_assetService;
|
||||
protected UuidGatherer m_uuidGatherer;
|
||||
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
m_ug = new UuidGatherer(new TestAssetService());
|
||||
m_assetService = new TestAssetService();
|
||||
m_uuidGatherer = new UuidGatherer(m_assetService);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCorruptAsset()
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
|
||||
UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
|
||||
AssetBase corruptAsset = new AssetBase(corruptAssetUuid, corruptAssetUuid.ToString(), (sbyte)AssetType.Object);
|
||||
corruptAsset.Data = Encoding.ASCII.GetBytes("CORRUPT ASSET");
|
||||
|
||||
m_assetService.Store(corruptAsset);
|
||||
|
||||
IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>();
|
||||
m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids);
|
||||
|
||||
// We count the uuid as gathered even if the asset itself is corrupt.
|
||||
Assert.That(foundAssetUuids.Count, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test requests made for non-existent assets
|
||||
/// Test requests made for non-existent assets while we're gathering
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestMissingAsset()
|
||||
|
@ -57,7 +80,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
|||
UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
|
||||
IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>();
|
||||
|
||||
m_ug.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids);
|
||||
m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids);
|
||||
|
||||
// We count the uuid as gathered even if the asset itself is missing.
|
||||
Assert.That(foundAssetUuids.Count, Is.EqualTo(1));
|
||||
|
|
|
@ -273,6 +273,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
string xml = Utils.BytesToString(objectAsset.Data);
|
||||
SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml);
|
||||
|
||||
if (null != sog)
|
||||
GatherAssetUuids(sog, assetUuids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Data;
|
||||
|
@ -37,6 +39,8 @@ namespace OpenSim.Tests.Common.Mock
|
|||
{
|
||||
public class TestAssetService : IAssetService
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>();
|
||||
|
||||
public TestAssetService() {}
|
||||
|
@ -50,6 +54,8 @@ namespace OpenSim.Tests.Common.Mock
|
|||
|
||||
public AssetBase Get(string id)
|
||||
{
|
||||
m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id);
|
||||
|
||||
AssetBase asset;
|
||||
if (Assets.ContainsKey(id))
|
||||
asset = Assets[id];
|
||||
|
@ -78,6 +84,8 @@ namespace OpenSim.Tests.Common.Mock
|
|||
|
||||
public string Store(AssetBase asset)
|
||||
{
|
||||
m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID);
|
||||
|
||||
Assets[asset.ID] = asset;
|
||||
|
||||
return asset.ID;
|
||||
|
|
Loading…
Reference in New Issue