From 4e779bbd8129c8fb0b2c109ca2912265ca85c8a5 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 17 Feb 2009 16:51:09 +0000 Subject: * switch to pulsing monitors to perform test sync instead of events, since this doesn't allow one to accidentally forget to reset the event --- .../Archiver/Tests/InventoryArchiverTests.cs | 16 +++++++++---- .../World/Archiver/Tests/ArchiverTests.cs | 28 +++++++++++++--------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d1956b4..4e55f21 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -44,12 +44,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [TestFixture] public class InventoryArchiverTests { - private EventWaitHandle m_waitHandle = new AutoResetEvent(false); - private void SaveCompleted( bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) { - m_waitHandle.Set(); + lock (this) + { + Monitor.PulseAll(this); + } } /// @@ -109,8 +110,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests MemoryStream archiveWriteStream = new MemoryStream(); archiverModule.OnInventoryArchiveSaved += SaveCompleted; - archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream); - m_waitHandle.WaitOne(60000, true); + archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream); + + lock (this) + { + archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream); + Monitor.Wait(this, 60000); + } /* byte[] archive = archiveWriteStream.ToArray(); diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 25fffc4..bde15b3 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -43,11 +43,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests [TestFixture] public class ArchiverTests { - private EventWaitHandle m_waitHandle = new ManualResetEvent(false); - private void SaveCompleted(string errorMessage) { - m_waitHandle.Set(); + lock (this) + { + Monitor.PulseAll(this); + } } /// @@ -103,12 +104,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests scene.AddNewSceneObject(new SceneObjectGroup(part2), false); } - MemoryStream archiveWriteStream = new MemoryStream(); - + MemoryStream archiveWriteStream = new MemoryStream(); scene.EventManager.OnOarFileSaved += SaveCompleted; - archiverModule.ArchiveRegion(archiveWriteStream); - m_waitHandle.WaitOne(60000, true); - m_waitHandle.Reset(); + + lock (this) + { + archiverModule.ArchiveRegion(archiveWriteStream); + Monitor.Wait(this, 60000); + } byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); @@ -251,9 +254,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests // Write out this scene scene.EventManager.OnOarFileSaved += SaveCompleted; - archiverModule.ArchiveRegion(archiveWriteStream); - m_waitHandle.WaitOne(60000, true); - m_waitHandle.Reset(); + + lock (this) + { + archiverModule.ArchiveRegion(archiveWriteStream); + Monitor.Wait(this, 60000); + } } { -- cgit v1.1