aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-01-30 20:54:38 +0000
committerJustin Clarke Casey2009-01-30 20:54:38 +0000
commitc307e0e4a7ddf0b07f2b0662fe55adc31b64b393 (patch)
tree3206f4a7aa0d00ad5256599eb457de0ce608fcc6 /OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
parent* furhter simplify test setups for objects (diff)
downloadopensim-SC-c307e0e4a7ddf0b07f2b0662fe55adc31b64b393.zip
opensim-SC-c307e0e4a7ddf0b07f2b0662fe55adc31b64b393.tar.gz
opensim-SC-c307e0e4a7ddf0b07f2b0662fe55adc31b64b393.tar.bz2
opensim-SC-c307e0e4a7ddf0b07f2b0662fe55adc31b64b393.tar.xz
* Extend archive save test to check for the presence of the file for the object that was in the scene
* Can now pass in a wait handle to ArchiveRegion() if you want same thread signalling that the save has completed
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs48
1 files changed, 41 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
index 6450238..ccd2411 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
@@ -25,11 +25,16 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.IO; 29using System.IO;
30using System.Threading;
29using NUnit.Framework; 31using NUnit.Framework;
30using NUnit.Framework.SyntaxHelpers; 32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse;
34using OpenSim.Framework;
31using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
32using OpenSim.Region.Environment.Modules.World.Archiver; 36using OpenSim.Region.Environment.Modules.World.Archiver;
37using OpenSim.Region.Environment.Modules.World.Serialiser;
33using OpenSim.Region.Environment.Modules.World.Terrain; 38using OpenSim.Region.Environment.Modules.World.Terrain;
34using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
35using OpenSim.Tests.Common.Setup; 40using OpenSim.Tests.Common.Setup;
@@ -48,21 +53,41 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
48 //log4net.Config.XmlConfigurator.Configure(); 53 //log4net.Config.XmlConfigurator.Configure();
49 54
50 ArchiverModule archiverModule = new ArchiverModule(); 55 ArchiverModule archiverModule = new ArchiverModule();
56 SerialiserModule serialiserModule = new SerialiserModule();
51 TerrainModule terrainModule = new TerrainModule(); 57 TerrainModule terrainModule = new TerrainModule();
52 58
53 Scene scene = SceneSetupHelpers.SetupScene(); 59 Scene scene = SceneSetupHelpers.SetupScene();
54 SceneSetupHelpers.SetupSceneModules(scene, archiverModule, terrainModule); 60 SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
55 61
56 62 string partName = "My Little Pony";
63 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000015");
64 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
65 Vector3 groupPosition = new Vector3(10, 20, 30);
66 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
67 Vector3 offsetPosition = new Vector3(5, 10, 15);
68
69 SceneObjectPart part
70 = new SceneObjectPart(
71 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
72 part.Name = partName;
73
74 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
75 EventWaitHandle waitHandle = new ManualResetEvent(false);
57 MemoryStream archiveWriteStream = new MemoryStream(); 76 MemoryStream archiveWriteStream = new MemoryStream();
58 archiverModule.ArchiveRegion(archiveWriteStream); 77 archiverModule.ArchiveRegion(archiveWriteStream, waitHandle);
78 waitHandle.WaitOne();
59 79
60 // If there are no assets to fetch, then the entire archive region code path will execute in this thread, 80 byte[] archive = archiveWriteStream.ToArray();
61 // so no need to worry about signalling. 81 MemoryStream archiveReadStream = new MemoryStream(archive);
62 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
63 TarArchiveReader tar = new TarArchiveReader(archiveReadStream); 82 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
64 83
65 bool gotControlFile = false; 84 bool gotControlFile = false;
85 bool gotObjectFile = false;
86 string expectedObjectFileName = string.Format(
87 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
88 partName,
89 Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
90 part.UUID);
66 91
67 string filePath; 92 string filePath;
68 TarArchiveReader.TarEntryType tarEntryType; 93 TarArchiveReader.TarEntryType tarEntryType;
@@ -70,10 +95,19 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
70 while (tar.ReadEntry(out filePath, out tarEntryType) != null) 95 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
71 { 96 {
72 if (ArchiveConstants.CONTROL_FILE_PATH == filePath) 97 if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
98 {
73 gotControlFile = true; 99 gotControlFile = true;
100 }
101 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
102 {
103 string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length);
104 Assert.That(fileName, Is.EqualTo(expectedObjectFileName));
105 gotObjectFile = true;
106 }
74 } 107 }
75 108
76 Assert.That(gotControlFile, Is.True, "No control file in archive"); 109 Assert.That(gotControlFile, Is.True, "No control file in archive");
110 Assert.That(gotObjectFile, Is.True, "No object file in archive");
77 111
78 // TODO: Test presence of more files and contents of files. 112 // TODO: Test presence of more files and contents of files.
79 } 113 }