diff options
Diffstat (limited to 'OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs')
-rw-r--r-- | OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 129 |
1 files changed, 99 insertions, 30 deletions
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index c11691f..b1b32cc 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -54,6 +54,12 @@ namespace OpenSim.Tests.Common.Setup | |||
54 | /// </summary> | 54 | /// </summary> |
55 | public class SceneSetupHelpers | 55 | public class SceneSetupHelpers |
56 | { | 56 | { |
57 | // These static variables in order to allow regions to be linked by shared modules and same | ||
58 | // CommunicationsManager. | ||
59 | private static ISharedRegionModule m_assetService = null; | ||
60 | private static ISharedRegionModule m_inventoryService = null; | ||
61 | private static TestCommunicationsManager commsManager = null; | ||
62 | |||
57 | /// <summary> | 63 | /// <summary> |
58 | /// Set up a test scene | 64 | /// Set up a test scene |
59 | /// </summary> | 65 | /// </summary> |
@@ -63,21 +69,33 @@ namespace OpenSim.Tests.Common.Setup | |||
63 | /// <returns></returns> | 69 | /// <returns></returns> |
64 | public static TestScene SetupScene() | 70 | public static TestScene SetupScene() |
65 | { | 71 | { |
66 | return SetupScene(true); | 72 | return SetupScene(""); |
67 | } | 73 | } |
68 | 74 | ||
69 | /// <summary> | 75 | /// <summary> |
70 | /// Set up a test scene | 76 | /// Set up a test scene |
71 | /// </summary> | 77 | /// </summary> |
72 | /// | 78 | /// |
73 | /// <param name="startServices">Start associated service threads for the scene</param> | 79 | /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> |
74 | /// <returns></returns> | 80 | /// <returns></returns> |
75 | public static TestScene SetupScene(bool startServices) | 81 | public static TestScene SetupScene(String realServices) |
76 | { | 82 | { |
77 | return SetupScene( | 83 | return SetupScene( |
78 | "Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager(), startServices); | 84 | "Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager(), realServices); |
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Set up a test scene | ||
89 | /// </summary> | ||
90 | /// | ||
91 | /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> | ||
92 | /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> | ||
93 | /// <returns></returns> | ||
94 | public static TestScene SetupScene(TestCommunicationsManager cm, String realServices) | ||
95 | { | ||
96 | return SetupScene( | ||
97 | "Unit test region", UUID.Random(), 1000, 1000, cm, ""); | ||
79 | } | 98 | } |
80 | |||
81 | /// <summary> | 99 | /// <summary> |
82 | /// Set up a test scene | 100 | /// Set up a test scene |
83 | /// </summary> | 101 | /// </summary> |
@@ -89,28 +107,40 @@ namespace OpenSim.Tests.Common.Setup | |||
89 | /// <returns></returns> | 107 | /// <returns></returns> |
90 | public static TestScene SetupScene(string name, UUID id, uint x, uint y, TestCommunicationsManager cm) | 108 | public static TestScene SetupScene(string name, UUID id, uint x, uint y, TestCommunicationsManager cm) |
91 | { | 109 | { |
92 | return SetupScene(name, id, x, y, cm, true); | 110 | return SetupScene(name, id, x, y, cm, ""); |
93 | } | 111 | } |
94 | 112 | ||
95 | /// <summary> | 113 | /// <summary> |
96 | /// Set up a test scene | 114 | /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions |
115 | /// or a different, to get a brand new scene with new shared region modules. | ||
97 | /// </summary> | 116 | /// </summary> |
98 | /// <param name="name">Name of the region</param> | 117 | /// <param name="name">Name of the region</param> |
99 | /// <param name="id">ID of the region</param> | 118 | /// <param name="id">ID of the region</param> |
100 | /// <param name="x">X co-ordinate of the region</param> | 119 | /// <param name="x">X co-ordinate of the region</param> |
101 | /// <param name="y">Y co-ordinate of the region</param> | 120 | /// <param name="y">Y co-ordinate of the region</param> |
102 | /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> | 121 | /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> |
103 | /// <param name="startServices">Start associated threads for the services used by the scene</param> | 122 | /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> |
104 | /// <returns></returns> | 123 | /// <returns></returns> |
105 | public static TestScene SetupScene( | 124 | public static TestScene SetupScene( |
106 | string name, UUID id, uint x, uint y, TestCommunicationsManager cm, bool startServices) | 125 | string name, UUID id, uint x, uint y, TestCommunicationsManager cm, String realServices) |
107 | { | 126 | { |
127 | bool newScene= false; | ||
128 | |||
108 | Console.WriteLine("Setting up test scene {0}", name); | 129 | Console.WriteLine("Setting up test scene {0}", name); |
130 | |||
131 | // If cm is the same as our last commsManager used, this means the tester wants to link | ||
132 | // regions. In this case, don't use the sameshared region modules and dont initialize them again. | ||
133 | // Also, no need to start another MainServer and MainConsole instance. | ||
134 | if (cm == null || cm != commsManager) | ||
135 | { | ||
136 | System.Console.WriteLine("Starting a brand new scene"); | ||
137 | newScene = true; | ||
138 | MainConsole.Instance = new LocalConsole("TEST PROMPT"); | ||
139 | MainServer.Instance = new BaseHttpServer(980); | ||
140 | commsManager = cm; | ||
141 | } | ||
109 | 142 | ||
110 | // We must set up a console otherwise setup of some modules may fail | 143 | // We must set up a console otherwise setup of some modules may fail |
111 | MainConsole.Instance = new LocalConsole("TEST PROMPT"); | ||
112 | |||
113 | MainServer.Instance = new BaseHttpServer(980); | ||
114 | RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); | 144 | RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); |
115 | regInfo.RegionName = name; | 145 | regInfo.RegionName = name; |
116 | regInfo.RegionID = id; | 146 | regInfo.RegionID = id; |
@@ -132,44 +162,83 @@ namespace OpenSim.Tests.Common.Setup | |||
132 | IRegionModule godsModule = new GodsModule(); | 162 | IRegionModule godsModule = new GodsModule(); |
133 | godsModule.Initialise(testScene, new IniConfigSource()); | 163 | godsModule.Initialise(testScene, new IniConfigSource()); |
134 | testScene.AddModule(godsModule.Name, godsModule); | 164 | testScene.AddModule(godsModule.Name, godsModule); |
165 | realServices = realServices.ToLower(); | ||
166 | IniConfigSource config = new IniConfigSource(); | ||
167 | |||
168 | // If we have a brand new scene, need to initialize shared region modules | ||
169 | if ((m_assetService == null && m_inventoryService == null) || newScene) | ||
170 | { | ||
171 | if (realServices.Contains("asset")) | ||
172 | StartAssetService(testScene, true); | ||
173 | else | ||
174 | StartAssetService(testScene, false); | ||
175 | if (realServices.Contains("inventory")) | ||
176 | StartInventoryService(testScene, true); | ||
177 | else | ||
178 | StartInventoryService(testScene, false); | ||
179 | } | ||
180 | // If not, make sure the shared module gets references to this new scene | ||
181 | else | ||
182 | { | ||
183 | m_assetService.AddRegion(testScene); | ||
184 | m_assetService.RegionLoaded(testScene); | ||
185 | m_inventoryService.AddRegion(testScene); | ||
186 | m_inventoryService.RegionLoaded(testScene); | ||
187 | } | ||
188 | m_inventoryService.PostInitialise(); | ||
189 | m_assetService.PostInitialise(); | ||
190 | |||
191 | testScene.CommsManager.UserService.SetInventoryService(testScene.InventoryService); | ||
192 | |||
193 | testScene.SetModuleInterfaces(); | ||
135 | 194 | ||
195 | testScene.LandChannel = new TestLandChannel(); | ||
196 | testScene.LoadWorldMap(); | ||
197 | |||
198 | PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); | ||
199 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); | ||
200 | testScene.PhysicsScene | ||
201 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); | ||
202 | |||
203 | return testScene; | ||
204 | } | ||
205 | |||
206 | private static void StartAssetService(Scene testScene, bool real) | ||
207 | { | ||
136 | ISharedRegionModule assetService = new LocalAssetServicesConnector(); | 208 | ISharedRegionModule assetService = new LocalAssetServicesConnector(); |
137 | IniConfigSource config = new IniConfigSource(); | 209 | IniConfigSource config = new IniConfigSource(); |
138 | config.AddConfig("Modules"); | 210 | config.AddConfig("Modules"); |
139 | config.AddConfig("AssetService"); | 211 | config.AddConfig("AssetService"); |
140 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); | 212 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); |
141 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); | 213 | if (real) |
214 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); | ||
215 | else | ||
216 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestAssetService"); | ||
142 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 217 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
143 | assetService.Initialise(config); | 218 | assetService.Initialise(config); |
144 | assetService.AddRegion(testScene); | 219 | assetService.AddRegion(testScene); |
145 | assetService.RegionLoaded(testScene); | 220 | assetService.RegionLoaded(testScene); |
146 | testScene.AddRegionModule(assetService.Name, assetService); | 221 | testScene.AddRegionModule(assetService.Name, assetService); |
147 | assetService.PostInitialise(); | 222 | m_assetService = assetService; |
223 | } | ||
148 | 224 | ||
225 | private static void StartInventoryService(Scene testScene, bool real) | ||
226 | { | ||
149 | ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); | 227 | ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); |
150 | config = new IniConfigSource(); | 228 | IniConfigSource config = new IniConfigSource(); |
151 | config.AddConfig("Modules"); | 229 | config.AddConfig("Modules"); |
152 | config.AddConfig("InventoryService"); | 230 | config.AddConfig("InventoryService"); |
153 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); | 231 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); |
154 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); | 232 | if (real) |
233 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); | ||
234 | else | ||
235 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestInventoryService"); | ||
155 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 236 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
156 | inventoryService.Initialise(config); | 237 | inventoryService.Initialise(config); |
157 | inventoryService.AddRegion(testScene); | 238 | inventoryService.AddRegion(testScene); |
158 | inventoryService.RegionLoaded(testScene); | 239 | inventoryService.RegionLoaded(testScene); |
159 | testScene.AddRegionModule(inventoryService.Name, inventoryService); | 240 | testScene.AddRegionModule(inventoryService.Name, inventoryService); |
160 | inventoryService.PostInitialise(); | 241 | m_inventoryService = inventoryService; |
161 | |||
162 | testScene.SetModuleInterfaces(); | ||
163 | |||
164 | testScene.LandChannel = new TestLandChannel(); | ||
165 | testScene.LoadWorldMap(); | ||
166 | |||
167 | PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); | ||
168 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); | ||
169 | testScene.PhysicsScene | ||
170 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); | ||
171 | |||
172 | return testScene; | ||
173 | } | 242 | } |
174 | 243 | ||
175 | /// <summary> | 244 | /// <summary> |