diff options
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r-- | OpenSim/Tests/Common/DoubleToleranceConstraint.cs | 1 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 140 | ||||
-rw-r--r-- | OpenSim/Tests/Common/TestHelper.cs | 3 | ||||
-rw-r--r-- | OpenSim/Tests/Common/VectorToleranceConstraint.cs | 1 |
4 files changed, 53 insertions, 92 deletions
diff --git a/OpenSim/Tests/Common/DoubleToleranceConstraint.cs b/OpenSim/Tests/Common/DoubleToleranceConstraint.cs index c397a62..b2f2057 100644 --- a/OpenSim/Tests/Common/DoubleToleranceConstraint.cs +++ b/OpenSim/Tests/Common/DoubleToleranceConstraint.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using NUnit.Framework; | 29 | using NUnit.Framework; |
30 | using NUnit.Framework.Constraints; | ||
30 | 31 | ||
31 | namespace OpenSim.Tests.Common | 32 | namespace OpenSim.Tests.Common |
32 | { | 33 | { |
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 5be70bc..aa4b285 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -57,21 +57,12 @@ namespace OpenSim.Tests.Common.Setup | |||
57 | /// </summary> | 57 | /// </summary> |
58 | public class SceneSetupHelpers | 58 | public class SceneSetupHelpers |
59 | { | 59 | { |
60 | // These static variables in order to allow regions to be linked by shared modules and same | ||
61 | // CommunicationsManager. | ||
62 | private static ISharedRegionModule m_assetService = null; | ||
63 | // private static ISharedRegionModule m_authenticationService = null; | ||
64 | private static ISharedRegionModule m_inventoryService = null; | ||
65 | private static ISharedRegionModule m_gridService = null; | ||
66 | private static ISharedRegionModule m_userAccountService = null; | ||
67 | private static ISharedRegionModule m_presenceService = null; | ||
68 | |||
69 | /// <summary> | 60 | /// <summary> |
70 | /// Set up a test scene | 61 | /// Set up a test scene |
71 | /// </summary> | 62 | /// </summary> |
72 | /// | 63 | /// <remarks> |
73 | /// Automatically starts service threads, as would the normal runtime. | 64 | /// Automatically starts service threads, as would the normal runtime. |
74 | /// | 65 | /// </remarks> |
75 | /// <returns></returns> | 66 | /// <returns></returns> |
76 | public static TestScene SetupScene() | 67 | public static TestScene SetupScene() |
77 | { | 68 | { |
@@ -86,24 +77,9 @@ namespace OpenSim.Tests.Common.Setup | |||
86 | /// <returns></returns> | 77 | /// <returns></returns> |
87 | public static TestScene SetupScene(String realServices) | 78 | public static TestScene SetupScene(String realServices) |
88 | { | 79 | { |
89 | return SetupScene( | 80 | return SetupScene("Unit test region", UUID.Random(), 1000, 1000, realServices); |
90 | "Unit test region", UUID.Random(), 1000, 1000, realServices); | ||
91 | } | 81 | } |
92 | 82 | ||
93 | // REFACTORING PROBLEM. No idea what the difference is with the previous one | ||
94 | ///// <summary> | ||
95 | ///// Set up a test scene | ||
96 | ///// </summary> | ||
97 | ///// | ||
98 | ///// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> | ||
99 | ///// <param name="cm">This should be the same if simulating two scenes within a standalone</param> | ||
100 | ///// <returns></returns> | ||
101 | //public static TestScene SetupScene(String realServices) | ||
102 | //{ | ||
103 | // return SetupScene( | ||
104 | // "Unit test region", UUID.Random(), 1000, 1000, ""); | ||
105 | //} | ||
106 | |||
107 | /// <summary> | 83 | /// <summary> |
108 | /// Set up a test scene | 84 | /// Set up a test scene |
109 | /// </summary> | 85 | /// </summary> |
@@ -115,7 +91,7 @@ namespace OpenSim.Tests.Common.Setup | |||
115 | /// <returns></returns> | 91 | /// <returns></returns> |
116 | public static TestScene SetupScene(string name, UUID id, uint x, uint y) | 92 | public static TestScene SetupScene(string name, UUID id, uint x, uint y) |
117 | { | 93 | { |
118 | return SetupScene(name, id, x, y,""); | 94 | return SetupScene(name, id, x, y, ""); |
119 | } | 95 | } |
120 | 96 | ||
121 | /// <summary> | 97 | /// <summary> |
@@ -156,27 +132,21 @@ namespace OpenSim.Tests.Common.Setup | |||
156 | testScene.AddModule(godsModule.Name, godsModule); | 132 | testScene.AddModule(godsModule.Name, godsModule); |
157 | realServices = realServices.ToLower(); | 133 | realServices = realServices.ToLower(); |
158 | 134 | ||
159 | if (realServices.Contains("asset")) | 135 | LocalAssetServicesConnector assetService = StartAssetService(testScene, realServices.Contains("asset")); |
160 | StartAssetService(testScene, true); | ||
161 | else | ||
162 | StartAssetService(testScene, false); | ||
163 | 136 | ||
164 | // For now, always started a 'real' authentication service | 137 | // For now, always started a 'real' authentication service |
165 | StartAuthenticationService(testScene, true); | 138 | StartAuthenticationService(testScene, true); |
166 | 139 | ||
167 | if (realServices.Contains("inventory")) | 140 | LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene, realServices.Contains("inventory")); |
168 | StartInventoryService(testScene, true); | 141 | StartGridService(testScene, true); |
169 | else | 142 | LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); |
170 | StartInventoryService(testScene, false); | 143 | LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); |
171 | |||
172 | StartGridService(testScene, true); | ||
173 | StartUserAccountService(testScene); | ||
174 | StartPresenceService(testScene); | ||
175 | 144 | ||
176 | m_inventoryService.PostInitialise(); | 145 | inventoryService.PostInitialise(); |
177 | m_assetService.PostInitialise(); | 146 | assetService.PostInitialise(); |
178 | m_userAccountService.PostInitialise(); | 147 | userAccountService.PostInitialise(); |
179 | m_presenceService.PostInitialise(); | 148 | presenceService.PostInitialise(); |
149 | |||
180 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); | 150 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); |
181 | testScene.SetModuleInterfaces(); | 151 | testScene.SetModuleInterfaces(); |
182 | 152 | ||
@@ -188,24 +158,15 @@ namespace OpenSim.Tests.Common.Setup | |||
188 | testScene.PhysicsScene | 158 | testScene.PhysicsScene |
189 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); | 159 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); |
190 | 160 | ||
191 | // It's really not a good idea to use static variables as they carry over between tests, leading to | ||
192 | // problems that are extremely hard to debug. Really, these static fields need to be eliminated - | ||
193 | // tests using multiple regions that need to share modules need to find another solution. | ||
194 | m_assetService = null; | ||
195 | m_inventoryService = null; | ||
196 | m_gridService = null; | ||
197 | m_userAccountService = null; | ||
198 | m_presenceService = null; | ||
199 | |||
200 | testScene.RegionInfo.EstateSettings = new EstateSettings(); | 161 | testScene.RegionInfo.EstateSettings = new EstateSettings(); |
201 | testScene.LoginsDisabled = false; | 162 | testScene.LoginsDisabled = false; |
202 | 163 | ||
203 | return testScene; | 164 | return testScene; |
204 | } | 165 | } |
205 | 166 | ||
206 | private static void StartAssetService(Scene testScene, bool real) | 167 | private static LocalAssetServicesConnector StartAssetService(Scene testScene, bool real) |
207 | { | 168 | { |
208 | ISharedRegionModule assetService = new LocalAssetServicesConnector(); | 169 | LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); |
209 | IConfigSource config = new IniConfigSource(); | 170 | IConfigSource config = new IniConfigSource(); |
210 | config.AddConfig("Modules"); | 171 | config.AddConfig("Modules"); |
211 | config.AddConfig("AssetService"); | 172 | config.AddConfig("AssetService"); |
@@ -219,7 +180,8 @@ namespace OpenSim.Tests.Common.Setup | |||
219 | assetService.AddRegion(testScene); | 180 | assetService.AddRegion(testScene); |
220 | assetService.RegionLoaded(testScene); | 181 | assetService.RegionLoaded(testScene); |
221 | testScene.AddRegionModule(assetService.Name, assetService); | 182 | testScene.AddRegionModule(assetService.Name, assetService); |
222 | m_assetService = assetService; | 183 | |
184 | return assetService; | ||
223 | } | 185 | } |
224 | 186 | ||
225 | private static void StartAuthenticationService(Scene testScene, bool real) | 187 | private static void StartAuthenticationService(Scene testScene, bool real) |
@@ -243,9 +205,9 @@ namespace OpenSim.Tests.Common.Setup | |||
243 | //m_authenticationService = service; | 205 | //m_authenticationService = service; |
244 | } | 206 | } |
245 | 207 | ||
246 | private static void StartInventoryService(Scene testScene, bool real) | 208 | private static LocalInventoryServicesConnector StartInventoryService(Scene testScene, bool real) |
247 | { | 209 | { |
248 | ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); | 210 | LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); |
249 | IConfigSource config = new IniConfigSource(); | 211 | IConfigSource config = new IniConfigSource(); |
250 | config.AddConfig("Modules"); | 212 | config.AddConfig("Modules"); |
251 | config.AddConfig("InventoryService"); | 213 | config.AddConfig("InventoryService"); |
@@ -265,10 +227,11 @@ namespace OpenSim.Tests.Common.Setup | |||
265 | inventoryService.AddRegion(testScene); | 227 | inventoryService.AddRegion(testScene); |
266 | inventoryService.RegionLoaded(testScene); | 228 | inventoryService.RegionLoaded(testScene); |
267 | testScene.AddRegionModule(inventoryService.Name, inventoryService); | 229 | testScene.AddRegionModule(inventoryService.Name, inventoryService); |
268 | m_inventoryService = inventoryService; | 230 | |
231 | return inventoryService; | ||
269 | } | 232 | } |
270 | 233 | ||
271 | private static void StartGridService(Scene testScene, bool real) | 234 | private static LocalGridServicesConnector StartGridService(Scene testScene, bool real) |
272 | { | 235 | { |
273 | IConfigSource config = new IniConfigSource(); | 236 | IConfigSource config = new IniConfigSource(); |
274 | config.AddConfig("Modules"); | 237 | config.AddConfig("Modules"); |
@@ -277,24 +240,25 @@ namespace OpenSim.Tests.Common.Setup | |||
277 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); | 240 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); |
278 | if (real) | 241 | if (real) |
279 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); | 242 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); |
280 | if (m_gridService == null) | 243 | |
281 | { | 244 | LocalGridServicesConnector gridService = new LocalGridServicesConnector(); |
282 | ISharedRegionModule gridService = new LocalGridServicesConnector(); | 245 | gridService.Initialise(config); |
283 | gridService.Initialise(config); | 246 | |
284 | m_gridService = gridService; | ||
285 | } | ||
286 | //else | 247 | //else |
287 | // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService"); | 248 | // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService"); |
288 | m_gridService.AddRegion(testScene); | 249 | gridService.AddRegion(testScene); |
289 | m_gridService.RegionLoaded(testScene); | 250 | gridService.RegionLoaded(testScene); |
290 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); | 251 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); |
252 | |||
253 | return gridService; | ||
291 | } | 254 | } |
292 | 255 | ||
293 | /// <summary> | 256 | /// <summary> |
294 | /// Start a user account service | 257 | /// Start a user account service |
295 | /// </summary> | 258 | /// </summary> |
296 | /// <param name="testScene"></param> | 259 | /// <param name="testScene"></param> |
297 | private static void StartUserAccountService(Scene testScene) | 260 | /// <returns></returns> |
261 | private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) | ||
298 | { | 262 | { |
299 | IConfigSource config = new IniConfigSource(); | 263 | IConfigSource config = new IniConfigSource(); |
300 | config.AddConfig("Modules"); | 264 | config.AddConfig("Modules"); |
@@ -304,23 +268,21 @@ namespace OpenSim.Tests.Common.Setup | |||
304 | config.Configs["UserAccountService"].Set( | 268 | config.Configs["UserAccountService"].Set( |
305 | "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); | 269 | "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); |
306 | 270 | ||
307 | if (m_userAccountService == null) | 271 | LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); |
308 | { | 272 | userAccountService.Initialise(config); |
309 | ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector(); | ||
310 | userAccountService.Initialise(config); | ||
311 | m_userAccountService = userAccountService; | ||
312 | } | ||
313 | 273 | ||
314 | m_userAccountService.AddRegion(testScene); | 274 | userAccountService.AddRegion(testScene); |
315 | m_userAccountService.RegionLoaded(testScene); | 275 | userAccountService.RegionLoaded(testScene); |
316 | testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService); | 276 | testScene.AddRegionModule(userAccountService.Name, userAccountService); |
277 | |||
278 | return userAccountService; | ||
317 | } | 279 | } |
318 | 280 | ||
319 | /// <summary> | 281 | /// <summary> |
320 | /// Start a presence service | 282 | /// Start a presence service |
321 | /// </summary> | 283 | /// </summary> |
322 | /// <param name="testScene"></param> | 284 | /// <param name="testScene"></param> |
323 | private static void StartPresenceService(Scene testScene) | 285 | private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) |
324 | { | 286 | { |
325 | IConfigSource config = new IniConfigSource(); | 287 | IConfigSource config = new IniConfigSource(); |
326 | config.AddConfig("Modules"); | 288 | config.AddConfig("Modules"); |
@@ -330,16 +292,14 @@ namespace OpenSim.Tests.Common.Setup | |||
330 | config.Configs["PresenceService"].Set( | 292 | config.Configs["PresenceService"].Set( |
331 | "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | 293 | "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); |
332 | 294 | ||
333 | if (m_presenceService == null) | 295 | LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); |
334 | { | 296 | presenceService.Initialise(config); |
335 | ISharedRegionModule presenceService = new LocalPresenceServicesConnector(); | ||
336 | presenceService.Initialise(config); | ||
337 | m_presenceService = presenceService; | ||
338 | } | ||
339 | 297 | ||
340 | m_presenceService.AddRegion(testScene); | 298 | presenceService.AddRegion(testScene); |
341 | m_presenceService.RegionLoaded(testScene); | 299 | presenceService.RegionLoaded(testScene); |
342 | testScene.AddRegionModule(m_presenceService.Name, m_presenceService); | 300 | testScene.AddRegionModule(presenceService.Name, presenceService); |
301 | |||
302 | return presenceService; | ||
343 | } | 303 | } |
344 | 304 | ||
345 | /// <summary> | 305 | /// <summary> |
@@ -436,7 +396,7 @@ namespace OpenSim.Tests.Common.Setup | |||
436 | /// <summary> | 396 | /// <summary> |
437 | /// Add a root agent. | 397 | /// Add a root agent. |
438 | /// </summary> | 398 | /// </summary> |
439 | /// | 399 | /// <remarks> |
440 | /// This function | 400 | /// This function |
441 | /// | 401 | /// |
442 | /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the | 402 | /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the |
@@ -447,7 +407,7 @@ namespace OpenSim.Tests.Common.Setup | |||
447 | /// | 407 | /// |
448 | /// This function performs actions equivalent with notifying the scene that an agent is | 408 | /// This function performs actions equivalent with notifying the scene that an agent is |
449 | /// coming and then actually connecting the agent to the scene. The one step missed out is the very first | 409 | /// coming and then actually connecting the agent to the scene. The one step missed out is the very first |
450 | /// | 410 | /// </remarks> |
451 | /// <param name="scene"></param> | 411 | /// <param name="scene"></param> |
452 | /// <param name="agentData"></param> | 412 | /// <param name="agentData"></param> |
453 | /// <returns></returns> | 413 | /// <returns></returns> |
diff --git a/OpenSim/Tests/Common/TestHelper.cs b/OpenSim/Tests/Common/TestHelper.cs index 9d53063..1722e59 100644 --- a/OpenSim/Tests/Common/TestHelper.cs +++ b/OpenSim/Tests/Common/TestHelper.cs | |||
@@ -27,11 +27,10 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; | 29 | using System.Diagnostics; |
30 | using NUnit.Framework; | ||
30 | 31 | ||
31 | namespace OpenSim.Tests.Common | 32 | namespace OpenSim.Tests.Common |
32 | { | 33 | { |
33 | public delegate void TestDelegate(); | ||
34 | |||
35 | public class TestHelper | 34 | public class TestHelper |
36 | { | 35 | { |
37 | public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) | 36 | public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) |
diff --git a/OpenSim/Tests/Common/VectorToleranceConstraint.cs b/OpenSim/Tests/Common/VectorToleranceConstraint.cs index 118cc70..2fa20ed 100644 --- a/OpenSim/Tests/Common/VectorToleranceConstraint.cs +++ b/OpenSim/Tests/Common/VectorToleranceConstraint.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.Constraints; | ||
31 | 32 | ||
32 | namespace OpenSim.Tests.Common | 33 | namespace OpenSim.Tests.Common |
33 | { | 34 | { |