Add regression test to check that OARs start with the control file.

bulletsim
Justin Clark-Casey (justincc) 2011-04-18 22:35:33 +01:00
parent e00e518692
commit 6600aa2baf
3 changed files with 21 additions and 9 deletions

View File

@ -77,6 +77,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// </value>
private Stream m_loadStream;
/// <summary>
/// Has the control file been loaded for this archive?
/// </summary>
public bool ControlFileLoaded { get; private set; }
protected bool m_assetsLoaded;

View File

@ -57,6 +57,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// bumps here should be compatible.
/// </summary>
public static int MAX_MAJOR_VERSION = 1;
/// <summary>
/// Has the control file been loaded for this archive?
/// </summary>
public bool ControlFileLoaded { get; private set; }
protected Scene m_scene;
protected Stream m_loadStream;
@ -527,7 +532,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// </summary>
/// <param name="path"></param>
/// <param name="data"></param>
protected void LoadControlFile(string path, byte[] data)
public void LoadControlFile(string path, byte[] data)
{
XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
@ -573,6 +578,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
currentRegionSettings.Save();
ControlFileLoaded = true;
}
}
}

View File

@ -171,7 +171,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
MemoryStream archiveReadStream = new MemoryStream(archive);
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
bool gotControlFile = false;
bool gotNcAssetFile = false;
string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt");
@ -182,15 +181,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2));
string filePath;
TarArchiveReader.TarEntryType tarEntryType;
TarArchiveReader.TarEntryType tarEntryType;
byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty);
arr.LoadControlFile(filePath, data);
Assert.That(arr.ControlFileLoaded, Is.True);
while (tar.ReadEntry(out filePath, out tarEntryType) != null)
{
if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
{
gotControlFile = true;
}
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
{
string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
@ -203,7 +206,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
}
}
Assert.That(gotControlFile, Is.True, "No control file in archive");
Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive");
Assert.That(foundPaths, Is.EquivalentTo(expectedPaths));