diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 02af5d9d7c..ab4ed66ae6 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -412,12 +412,20 @@ namespace OpenSim.Framework
}
///
- /// Add an attachment, if the attachpoint has the
+ /// Add an attachment
+ ///
+ ///
+ /// If the attachpoint has the
/// 0x80 bit set then we assume this is an append
/// operation otherwise we replace whatever is
/// currently attached at the attachpoint
+ ///
+ ///
+ /// If UUID.Zero, then an any attachment at the attachpoint is removed.
+ ///
+ ///
/// return true if something actually changed
- ///
+ ///
public bool SetAttachment(int attachpoint, UUID item, UUID asset)
{
if (attachpoint == 0)
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 984a7a81f7..51ced7b3ac 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -56,8 +56,13 @@ namespace OpenSim.Framework
///
/// The method used by Util.FireAndForget for asynchronously firing events
///
+ ///
+ /// None is used to execute the method in the same thread that made the call. It should only be used by regression
+ /// test code that relies on predictable event ordering.
+ ///
public enum FireAndForgetMethod
{
+ None,
UnsafeQueueUserWorkItem,
QueueUserWorkItem,
BeginInvoke,
@@ -89,7 +94,8 @@ namespace OpenSim.Framework
public static readonly Regex UUIDPattern
= new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
- public static FireAndForgetMethod FireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
+ public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
+ public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod;
///
/// Gets the name of the directory where the current running executable
@@ -1506,6 +1512,9 @@ namespace OpenSim.Framework
switch (FireAndForgetMethod)
{
+ case FireAndForgetMethod.None:
+ realCallback.Invoke(obj);
+ break;
case FireAndForgetMethod.UnsafeQueueUserWorkItem:
ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj);
break;
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index c52409000d..7f258645d5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -37,10 +37,11 @@ using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
@@ -61,18 +62,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
[SetUp]
public void Init()
{
- scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
+ // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
+ Util.FireAndForgetMethod = FireAndForgetMethod.None;
- ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
- interregionComms.Initialise(new IniConfigSource());
- interregionComms.PostInitialise();
- SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
+ scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
+ SceneHelpers.SetupSceneModules(scene, new AttachmentsModule());
agent1 = UUID.Random();
random = new Random();
sog1 = NewSOG(UUID.Random(), scene, agent1);
sog2 = NewSOG(UUID.Random(), scene, agent1);
- }
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
+ // threads. Possibly, later tests should be rewritten not to worry about such things.
+ Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
+ }
[Test]
public void TestAddAttachments()
@@ -100,11 +108,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(presence.HasAttachments(), Is.False);
}
-// [Test]
-// public void TestRezAttachmentsOnAvatarEntrance()
-// {
-// ScenePresence presence = scene.GetScenePresence(agent1);
-// }
+ [Test]
+ public void TestRezAttachmentsOnAvatarEntrance()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ UUID spId = TestHelpers.ParseTail(0x1);
+ UUID attItemId = TestHelpers.ParseTail(0x2);
+ UUID attAssetId = TestHelpers.ParseTail(0x3);
+
+ AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId);
+ acd.Appearance = new AvatarAppearance();
+ acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId);
+ ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
+
+// Assert.That(presence.HasAttachments(), Is.True);
+ }
// I'm commenting this test because scene setup NEEDS InventoryService to
// be non-null