aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs218
-rw-r--r--OpenSim/Tests/Common/Mock/TestLandChannel.cs17
2 files changed, 138 insertions, 97 deletions
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 7a6b1cf..8e54707 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -58,57 +58,67 @@ namespace OpenSim.Tests.Common
58 /// </summary> 58 /// </summary>
59 public class SceneHelpers 59 public class SceneHelpers
60 { 60 {
61 public static TestScene SetupScene() 61 private AgentCircuitManager m_acm = new AgentCircuitManager();
62 private ISimulationDataService m_simDataService
63 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
64 private IEstateDataService m_estateDataService;
65
66 private LocalAssetServicesConnector m_assetService;
67 private LocalAuthenticationServicesConnector m_authenticationService;
68 private LocalInventoryServicesConnector m_inventoryService;
69 private LocalGridServicesConnector m_gridService;
70 private LocalUserAccountServicesConnector m_userAccountService;
71 private LocalPresenceServicesConnector m_presenceService;
72
73 private CoreAssetCache m_cache;
74
75 public SceneHelpers() : this(null) {}
76
77 public SceneHelpers(CoreAssetCache cache)
62 { 78 {
63 return SetupScene(null); 79 m_assetService = StartAssetService(cache);
80 m_authenticationService = StartAuthenticationService();
81 m_inventoryService = StartInventoryService();
82 m_gridService = StartGridService();
83 m_userAccountService = StartUserAccountService();
84 m_presenceService = StartPresenceService();
85
86 m_inventoryService.PostInitialise();
87 m_assetService.PostInitialise();
88 m_userAccountService.PostInitialise();
89 m_presenceService.PostInitialise();
90
91 m_cache = cache;
64 } 92 }
65 93
66 /// <summary> 94 /// <summary>
67 /// Set up a test scene 95 /// Set up a test scene
68 /// </summary> 96 /// </summary>
69 /// <remarks> 97 /// <remarks>
70 /// Automatically starts service threads, as would the normal runtime. 98 /// Automatically starts services, as would the normal runtime.
71 /// </remarks> 99 /// </remarks>
72 /// <returns></returns> 100 /// <returns></returns>
73 public static TestScene SetupScene(CoreAssetCache cache) 101 public TestScene SetupScene()
74 { 102 {
75 return SetupScene("Unit test region", UUID.Random(), 1000, 1000, cache); 103 return SetupScene("Unit test region", UUID.Random(), 1000, 1000);
76 } 104 }
77 105
78 public static TestScene SetupScene(string name, UUID id, uint x, uint y) 106 public TestScene SetupScene(string name, UUID id, uint x, uint y)
79 {
80 return SetupScene(name, id, x, y, null);
81 }
82
83 /// <summary>
84 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
85 /// or a different, to get a brand new scene with new shared region modules.
86 /// </summary>
87 /// <param name="name">Name of the region</param>
88 /// <param name="id">ID of the region</param>
89 /// <param name="x">X co-ordinate of the region</param>
90 /// <param name="y">Y co-ordinate of the region</param>
91 /// <param name="cache"></param>
92 /// <returns></returns>
93 public static TestScene SetupScene(
94 string name, UUID id, uint x, uint y, CoreAssetCache cache)
95 { 107 {
96 return SetupScene(name, id, x, y, cache, new IniConfigSource()); 108 return SetupScene(name, id, x, y, new IniConfigSource());
97 } 109 }
98 110
99 /// <summary> 111 /// <summary>
100 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions 112 /// Set up a scene.
101 /// or a different, to get a brand new scene with new shared region modules.
102 /// </summary> 113 /// </summary>
103 /// <param name="name">Name of the region</param> 114 /// <param name="name">Name of the region</param>
104 /// <param name="id">ID of the region</param> 115 /// <param name="id">ID of the region</param>
105 /// <param name="x">X co-ordinate of the region</param> 116 /// <param name="x">X co-ordinate of the region</param>
106 /// <param name="y">Y co-ordinate of the region</param> 117 /// <param name="y">Y co-ordinate of the region</param>
107 /// <param name="cache"></param>
108 /// <param name="configSource"></param> 118 /// <param name="configSource"></param>
109 /// <returns></returns> 119 /// <returns></returns>
110 public static TestScene SetupScene( 120 public TestScene SetupScene(
111 string name, UUID id, uint x, uint y, CoreAssetCache cache, IConfigSource configSource) 121 string name, UUID id, uint x, uint y, IConfigSource configSource)
112 { 122 {
113 Console.WriteLine("Setting up test scene {0}", name); 123 Console.WriteLine("Setting up test scene {0}", name);
114 124
@@ -119,30 +129,47 @@ namespace OpenSim.Tests.Common
119 regInfo.RegionName = name; 129 regInfo.RegionName = name;
120 regInfo.RegionID = id; 130 regInfo.RegionID = id;
121 131
122 AgentCircuitManager acm = new AgentCircuitManager();
123 SceneCommunicationService scs = new SceneCommunicationService(); 132 SceneCommunicationService scs = new SceneCommunicationService();
124 133
125 ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
126 IEstateDataService estateDataService = null;
127
128 TestScene testScene = new TestScene( 134 TestScene testScene = new TestScene(
129 regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null); 135 regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null);
130 136
131 IRegionModule godsModule = new GodsModule(); 137 IRegionModule godsModule = new GodsModule();
132 godsModule.Initialise(testScene, new IniConfigSource()); 138 godsModule.Initialise(testScene, new IniConfigSource());
133 testScene.AddModule(godsModule.Name, godsModule); 139 testScene.AddModule(godsModule.Name, godsModule);
134 140
135 LocalAssetServicesConnector assetService = StartAssetService(testScene, cache); 141 // Add scene to services
136 StartAuthenticationService(testScene); 142 m_assetService.AddRegion(testScene);
137 LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); 143
138 StartGridService(testScene); 144 if (m_cache != null)
139 LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); 145 {
140 LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); 146 m_cache.AddRegion(testScene);
141 147 m_cache.RegionLoaded(testScene);
142 inventoryService.PostInitialise(); 148 testScene.AddRegionModule(m_cache.Name, m_cache);
143 assetService.PostInitialise(); 149 }
144 userAccountService.PostInitialise(); 150
145 presenceService.PostInitialise(); 151 m_assetService.RegionLoaded(testScene);
152 testScene.AddRegionModule(m_assetService.Name, m_assetService);
153
154 m_authenticationService.AddRegion(testScene);
155 m_authenticationService.RegionLoaded(testScene);
156 testScene.AddRegionModule(m_authenticationService.Name, m_authenticationService);
157
158 m_inventoryService.AddRegion(testScene);
159 m_inventoryService.RegionLoaded(testScene);
160 testScene.AddRegionModule(m_inventoryService.Name, m_inventoryService);
161
162 m_gridService.AddRegion(testScene);
163 m_gridService.RegionLoaded(testScene);
164 testScene.AddRegionModule(m_gridService.Name, m_gridService);
165
166 m_userAccountService.AddRegion(testScene);
167 m_userAccountService.RegionLoaded(testScene);
168 testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService);
169
170 m_presenceService.AddRegion(testScene);
171 m_presenceService.RegionLoaded(testScene);
172 testScene.AddRegionModule(m_presenceService.Name, m_presenceService);
146 173
147 testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); 174 testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random();
148 testScene.SetModuleInterfaces(); 175 testScene.SetModuleInterfaces();
@@ -162,19 +189,17 @@ namespace OpenSim.Tests.Common
162 return testScene; 189 return testScene;
163 } 190 }
164 191
165 private static LocalAssetServicesConnector StartAssetService(Scene testScene, CoreAssetCache cache) 192 private static LocalAssetServicesConnector StartAssetService(CoreAssetCache cache)
166 { 193 {
167 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
168 IConfigSource config = new IniConfigSource(); 194 IConfigSource config = new IniConfigSource();
169
170 config.AddConfig("Modules"); 195 config.AddConfig("Modules");
171 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); 196 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
172 config.AddConfig("AssetService"); 197 config.AddConfig("AssetService");
173 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); 198 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
174 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 199 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
175 200
201 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
176 assetService.Initialise(config); 202 assetService.Initialise(config);
177 assetService.AddRegion(testScene);
178 203
179 if (cache != null) 204 if (cache != null)
180 { 205 {
@@ -184,56 +209,43 @@ namespace OpenSim.Tests.Common
184 cacheConfig.AddConfig("AssetCache"); 209 cacheConfig.AddConfig("AssetCache");
185 210
186 cache.Initialise(cacheConfig); 211 cache.Initialise(cacheConfig);
187 cache.AddRegion(testScene);
188 cache.RegionLoaded(testScene);
189 testScene.AddRegionModule(cache.Name, cache);
190 } 212 }
191
192 assetService.RegionLoaded(testScene);
193 testScene.AddRegionModule(assetService.Name, assetService);
194 213
195 return assetService; 214 return assetService;
196 } 215 }
197 216
198 private static void StartAuthenticationService(Scene testScene) 217 private static LocalAuthenticationServicesConnector StartAuthenticationService()
199 { 218 {
200 ISharedRegionModule service = new LocalAuthenticationServicesConnector();
201 IConfigSource config = new IniConfigSource(); 219 IConfigSource config = new IniConfigSource();
202
203 config.AddConfig("Modules"); 220 config.AddConfig("Modules");
204 config.AddConfig("AuthenticationService"); 221 config.AddConfig("AuthenticationService");
205 config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); 222 config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector");
206 config.Configs["AuthenticationService"].Set( 223 config.Configs["AuthenticationService"].Set(
207 "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); 224 "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService");
208 config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); 225 config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
209 226
227 LocalAuthenticationServicesConnector service = new LocalAuthenticationServicesConnector();
210 service.Initialise(config); 228 service.Initialise(config);
211 service.AddRegion(testScene); 229
212 service.RegionLoaded(testScene); 230 return service;
213 testScene.AddRegionModule(service.Name, service);
214 //m_authenticationService = service;
215 } 231 }
216 232
217 private static LocalInventoryServicesConnector StartInventoryService(Scene testScene) 233 private static LocalInventoryServicesConnector StartInventoryService()
218 { 234 {
219 LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
220
221 IConfigSource config = new IniConfigSource(); 235 IConfigSource config = new IniConfigSource();
222 config.AddConfig("Modules"); 236 config.AddConfig("Modules");
223 config.AddConfig("InventoryService"); 237 config.AddConfig("InventoryService");
224 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); 238 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
225 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); 239 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
226 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 240 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
227 241
242 LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
228 inventoryService.Initialise(config); 243 inventoryService.Initialise(config);
229 inventoryService.AddRegion(testScene);
230 inventoryService.RegionLoaded(testScene);
231 testScene.AddRegionModule(inventoryService.Name, inventoryService);
232 244
233 return inventoryService; 245 return inventoryService;
234 } 246 }
235 247
236 private static LocalGridServicesConnector StartGridService(Scene testScene) 248 private static LocalGridServicesConnector StartGridService()
237 { 249 {
238 IConfigSource config = new IniConfigSource(); 250 IConfigSource config = new IniConfigSource();
239 config.AddConfig("Modules"); 251 config.AddConfig("Modules");
@@ -245,8 +257,6 @@ namespace OpenSim.Tests.Common
245 257
246 LocalGridServicesConnector gridService = new LocalGridServicesConnector(); 258 LocalGridServicesConnector gridService = new LocalGridServicesConnector();
247 gridService.Initialise(config); 259 gridService.Initialise(config);
248 gridService.AddRegion(testScene);
249 gridService.RegionLoaded(testScene);
250 260
251 return gridService; 261 return gridService;
252 } 262 }
@@ -256,7 +266,7 @@ namespace OpenSim.Tests.Common
256 /// </summary> 266 /// </summary>
257 /// <param name="testScene"></param> 267 /// <param name="testScene"></param>
258 /// <returns></returns> 268 /// <returns></returns>
259 private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) 269 private static LocalUserAccountServicesConnector StartUserAccountService()
260 { 270 {
261 IConfigSource config = new IniConfigSource(); 271 IConfigSource config = new IniConfigSource();
262 config.AddConfig("Modules"); 272 config.AddConfig("Modules");
@@ -268,10 +278,6 @@ namespace OpenSim.Tests.Common
268 278
269 LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); 279 LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector();
270 userAccountService.Initialise(config); 280 userAccountService.Initialise(config);
271
272 userAccountService.AddRegion(testScene);
273 userAccountService.RegionLoaded(testScene);
274 testScene.AddRegionModule(userAccountService.Name, userAccountService);
275 281
276 return userAccountService; 282 return userAccountService;
277 } 283 }
@@ -280,7 +286,7 @@ namespace OpenSim.Tests.Common
280 /// Start a presence service 286 /// Start a presence service
281 /// </summary> 287 /// </summary>
282 /// <param name="testScene"></param> 288 /// <param name="testScene"></param>
283 private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) 289 private static LocalPresenceServicesConnector StartPresenceService()
284 { 290 {
285 IConfigSource config = new IniConfigSource(); 291 IConfigSource config = new IniConfigSource();
286 config.AddConfig("Modules"); 292 config.AddConfig("Modules");
@@ -292,10 +298,6 @@ namespace OpenSim.Tests.Common
292 298
293 LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); 299 LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector();
294 presenceService.Initialise(config); 300 presenceService.Initialise(config);
295
296 presenceService.AddRegion(testScene);
297 presenceService.RegionLoaded(testScene);
298 testScene.AddRegionModule(presenceService.Name, presenceService);
299 301
300 return presenceService; 302 return presenceService;
301 } 303 }
@@ -313,19 +315,51 @@ namespace OpenSim.Tests.Common
313 /// <summary> 315 /// <summary>
314 /// Setup modules for a scene. 316 /// Setup modules for a scene.
315 /// </summary> 317 /// </summary>
316 /// <param name="scene"></param> 318 /// <remarks>
319 /// If called directly, then all the modules must be shared modules.
320 /// </remarks>
321 /// <param name="scenes"></param>
317 /// <param name="config"></param> 322 /// <param name="config"></param>
318 /// <param name="modules"></param> 323 /// <param name="modules"></param>
319 public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) 324 public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules)
320 { 325 {
326 SetupSceneModules(new Scene[] { scene }, config, modules);
327 }
328
329 /// <summary>
330 /// Setup modules for a scene using their default settings.
331 /// </summary>
332 /// <param name="scenes"></param>
333 /// <param name="modules"></param>
334 public static void SetupSceneModules(Scene[] scenes, params object[] modules)
335 {
336 SetupSceneModules(scenes, new IniConfigSource(), modules);
337 }
338
339 /// <summary>
340 /// Setup modules for scenes.
341 /// </summary>
342 /// <remarks>
343 /// If called directly, then all the modules must be shared modules.
344 /// </remarks>
345 /// <param name="scenes"></param>
346 /// <param name="config"></param>
347 /// <param name="modules"></param>
348 public static void SetupSceneModules(Scene[] scenes, IConfigSource config, params object[] modules)
349 {
321 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); 350 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>();
322 foreach (object module in modules) 351 foreach (object module in modules)
323 { 352 {
324 if (module is IRegionModule) 353 if (module is IRegionModule)
325 { 354 {
326 IRegionModule m = (IRegionModule)module; 355 IRegionModule m = (IRegionModule)module;
327 m.Initialise(scene, config); 356
328 scene.AddModule(m.Name, m); 357 foreach (Scene scene in scenes)
358 {
359 m.Initialise(scene, config);
360 scene.AddModule(m.Name, m);
361 }
362
329 m.PostInitialise(); 363 m.PostInitialise();
330 } 364 }
331 else if (module is IRegionModuleBase) 365 else if (module is IRegionModuleBase)
@@ -345,15 +379,19 @@ namespace OpenSim.Tests.Common
345 379
346 foreach (IRegionModuleBase module in newModules) 380 foreach (IRegionModuleBase module in newModules)
347 { 381 {
348 module.AddRegion(scene); 382 foreach (Scene scene in scenes)
349 scene.AddRegionModule(module.Name, module); 383 {
384 module.AddRegion(scene);
385 scene.AddRegionModule(module.Name, module);
386 }
350 } 387 }
351 388
352 // RegionLoaded is fired after all modules have been appropriately added to all scenes 389 // RegionLoaded is fired after all modules have been appropriately added to all scenes
353 foreach (IRegionModuleBase module in newModules) 390 foreach (IRegionModuleBase module in newModules)
354 module.RegionLoaded(scene); 391 foreach (Scene scene in scenes)
392 module.RegionLoaded(scene);
355 393
356 scene.SetModuleInterfaces(); 394 foreach (Scene scene in scenes) { scene.SetModuleInterfaces(); }
357 } 395 }
358 396
359 /// <summary> 397 /// <summary>
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
index 0e4dfb9..4b4d52d 100644
--- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs
+++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
@@ -46,6 +46,14 @@ namespace OpenSim.Tests.Common.Mock
46 { 46 {
47 m_scene = scene; 47 m_scene = scene;
48 m_parcels = new List<ILandObject>(); 48 m_parcels = new List<ILandObject>();
49 SetupDefaultParcel();
50 }
51
52 private void SetupDefaultParcel()
53 {
54 ILandObject obj = new LandObject(UUID.Zero, false, m_scene);
55 obj.LandData.Name = "Your Parcel";
56 m_parcels.Add(obj);
49 } 57 }
50 58
51 public List<ILandObject> ParcelsNearPoint(Vector3 position) 59 public List<ILandObject> ParcelsNearPoint(Vector3 position)
@@ -63,11 +71,7 @@ namespace OpenSim.Tests.Common.Mock
63 m_parcels.Clear(); 71 m_parcels.Clear();
64 72
65 if (setupDefaultParcel) 73 if (setupDefaultParcel)
66 { 74 SetupDefaultParcel();
67 ILandObject obj = new LandObject(UUID.Zero, false, m_scene);
68 obj.LandData.Name = "Your Parcel";
69 m_parcels.Add(obj);
70 }
71 } 75 }
72 76
73 protected ILandObject GetNoLand() 77 protected ILandObject GetNoLand()
@@ -102,6 +106,5 @@ namespace OpenSim.Tests.Common.Mock
102 106
103 public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} 107 public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {}
104 public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} 108 public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {}
105
106 } 109 }
107} 110} \ No newline at end of file