aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Archiver/Tests
diff options
context:
space:
mode:
authorDr Scofield2009-02-10 13:10:57 +0000
committerDr Scofield2009-02-10 13:10:57 +0000
commit180be7de07014aa33bc6066f12a0819b731c1c9d (patch)
tree3aa13af3cda4b808fa9453655875327699b61311 /OpenSim/Region/CoreModules/World/Archiver/Tests
parentStopgap measure: To use gridlaunch, or GUI, start opensim with (diff)
downloadopensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.zip
opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.gz
opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.bz2
opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.xz
this is step 2 of 2 of the OpenSim.Region.Environment refactor.
NOTHING has been deleted or moved off to forge at this point. what has happened is that OpenSim.Region.Environment.Modules has been split in two: - OpenSim.Region.CoreModules: all those modules that are either directly or indirectly referenced from other OpenSim packages, or that provide functionality that the OpenSim developer community considers core functionality: CoreModules/Agent/AssetTransaction CoreModules/Agent/Capabilities CoreModules/Agent/TextureDownload CoreModules/Agent/TextureSender CoreModules/Agent/TextureSender/Tests CoreModules/Agent/Xfer CoreModules/Avatar/AvatarFactory CoreModules/Avatar/Chat/ChatModule CoreModules/Avatar/Combat CoreModules/Avatar/Currency/SampleMoney CoreModules/Avatar/Dialog CoreModules/Avatar/Friends CoreModules/Avatar/Gestures CoreModules/Avatar/Groups CoreModules/Avatar/InstantMessage CoreModules/Avatar/Inventory CoreModules/Avatar/Inventory/Archiver CoreModules/Avatar/Inventory/Transfer CoreModules/Avatar/Lure CoreModules/Avatar/ObjectCaps CoreModules/Avatar/Profiles CoreModules/Communications/Local CoreModules/Communications/REST CoreModules/Framework/EventQueue CoreModules/Framework/InterfaceCommander CoreModules/Hypergrid CoreModules/InterGrid CoreModules/Scripting/DynamicTexture CoreModules/Scripting/EMailModules CoreModules/Scripting/HttpRequest CoreModules/Scripting/LoadImageURL CoreModules/Scripting/VectorRender CoreModules/Scripting/WorldComm CoreModules/Scripting/XMLRPC CoreModules/World/Archiver CoreModules/World/Archiver/Tests CoreModules/World/Estate CoreModules/World/Land CoreModules/World/Permissions CoreModules/World/Serialiser CoreModules/World/Sound CoreModules/World/Sun CoreModules/World/Terrain CoreModules/World/Terrain/DefaultEffects CoreModules/World/Terrain/DefaultEffects/bin CoreModules/World/Terrain/DefaultEffects/bin/Debug CoreModules/World/Terrain/Effects CoreModules/World/Terrain/FileLoaders CoreModules/World/Terrain/FloodBrushes CoreModules/World/Terrain/PaintBrushes CoreModules/World/Terrain/Tests CoreModules/World/Vegetation CoreModules/World/Wind CoreModules/World/WorldMap - OpenSim.Region.OptionalModules: all those modules that are not core modules: OptionalModules/Avatar/Chat/IRC-stuff OptionalModules/Avatar/Concierge OptionalModules/Avatar/Voice/AsterixVoice OptionalModules/Avatar/Voice/SIPVoice OptionalModules/ContentManagementSystem OptionalModules/Grid/Interregion OptionalModules/Python OptionalModules/SvnSerialiser OptionalModules/World/NPC OptionalModules/World/TreePopulator
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/Tests')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs188
1 files changed, 188 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
new file mode 100644
index 0000000..a14e0f6
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -0,0 +1,188 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Threading;
31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.CoreModules.World.Archiver;
37using OpenSim.Region.CoreModules.World.Serialiser;
38using OpenSim.Region.CoreModules.World.Terrain;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Tests.Common.Setup;
41
42namespace OpenSim.Region.CoreModules.World.Archiver.Tests
43{
44 [TestFixture]
45 public class ArchiverTests
46 {
47 private EventWaitHandle m_waitHandle = new AutoResetEvent(false);
48
49 private void SaveCompleted(string errorMessage)
50 {
51 m_waitHandle.Set();
52 }
53
54 /// <summary>
55 /// Test saving a V0.2 OpenSim Region Archive.
56 /// </summary>
57 [Test]
58 public void TestSaveOarV0p2()
59 {
60 log4net.Config.XmlConfigurator.Configure();
61
62 ArchiverModule archiverModule = new ArchiverModule();
63 SerialiserModule serialiserModule = new SerialiserModule();
64 TerrainModule terrainModule = new TerrainModule();
65
66 Scene scene = SceneSetupHelpers.SetupScene();
67 SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
68
69 SceneObjectPart part1;
70
71 // Create and add prim 1
72 {
73 string partName = "My Little Pony";
74 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000015");
75 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
76 Vector3 groupPosition = new Vector3(10, 20, 30);
77 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
78 Vector3 offsetPosition = new Vector3(5, 10, 15);
79
80 part1
81 = new SceneObjectPart(
82 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
83 part1.Name = partName;
84
85 scene.AddNewSceneObject(new SceneObjectGroup(part1), false);
86 }
87
88 SceneObjectPart part2;
89
90 // Create and add prim 2
91 {
92 string partName = "Action Man";
93 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000016");
94 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateCylinder();
95 Vector3 groupPosition = new Vector3(90, 80, 70);
96 Quaternion rotationOffset = new Quaternion(60, 70, 80, 90);
97 Vector3 offsetPosition = new Vector3(20, 25, 30);
98
99 part2
100 = new SceneObjectPart(
101 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
102 part2.Name = partName;
103
104 scene.AddNewSceneObject(new SceneObjectGroup(part2), false);
105 }
106
107 MemoryStream archiveWriteStream = new MemoryStream();
108
109 scene.EventManager.OnOarFileSaved += SaveCompleted;
110 archiverModule.ArchiveRegion(archiveWriteStream);
111 m_waitHandle.WaitOne(60000, true);
112
113 byte[] archive = archiveWriteStream.ToArray();
114 MemoryStream archiveReadStream = new MemoryStream(archive);
115 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
116
117 bool gotControlFile = false;
118 bool gotObject1File = false;
119 bool gotObject2File = false;
120 string expectedObject1FileName = string.Format(
121 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
122 part1.Name,
123 Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
124 part1.UUID);
125 string expectedObject2FileName = string.Format(
126 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
127 part2.Name,
128 Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z),
129 part2.UUID);
130
131 string filePath;
132 TarArchiveReader.TarEntryType tarEntryType;
133
134 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
135 {
136 if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
137 {
138 gotControlFile = true;
139 }
140 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
141 {
142 string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length);
143
144 if (fileName.StartsWith(part1.Name))
145 {
146 Assert.That(fileName, Is.EqualTo(expectedObject1FileName));
147 gotObject1File = true;
148 }
149 else if (fileName.StartsWith(part2.Name))
150 {
151 Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
152 gotObject2File = true;
153 }
154 }
155 }
156
157 Assert.That(gotControlFile, Is.True, "No control file in archive");
158 Assert.That(gotObject1File, Is.True, "No object1 file in archive");
159 Assert.That(gotObject2File, Is.True, "No object2 file in archive");
160
161 // TODO: Test presence of more files and contents of files.
162 }
163
164 /// <summary>
165 /// Test loading a V0.2 OpenSim Region Archive. Does not yet do what it says on the tin.
166 /// </summary>
167 [Test]
168 public void TestLoadOarV0p2()
169 {
170 MemoryStream archiveWriteStream = new MemoryStream();
171 TarArchiveWriter tar = new TarArchiveWriter();
172
173 tar.AddFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
174 tar.WriteTar(archiveWriteStream);
175
176 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
177
178 ArchiverModule archiverModule = new ArchiverModule();
179
180 Scene scene = SceneSetupHelpers.SetupScene();
181 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
182
183 archiverModule.DearchiveRegion(archiveReadStream);
184
185 // TODO: Okay, so nothing is tested yet apart from the fact that it doesn't blow up
186 }
187 }
188} \ No newline at end of file