From a60ca5236c247b88909a3c0462675627575b334c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 21:37:48 +0100 Subject: restore InventoryArchiverTests.TestReplicateArchivePathToUserInventory() to work with the new UserAccountService/InventoryService --- .../Archiver/Tests/InventoryArchiverTests.cs | 88 +++++++++------------- OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs | 13 +++- 2 files changed, 49 insertions(+), 52 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index e434e46..d339543 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -540,55 +540,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// /// Test replication of an archive path to the user's inventory. /// -// [Test] -// public void TestReplicateArchivePathToUserInventory() -// { -// TestHelper.InMethod(); -// //log4net.Config.XmlConfigurator.Configure(); -// -// Scene scene = SceneSetupHelpers.SetupScene("inventory"); -// CommunicationsManager commsManager = scene.CommsManager; -// CachedUserInfo userInfo; -// -// lock (this) -// { -// // !!! REFACTORING PROBLEM. This needs to be rewritten -// userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); -// Monitor.Wait(this, 60000); -// } -// -// //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); -// -// Dictionary foldersCreated = new Dictionary(); -// List nodesLoaded = new List(); -// -// string folder1Name = "a"; -// string folder2Name = "b"; -// string itemName = "c.lsl"; -// -// string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); -// string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); -// string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); -// -// string itemArchivePath -// = string.Format( -// "{0}{1}{2}{3}", -// ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); -// -// //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); -// -// new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) -// .ReplicateArchivePathToUserInventory( -// itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), -// foldersCreated, nodesLoaded); -// -// //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); -// //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); -// InventoryFolderBase folder1 -// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); -// Assert.That(folder1, Is.Not.Null, "Could not find folder a"); -// InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); -// Assert.That(folder2, Is.Not.Null, "Could not find folder b"); -// } + [Test] + public void TestReplicateArchivePathToUserInventory() + { + TestHelper.InMethod(); + //log4net.Config.XmlConfigurator.Configure(); + + Scene scene = SceneSetupHelpers.SetupScene("inventory"); + UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); + + Dictionary foldersCreated = new Dictionary(); + List nodesLoaded = new List(); + + string folder1Name = "a"; + string folder2Name = "b"; + string itemName = "c.lsl"; + + string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); + string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); + string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); + + string itemArchivePath + = string.Format( + "{0}{1}{2}{3}", + ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); + + new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) + .ReplicateArchivePathToUserInventory( + itemArchivePath, false, scene.InventoryService.GetRootFolder(ua1.PrincipalID), + foldersCreated, nodesLoaded); + + InventoryFolderBase folder1 + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a"); + Assert.That(folder1, Is.Not.Null, "Could not find folder a"); + InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); + Assert.That(folder2, Is.Not.Null, "Could not find folder b"); + } } -} +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs index 2b14d97..a6b9520 100644 --- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs +++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs @@ -27,7 +27,8 @@ using OpenMetaverse; using OpenSim.Framework.Communications; - +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Tests.Common.Setup { @@ -113,5 +114,15 @@ namespace OpenSim.Tests.Common.Setup // // return userInfo; // } + + public static UserAccount CreateUserWithInventory(Scene scene) + { + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); + UserAccount ua = new UserAccount(userId) { FirstName = "Bill", LastName = "Bailey" }; + scene.UserAccountService.StoreUserAccount(ua); + scene.InventoryService.CreateUserInventory(ua.PrincipalID); + + return ua; + } } } \ No newline at end of file -- cgit v1.1