diff options
author | Sean McNamara | 2011-04-10 18:28:54 -0400 |
---|---|---|
committer | Sean McNamara | 2011-04-10 18:28:54 -0400 |
commit | 9c0f3c73b1fd56ac145e866af0316a3285ddb689 (patch) | |
tree | 03541a853c2ecf5829ac296537b14d4553ad4b2e /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |
parent | Merge git://opensimulator.org/git/opensim (diff) | |
parent | minor: remove mono compiler warnings (diff) | |
download | opensim-SC_OLD-9c0f3c73b1fd56ac145e866af0316a3285ddb689.zip opensim-SC_OLD-9c0f3c73b1fd56ac145e866af0316a3285ddb689.tar.gz opensim-SC_OLD-9c0f3c73b1fd56ac145e866af0316a3285ddb689.tar.bz2 opensim-SC_OLD-9c0f3c73b1fd56ac145e866af0316a3285ddb689.tar.xz |
Merge git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 680 |
1 files changed, 69 insertions, 611 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 76d0b85..7f156f8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -31,7 +31,6 @@ using System.IO; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using NUnit.Framework; | 33 | using NUnit.Framework; |
34 | using NUnit.Framework.SyntaxHelpers; | ||
35 | using OpenMetaverse; | 34 | using OpenMetaverse; |
36 | using OpenSim.Data; | 35 | using OpenSim.Data; |
37 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
@@ -50,182 +49,21 @@ using OpenSim.Tests.Common.Setup; | |||
50 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | 49 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests |
51 | { | 50 | { |
52 | [TestFixture] | 51 | [TestFixture] |
53 | public class InventoryArchiverTests | 52 | public class InventoryArchiverTests : InventoryArchiveTestCase |
54 | { | 53 | { |
55 | protected ManualResetEvent mre = new ManualResetEvent(false); | 54 | protected TestScene m_scene; |
56 | 55 | protected InventoryArchiverModule m_archiverModule; | |
57 | /// <summary> | 56 | |
58 | /// Stream of data representing a common IAR that can be reused in load tests. | ||
59 | /// </summary> | ||
60 | protected MemoryStream m_iarStream; | ||
61 | |||
62 | protected UserAccount m_ua1 | ||
63 | = new UserAccount { | ||
64 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), | ||
65 | FirstName = "Mr", | ||
66 | LastName = "Tiddles" }; | ||
67 | protected UserAccount m_ua2 | ||
68 | = new UserAccount { | ||
69 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), | ||
70 | FirstName = "Lord", | ||
71 | LastName = "Lucan" }; | ||
72 | string m_item1Name = "b.lsl"; | ||
73 | |||
74 | private void SaveCompleted( | ||
75 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | ||
76 | Exception reportedException) | ||
77 | { | ||
78 | mre.Set(); | ||
79 | } | ||
80 | |||
81 | [SetUp] | 57 | [SetUp] |
82 | public void Init() | 58 | public override void SetUp() |
83 | { | ||
84 | ConstructDefaultIarForTestLoad(); | ||
85 | } | ||
86 | |||
87 | protected void ConstructDefaultIarForTestLoad() | ||
88 | { | ||
89 | string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random()); | ||
90 | |||
91 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
92 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
93 | |||
94 | InventoryItemBase item1 = new InventoryItemBase(); | ||
95 | item1.Name = m_item1Name; | ||
96 | item1.AssetID = UUID.Random(); | ||
97 | item1.GroupID = UUID.Random(); | ||
98 | //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName); | ||
99 | //item1.CreatorId = userUuid.ToString(); | ||
100 | item1.CreatorId = m_ua2.PrincipalID.ToString(); | ||
101 | item1.Owner = UUID.Zero; | ||
102 | |||
103 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
104 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); | ||
105 | |||
106 | string item1FileName | ||
107 | = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); | ||
108 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService)); | ||
109 | tar.Close(); | ||
110 | m_iarStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive | ||
115 | /// (subject to change since there is no fixed format yet). | ||
116 | /// </summary> | ||
117 | [Test] | ||
118 | public void TestSavePathToIarV0_1() | ||
119 | { | 59 | { |
120 | TestHelper.InMethod(); | 60 | base.SetUp(); |
121 | // log4net.Config.XmlConfigurator.Configure(); | ||
122 | |||
123 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
124 | |||
125 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
126 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
127 | |||
128 | // Create user | ||
129 | string userFirstName = "Jock"; | ||
130 | string userLastName = "Stirrup"; | ||
131 | string userPassword = "troll"; | ||
132 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
133 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | ||
134 | 61 | ||
135 | // Create asset | 62 | SerialiserModule serialiserModule = new SerialiserModule(); |
136 | SceneObjectGroup object1; | 63 | m_archiverModule = new InventoryArchiverModule(); |
137 | SceneObjectPart part1; | ||
138 | { | ||
139 | string partName = "My Little Dog Object"; | ||
140 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
141 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
142 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
143 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
144 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
145 | |||
146 | part1 | ||
147 | = new SceneObjectPart( | ||
148 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
149 | part1.Name = partName; | ||
150 | |||
151 | object1 = new SceneObjectGroup(part1); | ||
152 | scene.AddNewSceneObject(object1, false); | ||
153 | } | ||
154 | |||
155 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
156 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
157 | scene.AssetService.Store(asset1); | ||
158 | |||
159 | // Create item | ||
160 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
161 | InventoryItemBase item1 = new InventoryItemBase(); | ||
162 | item1.Name = "My Little Dog"; | ||
163 | item1.AssetID = asset1.FullID; | ||
164 | item1.ID = item1Id; | ||
165 | InventoryFolderBase objsFolder | ||
166 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | ||
167 | item1.Folder = objsFolder.ID; | ||
168 | scene.AddInventoryItem(item1); | ||
169 | |||
170 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
171 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
172 | |||
173 | // Test saving a particular path | ||
174 | mre.Reset(); | ||
175 | archiverModule.ArchiveInventory( | ||
176 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
177 | mre.WaitOne(60000, false); | ||
178 | |||
179 | byte[] archive = archiveWriteStream.ToArray(); | ||
180 | MemoryStream archiveReadStream = new MemoryStream(archive); | ||
181 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
182 | |||
183 | //bool gotControlFile = false; | ||
184 | bool gotObject1File = false; | ||
185 | //bool gotObject2File = false; | ||
186 | string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); | ||
187 | string expectedObject1FilePath = string.Format( | ||
188 | "{0}{1}{2}", | ||
189 | ArchiveConstants.INVENTORY_PATH, | ||
190 | InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), | ||
191 | expectedObject1FileName); | ||
192 | |||
193 | string filePath; | ||
194 | TarArchiveReader.TarEntryType tarEntryType; | ||
195 | |||
196 | // Console.WriteLine("Reading archive"); | ||
197 | |||
198 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) | ||
199 | { | ||
200 | // Console.WriteLine("Got {0}", filePath); | ||
201 | |||
202 | // if (ArchiveConstants.CONTROL_FILE_PATH == filePath) | ||
203 | // { | ||
204 | // gotControlFile = true; | ||
205 | // } | ||
206 | |||
207 | if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) | ||
208 | { | ||
209 | // string fileName = filePath.Remove(0, "Objects/".Length); | ||
210 | // | ||
211 | // if (fileName.StartsWith(part1.Name)) | ||
212 | // { | ||
213 | Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); | ||
214 | gotObject1File = true; | ||
215 | // } | ||
216 | // else if (fileName.StartsWith(part2.Name)) | ||
217 | // { | ||
218 | // Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | ||
219 | // gotObject2File = true; | ||
220 | // } | ||
221 | } | ||
222 | } | ||
223 | |||
224 | // Assert.That(gotControlFile, Is.True, "No control file in archive"); | ||
225 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); | ||
226 | // Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | ||
227 | 64 | ||
228 | // TODO: Test presence of more files and contents of files. | 65 | m_scene = SceneSetupHelpers.SetupScene("Inventory"); |
66 | SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); | ||
229 | } | 67 | } |
230 | 68 | ||
231 | /// <summary> | 69 | /// <summary> |
@@ -238,17 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
238 | TestHelper.InMethod(); | 76 | TestHelper.InMethod(); |
239 | // log4net.Config.XmlConfigurator.Configure(); | 77 | // log4net.Config.XmlConfigurator.Configure(); |
240 | 78 | ||
241 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
242 | |||
243 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
244 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
245 | |||
246 | // Create user | 79 | // Create user |
247 | string userFirstName = "Jock"; | 80 | string userFirstName = "Jock"; |
248 | string userLastName = "Stirrup"; | 81 | string userLastName = "Stirrup"; |
249 | string userPassword = "troll"; | 82 | string userPassword = "troll"; |
250 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 83 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
251 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | 84 | UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); |
252 | 85 | ||
253 | // Create asset | 86 | // Create asset |
254 | SceneObjectGroup object1; | 87 | SceneObjectGroup object1; |
@@ -267,12 +100,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
267 | part1.Name = partName; | 100 | part1.Name = partName; |
268 | 101 | ||
269 | object1 = new SceneObjectGroup(part1); | 102 | object1 = new SceneObjectGroup(part1); |
270 | scene.AddNewSceneObject(object1, false); | 103 | m_scene.AddNewSceneObject(object1, false); |
271 | } | 104 | } |
272 | 105 | ||
273 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 106 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
274 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 107 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
275 | scene.AssetService.Store(asset1); | 108 | m_scene.AssetService.Store(asset1); |
276 | 109 | ||
277 | // Create item | 110 | // Create item |
278 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | 111 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); |
@@ -282,15 +115,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
282 | item1.AssetID = asset1.FullID; | 115 | item1.AssetID = asset1.FullID; |
283 | item1.ID = item1Id; | 116 | item1.ID = item1Id; |
284 | InventoryFolderBase objsFolder | 117 | InventoryFolderBase objsFolder |
285 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | 118 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0]; |
286 | item1.Folder = objsFolder.ID; | 119 | item1.Folder = objsFolder.ID; |
287 | scene.AddInventoryItem(item1); | 120 | m_scene.AddInventoryItem(item1); |
288 | 121 | ||
289 | MemoryStream archiveWriteStream = new MemoryStream(); | 122 | MemoryStream archiveWriteStream = new MemoryStream(); |
290 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | 123 | m_archiverModule.OnInventoryArchiveSaved += SaveCompleted; |
291 | 124 | ||
292 | mre.Reset(); | 125 | mre.Reset(); |
293 | archiverModule.ArchiveInventory( | 126 | m_archiverModule.ArchiveInventory( |
294 | Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); | 127 | Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); |
295 | mre.WaitOne(60000, false); | 128 | mre.WaitOne(60000, false); |
296 | 129 | ||
@@ -346,474 +179,99 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
346 | } | 179 | } |
347 | 180 | ||
348 | /// <summary> | 181 | /// <summary> |
349 | /// Test that things work when the load path specified starts with a slash | 182 | /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized |
350 | /// </summary> | 183 | /// objects. |
184 | /// </summary> | ||
351 | [Test] | 185 | [Test] |
352 | public void TestLoadIarPathStartsWithSlash() | 186 | public void TestLoadIarCreatorAccountPresent() |
353 | { | 187 | { |
354 | TestHelper.InMethod(); | 188 | TestHelper.InMethod(); |
355 | // log4net.Config.XmlConfigurator.Configure(); | 189 | // log4net.Config.XmlConfigurator.Configure(); |
356 | |||
357 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
358 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
359 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
360 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
361 | |||
362 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password"); | ||
363 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream); | ||
364 | 190 | ||
191 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); | ||
192 | |||
193 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream); | ||
365 | InventoryItemBase foundItem1 | 194 | InventoryItemBase foundItem1 |
366 | = InventoryArchiveUtils.FindItemByPath( | 195 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name); |
367 | scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); | 196 | |
197 | Assert.That( | ||
198 | foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()), | ||
199 | "Loaded item non-uuid creator doesn't match original"); | ||
200 | Assert.That( | ||
201 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID), | ||
202 | "Loaded item uuid creator doesn't match original"); | ||
203 | Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID), | ||
204 | "Loaded item owner doesn't match inventory reciever"); | ||
368 | 205 | ||
369 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); | 206 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
207 | string xmlData = Utils.BytesToString(asset1.Data); | ||
208 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
209 | |||
210 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID)); | ||
370 | } | 211 | } |
371 | 212 | ||
372 | /// <summary> | 213 | /// <summary> |
373 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 214 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
374 | /// an account exists with the creator name. | 215 | /// an account exists with the same name as the creator, though not the same id. |
375 | /// </summary> | 216 | /// </summary> |
376 | /// | ||
377 | /// This test also does some deeper probing of loading into nested inventory structures | ||
378 | [Test] | 217 | [Test] |
379 | public void TestLoadIarV0_1ExistingUsers() | 218 | public void TestLoadIarV0_1SameNameCreator() |
380 | { | 219 | { |
381 | TestHelper.InMethod(); | 220 | TestHelper.InMethod(); |
382 | //log4net.Config.XmlConfigurator.Configure(); | 221 | // log4net.Config.XmlConfigurator.Configure(); |
383 | |||
384 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
385 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
386 | |||
387 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | ||
388 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
389 | |||
390 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
391 | 222 | ||
392 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); | 223 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); |
393 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); | 224 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); |
394 | 225 | ||
395 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); | 226 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); |
396 | |||
397 | InventoryItemBase foundItem1 | 227 | InventoryItemBase foundItem1 |
398 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); | 228 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
399 | |||
400 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | ||
401 | 229 | ||
402 | // We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the | ||
403 | // UUID, not the OSPA itself. | ||
404 | // Assert.That( | ||
405 | // foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), | ||
406 | // "Loaded item non-uuid creator doesn't match original"); | ||
407 | Assert.That( | 230 | Assert.That( |
408 | foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()), | 231 | foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()), |
409 | "Loaded item non-uuid creator doesn't match original"); | 232 | "Loaded item non-uuid creator doesn't match original"); |
410 | |||
411 | Assert.That( | 233 | Assert.That( |
412 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID), | 234 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID), |
413 | "Loaded item uuid creator doesn't match original"); | 235 | "Loaded item uuid creator doesn't match original"); |
414 | Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), | 236 | Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID), |
415 | "Loaded item owner doesn't match inventory reciever"); | 237 | "Loaded item owner doesn't match inventory reciever"); |
416 | |||
417 | // Now try loading to a root child folder | ||
418 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA"); | ||
419 | MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); | ||
420 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream); | ||
421 | |||
422 | InventoryItemBase foundItem2 | ||
423 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name); | ||
424 | Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); | ||
425 | |||
426 | // Now try loading to a more deeply nested folder | ||
427 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC"); | ||
428 | archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); | ||
429 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream); | ||
430 | |||
431 | InventoryItemBase foundItem3 | ||
432 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name); | ||
433 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); | ||
434 | } | ||
435 | |||
436 | [Test] | ||
437 | public void TestIarV0_1WithEscapedChars() | ||
438 | { | ||
439 | TestHelper.InMethod(); | ||
440 | // log4net.Config.XmlConfigurator.Configure(); | ||
441 | |||
442 | string itemName = "You & you are a mean/man/"; | ||
443 | string humanEscapedItemName = @"You & you are a mean\/man\/"; | ||
444 | string userPassword = "meowfood"; | ||
445 | |||
446 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
447 | |||
448 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
449 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
450 | |||
451 | // Create user | ||
452 | string userFirstName = "Jock"; | ||
453 | string userLastName = "Stirrup"; | ||
454 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
455 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood"); | ||
456 | |||
457 | // Create asset | ||
458 | SceneObjectGroup object1; | ||
459 | SceneObjectPart part1; | ||
460 | { | ||
461 | string partName = "part name"; | ||
462 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
463 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
464 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
465 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
466 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
467 | |||
468 | part1 | ||
469 | = new SceneObjectPart( | ||
470 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
471 | part1.Name = partName; | ||
472 | |||
473 | object1 = new SceneObjectGroup(part1); | ||
474 | scene.AddNewSceneObject(object1, false); | ||
475 | } | ||
476 | |||
477 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
478 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
479 | scene.AssetService.Store(asset1); | ||
480 | |||
481 | // Create item | ||
482 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
483 | InventoryItemBase item1 = new InventoryItemBase(); | ||
484 | item1.Name = itemName; | ||
485 | item1.AssetID = asset1.FullID; | ||
486 | item1.ID = item1Id; | ||
487 | InventoryFolderBase objsFolder | ||
488 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | ||
489 | item1.Folder = objsFolder.ID; | ||
490 | scene.AddInventoryItem(item1); | ||
491 | |||
492 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
493 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
494 | |||
495 | mre.Reset(); | ||
496 | archiverModule.ArchiveInventory( | ||
497 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
498 | mre.WaitOne(60000, false); | ||
499 | |||
500 | // LOAD ITEM | ||
501 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
502 | 238 | ||
503 | archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); | 239 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
504 | 240 | string xmlData = Utils.BytesToString(asset1.Data); | |
505 | InventoryItemBase foundItem1 | 241 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
506 | = InventoryArchiveUtils.FindItemByPath( | ||
507 | scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); | ||
508 | 242 | ||
509 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | 243 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID)); |
510 | // Assert.That( | ||
511 | // foundItem1.CreatorId, Is.EqualTo(userUuid), | ||
512 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
513 | Assert.That( | ||
514 | foundItem1.Name, Is.EqualTo(itemName), | ||
515 | "Loaded item name doesn't match saved name"); | ||
516 | } | 244 | } |
517 | 245 | ||
518 | /// <summary> | 246 | /// <summary> |
519 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 247 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
520 | /// embedded creators do not exist in the system | 248 | /// the creator or an account with the creator's name does not exist within the system. |
521 | /// </summary> | 249 | /// </summary> |
522 | /// | ||
523 | /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature | ||
524 | /// (as tested in the a later commented out test) | ||
525 | /// This test is currently disabled | ||
526 | [Test] | 250 | [Test] |
527 | public void TestLoadIarV0_1AbsentUsers() | 251 | public void TestLoadIarV0_1AbsentCreator() |
528 | { | 252 | { |
529 | TestHelper.InMethod(); | 253 | TestHelper.InMethod(); |
530 | //log4net.Config.XmlConfigurator.Configure(); | 254 | // log4net.Config.XmlConfigurator.Configure(); |
531 | |||
532 | string userFirstName = "Charlie"; | ||
533 | string userLastName = "Chan"; | ||
534 | UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999"); | ||
535 | string userItemCreatorFirstName = "Bat"; | ||
536 | string userItemCreatorLastName = "Man"; | ||
537 | //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888"); | ||
538 | |||
539 | string itemName = "b.lsl"; | ||
540 | string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); | ||
541 | |||
542 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
543 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
544 | |||
545 | InventoryItemBase item1 = new InventoryItemBase(); | ||
546 | item1.Name = itemName; | ||
547 | item1.AssetID = UUID.Random(); | ||
548 | item1.GroupID = UUID.Random(); | ||
549 | item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); | ||
550 | //item1.CreatorId = userUuid.ToString(); | ||
551 | //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; | ||
552 | item1.Owner = UUID.Zero; | ||
553 | |||
554 | string item1FileName | ||
555 | = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); | ||
556 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null)); | ||
557 | tar.Close(); | ||
558 | |||
559 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
560 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
561 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
562 | |||
563 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | ||
564 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
565 | |||
566 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
567 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood"); | ||
568 | 255 | ||
569 | archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); | 256 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "password"); |
257 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream); | ||
570 | 258 | ||
571 | InventoryItemBase foundItem1 | 259 | InventoryItemBase foundItem1 |
572 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName); | 260 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
573 | 261 | ||
574 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | 262 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); |
575 | // Assert.That( | ||
576 | // foundItem1.CreatorId, Is.EqualTo(userUuid), | ||
577 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
578 | Assert.That( | 263 | Assert.That( |
579 | foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), | 264 | foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()), |
265 | "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
266 | Assert.That( | ||
267 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID), | ||
580 | "Loaded item uuid creator doesn't match that of the loading user"); | 268 | "Loaded item uuid creator doesn't match that of the loading user"); |
581 | } | ||
582 | |||
583 | /// <summary> | ||
584 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | ||
585 | /// no account exists with the creator name | ||
586 | /// </summary> | ||
587 | /// Disabled since temporary profiles have not yet been implemented. | ||
588 | /// | ||
589 | //[Test] | ||
590 | //public void TestLoadIarV0_1TempProfiles() | ||
591 | //{ | ||
592 | // TestHelper.InMethod(); | ||
593 | |||
594 | // //log4net.Config.XmlConfigurator.Configure(); | ||
595 | 269 | ||
596 | // string userFirstName = "Dennis"; | 270 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
597 | // string userLastName = "Menace"; | 271 | string xmlData = Utils.BytesToString(asset1.Data); |
598 | // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); | 272 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
599 | // string user2FirstName = "Walter"; | ||
600 | // string user2LastName = "Mitty"; | ||
601 | 273 | ||
602 | // string itemName = "b.lsl"; | 274 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID)); |
603 | // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); | ||
604 | |||
605 | // MemoryStream archiveWriteStream = new MemoryStream(); | ||
606 | // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
607 | |||
608 | // InventoryItemBase item1 = new InventoryItemBase(); | ||
609 | // item1.Name = itemName; | ||
610 | // item1.AssetID = UUID.Random(); | ||
611 | // item1.GroupID = UUID.Random(); | ||
612 | // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName); | ||
613 | // item1.Owner = UUID.Zero; | ||
614 | |||
615 | // string item1FileName | ||
616 | // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); | ||
617 | // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); | ||
618 | // tar.Close(); | ||
619 | |||
620 | // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
621 | // SerialiserModule serialiserModule = new SerialiserModule(); | ||
622 | // InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
623 | |||
624 | // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | ||
625 | // Scene scene = SceneSetupHelpers.SetupScene(); | ||
626 | // IUserAdminService userAdminService = scene.CommsManager.UserAdminService; | ||
627 | |||
628 | // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
629 | // userAdminService.AddUser( | ||
630 | // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); | ||
631 | |||
632 | // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); | ||
633 | |||
634 | // // Check that a suitable temporary user profile has been created. | ||
635 | // UserProfileData user2Profile | ||
636 | // = scene.CommsManager.UserService.GetUserProfile( | ||
637 | // OspResolver.HashName(user2FirstName + " " + user2LastName)); | ||
638 | // Assert.That(user2Profile, Is.Not.Null); | ||
639 | // Assert.That(user2Profile.FirstName == user2FirstName); | ||
640 | // Assert.That(user2Profile.SurName == user2LastName); | ||
641 | |||
642 | // CachedUserInfo userInfo | ||
643 | // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | ||
644 | // userInfo.OnInventoryReceived += InventoryReceived; | ||
645 | |||
646 | // lock (this) | ||
647 | // { | ||
648 | // userInfo.FetchInventory(); | ||
649 | // Monitor.Wait(this, 60000); | ||
650 | // } | ||
651 | |||
652 | // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); | ||
653 | |||
654 | // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); | ||
655 | // Assert.That( | ||
656 | // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName))); | ||
657 | // Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); | ||
658 | |||
659 | // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); | ||
660 | //} | ||
661 | |||
662 | /// <summary> | ||
663 | /// Test replication of an archive path to the user's inventory. | ||
664 | /// </summary> | ||
665 | [Test] | ||
666 | public void TestNewIarPath() | ||
667 | { | ||
668 | TestHelper.InMethod(); | ||
669 | // log4net.Config.XmlConfigurator.Configure(); | ||
670 | |||
671 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
672 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
673 | |||
674 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); | ||
675 | HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>(); | ||
676 | |||
677 | string folder1Name = "1"; | ||
678 | string folder2aName = "2a"; | ||
679 | string folder2bName = "2b"; | ||
680 | |||
681 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); | ||
682 | string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random()); | ||
683 | string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random()); | ||
684 | |||
685 | string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName }); | ||
686 | string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName }); | ||
687 | |||
688 | { | ||
689 | // Test replication of path1 | ||
690 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
691 | .ReplicateArchivePathToUserInventory( | ||
692 | iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
693 | foldersCreated, nodesLoaded); | ||
694 | |||
695 | List<InventoryFolderBase> folder1Candidates | ||
696 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); | ||
697 | Assert.That(folder1Candidates.Count, Is.EqualTo(1)); | ||
698 | |||
699 | InventoryFolderBase folder1 = folder1Candidates[0]; | ||
700 | List<InventoryFolderBase> folder2aCandidates | ||
701 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); | ||
702 | Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); | ||
703 | } | ||
704 | |||
705 | { | ||
706 | // Test replication of path2 | ||
707 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
708 | .ReplicateArchivePathToUserInventory( | ||
709 | iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
710 | foldersCreated, nodesLoaded); | ||
711 | |||
712 | List<InventoryFolderBase> folder1Candidates | ||
713 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); | ||
714 | Assert.That(folder1Candidates.Count, Is.EqualTo(1)); | ||
715 | |||
716 | InventoryFolderBase folder1 = folder1Candidates[0]; | ||
717 | |||
718 | List<InventoryFolderBase> folder2aCandidates | ||
719 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); | ||
720 | Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); | ||
721 | |||
722 | List<InventoryFolderBase> folder2bCandidates | ||
723 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName); | ||
724 | Assert.That(folder2bCandidates.Count, Is.EqualTo(1)); | ||
725 | } | ||
726 | } | ||
727 | |||
728 | /// <summary> | ||
729 | /// Test replication of a partly existing archive path to the user's inventory. This should create | ||
730 | /// a duplicate path without the merge option. | ||
731 | /// </summary> | ||
732 | [Test] | ||
733 | public void TestPartExistingIarPath() | ||
734 | { | ||
735 | TestHelper.InMethod(); | ||
736 | //log4net.Config.XmlConfigurator.Configure(); | ||
737 | |||
738 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
739 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
740 | |||
741 | string folder1ExistingName = "a"; | ||
742 | string folder2Name = "b"; | ||
743 | |||
744 | InventoryFolderBase folder1 | ||
745 | = UserInventoryTestUtils.CreateInventoryFolder( | ||
746 | scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
747 | |||
748 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); | ||
749 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | ||
750 | |||
751 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); | ||
752 | |||
753 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
754 | .ReplicateArchivePathToUserInventory( | ||
755 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
756 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); | ||
757 | |||
758 | List<InventoryFolderBase> folder1PostCandidates | ||
759 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
760 | Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); | ||
761 | |||
762 | // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. | ||
763 | InventoryFolderBase folder1Post = null; | ||
764 | foreach (InventoryFolderBase folder in folder1PostCandidates) | ||
765 | { | ||
766 | if (folder.ID != folder1.ID) | ||
767 | { | ||
768 | folder1Post = folder; | ||
769 | break; | ||
770 | } | ||
771 | } | ||
772 | // Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); | ||
773 | |||
774 | List<InventoryFolderBase> folder2PostCandidates | ||
775 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); | ||
776 | Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); | ||
777 | } | ||
778 | |||
779 | /// <summary> | ||
780 | /// Test replication of a partly existing archive path to the user's inventory. This should create | ||
781 | /// a merged path. | ||
782 | /// </summary> | ||
783 | [Test] | ||
784 | public void TestMergeIarPath() | ||
785 | { | ||
786 | TestHelper.InMethod(); | ||
787 | // log4net.Config.XmlConfigurator.Configure(); | ||
788 | |||
789 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
790 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
791 | |||
792 | string folder1ExistingName = "a"; | ||
793 | string folder2Name = "b"; | ||
794 | |||
795 | InventoryFolderBase folder1 | ||
796 | = UserInventoryTestUtils.CreateInventoryFolder( | ||
797 | scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
798 | |||
799 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); | ||
800 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | ||
801 | |||
802 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); | ||
803 | |||
804 | new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true) | ||
805 | .ReplicateArchivePathToUserInventory( | ||
806 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
807 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); | ||
808 | |||
809 | List<InventoryFolderBase> folder1PostCandidates | ||
810 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
811 | Assert.That(folder1PostCandidates.Count, Is.EqualTo(1)); | ||
812 | Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID)); | ||
813 | |||
814 | List<InventoryFolderBase> folder2PostCandidates | ||
815 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b"); | ||
816 | Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); | ||
817 | } | 275 | } |
818 | } | 276 | } |
819 | } \ No newline at end of file | 277 | } \ No newline at end of file |