* Extend archive test to check for the presence of a control file in a saved archive

This commit is contained in:
Justin Clarke Casey
2009-01-23 19:24:36 +00:00
parent 04a565e6b1
commit 664f983943
6 changed files with 55 additions and 12 deletions

View File

@@ -94,11 +94,13 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
byte[] data;
TarArchiveReader.TarEntryType entryType;
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
{
//m_log.DebugFormat(
// "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
if (entryType==TarArchiveReader.TarEntryType.TYPE_DIRECTORY) {
if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
{
m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}",
filePath);
}
@@ -407,7 +409,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
private static Stream URIFetch(Uri uri)
{
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
// request.Credentials = credentials;
@@ -425,8 +426,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
// return new BufferedStream(file, (int) response.ContentLength);
return new BufferedStream(file, 1000000);
}
}
}

View File

@@ -25,8 +25,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.IO;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Archiver;
using OpenSim.Region.Environment.Modules.World.Terrain;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Tests.Common.Setup;
namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
{
@@ -38,11 +44,37 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
/// </summary>
[Test]
public void TestSaveOarV0p2()
{
// Create an archive containing only a terrain
//TarArchiveWriter taw = new TarArchiveWriter();
{
//log4net.Config.XmlConfigurator.Configure();
//System.Console.WriteLine("wibble");
ArchiverModule archiverModule = new ArchiverModule();
TerrainModule terrainModule = new TerrainModule();
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule, terrainModule);
MemoryStream archiveWriteStream = new MemoryStream();
archiverModule.ArchiveRegion(archiveWriteStream);
// If there are no assets to fetch, then the entire archive region code path will execute in this thread,
// so no need to worry about signalling.
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
bool gotControlFile = false;
string filePath;
TarArchiveReader.TarEntryType tarEntryType;
while (tar.ReadEntry(out filePath, out tarEntryType) != null)
{
if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
gotControlFile = true;
}
Assert.That(gotControlFile, Is.True, "No control file in archive");
// TODO: Test presence of more files and contents of files.
}
}
}