diff options
Diffstat (limited to 'OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs')
-rw-r--r-- | OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 119 |
1 files changed, 84 insertions, 35 deletions
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index b13e8dd..864e2aa 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -32,7 +32,7 @@ using Nini.Config; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
38 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
@@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.Avatar.Gods; | |||
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; | 45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; |
46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; | 46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; |
47 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | 47 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; |
48 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; | ||
48 | using OpenSim.Services.Interfaces; | 49 | using OpenSim.Services.Interfaces; |
49 | using OpenSim.Tests.Common.Mock; | 50 | using OpenSim.Tests.Common.Mock; |
50 | 51 | ||
@@ -60,7 +61,7 @@ namespace OpenSim.Tests.Common.Setup | |||
60 | private static ISharedRegionModule m_assetService = null; | 61 | private static ISharedRegionModule m_assetService = null; |
61 | private static ISharedRegionModule m_inventoryService = null; | 62 | private static ISharedRegionModule m_inventoryService = null; |
62 | private static ISharedRegionModule m_gridService = null; | 63 | private static ISharedRegionModule m_gridService = null; |
63 | private static TestCommunicationsManager commsManager = null; | 64 | private static ISharedRegionModule m_userAccountService = null; |
64 | 65 | ||
65 | /// <summary> | 66 | /// <summary> |
66 | /// Set up a test scene | 67 | /// Set up a test scene |
@@ -83,21 +84,23 @@ namespace OpenSim.Tests.Common.Setup | |||
83 | public static TestScene SetupScene(String realServices) | 84 | public static TestScene SetupScene(String realServices) |
84 | { | 85 | { |
85 | return SetupScene( | 86 | return SetupScene( |
86 | "Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager(), realServices); | 87 | "Unit test region", UUID.Random(), 1000, 1000, realServices); |
87 | } | 88 | } |
88 | 89 | ||
89 | /// <summary> | 90 | // REFACTORING PROBLEM. No idea what the difference is with the previous one |
90 | /// Set up a test scene | 91 | ///// <summary> |
91 | /// </summary> | 92 | ///// Set up a test scene |
92 | /// | 93 | ///// </summary> |
93 | /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> | 94 | ///// |
94 | /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> | 95 | ///// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> |
95 | /// <returns></returns> | 96 | ///// <param name="cm">This should be the same if simulating two scenes within a standalone</param> |
96 | public static TestScene SetupScene(TestCommunicationsManager cm, String realServices) | 97 | ///// <returns></returns> |
97 | { | 98 | //public static TestScene SetupScene(String realServices) |
98 | return SetupScene( | 99 | //{ |
99 | "Unit test region", UUID.Random(), 1000, 1000, cm, ""); | 100 | // return SetupScene( |
100 | } | 101 | // "Unit test region", UUID.Random(), 1000, 1000, ""); |
102 | //} | ||
103 | |||
101 | /// <summary> | 104 | /// <summary> |
102 | /// Set up a test scene | 105 | /// Set up a test scene |
103 | /// </summary> | 106 | /// </summary> |
@@ -107,9 +110,9 @@ namespace OpenSim.Tests.Common.Setup | |||
107 | /// <param name="y">Y co-ordinate of the region</param> | 110 | /// <param name="y">Y co-ordinate of the region</param> |
108 | /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> | 111 | /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> |
109 | /// <returns></returns> | 112 | /// <returns></returns> |
110 | public static TestScene SetupScene(string name, UUID id, uint x, uint y, TestCommunicationsManager cm) | 113 | public static TestScene SetupScene(string name, UUID id, uint x, uint y) |
111 | { | 114 | { |
112 | return SetupScene(name, id, x, y, cm, ""); | 115 | return SetupScene(name, id, x, y,""); |
113 | } | 116 | } |
114 | 117 | ||
115 | 118 | ||
@@ -125,23 +128,24 @@ namespace OpenSim.Tests.Common.Setup | |||
125 | /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> | 128 | /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> |
126 | /// <returns></returns> | 129 | /// <returns></returns> |
127 | public static TestScene SetupScene( | 130 | public static TestScene SetupScene( |
128 | string name, UUID id, uint x, uint y, TestCommunicationsManager cm, String realServices) | 131 | string name, UUID id, uint x, uint y, String realServices) |
129 | { | 132 | { |
130 | bool newScene = false; | 133 | bool newScene = false; |
131 | 134 | ||
132 | Console.WriteLine("Setting up test scene {0}", name); | 135 | Console.WriteLine("Setting up test scene {0}", name); |
133 | 136 | ||
134 | // If cm is the same as our last commsManager used, this means the tester wants to link | 137 | // REFACTORING PROBLEM! |
135 | // regions. In this case, don't use the sameshared region modules and dont initialize them again. | 138 | //// If cm is the same as our last commsManager used, this means the tester wants to link |
136 | // Also, no need to start another MainServer and MainConsole instance. | 139 | //// regions. In this case, don't use the sameshared region modules and dont initialize them again. |
137 | if (cm == null || cm != commsManager) | 140 | //// Also, no need to start another MainServer and MainConsole instance. |
138 | { | 141 | //if (cm == null || cm != commsManager) |
139 | System.Console.WriteLine("Starting a brand new scene"); | 142 | //{ |
140 | newScene = true; | 143 | // System.Console.WriteLine("Starting a brand new scene"); |
141 | MainConsole.Instance = new LocalConsole("TEST PROMPT"); | 144 | // newScene = true; |
142 | MainServer.Instance = new BaseHttpServer(980); | 145 | // MainConsole.Instance = new LocalConsole("TEST PROMPT"); |
143 | commsManager = cm; | 146 | // MainServer.Instance = new BaseHttpServer(980); |
144 | } | 147 | // commsManager = cm; |
148 | //} | ||
145 | 149 | ||
146 | // We must set up a console otherwise setup of some modules may fail | 150 | // We must set up a console otherwise setup of some modules may fail |
147 | RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); | 151 | RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); |
@@ -149,13 +153,13 @@ namespace OpenSim.Tests.Common.Setup | |||
149 | regInfo.RegionID = id; | 153 | regInfo.RegionID = id; |
150 | 154 | ||
151 | AgentCircuitManager acm = new AgentCircuitManager(); | 155 | AgentCircuitManager acm = new AgentCircuitManager(); |
152 | SceneCommunicationService scs = new SceneCommunicationService(cm); | 156 | SceneCommunicationService scs = new SceneCommunicationService(); |
153 | 157 | ||
154 | StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", ""); | 158 | StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", ""); |
155 | IConfigSource configSource = new IniConfigSource(); | 159 | IConfigSource configSource = new IniConfigSource(); |
156 | 160 | ||
157 | TestScene testScene = new TestScene( | 161 | TestScene testScene = new TestScene( |
158 | regInfo, acm, cm, scs, sm, null, false, false, false, configSource, null); | 162 | regInfo, acm, scs, sm, null, false, false, false, configSource, null); |
159 | 163 | ||
160 | INonSharedRegionModule capsModule = new CapabilitiesModule(); | 164 | INonSharedRegionModule capsModule = new CapabilitiesModule(); |
161 | capsModule.Initialise(new IniConfigSource()); | 165 | capsModule.Initialise(new IniConfigSource()); |
@@ -175,13 +179,16 @@ namespace OpenSim.Tests.Common.Setup | |||
175 | StartAssetService(testScene, true); | 179 | StartAssetService(testScene, true); |
176 | else | 180 | else |
177 | StartAssetService(testScene, false); | 181 | StartAssetService(testScene, false); |
182 | |||
178 | if (realServices.Contains("inventory")) | 183 | if (realServices.Contains("inventory")) |
179 | StartInventoryService(testScene, true); | 184 | StartInventoryService(testScene, true); |
180 | else | 185 | else |
181 | StartInventoryService(testScene, false); | 186 | StartInventoryService(testScene, false); |
187 | |||
182 | if (realServices.Contains("grid")) | 188 | if (realServices.Contains("grid")) |
183 | StartGridService(testScene, true); | 189 | StartGridService(testScene, true); |
184 | 190 | ||
191 | StartUserAccountService(testScene, realServices.Contains("useraccounts")); | ||
185 | } | 192 | } |
186 | // If not, make sure the shared module gets references to this new scene | 193 | // If not, make sure the shared module gets references to this new scene |
187 | else | 194 | else |
@@ -190,11 +197,13 @@ namespace OpenSim.Tests.Common.Setup | |||
190 | m_assetService.RegionLoaded(testScene); | 197 | m_assetService.RegionLoaded(testScene); |
191 | m_inventoryService.AddRegion(testScene); | 198 | m_inventoryService.AddRegion(testScene); |
192 | m_inventoryService.RegionLoaded(testScene); | 199 | m_inventoryService.RegionLoaded(testScene); |
200 | m_userAccountService.AddRegion(testScene); | ||
201 | m_userAccountService.RegionLoaded(testScene); | ||
193 | } | 202 | } |
203 | |||
194 | m_inventoryService.PostInitialise(); | 204 | m_inventoryService.PostInitialise(); |
195 | m_assetService.PostInitialise(); | 205 | m_assetService.PostInitialise(); |
196 | 206 | m_userAccountService.PostInitialise(); | |
197 | testScene.CommsManager.UserService.SetInventoryService(testScene.InventoryService); | ||
198 | 207 | ||
199 | testScene.SetModuleInterfaces(); | 208 | testScene.SetModuleInterfaces(); |
200 | 209 | ||
@@ -205,6 +214,14 @@ namespace OpenSim.Tests.Common.Setup | |||
205 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); | 214 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); |
206 | testScene.PhysicsScene | 215 | testScene.PhysicsScene |
207 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); | 216 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); |
217 | |||
218 | // It's really not a good idea to use static variables as they carry over between tests, leading to | ||
219 | // problems that are extremely hard to debug. Really, these static fields need to be eliminated - | ||
220 | // tests using multiple regions that need to share modules need to find another solution. | ||
221 | m_assetService = null; | ||
222 | m_inventoryService = null; | ||
223 | m_gridService = null; | ||
224 | m_userAccountService = null; | ||
208 | 225 | ||
209 | return testScene; | 226 | return testScene; |
210 | } | 227 | } |
@@ -269,6 +286,38 @@ namespace OpenSim.Tests.Common.Setup | |||
269 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); | 286 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); |
270 | } | 287 | } |
271 | 288 | ||
289 | /// <summary> | ||
290 | /// Start a user account service, whether real or mock | ||
291 | /// </summary> | ||
292 | /// <param name="testScene"></param> | ||
293 | /// <param name="real">Starts a real service if true, a mock service if not</param> | ||
294 | private static void StartUserAccountService(Scene testScene, bool real) | ||
295 | { | ||
296 | IConfigSource config = new IniConfigSource(); | ||
297 | config.AddConfig("Modules"); | ||
298 | config.AddConfig("UserAccountService"); | ||
299 | config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector"); | ||
300 | config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | ||
301 | |||
302 | if (real) | ||
303 | config.Configs["UserAccountService"].Set( | ||
304 | "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); | ||
305 | else | ||
306 | config.Configs["UserAccountService"].Set( | ||
307 | "LocalServiceModule", "OpenSim.Tests.Common.dll:MockUserAccountService"); | ||
308 | |||
309 | if (m_userAccountService == null) | ||
310 | { | ||
311 | ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector(); | ||
312 | userAccountService.Initialise(config); | ||
313 | m_userAccountService = userAccountService; | ||
314 | } | ||
315 | //else | ||
316 | // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService"); | ||
317 | m_userAccountService.AddRegion(testScene); | ||
318 | m_userAccountService.RegionLoaded(testScene); | ||
319 | testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService); | ||
320 | } | ||
272 | 321 | ||
273 | /// <summary> | 322 | /// <summary> |
274 | /// Setup modules for a scene using their default settings. | 323 | /// Setup modules for a scene using their default settings. |