29 using System.Collections.Generic;
31 using System.Reflection;
32 using System.Threading;
33 using NUnit.Framework;
36 using OpenSim.Framework;
37 using OpenSim.Framework.Serialization;
38 using OpenSim.Framework.Serialization.External;
39 using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
40 using OpenSim.Region.CoreModules.World.Serialiser;
41 using OpenSim.Region.Framework.Scenes;
42 using OpenSim.Region.Framework.Scenes.Serialization;
43 using OpenSim.Services.Interfaces;
44 using OpenSim.Tests.Common;
57 TestHelpers.InMethod();
66 SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
68 UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT,
"meowfood");
69 UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1,
"hampshire");
71 archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName,
"/",
"meowfood", m_iarStream);
73 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
75 Assert.That(foundItem1, Is.Not.Null,
"Didn't find loaded item 1");
78 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID,
"xA",
false);
79 MemoryStream archiveReadStream =
new MemoryStream(m_iarStream.ToArray());
80 archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName,
"xA",
"meowfood", archiveReadStream);
83 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID,
"xA/" + m_item1Name);
84 Assert.That(foundItem2, Is.Not.Null,
"Didn't find loaded item 2");
87 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID,
"xB/xC",
false);
88 archiveReadStream =
new MemoryStream(archiveReadStream.ToArray());
89 archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName,
"xB/xC",
"meowfood", archiveReadStream);
92 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID,
"xB/xC/" + m_item1Name);
93 Assert.That(foundItem3, Is.Not.Null,
"Didn't find loaded item 3");
102 TestHelpers.InMethod();
108 SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
110 UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT,
"password");
111 archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName,
"/Objects",
"password", m_iarStream);
114 = InventoryArchiveUtils.FindItemByPath(
115 scene.InventoryService, m_uaMT.PrincipalID,
"/Objects/" + m_item1Name);
117 Assert.That(foundItem1, Is.Not.Null,
"Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()");
123 TestHelpers.InMethod();
126 string itemName =
"You & you are a mean/man/";
127 string humanEscapedItemName =
@"You & you are a mean\/man\/";
128 string userPassword =
"meowfood";
133 SceneHelpers.SetupSceneModules(scene, archiverModule);
136 string userFirstName =
"Jock";
137 string userLastName =
"Stirrup";
138 UUID userId = UUID.Parse(
"00000000-0000-0000-0000-000000000020");
139 UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId,
"meowfood");
145 string partName =
"part name";
146 UUID ownerId = UUID.Parse(
"00000000-0000-0000-0000-000000000040");
148 Vector3 groupPosition =
new Vector3(10, 20, 30);
149 Quaternion rotationOffset =
new Quaternion(20, 30, 40, 50);
150 Vector3 offsetPosition =
new Vector3(5, 10, 15);
154 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
155 part1.Name = partName;
158 scene.AddNewSceneObject(object1,
false);
161 UUID asset1Id = UUID.Parse(
"00000000-0000-0000-0000-000000000060");
162 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
163 scene.AssetService.Store(asset1);
166 UUID item1Id = UUID.Parse(
"00000000-0000-0000-0000-000000000080");
168 item1.Name = itemName;
169 item1.AssetID = asset1.FullID;
172 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId,
"Objects")[0];
173 item1.Folder = objsFolder.ID;
174 scene.AddInventoryItem(item1);
176 MemoryStream archiveWriteStream =
new MemoryStream();
177 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
180 archiverModule.ArchiveInventory(
181 UUID.Random(), userFirstName, userLastName,
"Objects", userPassword, archiveWriteStream);
182 mre.WaitOne(60000,
false);
185 MemoryStream archiveReadStream =
new MemoryStream(archiveWriteStream.ToArray());
187 archiverModule.DearchiveInventory(UUID.Random(), userFirstName, userLastName,
"Scripts", userPassword, archiveReadStream);
190 = InventoryArchiveUtils.FindItemByPath(
191 scene.InventoryService, userId,
"Scripts/Objects/" + humanEscapedItemName);
193 Assert.That(foundItem1, Is.Not.Null,
"Didn't find loaded item 1");
198 foundItem1.Name, Is.EqualTo(itemName),
199 "Loaded item name doesn't match saved name");
208 TestHelpers.InMethod();
212 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
214 Dictionary <string, InventoryFolderBase> foldersCreated =
new Dictionary<string, InventoryFolderBase>();
215 HashSet<InventoryNodeBase> nodesLoaded =
new HashSet<InventoryNodeBase>();
217 string folder1Name =
"1";
218 string folder2aName =
"2a";
219 string folder2bName =
"2b";
221 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
222 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
223 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
225 string iarPath1 = string.Join(
"",
new string[] { folder1ArchiveName, folder2aArchiveName });
226 string iarPath2 = string.Join(
"",
new string[] { folder1ArchiveName, folder2bArchiveName });
230 new InventoryArchiveReadRequest(UUID.Random(), null, scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null,
false)
231 .ReplicateArchivePathToUserInventory(
232 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
233 foldersCreated, nodesLoaded);
235 List<InventoryFolderBase> folder1Candidates
236 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
237 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
240 List<InventoryFolderBase> folder2aCandidates
241 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName);
242 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
247 new InventoryArchiveReadRequest(UUID.Random(), null, scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null,
false)
248 .ReplicateArchivePathToUserInventory(
249 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
250 foldersCreated, nodesLoaded);
252 List<InventoryFolderBase> folder1Candidates
253 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
254 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
258 List<InventoryFolderBase> folder2aCandidates
259 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName);
260 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
262 List<InventoryFolderBase> folder2bCandidates
263 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2bName);
264 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
275 TestHelpers.InMethod();
279 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
281 string folder1ExistingName =
"a";
282 string folder2Name =
"b";
285 = UserInventoryHelpers.CreateInventoryFolder(
286 scene.InventoryService, ua1.PrincipalID, folder1ExistingName,
false);
288 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
289 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
291 string itemArchivePath = string.Join(
"",
new string[] { folder1ArchiveName, folder2ArchiveName });
293 new InventoryArchiveReadRequest(UUID.Random(), null, scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null,
false)
294 .ReplicateArchivePathToUserInventory(
295 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
296 new Dictionary<string, InventoryFolderBase>(),
new HashSet<InventoryNodeBase>());
298 List<InventoryFolderBase> folder1PostCandidates
299 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
300 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
306 if (folder.
ID != folder1.ID)
308 folder1Post = folder;
314 List<InventoryFolderBase> folder2PostCandidates
315 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1Post,
"b");
316 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
326 TestHelpers.InMethod();
330 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
332 string folder1ExistingName =
"a";
333 string folder2Name =
"b";
336 = UserInventoryHelpers.CreateInventoryFolder(
337 scene.InventoryService, ua1.PrincipalID, folder1ExistingName,
false);
339 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
340 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
342 string itemArchivePath = string.Join(
"",
new string[] { folder1ArchiveName, folder2ArchiveName });
344 new InventoryArchiveReadRequest(UUID.Random(), null, scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, folder1ExistingName, (Stream)null,
true)
345 .ReplicateArchivePathToUserInventory(
346 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
347 new Dictionary<string, InventoryFolderBase>(),
new HashSet<InventoryNodeBase>());
349 List<InventoryFolderBase> folder1PostCandidates
350 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
351 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
352 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
354 List<InventoryFolderBase> folder2PostCandidates
355 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1PostCandidates[0],
"b");
356 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
void TestLoadIarPathWithEscapedChars()
void TestPartExistingIarPath()
Test replication of a partly existing archive path to the user's inventory. This should create a dupl...
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Asset class. All Assets are reference by this class or a class derived from this class ...
void TestNewIarPath()
Test replication of an archive path to the user's inventory.
This module loads and saves OpenSimulator inventory archives
Inventory Item - contains all the properties associated with an individual inventory piece...
Helpers for setting up scenes.
Interactive OpenSim region server
UUID ID
A UUID containing the ID for the inventory node itself
void TestMergeIarPath()
Test replication of a partly existing archive path to the user's inventory. This should create a merg...
void TestLoadIarPathStartsWithSlash()
Test that things work when the load path specified starts with a slash
void TestLoadIarToInventoryPaths()
Test loading an IAR to various different inventory paths.