From 08606ae409b400b6f9b83006ed04826eede8a9c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Jan 2015 20:21:40 +0000 Subject: Make the IteratingUuidGatherer the only UuidGatherer. This UUID gatherer provides a superset of the previous gatherer's functionality as it also allows the caller to control gathering iterations for load purposes. --- .../Framework/Scenes/Tests/UuidGathererTests.cs | 48 ++++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs') diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index a12b170..1fe0e79 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -61,11 +61,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests = AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero); m_assetService.Store(corruptAsset); - IDictionary foundAssetUuids = new Dictionary(); - m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, (sbyte)AssetType.Object, foundAssetUuids); + m_uuidGatherer.AddForInspection(corruptAssetUuid); + m_uuidGatherer.GatherAll(); // We count the uuid as gathered even if the asset itself is corrupt. - Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); + Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(1)); } /// @@ -77,38 +77,42 @@ namespace OpenSim.Region.Framework.Scenes.Tests TestHelpers.InMethod(); UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); - IDictionary foundAssetUuids = new Dictionary(); - - m_uuidGatherer.GatherAssetUuids(missingAssetUuid, (sbyte)AssetType.Object, foundAssetUuids); - // We count the uuid as gathered even if the asset itself is missing. - Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); + m_uuidGatherer.AddForInspection(missingAssetUuid); + m_uuidGatherer.GatherAll(); + + Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(0)); } [Test] public void TestNotecardAsset() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); + TestHelpers.EnableLogging(); UUID ownerId = TestHelpers.ParseTail(0x10); - UUID soAssetId = TestHelpers.ParseTail(0x20); + UUID embeddedId = TestHelpers.ParseTail(0x20); + UUID missingEmbeddedId = TestHelpers.ParseTail(0x21); UUID ncAssetId = TestHelpers.ParseTail(0x30); - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId); - AssetBase soAsset = AssetHelpers.CreateAsset(soAssetId, so); - m_assetService.Store(soAsset); - - AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString()); + AssetBase ncAsset + = AssetHelpers.CreateNotecardAsset( + ncAssetId, string.Format("Hello{0}World{1}", embeddedId, missingEmbeddedId)); m_assetService.Store(ncAsset); - IDictionary foundAssetUuids = new Dictionary(); - m_uuidGatherer.GatherAssetUuids(ncAssetId, (sbyte)AssetType.Notecard, foundAssetUuids); + AssetBase embeddedAsset = AssetHelpers.CreateNotecardAsset(embeddedId, "We'll meet again."); + m_assetService.Store(embeddedAsset); - // We count the uuid as gathered even if the asset itself is corrupt. - Assert.That(foundAssetUuids.Count, Is.EqualTo(2)); - Assert.That(foundAssetUuids.ContainsKey(ncAssetId)); - Assert.That(foundAssetUuids.ContainsKey(soAssetId)); + m_uuidGatherer.AddForInspection(ncAssetId); + m_uuidGatherer.GatherAll(); + +// foreach (UUID key in m_uuidGatherer.GatheredUuids.Keys) +// System.Console.WriteLine("key : {0}", key); + + Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(3)); + Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(ncAssetId)); + Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(embeddedId)); + Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(missingEmbeddedId)); } } -} +} \ No newline at end of file -- cgit v1.1 From 801a86ca035b5c8bbd1f99082fd80f2471d6345c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Jan 2015 20:36:03 +0000 Subject: When inspecting a script or notecard, also try to look up any assets embedded therein. This is primarily to fix an issue where inventory items for NPC attachments would not be saved in archives as the assets referenced in the appearance notecard were not checked in this manner. Relates to http://opensimulator.org/mantis/view.php?id=7376 --- OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs') diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 1fe0e79..4ae27d7 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -88,11 +88,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests public void TestNotecardAsset() { TestHelpers.InMethod(); - TestHelpers.EnableLogging(); +// TestHelpers.EnableLogging(); UUID ownerId = TestHelpers.ParseTail(0x10); UUID embeddedId = TestHelpers.ParseTail(0x20); - UUID missingEmbeddedId = TestHelpers.ParseTail(0x21); + UUID secondLevelEmbeddedId = TestHelpers.ParseTail(0x21); + UUID missingEmbeddedId = TestHelpers.ParseTail(0x22); UUID ncAssetId = TestHelpers.ParseTail(0x30); AssetBase ncAsset @@ -100,9 +101,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests ncAssetId, string.Format("Hello{0}World{1}", embeddedId, missingEmbeddedId)); m_assetService.Store(ncAsset); - AssetBase embeddedAsset = AssetHelpers.CreateNotecardAsset(embeddedId, "We'll meet again."); + AssetBase embeddedAsset + = AssetHelpers.CreateNotecardAsset(embeddedId, string.Format("{0} We'll meet again.", secondLevelEmbeddedId)); m_assetService.Store(embeddedAsset); + AssetBase secondLevelEmbeddedAsset + = AssetHelpers.CreateNotecardAsset(secondLevelEmbeddedId, "Don't know where, don't know when."); + m_assetService.Store(secondLevelEmbeddedAsset); + m_uuidGatherer.AddForInspection(ncAssetId); m_uuidGatherer.GatherAll(); @@ -112,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(3)); Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(ncAssetId)); Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(embeddedId)); - Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(missingEmbeddedId)); + Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(secondLevelEmbeddedId)); } } } \ No newline at end of file -- cgit v1.1