aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-27 22:52:26 +0100
committerJustin Clark-Casey (justincc)2010-08-27 22:52:26 +0100
commit8f875700ef3f0d8e4d86192d2985aff250fe2d51 (patch)
treeb0e34f0ee202c8926a67f2ef29594cd6034bfe65 /OpenSim/Region
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-8f875700ef3f0d8e4d86192d2985aff250fe2d51.zip
opensim-SC_OLD-8f875700ef3f0d8e4d86192d2985aff250fe2d51.tar.gz
opensim-SC_OLD-8f875700ef3f0d8e4d86192d2985aff250fe2d51.tar.bz2
opensim-SC_OLD-8f875700ef3f0d8e4d86192d2985aff250fe2d51.tar.xz
refactor: Make IAR tests set up standard iar for loading
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs104
1 files changed, 60 insertions, 44 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 3fb2c8c..892680e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -55,12 +55,58 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
55 { 55 {
56 protected ManualResetEvent mre = new ManualResetEvent(false); 56 protected ManualResetEvent mre = new ManualResetEvent(false);
57 57
58 /// <summary>
59 /// Stream of data representing a common IAR that can be reused in load tests.
60 /// </summary>
61 protected MemoryStream m_iarStream;
62
63 protected UserAccount m_ua1
64 = new UserAccount {
65 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
66 FirstName = "Mr",
67 LastName = "Tiddles" };
68 protected UserAccount m_ua2
69 = new UserAccount {
70 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
71 FirstName = "Lord",
72 LastName = "Lucan" };
73 string m_item1Name = "b.lsl";
74
58 private void SaveCompleted( 75 private void SaveCompleted(
59 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, 76 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
60 Exception reportedException) 77 Exception reportedException)
61 { 78 {
62 mre.Set(); 79 mre.Set();
63 } 80 }
81
82 [SetUp]
83 public void Init()
84 {
85 ConstructDefaultIarForTestLoad();
86 }
87
88 protected void ConstructDefaultIarForTestLoad()
89 {
90 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random());
91
92 MemoryStream archiveWriteStream = new MemoryStream();
93 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
94
95 InventoryItemBase item1 = new InventoryItemBase();
96 item1.Name = m_item1Name;
97 item1.AssetID = UUID.Random();
98 item1.GroupID = UUID.Random();
99 item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName);
100 //item1.CreatorId = userUuid.ToString();
101 //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
102 item1.Owner = UUID.Zero;
103
104 string item1FileName
105 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
106 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
107 tar.Close();
108 m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
109 }
64 110
65 /// <summary> 111 /// <summary>
66 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive 112 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
@@ -308,34 +354,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
308 TestHelper.InMethod(); 354 TestHelper.InMethod();
309 //log4net.Config.XmlConfigurator.Configure(); 355 //log4net.Config.XmlConfigurator.Configure();
310 356
311 string userFirstName = "Mr";
312 string userLastName = "Tiddles";
313 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555");
314 string userItemCreatorFirstName = "Lord";
315 string userItemCreatorLastName = "Lucan";
316 UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
317
318 string item1Name = "b.lsl";
319 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random());
320
321 MemoryStream archiveWriteStream = new MemoryStream();
322 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
323
324 InventoryItemBase item1 = new InventoryItemBase();
325 item1.Name = item1Name;
326 item1.AssetID = UUID.Random();
327 item1.GroupID = UUID.Random();
328 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
329 //item1.CreatorId = userUuid.ToString();
330 //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
331 item1.Owner = UUID.Zero;
332
333 string item1FileName
334 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
335 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
336 tar.Close();
337
338 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
339 SerialiserModule serialiserModule = new SerialiserModule(); 357 SerialiserModule serialiserModule = new SerialiserModule();
340 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); 358 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
341 359
@@ -344,15 +362,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
344 362
345 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 363 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
346 364
347 UserProfileTestUtils.CreateUserWithInventory( 365 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood");
348 scene, userFirstName, userLastName, userUuid, "meowfood"); 366 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
349 UserProfileTestUtils.CreateUserWithInventory(
350 scene, userItemCreatorFirstName, userItemCreatorLastName, userItemCreatorUuid, "hampshire");
351 367
352 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 368 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream);
353 369
354 InventoryItemBase foundItem1 370 InventoryItemBase foundItem1
355 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, item1Name); 371 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name);
356 372
357 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 373 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
358 374
@@ -362,31 +378,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
362// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), 378// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
363// "Loaded item non-uuid creator doesn't match original"); 379// "Loaded item non-uuid creator doesn't match original");
364 Assert.That( 380 Assert.That(
365 foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()), 381 foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()),
366 "Loaded item non-uuid creator doesn't match original"); 382 "Loaded item non-uuid creator doesn't match original");
367 383
368 Assert.That( 384 Assert.That(
369 foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), 385 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID),
370 "Loaded item uuid creator doesn't match original"); 386 "Loaded item uuid creator doesn't match original");
371 Assert.That(foundItem1.Owner, Is.EqualTo(userUuid), 387 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID),
372 "Loaded item owner doesn't match inventory reciever"); 388 "Loaded item owner doesn't match inventory reciever");
373 389
374 // Now try loading to a root child folder 390 // Now try loading to a root child folder
375 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userUuid, "xA"); 391 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA");
376 archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); 392 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
377 archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); 393 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream);
378 394
379 InventoryItemBase foundItem2 395 InventoryItemBase foundItem2
380 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, "xA/" + item1Name); 396 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name);
381 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); 397 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
382 398
383 // Now try loading to a more deeply nested folder 399 // Now try loading to a more deeply nested folder
384 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userUuid, "xB/xC"); 400 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC");
385 archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); 401 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
386 archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); 402 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream);
387 403
388 InventoryItemBase foundItem3 404 InventoryItemBase foundItem3
389 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, "xB/xC/" + item1Name); 405 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name);
390 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); 406 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
391 } 407 }
392 408