aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2010-06-11 22:09:24 +0100
committerMelanie2010-06-11 22:09:24 +0100
commitc61e99858059ed0f82e4cfda74c74bf4a2fc9f61 (patch)
treee3479283bce26b2c7f9f477ac62fa1473a251196
parentRemove the lastmap stuff from the map module, also remove a bunch of comments (diff)
parentRevert "Allow IInventoryService.GetFolder(folderId, userId) as well as GetFol... (diff)
downloadopensim-SC_OLD-c61e99858059ed0f82e4cfda74c74bf4a2fc9f61.zip
opensim-SC_OLD-c61e99858059ed0f82e4cfda74c74bf4a2fc9f61.tar.gz
opensim-SC_OLD-c61e99858059ed0f82e4cfda74c74bf4a2fc9f61.tar.bz2
opensim-SC_OLD-c61e99858059ed0f82e4cfda74c74bf4a2fc9f61.tar.xz
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs34
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs50
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs46
-rw-r--r--OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs18
4 files changed, 100 insertions, 48 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 60d1720..b4f1ed6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -219,40 +219,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
219 CreateFoldersForPath(destFolder, archivePathSectionToCreate, resolvedFolders, loadedNodes); 219 CreateFoldersForPath(destFolder, archivePathSectionToCreate, resolvedFolders, loadedNodes);
220 220
221 return destFolder; 221 return destFolder;
222
223 /*
224 string[] rawFolders = filePath.Split(new char[] { '/' });
225
226 // Find the folders that do exist along the path given
227 int i = 0;
228 bool noFolder = false;
229 InventoryFolderImpl foundFolder = rootDestinationFolder;
230 while (!noFolder && i < rawFolders.Length)
231 {
232 InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]);
233 if (null != folder)
234 {
235 m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
236 foundFolder = folder;
237 i++;
238 }
239 else
240 {
241 noFolder = true;
242 }
243 }
244
245 // Create any folders that did not previously exist
246 while (i < rawFolders.Length)
247 {
248 m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
249
250 UUID newFolderId = UUID.Random();
251 m_userInfo.CreateFolder(
252 rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
253 foundFolder = foundFolder.GetChildFolder(newFolderId);
254 }
255 */
256 } 222 }
257 223
258 /// <summary> 224 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 59cd386..00bd27a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -279,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
279 public void TestIarV0_1WithEscapedChars() 279 public void TestIarV0_1WithEscapedChars()
280 { 280 {
281 TestHelper.InMethod(); 281 TestHelper.InMethod();
282 log4net.Config.XmlConfigurator.Configure(); 282// log4net.Config.XmlConfigurator.Configure();
283 283
284 string itemName = "You & you are a mean/man/"; 284 string itemName = "You & you are a mean/man/";
285 string humanEscapedItemName = @"You & you are a mean\/man\/"; 285 string humanEscapedItemName = @"You & you are a mean\/man\/";
@@ -505,7 +505,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
505 /// Test replication of an archive path to the user's inventory. 505 /// Test replication of an archive path to the user's inventory.
506 /// </summary> 506 /// </summary>
507 [Test] 507 [Test]
508 public void TestReplicateArchivePathToUserInventory() 508 public void TestNewIarPath()
509 { 509 {
510 TestHelper.InMethod(); 510 TestHelper.InMethod();
511 //log4net.Config.XmlConfigurator.Configure(); 511 //log4net.Config.XmlConfigurator.Configure();
@@ -540,5 +540,51 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
540 InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); 540 InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
541 Assert.That(folder2, Is.Not.Null, "Could not find folder b"); 541 Assert.That(folder2, Is.Not.Null, "Could not find folder b");
542 } 542 }
543
544 /// <summary>
545 /// Test replication of a partly existing archive path to the user's inventory.
546 /// </summary>
547 [Test]
548 public void TestPartExistingIarPath()
549 {
550 TestHelper.InMethod();
551 //log4net.Config.XmlConfigurator.Configure();
552
553 Scene scene = SceneSetupHelpers.SetupScene("inventory");
554 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
555
556 string folder1ExistingName = "a";
557 string folder2Name = "b";
558 string itemName = "c.lsl";
559
560 InventoryFolderBase folder1
561 = UserInventoryTestUtils.CreateInventoryFolder(
562 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
563
564 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
565 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
566 string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
567
568 string itemArchivePath
569 = string.Format(
570 "{0}{1}{2}{3}",
571 ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
572
573 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
574 .ReplicateArchivePathToUserInventory(
575 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
576 new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>());
577
578 InventoryFolderBase folder1Post
579 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
580 Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
581 /*
582 InventoryFolderBase folder2
583 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
584 Assert.That(folder2, Is.Not.Null);
585 InventoryItemBase item = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, folder2, itemName);
586 Assert.That(item, Is.Not.Null);
587 */
588 }
543 } 589 }
544} \ No newline at end of file 590} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
index 6dc993f..f9a80b0 100644
--- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
@@ -36,25 +36,29 @@ namespace OpenSim.Tests.Common
36 public class AssetHelpers 36 public class AssetHelpers
37 { 37 {
38 /// <summary> 38 /// <summary>
39 /// Create an asset from the given data 39 /// Create a notecard asset with a random uuid and dummy text.
40 /// </summary> 40 /// </summary>
41 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID) 41 /// <param name="creatorId">/param>
42 /// <returns></returns>
43 public static AssetBase CreateAsset(UUID creatorId)
42 { 44 {
43 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString()); 45 return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
44 asset.Data = data;
45 return asset;
46 } 46 }
47 47
48 /// <summary> 48 /// <summary>
49 /// Create an asset from the given data 49 /// Create and store a notecard asset with a random uuid and dummy text.
50 /// </summary> 50 /// </summary>
51 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID) 51 /// <param name="creatorId">/param>
52 /// <returns></returns>
53 public static AssetBase CreateAsset(Scene scene, UUID creatorId)
52 { 54 {
53 return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID); 55 AssetBase asset = CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
54 } 56 scene.AssetService.Store(asset);
55 57 return asset;
58 }
59
56 /// <summary> 60 /// <summary>
57 /// Create an asset from the given scene object 61 /// Create an asset from the given scene object.
58 /// </summary> 62 /// </summary>
59 /// <param name="assetUuid"></param> 63 /// <param name="assetUuid"></param>
60 /// <param name="sog"></param> 64 /// <param name="sog"></param>
@@ -67,5 +71,23 @@ namespace OpenSim.Tests.Common
67 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)), 71 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)),
68 sog.OwnerID); 72 sog.OwnerID);
69 } 73 }
74
75 /// <summary>
76 /// Create an asset from the given data.
77 /// </summary>
78 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID)
79 {
80 return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID);
81 }
82
83 /// <summary>
84 /// Create an asset from the given data.
85 /// </summary>
86 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID)
87 {
88 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString());
89 asset.Data = data;
90 return asset;
91 }
70 } 92 }
71} 93}
diff --git a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
index 7e0c567..c57363a 100644
--- a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
31using OpenSim.Services.Interfaces; 32using OpenSim.Services.Interfaces;
32 33
33namespace OpenSim.Tests.Common 34namespace OpenSim.Tests.Common
@@ -39,6 +40,23 @@ namespace OpenSim.Tests.Common
39 { 40 {
40 public static readonly string PATH_DELIMITER = "/"; 41 public static readonly string PATH_DELIMITER = "/";
41 42
43 public static InventoryItemBase CreateInventoryItem(
44 Scene scene, string itemName, UUID itemId, string folderPath, UUID userId)
45 {
46 InventoryItemBase item = new InventoryItemBase();
47 item.Name = itemName;
48 item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID;
49 item.ID = itemId;
50
51 // Really quite bad since the objs folder could be moved in the future and confuse the tests
52 InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object);
53
54 item.Folder = objsFolder.ID;
55 scene.AddInventoryItem(userId, item);
56
57 return item;
58 }
59
42 /// <summary> 60 /// <summary>
43 /// Create inventory folders starting from the user's root folder. 61 /// Create inventory folders starting from the user's root folder.
44 /// </summary> 62 /// </summary>