diff options
Diffstat (limited to 'OpenSim')
3 files changed, 117 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 81c3b74..c366150 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -290,6 +290,98 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
290 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); | 290 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); |
291 | } | 291 | } |
292 | 292 | ||
293 | [Test] | ||
294 | public void TestIarV0_1WithEscapedChars() | ||
295 | { | ||
296 | TestHelper.InMethod(); | ||
297 | log4net.Config.XmlConfigurator.Configure(); | ||
298 | |||
299 | string itemName = "You & you are a mean man"; | ||
300 | string userPassword = "meowfood"; | ||
301 | |||
302 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); | ||
303 | |||
304 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
305 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
306 | CommunicationsManager cm = scene.CommsManager; | ||
307 | |||
308 | // Create user | ||
309 | string userFirstName = "Jock"; | ||
310 | string userLastName = "Stirrup"; | ||
311 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
312 | |||
313 | lock (this) | ||
314 | { | ||
315 | UserProfileTestUtils.CreateUserWithInventory( | ||
316 | cm, userFirstName, userLastName, userPassword, userId, InventoryReceived); | ||
317 | Monitor.Wait(this, 60000); | ||
318 | } | ||
319 | |||
320 | // Create asset | ||
321 | SceneObjectGroup object1; | ||
322 | SceneObjectPart part1; | ||
323 | { | ||
324 | string partName = "part name"; | ||
325 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
326 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
327 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
328 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
329 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
330 | |||
331 | part1 | ||
332 | = new SceneObjectPart( | ||
333 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
334 | part1.Name = partName; | ||
335 | |||
336 | object1 = new SceneObjectGroup(part1); | ||
337 | scene.AddNewSceneObject(object1, false); | ||
338 | } | ||
339 | |||
340 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
341 | AssetBase asset1 = new AssetBase(); | ||
342 | asset1.FullID = asset1Id; | ||
343 | asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); | ||
344 | scene.AssetService.Store(asset1); | ||
345 | |||
346 | // Create item | ||
347 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
348 | InventoryItemBase item1 = new InventoryItemBase(); | ||
349 | item1.Name = itemName; | ||
350 | item1.AssetID = asset1.FullID; | ||
351 | item1.ID = item1Id; | ||
352 | InventoryFolderBase objsFolder | ||
353 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); | ||
354 | item1.Folder = objsFolder.ID; | ||
355 | scene.AddInventoryItem(userId, item1); | ||
356 | |||
357 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
358 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
359 | |||
360 | mre.Reset(); | ||
361 | archiverModule.ArchiveInventory( | ||
362 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
363 | mre.WaitOne(60000, false); | ||
364 | |||
365 | /// LOAD ITEM | ||
366 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
367 | |||
368 | archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); | ||
369 | |||
370 | CachedUserInfo userInfo | ||
371 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | ||
372 | |||
373 | InventoryItemBase foundItem1 | ||
374 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userId, "Scripts/Objects/" + itemName); | ||
375 | |||
376 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | ||
377 | // Assert.That( | ||
378 | // foundItem1.CreatorId, Is.EqualTo(userUuid), | ||
379 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
380 | Assert.That( | ||
381 | foundItem1.Name, Is.EqualTo(itemName), | ||
382 | "Loaded item name doesn't match saved name"); | ||
383 | } | ||
384 | |||
293 | /// <summary> | 385 | /// <summary> |
294 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 386 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
295 | /// embedded creators do not exist in the system | 387 | /// embedded creators do not exist in the system |
@@ -302,7 +394,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
302 | { | 394 | { |
303 | TestHelper.InMethod(); | 395 | TestHelper.InMethod(); |
304 | 396 | ||
305 | log4net.Config.XmlConfigurator.Configure(); | 397 | //log4net.Config.XmlConfigurator.Configure(); |
306 | 398 | ||
307 | string userFirstName = "Charlie"; | 399 | string userFirstName = "Charlie"; |
308 | string userLastName = "Chan"; | 400 | string userLastName = "Chan"; |
@@ -370,7 +462,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
370 | { | 462 | { |
371 | TestHelper.InMethod(); | 463 | TestHelper.InMethod(); |
372 | 464 | ||
373 | log4net.Config.XmlConfigurator.Configure(); | 465 | //log4net.Config.XmlConfigurator.Configure(); |
374 | 466 | ||
375 | string userFirstName = "Dennis"; | 467 | string userFirstName = "Dennis"; |
376 | string userLastName = "Menace"; | 468 | string userLastName = "Menace"; |
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs index 3ca44a1..1b06a46 100644 --- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs +++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs | |||
@@ -85,14 +85,34 @@ namespace OpenSim.Tests.Common.Setup | |||
85 | CommunicationsManager commsManager, string firstName, string lastName, | 85 | CommunicationsManager commsManager, string firstName, string lastName, |
86 | UUID userId, OnInventoryReceivedDelegate callback) | 86 | UUID userId, OnInventoryReceivedDelegate callback) |
87 | { | 87 | { |
88 | return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); | ||
89 | } | ||
90 | |||
91 | /// <summary> | ||
92 | /// Create a test user with a standard inventory | ||
93 | /// </summary> | ||
94 | /// <param name="commsManager"></param> | ||
95 | /// <param name="firstName">First name of user</param> | ||
96 | /// <param name="lastName">Last name of user</param> | ||
97 | /// <param name="password">Password</param> | ||
98 | /// <param name="userId">User ID</param> | ||
99 | /// <param name="callback"> | ||
100 | /// Callback to invoke when inventory has been loaded. This is required because | ||
101 | /// loading may be asynchronous, even on standalone | ||
102 | /// </param> | ||
103 | /// <returns></returns> | ||
104 | public static CachedUserInfo CreateUserWithInventory( | ||
105 | CommunicationsManager commsManager, string firstName, string lastName, string password, | ||
106 | UUID userId, OnInventoryReceivedDelegate callback) | ||
107 | { | ||
88 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; | 108 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; |
89 | lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); | 109 | lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); |
90 | 110 | ||
91 | CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); | 111 | CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); |
92 | userInfo.OnInventoryReceived += callback; | 112 | userInfo.OnInventoryReceived += callback; |
93 | userInfo.FetchInventory(); | 113 | userInfo.FetchInventory(); |
94 | 114 | ||
95 | return userInfo; | 115 | return userInfo; |
96 | } | 116 | } |
97 | } | 117 | } |
98 | } | 118 | } |
diff --git a/OpenSim/Tests/Common/TestHelper.cs b/OpenSim/Tests/Common/TestHelper.cs index 4abf2e3..9d53063 100644 --- a/OpenSim/Tests/Common/TestHelper.cs +++ b/OpenSim/Tests/Common/TestHelper.cs | |||
@@ -54,6 +54,7 @@ namespace OpenSim.Tests.Common | |||
54 | public static void InMethod() | 54 | public static void InMethod() |
55 | { | 55 | { |
56 | StackTrace stackTrace = new StackTrace(); | 56 | StackTrace stackTrace = new StackTrace(); |
57 | Console.WriteLine(); | ||
57 | Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); | 58 | Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); |
58 | } | 59 | } |
59 | } | 60 | } |