From e00e518692bd3d123db69dceb98b80d3bdd59156 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 18 Apr 2011 22:24:42 +0100
Subject: add test to ensure that an IAR starts with the control file
---
.../Archiver/InventoryArchiveReadRequest.cs | 21 ++++++++--------
.../Archiver/Tests/InventoryArchiverTests.cs | 29 +++++++++++++++++++++-
2 files changed, 39 insertions(+), 11 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index f3d2f26..9acdc90 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -77,12 +77,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
///
private Stream m_loadStream;
- ///
- /// FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things
- /// (I thought they weren't). We will need to bump the version number and perform this check on all
- /// subsequent IAR versions only
- ///
- protected bool m_controlFileLoaded = true;
+ public bool ControlFileLoaded { get; private set; }
+
protected bool m_assetsLoaded;
protected bool m_inventoryNodesLoaded;
@@ -131,6 +127,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_userInfo = userInfo;
m_invPath = invPath;
m_loadStream = loadStream;
+
+ // FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things
+ // (I thought they weren't). We will need to bump the version number and perform this check on all
+ // subsequent IAR versions only
+ ControlFileLoaded = true;
}
///
@@ -522,7 +523,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
///
///
///
- protected void LoadControlFile(string path, byte[] data)
+ public void LoadControlFile(string path, byte[] data)
{
XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data));
XElement archiveElement = doc.Element("archive");
@@ -538,7 +539,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
majorVersion, MAX_MAJOR_VERSION));
}
- m_controlFileLoaded = true;
+ ControlFileLoaded = true;
m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
}
@@ -550,7 +551,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
///
protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data)
{
- if (!m_controlFileLoaded)
+ if (!ControlFileLoaded)
throw new Exception(
string.Format(
"The IAR you are trying to load does not list {0} before {1}. Aborting load",
@@ -597,7 +598,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
///
protected void LoadAssetFile(string path, byte[] data)
{
- if (!m_controlFileLoaded)
+ if (!ControlFileLoaded)
throw new Exception(
string.Format(
"The IAR you are trying to load does not list {0} before {1}. Aborting load",
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index d03f6da..52232a0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -94,7 +94,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140")));
Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75)));
- }
+ }
+
+ ///
+ /// Test that the IAR has the required files in the right order.
+ ///
+ ///
+ /// At the moment, the only thing that matters is that the control file is the very first one.
+ ///
+ [Test]
+ public void TestOrder()
+ {
+ TestHelper.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ MemoryStream archiveReadStream = new MemoryStream(m_iarStreamBytes);
+ TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
+ string filePath;
+ TarArchiveReader.TarEntryType tarEntryType;
+
+ byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
+ Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
+
+ InventoryArchiveReadRequest iarr
+ = new InventoryArchiveReadRequest(null, null, null, (Stream)null, false);
+ iarr.LoadControlFile(filePath, data);
+
+ Assert.That(iarr.ControlFileLoaded, Is.True);
+ }
///
/// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive
--
cgit v1.1