diff options
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r-- | OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 411 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | 47 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs | 14 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs | 35 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestClient.cs | 43 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestLandChannel.cs | 17 | ||||
-rw-r--r-- | OpenSim/Tests/Common/OpenSimTestCase.cs | 46 | ||||
-rw-r--r-- | OpenSim/Tests/Common/TestHelpers.cs | 54 |
8 files changed, 519 insertions, 148 deletions
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 318758d..769de83 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 = null; | ||
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 | { | ||
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 | { | 114 | { |
96 | return SetupScene(name, id, x, y, cache, new IniConfigSource()); | 115 | return SetupScene(name, id, x, y, new IniConfigSource()); |
97 | } | 116 | } |
98 | 117 | ||
99 | /// <summary> | 118 | /// <summary> |
100 | /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions | 119 | /// Set up a scene. |
101 | /// or a different, to get a brand new scene with new shared region modules. | ||
102 | /// </summary> | 120 | /// </summary> |
103 | /// <param name="name">Name of the region</param> | 121 | /// <param name="name">Name of the region</param> |
104 | /// <param name="id">ID of the region</param> | 122 | /// <param name="id">ID of the region</param> |
105 | /// <param name="x">X co-ordinate of the region</param> | 123 | /// <param name="x">X co-ordinate of the region</param> |
106 | /// <param name="y">Y co-ordinate of the region</param> | 124 | /// <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> |
@@ -363,31 +412,61 @@ namespace OpenSim.Tests.Common | |||
363 | /// <returns></returns> | 412 | /// <returns></returns> |
364 | public static AgentCircuitData GenerateAgentData(UUID agentId) | 413 | public static AgentCircuitData GenerateAgentData(UUID agentId) |
365 | { | 414 | { |
366 | string firstName = "testfirstname"; | 415 | AgentCircuitData acd = GenerateCommonAgentData(); |
367 | 416 | ||
368 | AgentCircuitData agentData = new AgentCircuitData(); | 417 | acd.AgentID = agentId; |
369 | agentData.AgentID = agentId; | 418 | acd.firstname = "testfirstname"; |
370 | agentData.firstname = firstName; | 419 | acd.lastname = "testlastname"; |
371 | agentData.lastname = "testlastname"; | 420 | acd.ServiceURLs = new Dictionary<string, object>(); |
421 | |||
422 | return acd; | ||
423 | } | ||
424 | |||
425 | /// <summary> | ||
426 | /// Generate some standard agent connection data. | ||
427 | /// </summary> | ||
428 | /// <param name="agentId"></param> | ||
429 | /// <returns></returns> | ||
430 | public static AgentCircuitData GenerateAgentData(UserAccount ua) | ||
431 | { | ||
432 | AgentCircuitData acd = GenerateCommonAgentData(); | ||
433 | |||
434 | acd.AgentID = ua.PrincipalID; | ||
435 | acd.firstname = ua.FirstName; | ||
436 | acd.lastname = ua.LastName; | ||
437 | acd.ServiceURLs = ua.ServiceURLs; | ||
438 | |||
439 | return acd; | ||
440 | } | ||
441 | |||
442 | private static AgentCircuitData GenerateCommonAgentData() | ||
443 | { | ||
444 | AgentCircuitData acd = new AgentCircuitData(); | ||
372 | 445 | ||
373 | // XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData. | 446 | // XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData. |
374 | agentData.SessionID = UUID.Random(); | 447 | acd.SessionID = UUID.Random(); |
375 | agentData.SecureSessionID = UUID.Random(); | 448 | acd.SecureSessionID = UUID.Random(); |
376 | 449 | ||
377 | agentData.circuitcode = 123; | 450 | acd.circuitcode = 123; |
378 | agentData.BaseFolder = UUID.Zero; | 451 | acd.BaseFolder = UUID.Zero; |
379 | agentData.InventoryFolder = UUID.Zero; | 452 | acd.InventoryFolder = UUID.Zero; |
380 | agentData.startpos = Vector3.Zero; | 453 | acd.startpos = Vector3.Zero; |
381 | agentData.CapsPath = "http://wibble.com"; | 454 | acd.CapsPath = "http://wibble.com"; |
382 | agentData.ServiceURLs = new Dictionary<string, object>(); | 455 | acd.Appearance = new AvatarAppearance(); |
383 | agentData.Appearance = new AvatarAppearance(); | 456 | |
384 | 457 | return acd; | |
385 | return agentData; | ||
386 | } | 458 | } |
387 | 459 | ||
388 | /// <summary> | 460 | /// <summary> |
389 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test | 461 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test |
390 | /// </summary> | 462 | /// </summary> |
463 | /// <remarks> | ||
464 | /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions | ||
465 | /// and teleport doesn't take place. | ||
466 | /// | ||
467 | /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will | ||
468 | /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. | ||
469 | /// </remarks> | ||
391 | /// <param name="scene"></param> | 470 | /// <param name="scene"></param> |
392 | /// <param name="agentId"></param> | 471 | /// <param name="agentId"></param> |
393 | /// <returns></returns> | 472 | /// <returns></returns> |
@@ -397,6 +476,33 @@ namespace OpenSim.Tests.Common | |||
397 | } | 476 | } |
398 | 477 | ||
399 | /// <summary> | 478 | /// <summary> |
479 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test | ||
480 | /// </summary> | ||
481 | /// <remarks> | ||
482 | /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will | ||
483 | /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. | ||
484 | /// </remarks> | ||
485 | /// <param name="scene"></param> | ||
486 | /// <param name="agentId"></param> | ||
487 | /// <param name="sceneManager"></param> | ||
488 | /// <returns></returns> | ||
489 | public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager) | ||
490 | { | ||
491 | return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager); | ||
492 | } | ||
493 | |||
494 | /// <summary> | ||
495 | /// Add a root agent. | ||
496 | /// </summary> | ||
497 | /// <param name="scene"></param> | ||
498 | /// <param name="ua"></param> | ||
499 | /// <returns></returns> | ||
500 | public static ScenePresence AddScenePresence(Scene scene, UserAccount ua) | ||
501 | { | ||
502 | return AddScenePresence(scene, GenerateAgentData(ua)); | ||
503 | } | ||
504 | |||
505 | /// <summary> | ||
400 | /// Add a root agent. | 506 | /// Add a root agent. |
401 | /// </summary> | 507 | /// </summary> |
402 | /// <remarks> | 508 | /// <remarks> |
@@ -416,6 +522,30 @@ namespace OpenSim.Tests.Common | |||
416 | /// <returns></returns> | 522 | /// <returns></returns> |
417 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) | 523 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) |
418 | { | 524 | { |
525 | return AddScenePresence(scene, agentData, null); | ||
526 | } | ||
527 | |||
528 | /// <summary> | ||
529 | /// Add a root agent. | ||
530 | /// </summary> | ||
531 | /// <remarks> | ||
532 | /// This function | ||
533 | /// | ||
534 | /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the | ||
535 | /// userserver if grid) would give initial login data back to the client and separately tell the scene that the | ||
536 | /// agent was coming. | ||
537 | /// | ||
538 | /// 2) Connects the agent with the scene | ||
539 | /// | ||
540 | /// This function performs actions equivalent with notifying the scene that an agent is | ||
541 | /// coming and then actually connecting the agent to the scene. The one step missed out is the very first | ||
542 | /// </remarks> | ||
543 | /// <param name="scene"></param> | ||
544 | /// <param name="agentData"></param> | ||
545 | /// <param name="sceneManager"></param> | ||
546 | /// <returns></returns> | ||
547 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) | ||
548 | { | ||
419 | // We emulate the proper login sequence here by doing things in four stages | 549 | // We emulate the proper login sequence here by doing things in four stages |
420 | 550 | ||
421 | // Stage 0: login | 551 | // Stage 0: login |
@@ -425,7 +555,7 @@ namespace OpenSim.Tests.Common | |||
425 | lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); | 555 | lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); |
426 | 556 | ||
427 | // Stages 1 & 2 | 557 | // Stages 1 & 2 |
428 | ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); | 558 | ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin); |
429 | 559 | ||
430 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. | 560 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. |
431 | sp.CompleteMovement(sp.ControllingClient, true); | 561 | sp.CompleteMovement(sp.ControllingClient, true); |
@@ -433,7 +563,20 @@ namespace OpenSim.Tests.Common | |||
433 | return sp; | 563 | return sp; |
434 | } | 564 | } |
435 | 565 | ||
436 | private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf) | 566 | /// <summary> |
567 | /// Introduce an agent into the scene by adding a new client. | ||
568 | /// </summary> | ||
569 | /// <returns>The scene presence added</returns> | ||
570 | /// <param name='sceneManager'> | ||
571 | /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not | ||
572 | /// neighbours and where no teleporting takes place. | ||
573 | /// </param> | ||
574 | /// <param name='scene'></param> | ||
575 | /// <param name='sceneManager></param> | ||
576 | /// <param name='agentData'></param> | ||
577 | /// <param name='tf'></param> | ||
578 | private static ScenePresence IntroduceClientToScene( | ||
579 | Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf) | ||
437 | { | 580 | { |
438 | string reason; | 581 | string reason; |
439 | 582 | ||
@@ -442,7 +585,7 @@ namespace OpenSim.Tests.Common | |||
442 | Console.WriteLine("NewUserConnection failed: " + reason); | 585 | Console.WriteLine("NewUserConnection failed: " + reason); |
443 | 586 | ||
444 | // Stage 2: add the new client as a child agent to the scene | 587 | // Stage 2: add the new client as a child agent to the scene |
445 | TestClient client = new TestClient(agentData, scene); | 588 | TestClient client = new TestClient(agentData, scene, sceneManager); |
446 | scene.AddNewClient(client, PresenceType.User); | 589 | scene.AddNewClient(client, PresenceType.User); |
447 | 590 | ||
448 | return scene.GetScenePresence(agentData.AgentID); | 591 | return scene.GetScenePresence(agentData.AgentID); |
@@ -454,7 +597,7 @@ namespace OpenSim.Tests.Common | |||
454 | acd.child = true; | 597 | acd.child = true; |
455 | 598 | ||
456 | // XXX: ViaLogin may not be correct for child agents | 599 | // XXX: ViaLogin may not be correct for child agents |
457 | return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin); | 600 | return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin); |
458 | } | 601 | } |
459 | 602 | ||
460 | /// <summary> | 603 | /// <summary> |
@@ -462,9 +605,9 @@ namespace OpenSim.Tests.Common | |||
462 | /// </summary> | 605 | /// </summary> |
463 | /// <param name="scene"></param> | 606 | /// <param name="scene"></param> |
464 | /// <returns></returns> | 607 | /// <returns></returns> |
465 | public static SceneObjectPart AddSceneObject(Scene scene) | 608 | public static SceneObjectGroup AddSceneObject(Scene scene) |
466 | { | 609 | { |
467 | return AddSceneObject(scene, "Test Object"); | 610 | return AddSceneObject(scene, "Test Object", UUID.Zero); |
468 | } | 611 | } |
469 | 612 | ||
470 | /// <summary> | 613 | /// <summary> |
@@ -472,17 +615,18 @@ namespace OpenSim.Tests.Common | |||
472 | /// </summary> | 615 | /// </summary> |
473 | /// <param name="scene"></param> | 616 | /// <param name="scene"></param> |
474 | /// <param name="name"></param> | 617 | /// <param name="name"></param> |
618 | /// <param name="ownerId"></param> | ||
475 | /// <returns></returns> | 619 | /// <returns></returns> |
476 | public static SceneObjectPart AddSceneObject(Scene scene, string name) | 620 | public static SceneObjectGroup AddSceneObject(Scene scene, string name, UUID ownerId) |
477 | { | 621 | { |
478 | SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero); | 622 | SceneObjectGroup so = new SceneObjectGroup(CreateSceneObjectPart(name, UUID.Random(), ownerId)); |
479 | 623 | ||
480 | //part.UpdatePrimFlags(false, false, true); | 624 | //part.UpdatePrimFlags(false, false, true); |
481 | //part.ObjectFlags |= (uint)PrimFlags.Phantom; | 625 | //part.ObjectFlags |= (uint)PrimFlags.Phantom; |
482 | 626 | ||
483 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); | 627 | scene.AddNewSceneObject(so, false); |
484 | 628 | ||
485 | return part; | 629 | return so; |
486 | } | 630 | } |
487 | 631 | ||
488 | /// <summary> | 632 | /// <summary> |
@@ -498,19 +642,36 @@ namespace OpenSim.Tests.Common | |||
498 | ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | 642 | ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) |
499 | { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; | 643 | { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; |
500 | } | 644 | } |
501 | 645 | ||
502 | /// <summary> | 646 | /// <summary> |
503 | /// Create a scene object but do not add it to the scene. | 647 | /// Create a scene object but do not add it to the scene. |
504 | /// </summary> | 648 | /// </summary> |
505 | /// <remarks> | 649 | /// <remarks> |
506 | /// UUID always starts at 00000000-0000-0000-0000-000000000001 | 650 | /// UUID always starts at 00000000-0000-0000-0000-000000000001. For some purposes, (e.g. serializing direct |
651 | /// to another object's inventory) we do not need a scene unique ID. So it would be better to add the | ||
652 | /// UUID when we actually add an object to a scene rather than on creation. | ||
507 | /// </remarks> | 653 | /// </remarks> |
508 | /// <param name="parts">The number of parts that should be in the scene object</param> | 654 | /// <param name="parts">The number of parts that should be in the scene object</param> |
509 | /// <param name="ownerId"></param> | 655 | /// <param name="ownerId"></param> |
510 | /// <returns></returns> | 656 | /// <returns></returns> |
511 | public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) | 657 | public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) |
512 | { | 658 | { |
513 | return CreateSceneObject(parts, ownerId, "", 0x1); | 659 | return CreateSceneObject(parts, ownerId, 0x1); |
660 | } | ||
661 | |||
662 | /// <summary> | ||
663 | /// Create a scene object but do not add it to the scene. | ||
664 | /// </summary> | ||
665 | /// <param name="parts">The number of parts that should be in the scene object</param> | ||
666 | /// <param name="ownerId"></param> | ||
667 | /// <param name="uuidTail"> | ||
668 | /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" | ||
669 | /// will be given to the root part, and incremented for each part thereafter. | ||
670 | /// </param> | ||
671 | /// <returns></returns> | ||
672 | public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail) | ||
673 | { | ||
674 | return CreateSceneObject(parts, ownerId, "", uuidTail); | ||
514 | } | 675 | } |
515 | 676 | ||
516 | /// <summary> | 677 | /// <summary> |
@@ -522,7 +683,7 @@ namespace OpenSim.Tests.Common | |||
522 | /// <param name="ownerId"></param> | 683 | /// <param name="ownerId"></param> |
523 | /// <param name="partNamePrefix"> | 684 | /// <param name="partNamePrefix"> |
524 | /// The prefix to be given to part names. This will be suffixed with "Part<part no>" | 685 | /// The prefix to be given to part names. This will be suffixed with "Part<part no>" |
525 | /// (e.g. mynamePart0 for the root part) | 686 | /// (e.g. mynamePart1 for the root part) |
526 | /// </param> | 687 | /// </param> |
527 | /// <param name="uuidTail"> | 688 | /// <param name="uuidTail"> |
528 | /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" | 689 | /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" |
@@ -535,14 +696,14 @@ namespace OpenSim.Tests.Common | |||
535 | 696 | ||
536 | SceneObjectGroup sog | 697 | SceneObjectGroup sog |
537 | = new SceneObjectGroup( | 698 | = new SceneObjectGroup( |
538 | CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId)); | 699 | CreateSceneObjectPart(string.Format("{0}Part1", partNamePrefix), new UUID(rawSogId), ownerId)); |
539 | 700 | ||
540 | if (parts > 1) | 701 | if (parts > 1) |
541 | for (int i = 1; i < parts; i++) | 702 | for (int i = 2; i <= parts; i++) |
542 | sog.AddPart( | 703 | sog.AddPart( |
543 | CreateSceneObjectPart( | 704 | CreateSceneObjectPart( |
544 | string.Format("{0}Part{1}", partNamePrefix, i), | 705 | string.Format("{0}Part{1}", partNamePrefix, i), |
545 | new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)), | 706 | new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i - 1)), |
546 | ownerId)); | 707 | ownerId)); |
547 | 708 | ||
548 | return sog; | 709 | return sog; |
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index 7058d1e..9607f1f 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | |||
@@ -45,20 +45,23 @@ namespace OpenSim.Tests.Common | |||
45 | /// </summary> | 45 | /// </summary> |
46 | /// <param name="scene"></param> | 46 | /// <param name="scene"></param> |
47 | /// <param name="part"></param> | 47 | /// <param name="part"></param> |
48 | /// <param name="itemName"></param> | ||
49 | /// <param name="itemID"></param> | ||
50 | /// <param name="assetID"></param> | ||
48 | /// <returns>The item that was added</returns> | 51 | /// <returns>The item that was added</returns> |
49 | public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part) | 52 | public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID) |
50 | { | 53 | { |
51 | AssetNotecard nc = new AssetNotecard(); | 54 | AssetNotecard nc = new AssetNotecard(); |
52 | nc.BodyText = "Hello World!"; | 55 | nc.BodyText = "Hello World!"; |
53 | nc.Encode(); | 56 | nc.Encode(); |
54 | UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | 57 | |
55 | UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | ||
56 | AssetBase ncAsset | 58 | AssetBase ncAsset |
57 | = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); | 59 | = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); |
58 | scene.AssetService.Store(ncAsset); | 60 | scene.AssetService.Store(ncAsset); |
61 | |||
59 | TaskInventoryItem ncItem | 62 | TaskInventoryItem ncItem |
60 | = new TaskInventoryItem | 63 | = new TaskInventoryItem |
61 | { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, | 64 | { Name = itemName, AssetID = assetID, ItemID = itemID, |
62 | Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; | 65 | Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; |
63 | part.Inventory.AddInventoryItem(ncItem, true); | 66 | part.Inventory.AddInventoryItem(ncItem, true); |
64 | 67 | ||
@@ -66,8 +69,42 @@ namespace OpenSim.Tests.Common | |||
66 | } | 69 | } |
67 | 70 | ||
68 | /// <summary> | 71 | /// <summary> |
72 | /// Add a blank script to the given part. | ||
73 | /// </summary> | ||
74 | /// <remarks> | ||
75 | /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these | ||
76 | /// functions more than once in a test. | ||
77 | /// </remarks> | ||
78 | /// <param name="scene"></param> | ||
79 | /// <param name="part"></param> | ||
80 | /// <returns>The item that was added</returns> | ||
81 | public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) | ||
82 | { | ||
83 | AssetScriptText ast = new AssetScriptText(); | ||
84 | ast.Encode(); | ||
85 | |||
86 | UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | ||
87 | UUID itemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | ||
88 | AssetBase asset | ||
89 | = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); | ||
90 | scene.AssetService.Store(asset); | ||
91 | TaskInventoryItem item | ||
92 | = new TaskInventoryItem | ||
93 | { Name = "scriptItem", AssetID = assetUuid, ItemID = itemUuid, | ||
94 | Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; | ||
95 | part.Inventory.AddInventoryItem(item, true); | ||
96 | |||
97 | return item; | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
69 | /// Add a scene object item to the given part. | 101 | /// Add a scene object item to the given part. |
70 | /// </summary> | 102 | /// </summary> |
103 | /// <remarks> | ||
104 | /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these | ||
105 | /// functions more than once in a test. | ||
106 | /// </remarks> | ||
107 | /// | ||
71 | /// <param name="scene"></param> | 108 | /// <param name="scene"></param> |
72 | /// <param name="sop"></param> | 109 | /// <param name="sop"></param> |
73 | /// <param name="itemName"></param> | 110 | /// <param name="itemName"></param> |
diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs index b73df2c..2fbebc4 100644 --- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs | |||
@@ -126,6 +126,11 @@ namespace OpenSim.Tests.Common | |||
126 | return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll"); | 126 | return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll"); |
127 | } | 127 | } |
128 | 128 | ||
129 | public static UserAccount CreateUserWithInventory(Scene scene, int userId) | ||
130 | { | ||
131 | return CreateUserWithInventory(scene, "Bill", "Bailey", TestHelpers.ParseTail(userId), "troll"); | ||
132 | } | ||
133 | |||
129 | public static UserAccount CreateUserWithInventory( | 134 | public static UserAccount CreateUserWithInventory( |
130 | Scene scene, string firstName, string lastName, UUID userId, string pw) | 135 | Scene scene, string firstName, string lastName, UUID userId, string pw) |
131 | { | 136 | { |
@@ -133,6 +138,15 @@ namespace OpenSim.Tests.Common | |||
133 | CreateUserWithInventory(scene, ua, pw); | 138 | CreateUserWithInventory(scene, ua, pw); |
134 | return ua; | 139 | return ua; |
135 | } | 140 | } |
141 | |||
142 | public static UserAccount CreateUserWithInventory( | ||
143 | Scene scene, string firstName, string lastName, int userId, string pw) | ||
144 | { | ||
145 | UserAccount ua | ||
146 | = new UserAccount(TestHelpers.ParseTail(userId)) { FirstName = firstName, LastName = lastName }; | ||
147 | CreateUserWithInventory(scene, ua, pw); | ||
148 | return ua; | ||
149 | } | ||
136 | 150 | ||
137 | public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) | 151 | public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) |
138 | { | 152 | { |
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs index 38fbbe3..3f99a39 100644 --- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs | |||
@@ -113,6 +113,21 @@ namespace OpenSim.Data.Null | |||
113 | m_store.StoreRegionWindlightSettings(wl); | 113 | m_store.StoreRegionWindlightSettings(wl); |
114 | } | 114 | } |
115 | 115 | ||
116 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | ||
117 | { | ||
118 | return m_store.LoadRegionEnvironmentSettings(regionUUID); | ||
119 | } | ||
120 | |||
121 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | ||
122 | { | ||
123 | m_store.StoreRegionEnvironmentSettings(regionUUID, settings); | ||
124 | } | ||
125 | |||
126 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | ||
127 | { | ||
128 | m_store.RemoveRegionEnvironmentSettings(regionUUID); | ||
129 | } | ||
130 | |||
116 | public UUID[] GetObjectIDs(UUID regionID) | 131 | public UUID[] GetObjectIDs(UUID regionID) |
117 | { | 132 | { |
118 | return new UUID[0]; | 133 | return new UUID[0]; |
@@ -163,7 +178,25 @@ namespace OpenSim.Data.Null | |||
163 | { | 178 | { |
164 | //This connector doesn't support the windlight module yet | 179 | //This connector doesn't support the windlight module yet |
165 | } | 180 | } |
166 | 181 | ||
182 | #region Environment Settings | ||
183 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | ||
184 | { | ||
185 | //This connector doesn't support the Environment module yet | ||
186 | return string.Empty; | ||
187 | } | ||
188 | |||
189 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | ||
190 | { | ||
191 | //This connector doesn't support the Environment module yet | ||
192 | } | ||
193 | |||
194 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | ||
195 | { | ||
196 | //This connector doesn't support the Environment module yet | ||
197 | } | ||
198 | #endregion | ||
199 | |||
167 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 200 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
168 | { | 201 | { |
169 | RegionSettings rs = null; | 202 | RegionSettings rs = null; |
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index b2c824c..fb70904 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; } |
@@ -435,15 +433,29 @@ namespace OpenSim.Tests.Common.Mock | |||
435 | /// <summary> | 433 | /// <summary> |
436 | /// Constructor | 434 | /// Constructor |
437 | /// </summary> | 435 | /// </summary> |
436 | /// <remarks> | ||
437 | /// Can be used for a test where there is only one region or where there are multiple regions that are not | ||
438 | /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a | ||
439 | /// scene manager should be used. | ||
440 | /// </remarks> | ||
438 | /// <param name="agentData"></param> | 441 | /// <param name="agentData"></param> |
439 | /// <param name="scene"></param> | 442 | /// <param name="scene"></param> |
440 | public TestClient(AgentCircuitData agentData, Scene scene) | 443 | public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {} |
444 | |||
445 | /// <summary> | ||
446 | /// Constructor | ||
447 | /// </summary> | ||
448 | /// <param name="agentData"></param> | ||
449 | /// <param name="scene"></param> | ||
450 | /// <param name="sceneManager"></param> | ||
451 | public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager) | ||
441 | { | 452 | { |
442 | m_agentId = agentData.AgentID; | 453 | m_agentId = agentData.AgentID; |
443 | m_firstName = agentData.firstname; | 454 | m_firstName = agentData.firstname; |
444 | m_lastName = agentData.lastname; | 455 | m_lastName = agentData.lastname; |
445 | m_circuitCode = agentData.circuitcode; | 456 | m_circuitCode = agentData.circuitcode; |
446 | m_scene = scene; | 457 | m_scene = scene; |
458 | m_sceneManager = sceneManager; | ||
447 | SessionId = agentData.SessionID; | 459 | SessionId = agentData.SessionID; |
448 | SecureSessionId = agentData.SecureSessionID; | 460 | SecureSessionId = agentData.SecureSessionID; |
449 | CapsSeedUrl = agentData.CapsPath; | 461 | CapsSeedUrl = agentData.CapsPath; |
@@ -593,8 +605,16 @@ namespace OpenSim.Tests.Common.Mock | |||
593 | AgentCircuitData newAgent = RequestClientInfo(); | 605 | AgentCircuitData newAgent = RequestClientInfo(); |
594 | 606 | ||
595 | // Stage 2: add the new client as a child agent to the scene | 607 | // Stage 2: add the new client as a child agent to the scene |
596 | TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene); | 608 | uint x, y; |
597 | TeleportTargetScene.AddNewClient(TeleportSceneClient, PresenceType.User); | 609 | Utils.LongToUInts(neighbourHandle, out x, out y); |
610 | x /= Constants.RegionSize; | ||
611 | y /= Constants.RegionSize; | ||
612 | |||
613 | Scene neighbourScene; | ||
614 | m_sceneManager.TryGetScene(x, y, out neighbourScene); | ||
615 | |||
616 | TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager); | ||
617 | neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User); | ||
598 | } | 618 | } |
599 | 619 | ||
600 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 620 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
@@ -604,6 +624,13 @@ namespace OpenSim.Tests.Common.Mock | |||
604 | 624 | ||
605 | CapsSeedUrl = capsURL; | 625 | CapsSeedUrl = capsURL; |
606 | 626 | ||
627 | // We don't do this here so that the source region can complete processing first in a single-threaded | ||
628 | // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport | ||
629 | // CompleteTeleportClientSide(); | ||
630 | } | ||
631 | |||
632 | public void CompleteTeleportClientSide() | ||
633 | { | ||
607 | TeleportSceneClient.CompleteMovement(); | 634 | TeleportSceneClient.CompleteMovement(); |
608 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); | 635 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); |
609 | } | 636 | } |
@@ -1104,10 +1131,6 @@ namespace OpenSim.Tests.Common.Mock | |||
1104 | { | 1131 | { |
1105 | } | 1132 | } |
1106 | 1133 | ||
1107 | public void KillEndDone() | ||
1108 | { | ||
1109 | } | ||
1110 | |||
1111 | public void SendEventInfoReply (EventData info) | 1134 | public void SendEventInfoReply (EventData info) |
1112 | { | 1135 | { |
1113 | } | 1136 | } |
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/OpenSimTestCase.cs b/OpenSim/Tests/Common/OpenSimTestCase.cs new file mode 100644 index 0000000..8c40923 --- /dev/null +++ b/OpenSim/Tests/Common/OpenSimTestCase.cs | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using NUnit.Framework; | ||
30 | |||
31 | namespace OpenSim.Tests.Common | ||
32 | { | ||
33 | [TestFixture] | ||
34 | public class OpenSimTestCase | ||
35 | { | ||
36 | [SetUp] | ||
37 | public virtual void SetUp() | ||
38 | { | ||
39 | // TestHelpers.InMethod(); | ||
40 | // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests | ||
41 | // to have logging on if it failed with an exception. | ||
42 | TestHelpers.DisableLogging(); | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | |||
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index ced06de..30121fe 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 MemoryStream 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,26 @@ 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 | /// <remarks> | ||
104 | /// Remember, if a regression test throws an exception before completing this will not be invoked if it's at | ||
105 | /// the end of the test. | ||
106 | /// TODO: Always invoke this after every test - probably need to make all test cases inherit from a common | ||
107 | /// TestCase class where this can be done. | ||
108 | /// </remarks> | ||
109 | public static void DisableLogging() | ||
110 | { | ||
111 | log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream); | ||
112 | DisableLoggingConfigStream.Position = 0; | ||
113 | } | ||
114 | |||
61 | /// <summary> | 115 | /// <summary> |
62 | /// Parse tail section into full UUID. | 116 | /// Parse tail section into full UUID. |
63 | /// </summary> | 117 | /// </summary> |