extend load iar test to loading into a deeply nested directory

correct bug associated with this
remotes/origin/0.6.7-post-fixes
Justin Clark-Casey (justincc) 2009-09-08 17:42:07 +01:00
parent 36a40e0295
commit b7256f2567
6 changed files with 133 additions and 11 deletions

View File

@ -84,6 +84,14 @@ namespace OpenSim.Framework
Owner = owner; Owner = owner;
} }
public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent)
{
ID = id;
Name = name;
Owner = owner;
ParentID = parent;
}
public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version) public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version)
{ {
ID = id; ID = id;

View File

@ -233,7 +233,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
string originalArchivePath = archivePath; string originalArchivePath = archivePath;
m_log.DebugFormat( m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Loading to folder {0 {1}}", rootDestFolder.Name, rootDestFolder.ID); "[INVENTORY ARCHIVER]: Loading to folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID);
InventoryFolderBase destFolder = null; InventoryFolderBase destFolder = null;

View File

@ -106,8 +106,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (path == PATH_DELIMITER) if (path == PATH_DELIMITER)
return startFolder; return startFolder;
InventoryFolderBase foundFolder = null;
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID);
@ -116,7 +114,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (folder.Name == components[0]) if (folder.Name == components[0])
{ {
if (components.Length > 1) if (components.Length > 1)
return FindFolderByPath(inventoryService, foundFolder, components[1]); return FindFolderByPath(inventoryService, folder, components[1]);
else else
return folder; return folder;
} }

View File

@ -195,7 +195,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Assert.That(gotObject1File, Is.True, "No item1 file in archive"); Assert.That(gotObject1File, Is.True, "No item1 file in archive");
// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); // Assert.That(gotObject2File, Is.True, "No object2 file in archive");
// TODO: Test presence of more files and contents of files. // TODO: Test presence of more files and contents of files.
} }
/// <summary> /// <summary>
@ -257,24 +257,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
CachedUserInfo userInfo CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
InventoryItemBase foundItem InventoryItemBase foundItem1
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName);
Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
Assert.That( Assert.That(
foundItem.CreatorId, Is.EqualTo(item1.CreatorId), foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
"Loaded item non-uuid creator doesn't match original"); "Loaded item non-uuid creator doesn't match original");
Assert.That( Assert.That(
foundItem.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
"Loaded item uuid creator doesn't match original"); "Loaded item uuid creator doesn't match original");
Assert.That(foundItem.Owner, Is.EqualTo(userUuid), Assert.That(foundItem1.Owner, Is.EqualTo(userUuid),
"Loaded item owner doesn't match inventory reciever"); "Loaded item owner doesn't match inventory reciever");
// Now try loading to a root child folder
UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA");
archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", archiveReadStream);
InventoryItemBase foundItem2
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + itemName);
Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
// Now try loading to a more deeply nested folder
UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC");
archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", archiveReadStream);
InventoryItemBase foundItem3
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + itemName);
Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
} }
/// <summary> /// <summary>
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
/// no account exists with the creator name /// no account exists with the creator name
/// </summary> /// </summary>
/// Disabled since temporary profiles have not yet been implemented.
//[Test] //[Test]
public void TestLoadIarV0_1TempProfiles() public void TestLoadIarV0_1TempProfiles()
{ {

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
namespace OpenSim.Tests.Common
{
/// <summary>
/// Utility functions for carrying out user inventory related tests.
/// </summary>
public static class UserInventoryTestUtils
{
public static readonly string PATH_DELIMITER = "/";
/// <summary>
/// Create inventory folders starting from the user's root folder.
/// </summary>
///
/// Ignores any existing folders with the same name
///
/// <param name="inventoryService"></param>
/// <param name="userId"></param>
/// <param name="path">
/// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
/// </param>
/// <returns>
/// The folder created. If the path contains multiple folders then the last one created is returned.
/// Will return null if the root folder could not be found.
/// </returns>
public static InventoryFolderBase CreateInventoryFolder(
IInventoryService inventoryService, UUID userId, string path)
{
InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
if (null == rootFolder)
return null;
return CreateInventoryFolder(inventoryService, rootFolder, path);
}
/// <summary>
/// Create inventory folders starting from a given parent folder
/// </summary>
///
/// Ignores any existing folders with the same name
///
/// <param name="inventoryService"></param>
/// <param name="parentFolder"></param>
/// <param name="path">
/// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
/// </param>
/// <returns>
/// The folder created. If the path contains multiple folders then the last one created is returned.
/// </returns>
public static InventoryFolderBase CreateInventoryFolder(
IInventoryService inventoryService, InventoryFolderBase parentFolder, string path)
{
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
InventoryFolderBase newFolder
= new InventoryFolderBase(UUID.Random(), components[0], parentFolder.Owner, parentFolder.ID);
inventoryService.AddFolder(newFolder);
if (components.Length > 1)
return CreateInventoryFolder(inventoryService, newFolder, components[1]);
else
return newFolder;
}
}
}

View File

@ -35,7 +35,7 @@ namespace OpenSim.Tests.Common.Setup
/// <summary> /// <summary>
/// Utility functions for carrying out user profile related tests. /// Utility functions for carrying out user profile related tests.
/// </summary> /// </summary>
public class UserProfileTestUtils public static class UserProfileTestUtils
{ {
/// <summary> /// <summary>
/// Create a test user with a standard inventory /// Create a test user with a standard inventory