From d205cb5260b490ae92de8284d066a8a67f4993cb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 17 Feb 2009 17:40:48 +0000 Subject: * extend inventory archive save test to check for the presence of the item file in the saved archive --- .../Archiver/Tests/InventoryArchiverTests.cs | 58 ++++++++++++---------- 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 4e55f21..c43f543 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -30,12 +30,14 @@ using System.IO; using System.Text; using System.Threading; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; +using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common.Setup; @@ -101,9 +103,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests cm.AssetCache.AddAsset(asset1); // Create item + UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); InventoryItemBase item1 = new InventoryItemBase(); item1.Name = "My Little Dog"; item1.AssetID = asset1.FullID; + item1.ID = item1Id; item1.Folder = userInfo.RootFolder.FindFolderByPath("Objects").ID; scene.AddInventoryItem(userId, item1); @@ -118,57 +122,59 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Monitor.Wait(this, 60000); } - /* byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); TarArchiveReader tar = new TarArchiveReader(archiveReadStream); - - bool gotControlFile = false; + + //bool gotControlFile = false; bool gotObject1File = false; - bool gotObject2File = false; - string expectedObject1FileName = string.Format( - "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", - part1.Name, - Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), - part1.UUID); + //bool gotObject2File = false; + string expectedObject1FilePath = string.Format( + "{0}{1}_{2}.xml", + "Objects/", + item1.Name, + item1Id); +/* string expectedObject2FileName = string.Format( "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", part2.Name, Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z), - part2.UUID); + part2.UUID); + */ string filePath; TarArchiveReader.TarEntryType tarEntryType; while (tar.ReadEntry(out filePath, out tarEntryType) != null) { + /* if (ArchiveConstants.CONTROL_FILE_PATH == filePath) { gotControlFile = true; } - else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) + */ + if (filePath.StartsWith("Objects/") && filePath.EndsWith(".xml")) { - string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length); + //string fileName = filePath.Remove(0, "Objects/".Length); - if (fileName.StartsWith(part1.Name)) - { - Assert.That(fileName, Is.EqualTo(expectedObject1FileName)); + //if (fileName.StartsWith(part1.Name)) + //{ + Assert.That(filePath, Is.EqualTo(expectedObject1FilePath)); gotObject1File = true; - } - else if (fileName.StartsWith(part2.Name)) - { - Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); - gotObject2File = true; - } + //} + //else if (fileName.StartsWith(part2.Name)) + //{ + // Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); + // gotObject2File = true; + //} } } - Assert.That(gotControlFile, Is.True, "No control file in archive"); - Assert.That(gotObject1File, Is.True, "No object1 file in archive"); - Assert.That(gotObject2File, Is.True, "No object2 file in archive"); + //Assert.That(gotControlFile, Is.True, "No control file in archive"); + Assert.That(gotObject1File, Is.True, "No item1 file in archive"); + //Assert.That(gotObject2File, Is.True, "No object2 file in archive"); - // TODO: Test presence of more files and contents of files. - */ + // TODO: Test presence of more files and contents of files. } } } \ No newline at end of file -- cgit v1.1