aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-09-08 17:42:07 +0100
committerJustin Clark-Casey (justincc)2009-09-08 17:42:07 +0100
commitb7256f256733f1c7667edc95ec500694bbe35dab (patch)
tree7be2bc029b9c07672b757f7cc7aeb2ca4453da12 /OpenSim
parentrefactor: change method argument name (diff)
downloadopensim-SC-b7256f256733f1c7667edc95ec500694bbe35dab.zip
opensim-SC-b7256f256733f1c7667edc95ec500694bbe35dab.tar.gz
opensim-SC-b7256f256733f1c7667edc95ec500694bbe35dab.tar.bz2
opensim-SC-b7256f256733f1c7667edc95ec500694bbe35dab.tar.xz
extend load iar test to loading into a deeply nested directory
correct bug associated with this
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/InventoryFolderBase.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs31
-rw-r--r--OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs97
-rw-r--r--OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs2
6 files changed, 133 insertions, 11 deletions
diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs
index 0edb2c6..3eef6f6 100644
--- a/OpenSim/Framework/InventoryFolderBase.cs
+++ b/OpenSim/Framework/InventoryFolderBase.cs
@@ -84,6 +84,14 @@ namespace OpenSim.Framework
84 Owner = owner; 84 Owner = owner;
85 } 85 }
86 86
87 public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent)
88 {
89 ID = id;
90 Name = name;
91 Owner = owner;
92 ParentID = parent;
93 }
94
87 public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version) 95 public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version)
88 { 96 {
89 ID = id; 97 ID = id;
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 3250ddf..50c0f93 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -233,7 +233,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
233 string originalArchivePath = archivePath; 233 string originalArchivePath = archivePath;
234 234
235 m_log.DebugFormat( 235 m_log.DebugFormat(
236 "[INVENTORY ARCHIVER]: Loading to folder {0 {1}}", rootDestFolder.Name, rootDestFolder.ID); 236 "[INVENTORY ARCHIVER]: Loading to folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID);
237 237
238 InventoryFolderBase destFolder = null; 238 InventoryFolderBase destFolder = null;
239 239
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
index 2eeb637..5ebf2fa 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
@@ -106,8 +106,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
106 if (path == PATH_DELIMITER) 106 if (path == PATH_DELIMITER)
107 return startFolder; 107 return startFolder;
108 108
109 InventoryFolderBase foundFolder = null;
110
111 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); 109 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
112 InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); 110 InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID);
113 111
@@ -116,7 +114,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
116 if (folder.Name == components[0]) 114 if (folder.Name == components[0])
117 { 115 {
118 if (components.Length > 1) 116 if (components.Length > 1)
119 return FindFolderByPath(inventoryService, foundFolder, components[1]); 117 return FindFolderByPath(inventoryService, folder, components[1]);
120 else 118 else
121 return folder; 119 return folder;
122 } 120 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 5461ea2..384a1f2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -195,7 +195,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
195 Assert.That(gotObject1File, Is.True, "No item1 file in archive"); 195 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
196// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); 196// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
197 197
198 // TODO: Test presence of more files and contents of files. 198 // TODO: Test presence of more files and contents of files.
199 } 199 }
200 200
201 /// <summary> 201 /// <summary>
@@ -257,24 +257,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
257 CachedUserInfo userInfo 257 CachedUserInfo userInfo
258 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); 258 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
259 259
260 InventoryItemBase foundItem 260 InventoryItemBase foundItem1
261 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); 261 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName);
262 262
263 Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); 263 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
264 Assert.That( 264 Assert.That(
265 foundItem.CreatorId, Is.EqualTo(item1.CreatorId), 265 foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
266 "Loaded item non-uuid creator doesn't match original"); 266 "Loaded item non-uuid creator doesn't match original");
267 Assert.That( 267 Assert.That(
268 foundItem.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), 268 foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
269 "Loaded item uuid creator doesn't match original"); 269 "Loaded item uuid creator doesn't match original");
270 Assert.That(foundItem.Owner, Is.EqualTo(userUuid), 270 Assert.That(foundItem1.Owner, Is.EqualTo(userUuid),
271 "Loaded item owner doesn't match inventory reciever"); 271 "Loaded item owner doesn't match inventory reciever");
272
273 // Now try loading to a root child folder
274 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA");
275 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
276 archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", archiveReadStream);
277
278 InventoryItemBase foundItem2
279 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + itemName);
280 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
281
282 // Now try loading to a more deeply nested folder
283 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC");
284 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
285 archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", archiveReadStream);
286
287 InventoryItemBase foundItem3
288 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + itemName);
289 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
272 } 290 }
273 291
274 /// <summary> 292 /// <summary>
275 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 293 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
276 /// no account exists with the creator name 294 /// no account exists with the creator name
277 /// </summary> 295 /// </summary>
296 /// Disabled since temporary profiles have not yet been implemented.
278 //[Test] 297 //[Test]
279 public void TestLoadIarV0_1TempProfiles() 298 public void TestLoadIarV0_1TempProfiles()
280 { 299 {
diff --git a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
new file mode 100644
index 0000000..3528072
--- /dev/null
+++ b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
@@ -0,0 +1,97 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Services.Interfaces;
32
33namespace OpenSim.Tests.Common
34{
35 /// <summary>
36 /// Utility functions for carrying out user inventory related tests.
37 /// </summary>
38 public static class UserInventoryTestUtils
39 {
40 public static readonly string PATH_DELIMITER = "/";
41
42 /// <summary>
43 /// Create inventory folders starting from the user's root folder.
44 /// </summary>
45 ///
46 /// Ignores any existing folders with the same name
47 ///
48 /// <param name="inventoryService"></param>
49 /// <param name="userId"></param>
50 /// <param name="path">
51 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
52 /// </param>
53 /// <returns>
54 /// The folder created. If the path contains multiple folders then the last one created is returned.
55 /// Will return null if the root folder could not be found.
56 /// </returns>
57 public static InventoryFolderBase CreateInventoryFolder(
58 IInventoryService inventoryService, UUID userId, string path)
59 {
60 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
61
62 if (null == rootFolder)
63 return null;
64
65 return CreateInventoryFolder(inventoryService, rootFolder, path);
66 }
67
68 /// <summary>
69 /// Create inventory folders starting from a given parent folder
70 /// </summary>
71 ///
72 /// Ignores any existing folders with the same name
73 ///
74 /// <param name="inventoryService"></param>
75 /// <param name="parentFolder"></param>
76 /// <param name="path">
77 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
78 /// </param>
79 /// <returns>
80 /// The folder created. If the path contains multiple folders then the last one created is returned.
81 /// </returns>
82 public static InventoryFolderBase CreateInventoryFolder(
83 IInventoryService inventoryService, InventoryFolderBase parentFolder, string path)
84 {
85 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
86
87 InventoryFolderBase newFolder
88 = new InventoryFolderBase(UUID.Random(), components[0], parentFolder.Owner, parentFolder.ID);
89 inventoryService.AddFolder(newFolder);
90
91 if (components.Length > 1)
92 return CreateInventoryFolder(inventoryService, newFolder, components[1]);
93 else
94 return newFolder;
95 }
96 }
97} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
index f146a15..4ad9926 100644
--- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Tests.Common.Setup
35 /// <summary> 35 /// <summary>
36 /// Utility functions for carrying out user profile related tests. 36 /// Utility functions for carrying out user profile related tests.
37 /// </summary> 37 /// </summary>
38 public class UserProfileTestUtils 38 public static class UserProfileTestUtils
39 { 39 {
40 /// <summary> 40 /// <summary>
41 /// Create a test user with a standard inventory 41 /// Create a test user with a standard inventory