diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 126 |
1 files changed, 81 insertions, 45 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index b52014b..7f156f8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -50,7 +50,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
50 | { | 50 | { |
51 | [TestFixture] | 51 | [TestFixture] |
52 | public class InventoryArchiverTests : InventoryArchiveTestCase | 52 | public class InventoryArchiverTests : InventoryArchiveTestCase |
53 | { | 53 | { |
54 | protected TestScene m_scene; | ||
55 | protected InventoryArchiverModule m_archiverModule; | ||
56 | |||
57 | [SetUp] | ||
58 | public override void SetUp() | ||
59 | { | ||
60 | base.SetUp(); | ||
61 | |||
62 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
63 | m_archiverModule = new InventoryArchiverModule(); | ||
64 | |||
65 | m_scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
66 | SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); | ||
67 | } | ||
68 | |||
54 | /// <summary> | 69 | /// <summary> |
55 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive | 70 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive |
56 | /// (subject to change since there is no fixed format yet). | 71 | /// (subject to change since there is no fixed format yet). |
@@ -61,17 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
61 | TestHelper.InMethod(); | 76 | TestHelper.InMethod(); |
62 | // log4net.Config.XmlConfigurator.Configure(); | 77 | // log4net.Config.XmlConfigurator.Configure(); |
63 | 78 | ||
64 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
65 | |||
66 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
67 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
68 | |||
69 | // Create user | 79 | // Create user |
70 | string userFirstName = "Jock"; | 80 | string userFirstName = "Jock"; |
71 | string userLastName = "Stirrup"; | 81 | string userLastName = "Stirrup"; |
72 | string userPassword = "troll"; | 82 | string userPassword = "troll"; |
73 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 83 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
74 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | 84 | UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); |
75 | 85 | ||
76 | // Create asset | 86 | // Create asset |
77 | SceneObjectGroup object1; | 87 | SceneObjectGroup object1; |
@@ -90,12 +100,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
90 | part1.Name = partName; | 100 | part1.Name = partName; |
91 | 101 | ||
92 | object1 = new SceneObjectGroup(part1); | 102 | object1 = new SceneObjectGroup(part1); |
93 | scene.AddNewSceneObject(object1, false); | 103 | m_scene.AddNewSceneObject(object1, false); |
94 | } | 104 | } |
95 | 105 | ||
96 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 106 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
97 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 107 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
98 | scene.AssetService.Store(asset1); | 108 | m_scene.AssetService.Store(asset1); |
99 | 109 | ||
100 | // Create item | 110 | // Create item |
101 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | 111 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); |
@@ -105,15 +115,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
105 | item1.AssetID = asset1.FullID; | 115 | item1.AssetID = asset1.FullID; |
106 | item1.ID = item1Id; | 116 | item1.ID = item1Id; |
107 | InventoryFolderBase objsFolder | 117 | InventoryFolderBase objsFolder |
108 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | 118 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0]; |
109 | item1.Folder = objsFolder.ID; | 119 | item1.Folder = objsFolder.ID; |
110 | scene.AddInventoryItem(item1); | 120 | m_scene.AddInventoryItem(item1); |
111 | 121 | ||
112 | MemoryStream archiveWriteStream = new MemoryStream(); | 122 | MemoryStream archiveWriteStream = new MemoryStream(); |
113 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | 123 | m_archiverModule.OnInventoryArchiveSaved += SaveCompleted; |
114 | 124 | ||
115 | mre.Reset(); | 125 | mre.Reset(); |
116 | archiverModule.ArchiveInventory( | 126 | m_archiverModule.ArchiveInventory( |
117 | Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); | 127 | Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); |
118 | mre.WaitOne(60000, false); | 128 | mre.WaitOne(60000, false); |
119 | 129 | ||
@@ -169,6 +179,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
169 | } | 179 | } |
170 | 180 | ||
171 | /// <summary> | 181 | /// <summary> |
182 | /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized | ||
183 | /// objects. | ||
184 | /// </summary> | ||
185 | [Test] | ||
186 | public void TestLoadIarCreatorAccountPresent() | ||
187 | { | ||
188 | TestHelper.InMethod(); | ||
189 | // log4net.Config.XmlConfigurator.Configure(); | ||
190 | |||
191 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); | ||
192 | |||
193 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream); | ||
194 | InventoryItemBase foundItem1 | ||
195 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, 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"); | ||
205 | |||
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)); | ||
211 | } | ||
212 | |||
213 | /// <summary> | ||
172 | /// 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 |
173 | /// an account exists with the same name as the creator, though not the same id. | 215 | /// an account exists with the same name as the creator, though not the same id. |
174 | /// </summary> | 216 | /// </summary> |
@@ -177,35 +219,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
177 | { | 219 | { |
178 | TestHelper.InMethod(); | 220 | TestHelper.InMethod(); |
179 | // log4net.Config.XmlConfigurator.Configure(); | 221 | // log4net.Config.XmlConfigurator.Configure(); |
180 | |||
181 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
182 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
183 | |||
184 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | ||
185 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
186 | |||
187 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
188 | 222 | ||
189 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); | 223 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); |
190 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua3, "hampshire"); | 224 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); |
191 | 225 | ||
192 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); | 226 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); |
193 | InventoryItemBase foundItem1 | 227 | InventoryItemBase foundItem1 |
194 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); | 228 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
195 | 229 | ||
196 | // We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the | ||
197 | // UUID, not the OSPA itself. | ||
198 | // Assert.That( | ||
199 | // foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), | ||
200 | // "Loaded item non-uuid creator doesn't match original"); | ||
201 | Assert.That( | 230 | Assert.That( |
202 | foundItem1.CreatorId, Is.EqualTo(m_ua3.PrincipalID.ToString()), | 231 | foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()), |
203 | "Loaded item non-uuid creator doesn't match original"); | 232 | "Loaded item non-uuid creator doesn't match original"); |
204 | Assert.That( | 233 | Assert.That( |
205 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua3.PrincipalID), | 234 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID), |
206 | "Loaded item uuid creator doesn't match original"); | 235 | "Loaded item uuid creator doesn't match original"); |
207 | Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), | 236 | Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID), |
208 | "Loaded item owner doesn't match inventory reciever"); | 237 | "Loaded item owner doesn't match inventory reciever"); |
238 | |||
239 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); | ||
240 | string xmlData = Utils.BytesToString(asset1.Data); | ||
241 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
242 | |||
243 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID)); | ||
209 | } | 244 | } |
210 | 245 | ||
211 | /// <summary> | 246 | /// <summary> |
@@ -218,24 +253,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
218 | TestHelper.InMethod(); | 253 | TestHelper.InMethod(); |
219 | // log4net.Config.XmlConfigurator.Configure(); | 254 | // log4net.Config.XmlConfigurator.Configure(); |
220 | 255 | ||
221 | SerialiserModule serialiserModule = new SerialiserModule(); | 256 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "password"); |
222 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 257 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream); |
223 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
224 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
225 | |||
226 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password"); | ||
227 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "password", m_iarStream); | ||
228 | 258 | ||
229 | InventoryItemBase foundItem1 | 259 | InventoryItemBase foundItem1 |
230 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); | 260 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
231 | 261 | ||
232 | 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"); |
233 | // Assert.That( | ||
234 | // foundItem1.CreatorId, Is.EqualTo(userUuid), | ||
235 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
236 | Assert.That( | 263 | Assert.That( |
237 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua1.PrincipalID), | 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), | ||
238 | "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"); |
269 | |||
270 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); | ||
271 | string xmlData = Utils.BytesToString(asset1.Data); | ||
272 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
273 | |||
274 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID)); | ||
239 | } | 275 | } |
240 | } | 276 | } |
241 | } \ No newline at end of file | 277 | } \ No newline at end of file |