diff options
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 104 |
1 files changed, 102 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d97311a..ae3ab21 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -123,11 +123,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
123 | } | 123 | } |
124 | 124 | ||
125 | /// <summary> | 125 | /// <summary> |
126 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive | 126 | /// Test saving a single inventory item to an IAR |
127 | /// (subject to change since there is no fixed format yet). | 127 | /// (subject to change since there is no fixed format yet). |
128 | /// </summary> | 128 | /// </summary> |
129 | [Test] | 129 | [Test] |
130 | public void TestSaveItemToIarV0_1() | 130 | public void TestSaveItemToIar() |
131 | { | 131 | { |
132 | TestHelper.InMethod(); | 132 | TestHelper.InMethod(); |
133 | // log4net.Config.XmlConfigurator.Configure(); | 133 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -217,6 +217,106 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
217 | 217 | ||
218 | // TODO: Test presence of more files and contents of files. | 218 | // TODO: Test presence of more files and contents of files. |
219 | } | 219 | } |
220 | |||
221 | /// <summary> | ||
222 | /// Test saving a single inventory item to an IAR without its asset | ||
223 | /// </summary> | ||
224 | [Test] | ||
225 | public void TestSaveItemToIarNoAssets() | ||
226 | { | ||
227 | TestHelper.InMethod(); | ||
228 | // log4net.Config.XmlConfigurator.Configure(); | ||
229 | |||
230 | // Create user | ||
231 | string userFirstName = "Jock"; | ||
232 | string userLastName = "Stirrup"; | ||
233 | string userPassword = "troll"; | ||
234 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
235 | UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); | ||
236 | |||
237 | // Create asset | ||
238 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
239 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); | ||
240 | |||
241 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
242 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
243 | m_scene.AssetService.Store(asset1); | ||
244 | |||
245 | // Create item | ||
246 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
247 | string item1Name = "My Little Dog"; | ||
248 | InventoryItemBase item1 = new InventoryItemBase(); | ||
249 | item1.Name = item1Name; | ||
250 | item1.AssetID = asset1.FullID; | ||
251 | item1.ID = item1Id; | ||
252 | InventoryFolderBase objsFolder | ||
253 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0]; | ||
254 | item1.Folder = objsFolder.ID; | ||
255 | m_scene.AddInventoryItem(item1); | ||
256 | |||
257 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
258 | |||
259 | Dictionary<string, Object> options = new Dictionary<string, Object>(); | ||
260 | options.Add("noassets", true); | ||
261 | |||
262 | // When we're not saving assets, archiving is being done synchronously. | ||
263 | m_archiverModule.ArchiveInventory( | ||
264 | Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream, options); | ||
265 | |||
266 | byte[] archive = archiveWriteStream.ToArray(); | ||
267 | MemoryStream archiveReadStream = new MemoryStream(archive); | ||
268 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
269 | |||
270 | //bool gotControlFile = false; | ||
271 | bool gotObject1File = false; | ||
272 | //bool gotObject2File = false; | ||
273 | string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); | ||
274 | string expectedObject1FilePath = string.Format( | ||
275 | "{0}{1}", | ||
276 | ArchiveConstants.INVENTORY_PATH, | ||
277 | expectedObject1FileName); | ||
278 | |||
279 | string filePath; | ||
280 | TarArchiveReader.TarEntryType tarEntryType; | ||
281 | |||
282 | // Console.WriteLine("Reading archive"); | ||
283 | |||
284 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) | ||
285 | { | ||
286 | Console.WriteLine("Got {0}", filePath); | ||
287 | |||
288 | // if (ArchiveConstants.CONTROL_FILE_PATH == filePath) | ||
289 | // { | ||
290 | // gotControlFile = true; | ||
291 | // } | ||
292 | |||
293 | if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) | ||
294 | { | ||
295 | // string fileName = filePath.Remove(0, "Objects/".Length); | ||
296 | // | ||
297 | // if (fileName.StartsWith(part1.Name)) | ||
298 | // { | ||
299 | Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); | ||
300 | gotObject1File = true; | ||
301 | // } | ||
302 | // else if (fileName.StartsWith(part2.Name)) | ||
303 | // { | ||
304 | // Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | ||
305 | // gotObject2File = true; | ||
306 | // } | ||
307 | } | ||
308 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | ||
309 | { | ||
310 | Assert.Fail("Found asset path in TestSaveItemToIarNoAssets()"); | ||
311 | } | ||
312 | } | ||
313 | |||
314 | // Assert.That(gotControlFile, Is.True, "No control file in archive"); | ||
315 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); | ||
316 | // Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | ||
317 | |||
318 | // TODO: Test presence of more files and contents of files. | ||
319 | } | ||
220 | 320 | ||
221 | /// <summary> | 321 | /// <summary> |
222 | /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized | 322 | /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized |