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