From 304c78bbbbc9a176d70d2967a3f703f2e545565c Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sun, 6 Sep 2009 19:30:03 +0100 Subject: [PATCH] Temporarily re-enable save iar test by manually insert the item into the old cache during the test --- .../Archiver/InventoryArchiveWriteRequest.cs | 7 +++++++ .../Archiver/Tests/InventoryArchiverTests.cs | 15 ++++++++++----- .../Tests/Common/Mock/TestInventoryDataPlugin.cs | 8 +++++++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 18728c6970..66535168db 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -207,6 +207,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver InventoryFolderImpl inventoryFolder = null; InventoryItemBase inventoryItem = null; + // XXX: Very temporarily, drop and refetch inventory to make sure we have any newly created items in cache + // This will disappear very soon once we stop using the old cached inventory. + /* + m_userInfo.DropInventory(); + m_userInfo.FetchInventory(); + */ + if (!m_userInfo.HasReceivedInventory) { // If the region server has access to the user admin service (by which users are created), diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index a151c9d49d..2ad6f1af8c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// // Commenting for now! The mock inventory service needs more beef, at least for // GetFolderForType - //[Test] + [Test] public void TestSaveIarV0_1() { TestHelper.InMethod(); @@ -93,11 +93,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string userFirstName = "Jock"; string userLastName = "Stirrup"; UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - // CachedUserInfo userInfo; + CachedUserInfo userInfo; lock (this) { - UserProfileTestUtils.CreateUserWithInventory( + userInfo = UserProfileTestUtils.CreateUserWithInventory( cm, userFirstName, userLastName, userId, InventoryReceived); Monitor.Wait(this, 60000); } @@ -136,18 +136,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests item1.Name = "My Little Dog"; item1.AssetID = asset1.FullID; item1.ID = item1Id; - //userInfo.RootFolder.FindFolderByPath("Objects").ID; + InventoryFolderImpl objsFolder = userInfo.RootFolder.FindFolderByPath("Objects"); //InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); Console.WriteLine("here2"); + /* IInventoryService inventoryService = scene.InventoryService; InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); InventoryCollection rootContents = inventoryService.GetFolderContent(userId, rootFolder.ID); + */ + /* InventoryFolderBase objsFolder = null; foreach (InventoryFolderBase folder in rootContents.Folders) if (folder.Name == "Objects") objsFolder = folder; + */ item1.Folder = objsFolder.ID; scene.AddInventoryItem(userId, item1); + userInfo.AddItem(item1); MemoryStream archiveWriteStream = new MemoryStream(); archiverModule.OnInventoryArchiveSaved += SaveCompleted; @@ -155,7 +160,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests mre.Reset(); archiverModule.ArchiveInventory( Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream); - mre.WaitOne(); + mre.WaitOne(60000, false); byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index ce116f2d6e..a444d919a9 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs @@ -154,7 +154,13 @@ namespace OpenSim.Tests.Common.Mock m_folders.Remove(folderId); } - public void addInventoryItem(InventoryItemBase item) { m_items[item.ID] = item; } + public void addInventoryItem(InventoryItemBase item) + { + m_log.DebugFormat( + "[MOCK INV DB]: Adding inventory item {0} {1} in {2}", item.Name, item.ID, item.Folder); + + m_items[item.ID] = item; + } public void updateInventoryItem(InventoryItemBase item) { addInventoryItem(item); }