diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 90 | ||||
-rw-r--r-- | prebuild.xml | 2 |
3 files changed, 101 insertions, 7 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 0dbdbaf..0447bc4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -228,12 +228,18 @@ namespace OpenSim.Region.ClientStack.Linden | |||
228 | lock (queue) | 228 | lock (queue) |
229 | queue.Enqueue(ev); | 229 | queue.Enqueue(ev); |
230 | } | 230 | } |
231 | else | 231 | else if (DebugLevel > 0) |
232 | { | 232 | { |
233 | OSDMap evMap = (OSDMap)ev; | 233 | ScenePresence sp = m_scene.GetScenePresence(avatarID); |
234 | m_log.WarnFormat( | 234 | |
235 | "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} when placing message {1} in region {2}", | 235 | // This assumes that an NPC should never have a queue. |
236 | avatarID, evMap["message"], m_scene.Name); | 236 | if (sp != null && sp.PresenceType != PresenceType.Npc) |
237 | { | ||
238 | OSDMap evMap = (OSDMap)ev; | ||
239 | m_log.WarnFormat( | ||
240 | "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} {1} when placing message {2} in region {3}", | ||
241 | sp.Name, sp.UUID, evMap["message"], m_scene.Name); | ||
242 | } | ||
237 | } | 243 | } |
238 | } | 244 | } |
239 | catch (NullReferenceException e) | 245 | catch (NullReferenceException e) |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 9e24bce..fb24f58 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Net; | 31 | using System.Net; |
31 | using log4net.Config; | 32 | using log4net.Config; |
@@ -33,11 +34,14 @@ using Nini.Config; | |||
33 | using NUnit.Framework; | 34 | using NUnit.Framework; |
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
35 | using OpenMetaverse.Packets; | 36 | using OpenMetaverse.Packets; |
37 | using OpenMetaverse.StructuredData; | ||
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Servers; | 39 | using OpenSim.Framework.Servers; |
38 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
39 | using OpenSim.Region.ClientStack.Linden; | 41 | using OpenSim.Region.ClientStack.Linden; |
40 | using OpenSim.Region.CoreModules.Framework; | 42 | using OpenSim.Region.CoreModules.Framework; |
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Region.OptionalModules.World.NPC; | ||
41 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
42 | using OpenSim.Tests.Common.Mock; | 46 | using OpenSim.Tests.Common.Mock; |
43 | 47 | ||
@@ -47,6 +51,8 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
47 | public class EventQueueTests : OpenSimTestCase | 51 | public class EventQueueTests : OpenSimTestCase |
48 | { | 52 | { |
49 | private TestScene m_scene; | 53 | private TestScene m_scene; |
54 | private EventQueueGetModule m_eqgMod; | ||
55 | private NPCModule m_npcMod; | ||
50 | 56 | ||
51 | [SetUp] | 57 | [SetUp] |
52 | public override void SetUp() | 58 | public override void SetUp() |
@@ -69,10 +75,15 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
69 | config.Configs["Startup"].Set("EventQueue", "true"); | 75 | config.Configs["Startup"].Set("EventQueue", "true"); |
70 | 76 | ||
71 | CapabilitiesModule capsModule = new CapabilitiesModule(); | 77 | CapabilitiesModule capsModule = new CapabilitiesModule(); |
72 | EventQueueGetModule eqgModule = new EventQueueGetModule(); | 78 | m_eqgMod = new EventQueueGetModule(); |
79 | |||
80 | // For NPC test support | ||
81 | config.AddConfig("NPC"); | ||
82 | config.Configs["NPC"].Set("Enabled", "true"); | ||
83 | m_npcMod = new NPCModule(); | ||
73 | 84 | ||
74 | m_scene = new SceneHelpers().SetupScene(); | 85 | m_scene = new SceneHelpers().SetupScene(); |
75 | SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); | 86 | SceneHelpers.SetupSceneModules(m_scene, config, capsModule, m_eqgMod, m_npcMod); |
76 | } | 87 | } |
77 | 88 | ||
78 | [Test] | 89 | [Test] |
@@ -101,5 +112,80 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
101 | // TODO: Add more assertions for the other aspects of event queues | 112 | // TODO: Add more assertions for the other aspects of event queues |
102 | Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); | 113 | Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); |
103 | } | 114 | } |
115 | |||
116 | [Test] | ||
117 | public void TestEnqueueMessage() | ||
118 | { | ||
119 | TestHelpers.InMethod(); | ||
120 | // log4net.Config.XmlConfigurator.Configure(); | ||
121 | |||
122 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | ||
123 | |||
124 | string messageName = "TestMessage"; | ||
125 | |||
126 | m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), sp.UUID); | ||
127 | |||
128 | Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); | ||
129 | |||
130 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); | ||
131 | |||
132 | // Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); | ||
133 | |||
134 | OSDMap rawOsd = (OSDMap)OSDParser.DeserializeLLSDXml((string)eventsResponse["str_response_string"]); | ||
135 | OSDArray eventsOsd = (OSDArray)rawOsd["events"]; | ||
136 | |||
137 | bool foundUpdate = false; | ||
138 | foreach (OSD osd in eventsOsd) | ||
139 | { | ||
140 | OSDMap eventOsd = (OSDMap)osd; | ||
141 | |||
142 | if (eventOsd["message"] == messageName) | ||
143 | foundUpdate = true; | ||
144 | } | ||
145 | |||
146 | Assert.That(foundUpdate, Is.True, string.Format("Did not find {0} in response", messageName)); | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// Test an attempt to put a message on the queue of a user that is not in the region. | ||
151 | /// </summary> | ||
152 | [Test] | ||
153 | public void TestEnqueueMessageNoUser() | ||
154 | { | ||
155 | TestHelpers.InMethod(); | ||
156 | TestHelpers.EnableLogging(); | ||
157 | |||
158 | string messageName = "TestMessage"; | ||
159 | |||
160 | m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), TestHelpers.ParseTail(0x1)); | ||
161 | |||
162 | Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, TestHelpers.ParseTail(0x1)); | ||
163 | |||
164 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway)); | ||
165 | } | ||
166 | |||
167 | /// <summary> | ||
168 | /// NPCs do not currently have an event queue but a caller may try to send a message anyway, so check behaviour. | ||
169 | /// </summary> | ||
170 | [Test] | ||
171 | public void TestEnqueueMessageToNpc() | ||
172 | { | ||
173 | TestHelpers.InMethod(); | ||
174 | // TestHelpers.EnableLogging(); | ||
175 | |||
176 | UUID npcId | ||
177 | = m_npcMod.CreateNPC( | ||
178 | "John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, new AvatarAppearance()); | ||
179 | |||
180 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
181 | |||
182 | string messageName = "TestMessage"; | ||
183 | |||
184 | m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), npc.UUID); | ||
185 | |||
186 | Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, npc.UUID); | ||
187 | |||
188 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway)); | ||
189 | } | ||
104 | } | 190 | } |
105 | } \ No newline at end of file | 191 | } \ No newline at end of file |
diff --git a/prebuild.xml b/prebuild.xml index 5b18195..dfb30dc 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -3325,6 +3325,7 @@ | |||
3325 | <Reference name="nunit.framework" path="../../../../../bin/"/> | 3325 | <Reference name="nunit.framework" path="../../../../../bin/"/> |
3326 | <Reference name="OpenMetaverse" path="../../../../../bin/"/> | 3326 | <Reference name="OpenMetaverse" path="../../../../../bin/"/> |
3327 | <Reference name="OpenMetaverseTypes" path="../../../../../bin/"/> | 3327 | <Reference name="OpenMetaverseTypes" path="../../../../../bin/"/> |
3328 | <Reference name="OpenMetaverse.StructuredData" path="../../../../../bin/"/> | ||
3328 | <Reference name="OpenSim.Framework"/> | 3329 | <Reference name="OpenSim.Framework"/> |
3329 | <Reference name="OpenSim.Framework.Communications"/> | 3330 | <Reference name="OpenSim.Framework.Communications"/> |
3330 | <Reference name="OpenSim.Framework.Monitoring"/> | 3331 | <Reference name="OpenSim.Framework.Monitoring"/> |
@@ -3334,6 +3335,7 @@ | |||
3334 | <Reference name="OpenSim.Region.ClientStack.LindenUDP"/> | 3335 | <Reference name="OpenSim.Region.ClientStack.LindenUDP"/> |
3335 | <Reference name="OpenSim.Region.CoreModules"/> | 3336 | <Reference name="OpenSim.Region.CoreModules"/> |
3336 | <Reference name="OpenSim.Region.Framework"/> | 3337 | <Reference name="OpenSim.Region.Framework"/> |
3338 | <Reference name="OpenSim.Region.OptionalModules"/> | ||
3337 | <Reference name="OpenSim.Services.Interfaces"/> | 3339 | <Reference name="OpenSim.Services.Interfaces"/> |
3338 | <Reference name="OpenSim.Tests.Common"/> | 3340 | <Reference name="OpenSim.Tests.Common"/> |
3339 | 3341 | ||