* switch to pulsing monitors to perform test sync instead of events, since this doesn't allow one to accidentally forget to reset the event

0.6.3-post-fixes
Justin Clarke Casey 2009-02-17 16:51:09 +00:00
parent 014e9e2c6d
commit 4e779bbd81
2 changed files with 28 additions and 16 deletions

View File

@ -44,12 +44,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[TestFixture] [TestFixture]
public class InventoryArchiverTests public class InventoryArchiverTests
{ {
private EventWaitHandle m_waitHandle = new AutoResetEvent(false);
private void SaveCompleted( private void SaveCompleted(
bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException)
{ {
m_waitHandle.Set(); lock (this)
{
Monitor.PulseAll(this);
}
} }
/// <summary> /// <summary>
@ -110,7 +111,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
archiverModule.OnInventoryArchiveSaved += SaveCompleted; archiverModule.OnInventoryArchiveSaved += SaveCompleted;
archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream); archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream);
m_waitHandle.WaitOne(60000, true);
lock (this)
{
archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream);
Monitor.Wait(this, 60000);
}
/* /*
byte[] archive = archiveWriteStream.ToArray(); byte[] archive = archiveWriteStream.ToArray();

View File

@ -43,11 +43,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
[TestFixture] [TestFixture]
public class ArchiverTests public class ArchiverTests
{ {
private EventWaitHandle m_waitHandle = new ManualResetEvent(false);
private void SaveCompleted(string errorMessage) private void SaveCompleted(string errorMessage)
{ {
m_waitHandle.Set(); lock (this)
{
Monitor.PulseAll(this);
}
} }
/// <summary> /// <summary>
@ -104,11 +105,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
} }
MemoryStream archiveWriteStream = new MemoryStream(); MemoryStream archiveWriteStream = new MemoryStream();
scene.EventManager.OnOarFileSaved += SaveCompleted; scene.EventManager.OnOarFileSaved += SaveCompleted;
lock (this)
{
archiverModule.ArchiveRegion(archiveWriteStream); archiverModule.ArchiveRegion(archiveWriteStream);
m_waitHandle.WaitOne(60000, true); Monitor.Wait(this, 60000);
m_waitHandle.Reset(); }
byte[] archive = archiveWriteStream.ToArray(); byte[] archive = archiveWriteStream.ToArray();
MemoryStream archiveReadStream = new MemoryStream(archive); MemoryStream archiveReadStream = new MemoryStream(archive);
@ -251,9 +254,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
// Write out this scene // Write out this scene
scene.EventManager.OnOarFileSaved += SaveCompleted; scene.EventManager.OnOarFileSaved += SaveCompleted;
lock (this)
{
archiverModule.ArchiveRegion(archiveWriteStream); archiverModule.ArchiveRegion(archiveWriteStream);
m_waitHandle.WaitOne(60000, true); Monitor.Wait(this, 60000);
m_waitHandle.Reset(); }
} }
{ {