diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 103 |
1 files changed, 95 insertions, 8 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index ed8ec16..16a902d 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,13 +34,15 @@ 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; | ||
43 | 46 | ||
44 | namespace OpenSim.Region.ClientStack.Linden.Tests | 47 | namespace OpenSim.Region.ClientStack.Linden.Tests |
45 | { | 48 | { |
@@ -47,10 +50,14 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
47 | public class EventQueueTests : OpenSimTestCase | 50 | public class EventQueueTests : OpenSimTestCase |
48 | { | 51 | { |
49 | private TestScene m_scene; | 52 | private TestScene m_scene; |
53 | private EventQueueGetModule m_eqgMod; | ||
54 | private NPCModule m_npcMod; | ||
50 | 55 | ||
51 | [SetUp] | 56 | [SetUp] |
52 | public void SetUp() | 57 | public override void SetUp() |
53 | { | 58 | { |
59 | base.SetUp(); | ||
60 | |||
54 | uint port = 9999; | 61 | uint port = 9999; |
55 | uint sslPort = 9998; | 62 | uint sslPort = 9998; |
56 | 63 | ||
@@ -67,14 +74,19 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
67 | config.Configs["Startup"].Set("EventQueue", "true"); | 74 | config.Configs["Startup"].Set("EventQueue", "true"); |
68 | 75 | ||
69 | CapabilitiesModule capsModule = new CapabilitiesModule(); | 76 | CapabilitiesModule capsModule = new CapabilitiesModule(); |
70 | EventQueueGetModule eqgModule = new EventQueueGetModule(); | 77 | m_eqgMod = new EventQueueGetModule(); |
78 | |||
79 | // For NPC test support | ||
80 | config.AddConfig("NPC"); | ||
81 | config.Configs["NPC"].Set("Enabled", "true"); | ||
82 | m_npcMod = new NPCModule(); | ||
71 | 83 | ||
72 | m_scene = new SceneHelpers().SetupScene(); | 84 | m_scene = new SceneHelpers().SetupScene(); |
73 | SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); | 85 | SceneHelpers.SetupSceneModules(m_scene, config, capsModule, m_eqgMod, m_npcMod); |
74 | } | 86 | } |
75 | 87 | ||
76 | [Test] | 88 | [Test] |
77 | public void AddForClient() | 89 | public void TestAddForClient() |
78 | { | 90 | { |
79 | TestHelpers.InMethod(); | 91 | TestHelpers.InMethod(); |
80 | // log4net.Config.XmlConfigurator.Configure(); | 92 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -86,18 +98,93 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
86 | } | 98 | } |
87 | 99 | ||
88 | [Test] | 100 | [Test] |
89 | public void RemoveForClient() | 101 | public void TestRemoveForClient() |
90 | { | 102 | { |
91 | TestHelpers.InMethod(); | 103 | TestHelpers.InMethod(); |
92 | // log4net.Config.XmlConfigurator.Configure(); | 104 | // TestHelpers.EnableLogging(); |
93 | 105 | ||
94 | UUID spId = TestHelpers.ParseTail(0x1); | 106 | UUID spId = TestHelpers.ParseTail(0x1); |
95 | 107 | ||
96 | SceneHelpers.AddScenePresence(m_scene, spId); | 108 | SceneHelpers.AddScenePresence(m_scene, spId); |
97 | m_scene.IncomingCloseAgent(spId, false); | 109 | m_scene.CloseAgent(spId, false); |
98 | 110 | ||
99 | // TODO: Add more assertions for the other aspects of event queues | 111 | // TODO: Add more assertions for the other aspects of event queues |
100 | Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); | 112 | Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); |
101 | } | 113 | } |
114 | |||
115 | [Test] | ||
116 | public void TestEnqueueMessage() | ||
117 | { | ||
118 | TestHelpers.InMethod(); | ||
119 | // log4net.Config.XmlConfigurator.Configure(); | ||
120 | |||
121 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | ||
122 | |||
123 | string messageName = "TestMessage"; | ||
124 | |||
125 | m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), sp.UUID); | ||
126 | |||
127 | Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); | ||
128 | |||
129 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); | ||
130 | |||
131 | // Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); | ||
132 | |||
133 | OSDMap rawOsd = (OSDMap)OSDParser.DeserializeLLSDXml((string)eventsResponse["str_response_string"]); | ||
134 | OSDArray eventsOsd = (OSDArray)rawOsd["events"]; | ||
135 | |||
136 | bool foundUpdate = false; | ||
137 | foreach (OSD osd in eventsOsd) | ||
138 | { | ||
139 | OSDMap eventOsd = (OSDMap)osd; | ||
140 | |||
141 | if (eventOsd["message"] == messageName) | ||
142 | foundUpdate = true; | ||
143 | } | ||
144 | |||
145 | Assert.That(foundUpdate, Is.True, string.Format("Did not find {0} in response", messageName)); | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Test an attempt to put a message on the queue of a user that is not in the region. | ||
150 | /// </summary> | ||
151 | [Test] | ||
152 | public void TestEnqueueMessageNoUser() | ||
153 | { | ||
154 | TestHelpers.InMethod(); | ||
155 | TestHelpers.EnableLogging(); | ||
156 | |||
157 | string messageName = "TestMessage"; | ||
158 | |||
159 | m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), TestHelpers.ParseTail(0x1)); | ||
160 | |||
161 | Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, TestHelpers.ParseTail(0x1)); | ||
162 | |||
163 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway)); | ||
164 | } | ||
165 | |||
166 | /// <summary> | ||
167 | /// NPCs do not currently have an event queue but a caller may try to send a message anyway, so check behaviour. | ||
168 | /// </summary> | ||
169 | [Test] | ||
170 | public void TestEnqueueMessageToNpc() | ||
171 | { | ||
172 | TestHelpers.InMethod(); | ||
173 | // TestHelpers.EnableLogging(); | ||
174 | |||
175 | UUID npcId | ||
176 | = m_npcMod.CreateNPC( | ||
177 | "John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, new AvatarAppearance()); | ||
178 | |||
179 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
180 | |||
181 | string messageName = "TestMessage"; | ||
182 | |||
183 | m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), npc.UUID); | ||
184 | |||
185 | Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, npc.UUID); | ||
186 | |||
187 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway)); | ||
188 | } | ||
102 | } | 189 | } |
103 | } \ No newline at end of file | 190 | } \ No newline at end of file |