aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Setup
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common/Setup')
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs2
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs209
2 files changed, 116 insertions, 95 deletions
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
index 8647cfe..ff4423f 100644
--- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Tests.Common
68 return CreateAsset( 68 return CreateAsset(
69 assetUuid, 69 assetUuid,
70 AssetType.Object, 70 AssetType.Object,
71 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)), 71 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)),
72 sog.OwnerID); 72 sog.OwnerID);
73 } 73 }
74 74
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index 5be70bc..709dd78 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>
@@ -494,9 +454,7 @@ namespace OpenSim.Tests.Common.Setup
494 /// <returns></returns> 454 /// <returns></returns>
495 public static SceneObjectPart AddSceneObject(Scene scene, string name) 455 public static SceneObjectPart AddSceneObject(Scene scene, string name)
496 { 456 {
497 SceneObjectPart part 457 SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero);
498 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
499 part.Name = name;
500 458
501 //part.UpdatePrimFlags(false, false, true); 459 //part.UpdatePrimFlags(false, false, true);
502 //part.ObjectFlags |= (uint)PrimFlags.Phantom; 460 //part.ObjectFlags |= (uint)PrimFlags.Phantom;
@@ -505,5 +463,68 @@ namespace OpenSim.Tests.Common.Setup
505 463
506 return part; 464 return part;
507 } 465 }
466
467 /// <summary>
468 /// Create a scene object part.
469 /// </summary>
470 /// <param name="name"></param>
471 /// <param name="id"></param>
472 /// <param name="ownerId"></param>
473 /// <returns></returns>
474 public static SceneObjectPart CreateSceneObjectPart(string name, UUID id, UUID ownerId)
475 {
476 return new SceneObjectPart(
477 ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
478 { Name = name, UUID = id };
479 }
480
481 /// <summary>
482 /// Create a scene object but do not add it to the scene.
483 /// </summary>
484 /// <remarks>
485 /// UUID always starts at 00000000-0000-0000-0000-000000000001
486 /// </remarks>
487 /// <param name="parts">The number of parts that should be in the scene object</param>
488 /// <param name="ownerId"></param>
489 /// <returns></returns>
490 public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId)
491 {
492 return CreateSceneObject(parts, ownerId, "", 0x1);
493 }
494
495 /// <summary>
496 /// Create a scene object but do not add it to the scene.
497 /// </summary>
498 /// <param name="parts">
499 /// The number of parts that should be in the scene object
500 /// </param>
501 /// <param name="ownerId"></param>
502 /// <param name="partNamePrefix">
503 /// The prefix to be given to part names. This will be suffixed with "Part<part no>"
504 /// (e.g. mynamePart0 for the root part)
505 /// </param>
506 /// <param name="uuidTail">
507 /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
508 /// will be given to the root part, and incremented for each part thereafter.
509 /// </param>
510 /// <returns></returns>
511 public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, string partNamePrefix, int uuidTail)
512 {
513 string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail);
514
515 SceneObjectGroup sog
516 = new SceneObjectGroup(
517 CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId));
518
519 if (parts > 1)
520 for (int i = 1; i < parts; i++)
521 sog.AddPart(
522 CreateSceneObjectPart(
523 string.Format("{0}Part{1}", partNamePrefix, i),
524 new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)),
525 ownerId));
526
527 return sog;
528 }
508 } 529 }
509} 530} \ No newline at end of file