mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
* Extend archive test to check for the presence of a control file in a saved archive
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user