diff options
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r-- | OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 292 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestClient.cs | 39 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestLandChannel.cs | 17 | ||||
-rw-r--r-- | OpenSim/Tests/Common/TestHelpers.cs | 47 |
4 files changed, 287 insertions, 108 deletions
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 318758d..dc24418 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs | |||
@@ -58,57 +58,74 @@ namespace OpenSim.Tests.Common | |||
58 | /// </summary> | 58 | /// </summary> |
59 | public class SceneHelpers | 59 | public class SceneHelpers |
60 | { | 60 | { |
61 | public static TestScene SetupScene() | 61 | /// <summary> |
62 | /// We need a scene manager so that test clients can retrieve a scene when performing teleport tests. | ||
63 | /// </summary> | ||
64 | public SceneManager SceneManager { get; private set; } | ||
65 | |||
66 | private AgentCircuitManager m_acm = new AgentCircuitManager(); | ||
67 | private ISimulationDataService m_simDataService | ||
68 | = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); | ||
69 | private IEstateDataService m_estateDataService; | ||
70 | |||
71 | private LocalAssetServicesConnector m_assetService; | ||
72 | private LocalAuthenticationServicesConnector m_authenticationService; | ||
73 | private LocalInventoryServicesConnector m_inventoryService; | ||
74 | private LocalGridServicesConnector m_gridService; | ||
75 | private LocalUserAccountServicesConnector m_userAccountService; | ||
76 | private LocalPresenceServicesConnector m_presenceService; | ||
77 | |||
78 | private CoreAssetCache m_cache; | ||
79 | |||
80 | public SceneHelpers() : this(null) {} | ||
81 | |||
82 | public SceneHelpers(CoreAssetCache cache) | ||
62 | { | 83 | { |
63 | return SetupScene(null); | 84 | SceneManager = new SceneManager(); |
85 | |||
86 | m_assetService = StartAssetService(cache); | ||
87 | m_authenticationService = StartAuthenticationService(); | ||
88 | m_inventoryService = StartInventoryService(); | ||
89 | m_gridService = StartGridService(); | ||
90 | m_userAccountService = StartUserAccountService(); | ||
91 | m_presenceService = StartPresenceService(); | ||
92 | |||
93 | m_inventoryService.PostInitialise(); | ||
94 | m_assetService.PostInitialise(); | ||
95 | m_userAccountService.PostInitialise(); | ||
96 | m_presenceService.PostInitialise(); | ||
97 | |||
98 | m_cache = cache; | ||
64 | } | 99 | } |
65 | 100 | ||
66 | /// <summary> | 101 | /// <summary> |
67 | /// Set up a test scene | 102 | /// Set up a test scene |
68 | /// </summary> | 103 | /// </summary> |
69 | /// <remarks> | 104 | /// <remarks> |
70 | /// Automatically starts service threads, as would the normal runtime. | 105 | /// Automatically starts services, as would the normal runtime. |
71 | /// </remarks> | 106 | /// </remarks> |
72 | /// <returns></returns> | 107 | /// <returns></returns> |
73 | public static TestScene SetupScene(CoreAssetCache cache) | 108 | public TestScene SetupScene() |
74 | { | 109 | { |
75 | return SetupScene("Unit test region", UUID.Random(), 1000, 1000, cache); | 110 | return SetupScene("Unit test region", UUID.Random(), 1000, 1000); |
76 | } | 111 | } |
77 | 112 | ||
78 | public static TestScene SetupScene(string name, UUID id, uint x, uint y) | 113 | public TestScene SetupScene(string name, UUID id, uint x, uint y) |
79 | { | 114 | { |
80 | return SetupScene(name, id, x, y, null); | 115 | return SetupScene(name, id, x, y, new IniConfigSource()); |
81 | } | 116 | } |
82 | 117 | ||
83 | /// <summary> | 118 | /// <summary> |
84 | /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions | 119 | /// Set up a scene. |
85 | /// or a different, to get a brand new scene with new shared region modules. | ||
86 | /// </summary> | 120 | /// </summary> |
87 | /// <param name="name">Name of the region</param> | 121 | /// <param name="name">Name of the region</param> |
88 | /// <param name="id">ID of the region</param> | 122 | /// <param name="id">ID of the region</param> |
89 | /// <param name="x">X co-ordinate of the region</param> | 123 | /// <param name="x">X co-ordinate of the region</param> |
90 | /// <param name="y">Y co-ordinate of the region</param> | 124 | /// <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 | { | ||
96 | return SetupScene(name, id, x, y, cache, new IniConfigSource()); | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions | ||
101 | /// or a different, to get a brand new scene with new shared region modules. | ||
102 | /// </summary> | ||
103 | /// <param name="name">Name of the region</param> | ||
104 | /// <param name="id">ID of the region</param> | ||
105 | /// <param name="x">X co-ordinate of the region</param> | ||
106 | /// <param name="y">Y co-ordinate of the region</param> | ||
107 | /// <param name="cache"></param> | ||
108 | /// <param name="configSource"></param> | 125 | /// <param name="configSource"></param> |
109 | /// <returns></returns> | 126 | /// <returns></returns> |
110 | public static TestScene SetupScene( | 127 | public TestScene SetupScene( |
111 | string name, UUID id, uint x, uint y, CoreAssetCache cache, IConfigSource configSource) | 128 | string name, UUID id, uint x, uint y, IConfigSource configSource) |
112 | { | 129 | { |
113 | Console.WriteLine("Setting up test scene {0}", name); | 130 | Console.WriteLine("Setting up test scene {0}", name); |
114 | 131 | ||
@@ -119,30 +136,47 @@ namespace OpenSim.Tests.Common | |||
119 | regInfo.RegionName = name; | 136 | regInfo.RegionName = name; |
120 | regInfo.RegionID = id; | 137 | regInfo.RegionID = id; |
121 | 138 | ||
122 | AgentCircuitManager acm = new AgentCircuitManager(); | ||
123 | SceneCommunicationService scs = new SceneCommunicationService(); | 139 | SceneCommunicationService scs = new SceneCommunicationService(); |
124 | 140 | ||
125 | ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); | ||
126 | IEstateDataService estateDataService = null; | ||
127 | |||
128 | TestScene testScene = new TestScene( | 141 | TestScene testScene = new TestScene( |
129 | regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null); | 142 | regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null); |
130 | 143 | ||
131 | IRegionModule godsModule = new GodsModule(); | 144 | IRegionModule godsModule = new GodsModule(); |
132 | godsModule.Initialise(testScene, new IniConfigSource()); | 145 | godsModule.Initialise(testScene, new IniConfigSource()); |
133 | testScene.AddModule(godsModule.Name, godsModule); | 146 | testScene.AddModule(godsModule.Name, godsModule); |
134 | 147 | ||
135 | LocalAssetServicesConnector assetService = StartAssetService(testScene, cache); | 148 | // Add scene to services |
136 | StartAuthenticationService(testScene); | 149 | m_assetService.AddRegion(testScene); |
137 | LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); | 150 | |
138 | StartGridService(testScene); | 151 | if (m_cache != null) |
139 | LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); | 152 | { |
140 | LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); | 153 | m_cache.AddRegion(testScene); |
141 | 154 | m_cache.RegionLoaded(testScene); | |
142 | inventoryService.PostInitialise(); | 155 | testScene.AddRegionModule(m_cache.Name, m_cache); |
143 | assetService.PostInitialise(); | 156 | } |
144 | userAccountService.PostInitialise(); | 157 | |
145 | presenceService.PostInitialise(); | 158 | m_assetService.RegionLoaded(testScene); |
159 | testScene.AddRegionModule(m_assetService.Name, m_assetService); | ||
160 | |||
161 | m_authenticationService.AddRegion(testScene); | ||
162 | m_authenticationService.RegionLoaded(testScene); | ||
163 | testScene.AddRegionModule(m_authenticationService.Name, m_authenticationService); | ||
164 | |||
165 | m_inventoryService.AddRegion(testScene); | ||
166 | m_inventoryService.RegionLoaded(testScene); | ||
167 | testScene.AddRegionModule(m_inventoryService.Name, m_inventoryService); | ||
168 | |||
169 | m_gridService.AddRegion(testScene); | ||
170 | m_gridService.RegionLoaded(testScene); | ||
171 | testScene.AddRegionModule(m_gridService.Name, m_gridService); | ||
172 | |||
173 | m_userAccountService.AddRegion(testScene); | ||
174 | m_userAccountService.RegionLoaded(testScene); | ||
175 | testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService); | ||
176 | |||
177 | m_presenceService.AddRegion(testScene); | ||
178 | m_presenceService.RegionLoaded(testScene); | ||
179 | testScene.AddRegionModule(m_presenceService.Name, m_presenceService); | ||
146 | 180 | ||
147 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); | 181 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); |
148 | testScene.SetModuleInterfaces(); | 182 | testScene.SetModuleInterfaces(); |
@@ -153,28 +187,28 @@ namespace OpenSim.Tests.Common | |||
153 | PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); | 187 | PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); |
154 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); | 188 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); |
155 | testScene.PhysicsScene | 189 | testScene.PhysicsScene |
156 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); | 190 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); |
157 | 191 | ||
158 | testScene.RegionInfo.EstateSettings = new EstateSettings(); | 192 | testScene.RegionInfo.EstateSettings = new EstateSettings(); |
159 | testScene.LoginsDisabled = false; | 193 | testScene.LoginsDisabled = false; |
160 | testScene.RegisterRegionWithGrid(); | 194 | testScene.RegisterRegionWithGrid(); |
161 | 195 | ||
196 | SceneManager.Add(testScene); | ||
197 | |||
162 | return testScene; | 198 | return testScene; |
163 | } | 199 | } |
164 | 200 | ||
165 | private static LocalAssetServicesConnector StartAssetService(Scene testScene, CoreAssetCache cache) | 201 | private static LocalAssetServicesConnector StartAssetService(CoreAssetCache cache) |
166 | { | 202 | { |
167 | LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); | ||
168 | IConfigSource config = new IniConfigSource(); | 203 | IConfigSource config = new IniConfigSource(); |
169 | |||
170 | config.AddConfig("Modules"); | 204 | config.AddConfig("Modules"); |
171 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); | 205 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); |
172 | config.AddConfig("AssetService"); | 206 | config.AddConfig("AssetService"); |
173 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); | 207 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); |
174 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 208 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
175 | 209 | ||
210 | LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); | ||
176 | assetService.Initialise(config); | 211 | assetService.Initialise(config); |
177 | assetService.AddRegion(testScene); | ||
178 | 212 | ||
179 | if (cache != null) | 213 | if (cache != null) |
180 | { | 214 | { |
@@ -184,56 +218,43 @@ namespace OpenSim.Tests.Common | |||
184 | cacheConfig.AddConfig("AssetCache"); | 218 | cacheConfig.AddConfig("AssetCache"); |
185 | 219 | ||
186 | cache.Initialise(cacheConfig); | 220 | cache.Initialise(cacheConfig); |
187 | cache.AddRegion(testScene); | ||
188 | cache.RegionLoaded(testScene); | ||
189 | testScene.AddRegionModule(cache.Name, cache); | ||
190 | } | 221 | } |
191 | |||
192 | assetService.RegionLoaded(testScene); | ||
193 | testScene.AddRegionModule(assetService.Name, assetService); | ||
194 | 222 | ||
195 | return assetService; | 223 | return assetService; |
196 | } | 224 | } |
197 | 225 | ||
198 | private static void StartAuthenticationService(Scene testScene) | 226 | private static LocalAuthenticationServicesConnector StartAuthenticationService() |
199 | { | 227 | { |
200 | ISharedRegionModule service = new LocalAuthenticationServicesConnector(); | ||
201 | IConfigSource config = new IniConfigSource(); | 228 | IConfigSource config = new IniConfigSource(); |
202 | |||
203 | config.AddConfig("Modules"); | 229 | config.AddConfig("Modules"); |
204 | config.AddConfig("AuthenticationService"); | 230 | config.AddConfig("AuthenticationService"); |
205 | config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); | 231 | config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); |
206 | config.Configs["AuthenticationService"].Set( | 232 | config.Configs["AuthenticationService"].Set( |
207 | "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); | 233 | "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); |
208 | config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 234 | config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
209 | 235 | ||
236 | LocalAuthenticationServicesConnector service = new LocalAuthenticationServicesConnector(); | ||
210 | service.Initialise(config); | 237 | service.Initialise(config); |
211 | service.AddRegion(testScene); | 238 | |
212 | service.RegionLoaded(testScene); | 239 | return service; |
213 | testScene.AddRegionModule(service.Name, service); | ||
214 | //m_authenticationService = service; | ||
215 | } | 240 | } |
216 | 241 | ||
217 | private static LocalInventoryServicesConnector StartInventoryService(Scene testScene) | 242 | private static LocalInventoryServicesConnector StartInventoryService() |
218 | { | 243 | { |
219 | LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); | ||
220 | |||
221 | IConfigSource config = new IniConfigSource(); | 244 | IConfigSource config = new IniConfigSource(); |
222 | config.AddConfig("Modules"); | 245 | config.AddConfig("Modules"); |
223 | config.AddConfig("InventoryService"); | 246 | config.AddConfig("InventoryService"); |
224 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); | 247 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); |
225 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); | 248 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); |
226 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 249 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
227 | 250 | ||
251 | LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); | ||
228 | inventoryService.Initialise(config); | 252 | inventoryService.Initialise(config); |
229 | inventoryService.AddRegion(testScene); | ||
230 | inventoryService.RegionLoaded(testScene); | ||
231 | testScene.AddRegionModule(inventoryService.Name, inventoryService); | ||
232 | 253 | ||
233 | return inventoryService; | 254 | return inventoryService; |
234 | } | 255 | } |
235 | 256 | ||
236 | private static LocalGridServicesConnector StartGridService(Scene testScene) | 257 | private static LocalGridServicesConnector StartGridService() |
237 | { | 258 | { |
238 | IConfigSource config = new IniConfigSource(); | 259 | IConfigSource config = new IniConfigSource(); |
239 | config.AddConfig("Modules"); | 260 | config.AddConfig("Modules"); |
@@ -245,8 +266,6 @@ namespace OpenSim.Tests.Common | |||
245 | 266 | ||
246 | LocalGridServicesConnector gridService = new LocalGridServicesConnector(); | 267 | LocalGridServicesConnector gridService = new LocalGridServicesConnector(); |
247 | gridService.Initialise(config); | 268 | gridService.Initialise(config); |
248 | gridService.AddRegion(testScene); | ||
249 | gridService.RegionLoaded(testScene); | ||
250 | 269 | ||
251 | return gridService; | 270 | return gridService; |
252 | } | 271 | } |
@@ -256,7 +275,7 @@ namespace OpenSim.Tests.Common | |||
256 | /// </summary> | 275 | /// </summary> |
257 | /// <param name="testScene"></param> | 276 | /// <param name="testScene"></param> |
258 | /// <returns></returns> | 277 | /// <returns></returns> |
259 | private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) | 278 | private static LocalUserAccountServicesConnector StartUserAccountService() |
260 | { | 279 | { |
261 | IConfigSource config = new IniConfigSource(); | 280 | IConfigSource config = new IniConfigSource(); |
262 | config.AddConfig("Modules"); | 281 | config.AddConfig("Modules"); |
@@ -268,10 +287,6 @@ namespace OpenSim.Tests.Common | |||
268 | 287 | ||
269 | LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); | 288 | LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); |
270 | userAccountService.Initialise(config); | 289 | userAccountService.Initialise(config); |
271 | |||
272 | userAccountService.AddRegion(testScene); | ||
273 | userAccountService.RegionLoaded(testScene); | ||
274 | testScene.AddRegionModule(userAccountService.Name, userAccountService); | ||
275 | 290 | ||
276 | return userAccountService; | 291 | return userAccountService; |
277 | } | 292 | } |
@@ -280,7 +295,7 @@ namespace OpenSim.Tests.Common | |||
280 | /// Start a presence service | 295 | /// Start a presence service |
281 | /// </summary> | 296 | /// </summary> |
282 | /// <param name="testScene"></param> | 297 | /// <param name="testScene"></param> |
283 | private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) | 298 | private static LocalPresenceServicesConnector StartPresenceService() |
284 | { | 299 | { |
285 | IConfigSource config = new IniConfigSource(); | 300 | IConfigSource config = new IniConfigSource(); |
286 | config.AddConfig("Modules"); | 301 | config.AddConfig("Modules"); |
@@ -292,10 +307,6 @@ namespace OpenSim.Tests.Common | |||
292 | 307 | ||
293 | LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); | 308 | LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); |
294 | presenceService.Initialise(config); | 309 | presenceService.Initialise(config); |
295 | |||
296 | presenceService.AddRegion(testScene); | ||
297 | presenceService.RegionLoaded(testScene); | ||
298 | testScene.AddRegionModule(presenceService.Name, presenceService); | ||
299 | 310 | ||
300 | return presenceService; | 311 | return presenceService; |
301 | } | 312 | } |
@@ -313,19 +324,52 @@ namespace OpenSim.Tests.Common | |||
313 | /// <summary> | 324 | /// <summary> |
314 | /// Setup modules for a scene. | 325 | /// Setup modules for a scene. |
315 | /// </summary> | 326 | /// </summary> |
316 | /// <param name="scene"></param> | 327 | /// <remarks> |
328 | /// If called directly, then all the modules must be shared modules. | ||
329 | /// </remarks> | ||
330 | /// <param name="scenes"></param> | ||
317 | /// <param name="config"></param> | 331 | /// <param name="config"></param> |
318 | /// <param name="modules"></param> | 332 | /// <param name="modules"></param> |
319 | public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) | 333 | public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) |
320 | { | 334 | { |
335 | SetupSceneModules(new Scene[] { scene }, config, modules); | ||
336 | } | ||
337 | |||
338 | /// <summary> | ||
339 | /// Setup modules for a scene using their default settings. | ||
340 | /// </summary> | ||
341 | /// <param name="scenes"></param> | ||
342 | /// <param name="modules"></param> | ||
343 | public static void SetupSceneModules(Scene[] scenes, params object[] modules) | ||
344 | { | ||
345 | SetupSceneModules(scenes, new IniConfigSource(), modules); | ||
346 | } | ||
347 | |||
348 | /// <summary> | ||
349 | /// Setup modules for scenes. | ||
350 | /// </summary> | ||
351 | /// <remarks> | ||
352 | /// If called directly, then all the modules must be shared modules. | ||
353 | /// </remarks> | ||
354 | /// <param name="scenes"></param> | ||
355 | /// <param name="config"></param> | ||
356 | /// <param name="modules"></param> | ||
357 | public static void SetupSceneModules(Scene[] scenes, IConfigSource config, params object[] modules) | ||
358 | { | ||
321 | List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); | 359 | List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); |
322 | foreach (object module in modules) | 360 | foreach (object module in modules) |
323 | { | 361 | { |
362 | // Console.WriteLine("MODULE RAW {0}", module); | ||
324 | if (module is IRegionModule) | 363 | if (module is IRegionModule) |
325 | { | 364 | { |
326 | IRegionModule m = (IRegionModule)module; | 365 | IRegionModule m = (IRegionModule)module; |
327 | m.Initialise(scene, config); | 366 | |
328 | scene.AddModule(m.Name, m); | 367 | foreach (Scene scene in scenes) |
368 | { | ||
369 | m.Initialise(scene, config); | ||
370 | scene.AddModule(m.Name, m); | ||
371 | } | ||
372 | |||
329 | m.PostInitialise(); | 373 | m.PostInitialise(); |
330 | } | 374 | } |
331 | else if (module is IRegionModuleBase) | 375 | else if (module is IRegionModuleBase) |
@@ -333,6 +377,7 @@ namespace OpenSim.Tests.Common | |||
333 | // for the new system, everything has to be initialised first, | 377 | // for the new system, everything has to be initialised first, |
334 | // shared modules have to be post-initialised, then all get an AddRegion with the scene | 378 | // shared modules have to be post-initialised, then all get an AddRegion with the scene |
335 | IRegionModuleBase m = (IRegionModuleBase)module; | 379 | IRegionModuleBase m = (IRegionModuleBase)module; |
380 | // Console.WriteLine("MODULE {0}", m.Name); | ||
336 | m.Initialise(config); | 381 | m.Initialise(config); |
337 | newModules.Add(m); | 382 | newModules.Add(m); |
338 | } | 383 | } |
@@ -345,15 +390,19 @@ namespace OpenSim.Tests.Common | |||
345 | 390 | ||
346 | foreach (IRegionModuleBase module in newModules) | 391 | foreach (IRegionModuleBase module in newModules) |
347 | { | 392 | { |
348 | module.AddRegion(scene); | 393 | foreach (Scene scene in scenes) |
349 | scene.AddRegionModule(module.Name, module); | 394 | { |
395 | module.AddRegion(scene); | ||
396 | scene.AddRegionModule(module.Name, module); | ||
397 | } | ||
350 | } | 398 | } |
351 | 399 | ||
352 | // RegionLoaded is fired after all modules have been appropriately added to all scenes | 400 | // RegionLoaded is fired after all modules have been appropriately added to all scenes |
353 | foreach (IRegionModuleBase module in newModules) | 401 | foreach (IRegionModuleBase module in newModules) |
354 | module.RegionLoaded(scene); | 402 | foreach (Scene scene in scenes) |
403 | module.RegionLoaded(scene); | ||
355 | 404 | ||
356 | scene.SetModuleInterfaces(); | 405 | foreach (Scene scene in scenes) { scene.SetModuleInterfaces(); } |
357 | } | 406 | } |
358 | 407 | ||
359 | /// <summary> | 408 | /// <summary> |
@@ -388,6 +437,10 @@ namespace OpenSim.Tests.Common | |||
388 | /// <summary> | 437 | /// <summary> |
389 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test | 438 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test |
390 | /// </summary> | 439 | /// </summary> |
440 | /// <remarks> | ||
441 | /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions | ||
442 | /// and teleport doesn't take place. | ||
443 | /// </remarks> | ||
391 | /// <param name="scene"></param> | 444 | /// <param name="scene"></param> |
392 | /// <param name="agentId"></param> | 445 | /// <param name="agentId"></param> |
393 | /// <returns></returns> | 446 | /// <returns></returns> |
@@ -397,6 +450,18 @@ namespace OpenSim.Tests.Common | |||
397 | } | 450 | } |
398 | 451 | ||
399 | /// <summary> | 452 | /// <summary> |
453 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test | ||
454 | /// </summary> | ||
455 | /// <param name="scene"></param> | ||
456 | /// <param name="agentId"></param> | ||
457 | /// <param name="sceneManager"></param> | ||
458 | /// <returns></returns> | ||
459 | public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager) | ||
460 | { | ||
461 | return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager); | ||
462 | } | ||
463 | |||
464 | /// <summary> | ||
400 | /// Add a root agent. | 465 | /// Add a root agent. |
401 | /// </summary> | 466 | /// </summary> |
402 | /// <remarks> | 467 | /// <remarks> |
@@ -416,6 +481,30 @@ namespace OpenSim.Tests.Common | |||
416 | /// <returns></returns> | 481 | /// <returns></returns> |
417 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) | 482 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) |
418 | { | 483 | { |
484 | return AddScenePresence(scene, agentData, null); | ||
485 | } | ||
486 | |||
487 | /// <summary> | ||
488 | /// Add a root agent. | ||
489 | /// </summary> | ||
490 | /// <remarks> | ||
491 | /// This function | ||
492 | /// | ||
493 | /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the | ||
494 | /// userserver if grid) would give initial login data back to the client and separately tell the scene that the | ||
495 | /// agent was coming. | ||
496 | /// | ||
497 | /// 2) Connects the agent with the scene | ||
498 | /// | ||
499 | /// This function performs actions equivalent with notifying the scene that an agent is | ||
500 | /// coming and then actually connecting the agent to the scene. The one step missed out is the very first | ||
501 | /// </remarks> | ||
502 | /// <param name="scene"></param> | ||
503 | /// <param name="agentData"></param> | ||
504 | /// <param name="sceneManager"></param> | ||
505 | /// <returns></returns> | ||
506 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) | ||
507 | { | ||
419 | // We emulate the proper login sequence here by doing things in four stages | 508 | // We emulate the proper login sequence here by doing things in four stages |
420 | 509 | ||
421 | // Stage 0: login | 510 | // Stage 0: login |
@@ -425,7 +514,7 @@ namespace OpenSim.Tests.Common | |||
425 | lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); | 514 | lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); |
426 | 515 | ||
427 | // Stages 1 & 2 | 516 | // Stages 1 & 2 |
428 | ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); | 517 | ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin); |
429 | 518 | ||
430 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. | 519 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. |
431 | sp.CompleteMovement(sp.ControllingClient, true); | 520 | sp.CompleteMovement(sp.ControllingClient, true); |
@@ -433,7 +522,20 @@ namespace OpenSim.Tests.Common | |||
433 | return sp; | 522 | return sp; |
434 | } | 523 | } |
435 | 524 | ||
436 | private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf) | 525 | /// <summary> |
526 | /// Introduce an agent into the scene by adding a new client. | ||
527 | /// </summary> | ||
528 | /// <returns>The scene presence added</returns> | ||
529 | /// <param name='sceneManager'> | ||
530 | /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not | ||
531 | /// neighbours and where no teleporting takes place. | ||
532 | /// </param> | ||
533 | /// <param name='scene'></param> | ||
534 | /// <param name='sceneManager></param> | ||
535 | /// <param name='agentData'></param> | ||
536 | /// <param name='tf'></param> | ||
537 | private static ScenePresence IntroduceClientToScene( | ||
538 | Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf) | ||
437 | { | 539 | { |
438 | string reason; | 540 | string reason; |
439 | 541 | ||
@@ -442,7 +544,7 @@ namespace OpenSim.Tests.Common | |||
442 | Console.WriteLine("NewUserConnection failed: " + reason); | 544 | Console.WriteLine("NewUserConnection failed: " + reason); |
443 | 545 | ||
444 | // Stage 2: add the new client as a child agent to the scene | 546 | // Stage 2: add the new client as a child agent to the scene |
445 | TestClient client = new TestClient(agentData, scene); | 547 | TestClient client = new TestClient(agentData, scene, sceneManager); |
446 | scene.AddNewClient(client, PresenceType.User); | 548 | scene.AddNewClient(client, PresenceType.User); |
447 | 549 | ||
448 | return scene.GetScenePresence(agentData.AgentID); | 550 | return scene.GetScenePresence(agentData.AgentID); |
@@ -454,7 +556,7 @@ namespace OpenSim.Tests.Common | |||
454 | acd.child = true; | 556 | acd.child = true; |
455 | 557 | ||
456 | // XXX: ViaLogin may not be correct for child agents | 558 | // XXX: ViaLogin may not be correct for child agents |
457 | return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin); | 559 | return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin); |
458 | } | 560 | } |
459 | 561 | ||
460 | /// <summary> | 562 | /// <summary> |
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 6a7cb0a..8cedebb 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -46,12 +46,10 @@ namespace OpenSim.Tests.Common.Mock | |||
46 | 46 | ||
47 | EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); | 47 | EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); |
48 | 48 | ||
49 | // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup | ||
50 | // methods on when a teleport is requested | ||
51 | public Scene TeleportTargetScene; | ||
52 | private TestClient TeleportSceneClient; | 49 | private TestClient TeleportSceneClient; |
53 | 50 | ||
54 | private Scene m_scene; | 51 | private Scene m_scene; |
52 | private SceneManager m_sceneManager; | ||
55 | 53 | ||
56 | // Properties so that we can get at received data for test purposes | 54 | // Properties so that we can get at received data for test purposes |
57 | public List<UUID> ReceivedOfflineNotifications { get; private set; } | 55 | public List<UUID> ReceivedOfflineNotifications { get; private set; } |
@@ -434,15 +432,29 @@ namespace OpenSim.Tests.Common.Mock | |||
434 | /// <summary> | 432 | /// <summary> |
435 | /// Constructor | 433 | /// Constructor |
436 | /// </summary> | 434 | /// </summary> |
435 | /// <remarks> | ||
436 | /// Can be used for a test where there is only one region or where there are multiple regions that are not | ||
437 | /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a | ||
438 | /// scene manager should be used. | ||
439 | /// </remarks> | ||
437 | /// <param name="agentData"></param> | 440 | /// <param name="agentData"></param> |
438 | /// <param name="scene"></param> | 441 | /// <param name="scene"></param> |
439 | public TestClient(AgentCircuitData agentData, Scene scene) | 442 | public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {} |
443 | |||
444 | /// <summary> | ||
445 | /// Constructor | ||
446 | /// </summary> | ||
447 | /// <param name="agentData"></param> | ||
448 | /// <param name="scene"></param> | ||
449 | /// <param name="sceneManager"></param> | ||
450 | public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager) | ||
440 | { | 451 | { |
441 | m_agentId = agentData.AgentID; | 452 | m_agentId = agentData.AgentID; |
442 | m_firstName = agentData.firstname; | 453 | m_firstName = agentData.firstname; |
443 | m_lastName = agentData.lastname; | 454 | m_lastName = agentData.lastname; |
444 | m_circuitCode = agentData.circuitcode; | 455 | m_circuitCode = agentData.circuitcode; |
445 | m_scene = scene; | 456 | m_scene = scene; |
457 | m_sceneManager = sceneManager; | ||
446 | SessionId = agentData.SessionID; | 458 | SessionId = agentData.SessionID; |
447 | SecureSessionId = agentData.SecureSessionID; | 459 | SecureSessionId = agentData.SecureSessionID; |
448 | CapsSeedUrl = agentData.CapsPath; | 460 | CapsSeedUrl = agentData.CapsPath; |
@@ -592,8 +604,16 @@ namespace OpenSim.Tests.Common.Mock | |||
592 | AgentCircuitData newAgent = RequestClientInfo(); | 604 | AgentCircuitData newAgent = RequestClientInfo(); |
593 | 605 | ||
594 | // Stage 2: add the new client as a child agent to the scene | 606 | // Stage 2: add the new client as a child agent to the scene |
595 | TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene); | 607 | uint x, y; |
596 | TeleportTargetScene.AddNewClient(TeleportSceneClient, PresenceType.User); | 608 | Utils.LongToUInts(neighbourHandle, out x, out y); |
609 | x /= Constants.RegionSize; | ||
610 | y /= Constants.RegionSize; | ||
611 | |||
612 | Scene neighbourScene; | ||
613 | m_sceneManager.TryGetScene(x, y, out neighbourScene); | ||
614 | |||
615 | TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager); | ||
616 | neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User); | ||
597 | } | 617 | } |
598 | 618 | ||
599 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 619 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
@@ -603,6 +623,13 @@ namespace OpenSim.Tests.Common.Mock | |||
603 | 623 | ||
604 | CapsSeedUrl = capsURL; | 624 | CapsSeedUrl = capsURL; |
605 | 625 | ||
626 | // We don't do this here so that the source region can complete processing first in a single-threaded | ||
627 | // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport | ||
628 | // CompleteTeleportClientSide(); | ||
629 | } | ||
630 | |||
631 | public void CompleteTeleportClientSide() | ||
632 | { | ||
606 | TeleportSceneClient.CompleteMovement(); | 633 | TeleportSceneClient.CompleteMovement(); |
607 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); | 634 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); |
608 | } | 635 | } |
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 |
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index ced06de..6744fca 100644 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ b/OpenSim/Tests/Common/TestHelpers.cs | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; | 29 | using System.Diagnostics; |
30 | using System.IO; | ||
31 | using System.Text; | ||
30 | using NUnit.Framework; | 32 | using NUnit.Framework; |
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | 34 | ||
@@ -34,6 +36,38 @@ namespace OpenSim.Tests.Common | |||
34 | { | 36 | { |
35 | public class TestHelpers | 37 | public class TestHelpers |
36 | { | 38 | { |
39 | private static Stream EnableLoggingConfigStream | ||
40 | = new MemoryStream( | ||
41 | Encoding.UTF8.GetBytes( | ||
42 | @"<log4net> | ||
43 | <!-- A1 is set to be a ConsoleAppender --> | ||
44 | <appender name=""A1"" type=""log4net.Appender.ConsoleAppender""> | ||
45 | |||
46 | <!-- A1 uses PatternLayout --> | ||
47 | <layout type=""log4net.Layout.PatternLayout""> | ||
48 | <!-- Print the date in ISO 8601 format --> | ||
49 | <!-- <conversionPattern value=""%date [%thread] %-5level %logger %ndc - %message%newline"" /> --> | ||
50 | <conversionPattern value=""%date %message%newline"" /> | ||
51 | </layout> | ||
52 | </appender> | ||
53 | |||
54 | <!-- Set root logger level to DEBUG and its only appender to A1 --> | ||
55 | <root> | ||
56 | <level value=""DEBUG"" /> | ||
57 | <appender-ref ref=""A1"" /> | ||
58 | </root> | ||
59 | </log4net>")); | ||
60 | |||
61 | private static Stream DisableLoggingConfigStream | ||
62 | = new MemoryStream( | ||
63 | Encoding.UTF8.GetBytes( | ||
64 | // "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>"))); | ||
65 | //"<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>"))); | ||
66 | // "<configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>")); | ||
67 | // "<configuration><log4net><root></root></log4net></configuration>"))); | ||
68 | // "<configuration><log4net><root/></log4net></configuration>")); | ||
69 | "<log4net><root/></log4net>")); | ||
70 | |||
37 | public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) | 71 | public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) |
38 | { | 72 | { |
39 | try | 73 | try |
@@ -58,6 +92,19 @@ namespace OpenSim.Tests.Common | |||
58 | Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); | 92 | Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); |
59 | } | 93 | } |
60 | 94 | ||
95 | public static void EnableLogging() | ||
96 | { | ||
97 | log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream); | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Disable logging whilst running the tests. | ||
102 | /// </summary> | ||
103 | public static void DisableLogging() | ||
104 | { | ||
105 | log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream); | ||
106 | } | ||
107 | |||
61 | /// <summary> | 108 | /// <summary> |
62 | /// Parse tail section into full UUID. | 109 | /// Parse tail section into full UUID. |
63 | /// </summary> | 110 | /// </summary> |