aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs157
1 files changed, 76 insertions, 81 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 5b91e0d..d5fc666 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
80 public void TestSaveIarV0_1() 80 public void TestSaveIarV0_1()
81 { 81 {
82 TestHelper.InMethod(); 82 TestHelper.InMethod();
83 log4net.Config.XmlConfigurator.Configure(); 83// log4net.Config.XmlConfigurator.Configure();
84 84
85 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); 85 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
86 86
@@ -195,99 +195,94 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
195 /// </summary> 195 /// </summary>
196 /// 196 ///
197 /// This test also does some deeper probing of loading into nested inventory structures 197 /// This test also does some deeper probing of loading into nested inventory structures
198 /// REFACTORING PROBLEM. This needs to be rewritten. 198 [Test]
199// [Test] 199 public void TestLoadIarV0_1ExistingUsers()
200// public void TestLoadIarV0_1ExistingUsers() 200 {
201// { 201 TestHelper.InMethod();
202// TestHelper.InMethod();
203 202
204// //log4net.Config.XmlConfigurator.Configure(); 203 //log4net.Config.XmlConfigurator.Configure();
205 204
206// string userFirstName = "Mr"; 205 string userFirstName = "Mr";
207// string userLastName = "Tiddles"; 206 string userLastName = "Tiddles";
208// UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555"); 207 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555");
209// string userItemCreatorFirstName = "Lord"; 208 string userItemCreatorFirstName = "Lord";
210// string userItemCreatorLastName = "Lucan"; 209 string userItemCreatorLastName = "Lucan";
211// UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 210 UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
212 211
213// string item1Name = "b.lsl"; 212 string item1Name = "b.lsl";
214// string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random()); 213 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random());
215
216// MemoryStream archiveWriteStream = new MemoryStream();
217// TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
218 214
219// InventoryItemBase item1 = new InventoryItemBase(); 215 MemoryStream archiveWriteStream = new MemoryStream();
220// item1.Name = item1Name; 216 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
221// item1.AssetID = UUID.Random();
222// item1.GroupID = UUID.Random();
223// item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
224// //item1.CreatorId = userUuid.ToString();
225// //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
226// item1.Owner = UUID.Zero;
227
228// string item1FileName
229// = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
230// tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
231// tar.Close();
232 217
233// MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 218 InventoryItemBase item1 = new InventoryItemBase();
234// SerialiserModule serialiserModule = new SerialiserModule(); 219 item1.Name = item1Name;
235// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); 220 item1.AssetID = UUID.Random();
221 item1.GroupID = UUID.Random();
222 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
223 //item1.CreatorId = userUuid.ToString();
224 //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
225 item1.Owner = UUID.Zero;
226
227 string item1FileName
228 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
229 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
230 tar.Close();
231
232 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
233 SerialiserModule serialiserModule = new SerialiserModule();
234 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
236 235
237// // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene 236 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
238// Scene scene = SceneSetupHelpers.SetupScene("inventory"); 237 Scene scene = SceneSetupHelpers.SetupScene("inventory");
239// IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
240 238
241// SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 239 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
242// userAdminService.AddUser( 240
243// userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); 241 UserProfileTestUtils.CreateUserWithInventory(
244// userAdminService.AddUser( 242 scene, userFirstName, userLastName, userUuid, "meowfood");
245// userItemCreatorFirstName, userItemCreatorLastName, "hampshire", 243 UserProfileTestUtils.CreateUserWithInventory(
246// String.Empty, 1000, 1000, userItemCreatorUuid); 244 scene, userItemCreatorFirstName, userItemCreatorLastName, userItemCreatorUuid, "hampshire");
247 245
248// archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 246 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream);
249
250// CachedUserInfo userInfo
251// = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
252 247
253// InventoryItemBase foundItem1 248 InventoryItemBase foundItem1
254// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name); 249 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, item1Name);
255 250
256// Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 251 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
257 252
258//// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the 253// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
259//// UUID, not the OSPA itself. 254// UUID, not the OSPA itself.
260//// Assert.That(
261//// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
262//// "Loaded item non-uuid creator doesn't match original");
263// Assert.That( 255// Assert.That(
264// foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()), 256// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
265// "Loaded item non-uuid creator doesn't match original"); 257// "Loaded item non-uuid creator doesn't match original");
266 258 Assert.That(
267// Assert.That( 259 foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()),
268// foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), 260 "Loaded item non-uuid creator doesn't match original");
269// "Loaded item uuid creator doesn't match original"); 261
270// Assert.That(foundItem1.Owner, Is.EqualTo(userUuid), 262 Assert.That(
271// "Loaded item owner doesn't match inventory reciever"); 263 foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
272 264 "Loaded item uuid creator doesn't match original");
273// // Now try loading to a root child folder 265 Assert.That(foundItem1.Owner, Is.EqualTo(userUuid),
274// UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA"); 266 "Loaded item owner doesn't match inventory reciever");
275// archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); 267
276// archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); 268 // Now try loading to a root child folder
277 269 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userUuid, "xA");
278// InventoryItemBase foundItem2 270 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
279// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name); 271 archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream);
280// Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); 272
281 273 InventoryItemBase foundItem2
282// // Now try loading to a more deeply nested folder 274 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, "xA/" + item1Name);
283// UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC"); 275 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
284// archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); 276
285// archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); 277 // Now try loading to a more deeply nested folder
286 278 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userUuid, "xB/xC");
287// InventoryItemBase foundItem3 279 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
288// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name); 280 archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream);
289// Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); 281
290 //} 282 InventoryItemBase foundItem3
283 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, "xB/xC/" + item1Name);
284 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
285 }
291 286
292 // REFACTORING PROBLEM. Needs rewrite. 287 // REFACTORING PROBLEM. Needs rewrite.
293// [Test] 288// [Test]