diff options
author | Justin Clark-Casey (justincc) | 2010-01-29 20:59:56 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-01-29 20:59:56 +0000 |
commit | c1da07e4eb3510588e97f4652d72f875be51faa8 (patch) | |
tree | d2e6fa891db7d342536a826f68a38c2ded92c5d8 /OpenSim/Region | |
parent | improve locking of m_items in SceneObjectPartInventory (diff) | |
download | opensim-SC_OLD-c1da07e4eb3510588e97f4652d72f875be51faa8.zip opensim-SC_OLD-c1da07e4eb3510588e97f4652d72f875be51faa8.tar.gz opensim-SC_OLD-c1da07e4eb3510588e97f4652d72f875be51faa8.tar.bz2 opensim-SC_OLD-c1da07e4eb3510588e97f4652d72f875be51faa8.tar.xz |
factor out scene setup in ArchiverTests
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | 93 |
1 files changed, 53 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index bf80a1c..5a177b2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -42,6 +42,7 @@ using OpenSim.Region.CoreModules.World.Terrain; | |||
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Region.Framework.Scenes.Serialization; | 43 | using OpenSim.Region.Framework.Scenes.Serialization; |
44 | using OpenSim.Tests.Common; | 44 | using OpenSim.Tests.Common; |
45 | using OpenSim.Tests.Common.Mock; | ||
45 | using OpenSim.Tests.Common.Setup; | 46 | using OpenSim.Tests.Common.Setup; |
46 | 47 | ||
47 | namespace OpenSim.Region.CoreModules.World.Archiver.Tests | 48 | namespace OpenSim.Region.CoreModules.World.Archiver.Tests |
@@ -51,6 +52,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
51 | { | 52 | { |
52 | private Guid m_lastRequestId; | 53 | private Guid m_lastRequestId; |
53 | private string m_lastErrorMessage; | 54 | private string m_lastErrorMessage; |
55 | |||
56 | protected TestScene m_scene; | ||
57 | protected ArchiverModule m_archiverModule; | ||
58 | |||
59 | [SetUp] | ||
60 | public void SetUp() | ||
61 | { | ||
62 | m_archiverModule = new ArchiverModule(); | ||
63 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
64 | TerrainModule terrainModule = new TerrainModule(); | ||
65 | |||
66 | m_scene = SceneSetupHelpers.SetupScene("scene1"); | ||
67 | SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); | ||
68 | } | ||
54 | 69 | ||
55 | private void LoadCompleted(Guid requestId, string errorMessage) | 70 | private void LoadCompleted(Guid requestId, string errorMessage) |
56 | { | 71 | { |
@@ -75,6 +90,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
75 | } | 90 | } |
76 | } | 91 | } |
77 | 92 | ||
93 | // protected void AddSceneObject1() | ||
94 | // { | ||
95 | // string partName = "My Little Pony"; | ||
96 | // UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000015"); | ||
97 | // PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
98 | // Vector3 groupPosition = new Vector3(10, 20, 30); | ||
99 | // Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
100 | // Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
101 | // | ||
102 | // part1 | ||
103 | // = new SceneObjectPart( | ||
104 | // ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
105 | // part1.Name = partName; | ||
106 | // | ||
107 | // scene.AddNewSceneObject(new SceneObjectGroup(part1), false); | ||
108 | // } | ||
109 | |||
78 | /// <summary> | 110 | /// <summary> |
79 | /// Test saving a V0.2 OpenSim Region Archive. | 111 | /// Test saving a V0.2 OpenSim Region Archive. |
80 | /// </summary> | 112 | /// </summary> |
@@ -84,13 +116,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
84 | TestHelper.InMethod(); | 116 | TestHelper.InMethod(); |
85 | //log4net.Config.XmlConfigurator.Configure(); | 117 | //log4net.Config.XmlConfigurator.Configure(); |
86 | 118 | ||
87 | ArchiverModule archiverModule = new ArchiverModule(); | ||
88 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
89 | TerrainModule terrainModule = new TerrainModule(); | ||
90 | |||
91 | Scene scene = SceneSetupHelpers.SetupScene("asset"); | ||
92 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | ||
93 | |||
94 | SceneObjectPart part1; | 119 | SceneObjectPart part1; |
95 | 120 | ||
96 | // Create and add prim 1 | 121 | // Create and add prim 1 |
@@ -107,7 +132,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
107 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | 132 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); |
108 | part1.Name = partName; | 133 | part1.Name = partName; |
109 | 134 | ||
110 | scene.AddNewSceneObject(new SceneObjectGroup(part1), false); | 135 | m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false); |
111 | } | 136 | } |
112 | 137 | ||
113 | SceneObjectPart part2; | 138 | SceneObjectPart part2; |
@@ -126,17 +151,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
126 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | 151 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); |
127 | part2.Name = partName; | 152 | part2.Name = partName; |
128 | 153 | ||
129 | scene.AddNewSceneObject(new SceneObjectGroup(part2), false); | 154 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); |
130 | } | 155 | } |
131 | 156 | ||
132 | MemoryStream archiveWriteStream = new MemoryStream(); | 157 | MemoryStream archiveWriteStream = new MemoryStream(); |
133 | scene.EventManager.OnOarFileSaved += SaveCompleted; | 158 | m_scene.EventManager.OnOarFileSaved += SaveCompleted; |
134 | 159 | ||
135 | Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); | 160 | Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); |
136 | 161 | ||
137 | lock (this) | 162 | lock (this) |
138 | { | 163 | { |
139 | archiverModule.ArchiveRegion(archiveWriteStream, requestId); | 164 | m_archiverModule.ArchiveRegion(archiveWriteStream, requestId); |
140 | //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; | 165 | //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; |
141 | //while (assetServer.HasWaitingRequests()) | 166 | //while (assetServer.HasWaitingRequests()) |
142 | // assetServer.ProcessNextRequest(); | 167 | // assetServer.ProcessNextRequest(); |
@@ -224,11 +249,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
224 | Quaternion rotationOffset = new Quaternion(60, 70, 80, 90); | 249 | Quaternion rotationOffset = new Quaternion(60, 70, 80, 90); |
225 | Vector3 offsetPosition = new Vector3(20, 25, 30); | 250 | Vector3 offsetPosition = new Vector3(20, 25, 30); |
226 | 251 | ||
227 | SerialiserModule serialiserModule = new SerialiserModule(); | 252 | // SerialiserModule serialiserModule = new SerialiserModule(); |
228 | ArchiverModule archiverModule = new ArchiverModule(); | 253 | // ArchiverModule archiverModule = new ArchiverModule(); |
229 | 254 | // | |
230 | Scene scene = SceneSetupHelpers.SetupScene(); | 255 | // Scene scene = SceneSetupHelpers.SetupScene(); |
231 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 256 | // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
232 | 257 | ||
233 | SceneObjectPart part1 | 258 | SceneObjectPart part1 |
234 | = new SceneObjectPart( | 259 | = new SceneObjectPart( |
@@ -276,7 +301,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
276 | } | 301 | } |
277 | } | 302 | } |
278 | 303 | ||
279 | scene.AddNewSceneObject(object1, false); | 304 | m_scene.AddNewSceneObject(object1, false); |
280 | 305 | ||
281 | string object1FileName = string.Format( | 306 | string object1FileName = string.Format( |
282 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", | 307 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", |
@@ -291,13 +316,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
291 | 316 | ||
292 | lock (this) | 317 | lock (this) |
293 | { | 318 | { |
294 | scene.EventManager.OnOarFileLoaded += LoadCompleted; | 319 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; |
295 | archiverModule.DearchiveRegion(archiveReadStream); | 320 | m_archiverModule.DearchiveRegion(archiveReadStream); |
296 | } | 321 | } |
297 | 322 | ||
298 | Assert.That(m_lastErrorMessage, Is.Null); | 323 | Assert.That(m_lastErrorMessage, Is.Null); |
299 | 324 | ||
300 | SceneObjectPart object1PartLoaded = scene.GetSceneObjectPart(part1Name); | 325 | SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1Name); |
301 | 326 | ||
302 | Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded"); | 327 | Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded"); |
303 | Assert.That(object1PartLoaded.Name, Is.EqualTo(part1Name), "object1 names not identical"); | 328 | Assert.That(object1PartLoaded.Name, Is.EqualTo(part1Name), "object1 names not identical"); |
@@ -309,7 +334,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
309 | 334 | ||
310 | TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0]; | 335 | TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0]; |
311 | Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null"); | 336 | Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null"); |
312 | AssetBase loadedSoundAsset = scene.AssetService.Get(loadedSoundItem.AssetID.ToString()); | 337 | AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString()); |
313 | Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null"); | 338 | Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null"); |
314 | Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match"); | 339 | Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match"); |
315 | 340 | ||
@@ -324,12 +349,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
324 | public void TestLoadOarV0_2RegionSettings() | 349 | public void TestLoadOarV0_2RegionSettings() |
325 | { | 350 | { |
326 | TestHelper.InMethod(); | 351 | TestHelper.InMethod(); |
327 | //log4net.Config.XmlConfigurator.Configure(); | 352 | //log4net.Config.XmlConfigurator.Configure(); |
328 | |||
329 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
330 | ArchiverModule archiverModule = new ArchiverModule(); | ||
331 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
332 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
333 | 353 | ||
334 | MemoryStream archiveWriteStream = new MemoryStream(); | 354 | MemoryStream archiveWriteStream = new MemoryStream(); |
335 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | 355 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); |
@@ -376,12 +396,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
376 | 396 | ||
377 | lock (this) | 397 | lock (this) |
378 | { | 398 | { |
379 | scene.EventManager.OnOarFileLoaded += LoadCompleted; | 399 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; |
380 | archiverModule.DearchiveRegion(archiveReadStream); | 400 | m_archiverModule.DearchiveRegion(archiveReadStream); |
381 | } | 401 | } |
382 | 402 | ||
383 | Assert.That(m_lastErrorMessage, Is.Null); | 403 | Assert.That(m_lastErrorMessage, Is.Null); |
384 | RegionSettings loadedRs = scene.RegionInfo.RegionSettings; | 404 | RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings; |
385 | 405 | ||
386 | Assert.That(loadedRs.AgentLimit, Is.EqualTo(17)); | 406 | Assert.That(loadedRs.AgentLimit, Is.EqualTo(17)); |
387 | Assert.That(loadedRs.AllowDamage, Is.True); | 407 | Assert.That(loadedRs.AllowDamage, Is.True); |
@@ -433,27 +453,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
433 | 453 | ||
434 | // Create an oar file that we can use for the merge | 454 | // Create an oar file that we can use for the merge |
435 | { | 455 | { |
436 | ArchiverModule archiverModule = new ArchiverModule(); | ||
437 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
438 | TerrainModule terrainModule = new TerrainModule(); | ||
439 | |||
440 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
441 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | ||
442 | |||
443 | SceneObjectPart part2 | 456 | SceneObjectPart part2 |
444 | = new SceneObjectPart( | 457 | = new SceneObjectPart( |
445 | UUID.Zero, part2Shape, part2GroupPosition, part2RotationOffset, part2OffsetPosition); | 458 | UUID.Zero, part2Shape, part2GroupPosition, part2RotationOffset, part2OffsetPosition); |
446 | part2.Name = part2Name; | 459 | part2.Name = part2Name; |
447 | SceneObjectGroup object2 = new SceneObjectGroup(part2); | 460 | SceneObjectGroup object2 = new SceneObjectGroup(part2); |
448 | 461 | ||
449 | scene.AddNewSceneObject(object2, false); | 462 | m_scene.AddNewSceneObject(object2, false); |
450 | 463 | ||
451 | // Write out this scene | 464 | // Write out this scene |
452 | scene.EventManager.OnOarFileSaved += SaveCompleted; | 465 | m_scene.EventManager.OnOarFileSaved += SaveCompleted; |
453 | 466 | ||
454 | lock (this) | 467 | lock (this) |
455 | { | 468 | { |
456 | archiverModule.ArchiveRegion(archiveWriteStream); | 469 | m_archiverModule.ArchiveRegion(archiveWriteStream); |
457 | Monitor.Wait(this, 60000); | 470 | Monitor.Wait(this, 60000); |
458 | } | 471 | } |
459 | } | 472 | } |