diff options
author | Justin Clark-Casey (justincc) | 2009-11-12 18:26:22 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-11-12 18:26:22 +0000 |
commit | bb92ba97c6952c60f5bdd50b1c6599894bfef501 (patch) | |
tree | 6d1cce7b98b06549fc91dbdafa94c42f64437c5b /OpenSim | |
parent | minor: refactor common setup in uuid gatherer test (diff) | |
download | opensim-SC-bb92ba97c6952c60f5bdd50b1c6599894bfef501.zip opensim-SC-bb92ba97c6952c60f5bdd50b1c6599894bfef501.tar.gz opensim-SC-bb92ba97c6952c60f5bdd50b1c6599894bfef501.tar.bz2 opensim-SC-bb92ba97c6952c60f5bdd50b1c6599894bfef501.tar.xz |
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 fail
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | 31 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 4 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestAssetService.cs | 8 |
3 files changed, 38 insertions, 5 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index cf2b3b3..52891f4 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -26,10 +26,13 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Text; | ||
29 | using NUnit.Framework; | 30 | using NUnit.Framework; |
30 | using NUnit.Framework.SyntaxHelpers; | 31 | using NUnit.Framework.SyntaxHelpers; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Services.Interfaces; | ||
33 | using OpenSim.Tests.Common; | 36 | using OpenSim.Tests.Common; |
34 | using OpenSim.Tests.Common.Mock; | 37 | using OpenSim.Tests.Common.Mock; |
35 | 38 | ||
@@ -38,16 +41,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
38 | [TestFixture] | 41 | [TestFixture] |
39 | public class UuidGathererTests | 42 | public class UuidGathererTests |
40 | { | 43 | { |
41 | protected UuidGatherer m_ug; | 44 | protected IAssetService m_assetService; |
45 | protected UuidGatherer m_uuidGatherer; | ||
42 | 46 | ||
43 | [SetUp] | 47 | [SetUp] |
44 | public void Init() | 48 | public void Init() |
45 | { | 49 | { |
46 | m_ug = new UuidGatherer(new TestAssetService()); | 50 | m_assetService = new TestAssetService(); |
51 | m_uuidGatherer = new UuidGatherer(m_assetService); | ||
52 | } | ||
53 | |||
54 | [Test] | ||
55 | public void TestCorruptAsset() | ||
56 | { | ||
57 | TestHelper.InMethod(); | ||
58 | |||
59 | UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | ||
60 | AssetBase corruptAsset = new AssetBase(corruptAssetUuid, corruptAssetUuid.ToString(), (sbyte)AssetType.Object); | ||
61 | corruptAsset.Data = Encoding.ASCII.GetBytes("CORRUPT ASSET"); | ||
62 | |||
63 | m_assetService.Store(corruptAsset); | ||
64 | |||
65 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); | ||
66 | m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); | ||
67 | |||
68 | // We count the uuid as gathered even if the asset itself is corrupt. | ||
69 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | ||
47 | } | 70 | } |
48 | 71 | ||
49 | /// <summary> | 72 | /// <summary> |
50 | /// Test requests made for non-existent assets | 73 | /// Test requests made for non-existent assets while we're gathering |
51 | /// </summary> | 74 | /// </summary> |
52 | [Test] | 75 | [Test] |
53 | public void TestMissingAsset() | 76 | public void TestMissingAsset() |
@@ -57,7 +80,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
57 | UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | 80 | UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); |
58 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); | 81 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); |
59 | 82 | ||
60 | m_ug.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); | 83 | m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); |
61 | 84 | ||
62 | // We count the uuid as gathered even if the asset itself is missing. | 85 | // We count the uuid as gathered even if the asset itself is missing. |
63 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | 86 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 525a93a..930af81 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -273,7 +273,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
273 | { | 273 | { |
274 | string xml = Utils.BytesToString(objectAsset.Data); | 274 | string xml = Utils.BytesToString(objectAsset.Data); |
275 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml); | 275 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml); |
276 | GatherAssetUuids(sog, assetUuids); | 276 | |
277 | if (null != sog) | ||
278 | GatherAssetUuids(sog, assetUuids); | ||
277 | } | 279 | } |
278 | } | 280 | } |
279 | } | 281 | } |
diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/TestAssetService.cs index ff75d86..a537b97 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetService.cs +++ b/OpenSim/Tests/Common/Mock/TestAssetService.cs | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | ||
31 | using log4net; | ||
30 | using OpenMetaverse; | 32 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
32 | using OpenSim.Data; | 34 | using OpenSim.Data; |
@@ -37,6 +39,8 @@ namespace OpenSim.Tests.Common.Mock | |||
37 | { | 39 | { |
38 | public class TestAssetService : IAssetService | 40 | public class TestAssetService : IAssetService |
39 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
40 | private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); | 44 | private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); |
41 | 45 | ||
42 | public TestAssetService() {} | 46 | public TestAssetService() {} |
@@ -50,6 +54,8 @@ namespace OpenSim.Tests.Common.Mock | |||
50 | 54 | ||
51 | public AssetBase Get(string id) | 55 | public AssetBase Get(string id) |
52 | { | 56 | { |
57 | m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id); | ||
58 | |||
53 | AssetBase asset; | 59 | AssetBase asset; |
54 | if (Assets.ContainsKey(id)) | 60 | if (Assets.ContainsKey(id)) |
55 | asset = Assets[id]; | 61 | asset = Assets[id]; |
@@ -78,6 +84,8 @@ namespace OpenSim.Tests.Common.Mock | |||
78 | 84 | ||
79 | public string Store(AssetBase asset) | 85 | public string Store(AssetBase asset) |
80 | { | 86 | { |
87 | m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID); | ||
88 | |||
81 | Assets[asset.ID] = asset; | 89 | Assets[asset.ID] = asset; |
82 | 90 | ||
83 | return asset.ID; | 91 | return asset.ID; |