aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-07-02 23:48:44 +0100
committerJustin Clark-Casey (justincc)2014-07-02 23:49:25 +0100
commit889194db63016ad4b9ecb0c6ae82d3d9c7632c95 (patch)
tree823eba42a9ce5fcb04b8c7e1ff6e50deedc726f6
parentminor: Change default max phys prim size in code to match OpenSimDefaults.ini (diff)
downloadopensim-SC_OLD-889194db63016ad4b9ecb0c6ae82d3d9c7632c95.zip
opensim-SC_OLD-889194db63016ad4b9ecb0c6ae82d3d9c7632c95.tar.gz
opensim-SC_OLD-889194db63016ad4b9ecb0c6ae82d3d9c7632c95.tar.bz2
opensim-SC_OLD-889194db63016ad4b9ecb0c6ae82d3d9c7632c95.tar.xz
Actually call Close() for shared region modules when the simulator is being shutdown.
Adds regression test for this case.
-rw-r--r--OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs87
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs8
-rw-r--r--OpenSim/Framework/Util.cs7
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs44
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SharedRegionModuleTests.cs249
-rw-r--r--OpenSim/Tests/Common/OpenSimTestCase.cs1
-rw-r--r--prebuild.xml4
9 files changed, 361 insertions, 49 deletions
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
index 510be37..e03483a 100644
--- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
@@ -32,6 +32,7 @@ using log4net;
32using Mono.Addins; 32using Mono.Addins;
33using Nini.Config; 33using Nini.Config;
34using OpenSim; 34using OpenSim;
35using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
37 38
@@ -45,6 +46,12 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
45 LogManager.GetLogger( 46 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType); 47 MethodBase.GetCurrentMethod().DeclaringType);
47 48
49 /// <summary>
50 /// Controls whether we load modules from Mono.Addins.
51 /// </summary>
52 /// <remarks>For debug purposes. Defaults to true.</remarks>
53 public bool LoadModulesFromAddins { get; set; }
54
48 // Config access 55 // Config access
49 private OpenSimBase m_openSim; 56 private OpenSimBase m_openSim;
50 57
@@ -61,6 +68,11 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
61 private List<ISharedRegionModule> m_sharedInstances = 68 private List<ISharedRegionModule> m_sharedInstances =
62 new List<ISharedRegionModule>(); 69 new List<ISharedRegionModule>();
63 70
71 public RegionModulesControllerPlugin()
72 {
73 LoadModulesFromAddins = true;
74 }
75
64#region IApplicationPlugin implementation 76#region IApplicationPlugin implementation
65 77
66 public void Initialise (OpenSimBase openSim) 78 public void Initialise (OpenSimBase openSim)
@@ -69,6 +81,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
69 m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this); 81 m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
70 m_log.DebugFormat("[REGIONMODULES]: Initializing..."); 82 m_log.DebugFormat("[REGIONMODULES]: Initializing...");
71 83
84 if (!LoadModulesFromAddins)
85 return;
86
72 // Who we are 87 // Who we are
73 string id = AddinManager.CurrentAddin.Id; 88 string id = AddinManager.CurrentAddin.Id;
74 89
@@ -88,40 +103,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
88 Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>(); 103 Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>();
89 104
90 // Scan modules and load all that aren't disabled 105 // Scan modules and load all that aren't disabled
91 foreach (TypeExtensionNode node in 106 foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
92 AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) 107 AddNode(node, modulesConfig, loadedModules);
93 {
94 IList<int> loadedModuleData;
95
96 if (!loadedModules.ContainsKey(node.Addin))
97 loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 });
98
99 loadedModuleData = loadedModules[node.Addin];
100
101 if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
102 {
103 if (CheckModuleEnabled(node, modulesConfig))
104 {
105 m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
106 m_sharedModules.Add(node);
107 loadedModuleData[0]++;
108 }
109 }
110 else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
111 {
112 if (CheckModuleEnabled(node, modulesConfig))
113 {
114 m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
115 m_nonSharedModules.Add(node);
116 loadedModuleData[1]++;
117 }
118 }
119 else
120 {
121 m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
122 loadedModuleData[2]++;
123 }
124 }
125 108
126 foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules) 109 foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules)
127 { 110 {
@@ -194,6 +177,41 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
194 177
195#region IPlugin implementation 178#region IPlugin implementation
196 179
180 private void AddNode(
181 TypeExtensionNode node, IConfig modulesConfig, Dictionary<RuntimeAddin, IList<int>> loadedModules)
182 {
183 IList<int> loadedModuleData;
184
185 if (!loadedModules.ContainsKey(node.Addin))
186 loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 });
187
188 loadedModuleData = loadedModules[node.Addin];
189
190 if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
191 {
192 if (CheckModuleEnabled(node, modulesConfig))
193 {
194 m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
195 m_sharedModules.Add(node);
196 loadedModuleData[0]++;
197 }
198 }
199 else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
200 {
201 if (CheckModuleEnabled(node, modulesConfig))
202 {
203 m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
204 m_nonSharedModules.Add(node);
205 loadedModuleData[1]++;
206 }
207 }
208 else
209 {
210 m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
211 loadedModuleData[2]++;
212 }
213 }
214
197 // We don't do that here 215 // We don't do that here
198 // 216 //
199 public void Initialise () 217 public void Initialise ()
@@ -215,6 +233,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
215 m_sharedInstances[0].Close(); 233 m_sharedInstances[0].Close();
216 m_sharedInstances.RemoveAt(0); 234 m_sharedInstances.RemoveAt(0);
217 } 235 }
236
218 m_sharedModules.Clear(); 237 m_sharedModules.Clear();
219 m_nonSharedModules.Clear(); 238 m_nonSharedModules.Clear();
220 } 239 }
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 54e6061..828a852 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -57,6 +57,11 @@ namespace OpenSim.Framework.Servers
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 58
59 /// <summary> 59 /// <summary>
60 /// Used by tests to suppress Environment.Exit(0) so that post-run operations are possible.
61 /// </summary>
62 public bool SuppressExit { get; set; }
63
64 /// <summary>
60 /// This will control a periodic log printout of the current 'show stats' (if they are active) for this 65 /// This will control a periodic log printout of the current 'show stats' (if they are active) for this
61 /// server. 66 /// server.
62 /// </summary> 67 /// </summary>
@@ -109,7 +114,8 @@ namespace OpenSim.Framework.Servers
109 114
110 base.ShutdownSpecific(); 115 base.ShutdownSpecific();
111 116
112 Environment.Exit(0); 117 if (!SuppressExit)
118 Environment.Exit(0);
113 } 119 }
114 120
115 /// <summary> 121 /// <summary>
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 740e55a..729281c 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1964,10 +1964,15 @@ namespace OpenSim.Framework
1964 { 1964 {
1965 if (maxThreads < 2) 1965 if (maxThreads < 2)
1966 throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2"); 1966 throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2");
1967
1967 if (minThreads > maxThreads || minThreads < 2) 1968 if (minThreads > maxThreads || minThreads < 2)
1968 throw new ArgumentOutOfRangeException("minThreads", "minThreads must be greater than 2 and less than or equal to maxThreads"); 1969 throw new ArgumentOutOfRangeException("minThreads", "minThreads must be greater than 2 and less than or equal to maxThreads");
1970
1969 if (m_ThreadPool != null) 1971 if (m_ThreadPool != null)
1970 throw new InvalidOperationException("SmartThreadPool is already initialized"); 1972 {
1973 m_log.Warn("SmartThreadPool is already initialized. Ignoring request.");
1974 return;
1975 }
1971 1976
1972 STPStartInfo startInfo = new STPStartInfo(); 1977 STPStartInfo startInfo = new STPStartInfo();
1973 startInfo.ThreadPoolName = "Util"; 1978 startInfo.ThreadPoolName = "Util";
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 4c1914a..d2dce24 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -71,6 +71,20 @@ namespace OpenSim
71 // OpenSim.ini Section name for ESTATES Settings 71 // OpenSim.ini Section name for ESTATES Settings
72 public const string ESTATE_SECTION_NAME = "Estates"; 72 public const string ESTATE_SECTION_NAME = "Estates";
73 73
74 /// <summary>
75 /// Allow all plugin loading to be disabled for tests/debug.
76 /// </summary>
77 /// <remarks>
78 /// true by default
79 /// </remarks>
80 public bool EnableInitialPluginLoad { get; set; }
81
82 /// <summary>
83 /// Control whether we attempt to load an estate data service.
84 /// </summary>
85 /// <remarks>For tests/debugging</remarks>
86 public bool LoadEstateDataService { get; set; }
87
74 protected string proxyUrl; 88 protected string proxyUrl;
75 protected int proxyOffset = 0; 89 protected int proxyOffset = 0;
76 90
@@ -96,7 +110,7 @@ namespace OpenSim
96 110
97 public ConsoleCommand CreateAccount = null; 111 public ConsoleCommand CreateAccount = null;
98 112
99 protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>(); 113 public List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
100 114
101 /// <value> 115 /// <value>
102 /// The config information passed into the OpenSimulator region server. 116 /// The config information passed into the OpenSimulator region server.
@@ -135,6 +149,8 @@ namespace OpenSim
135 /// <param name="configSource"></param> 149 /// <param name="configSource"></param>
136 public OpenSimBase(IConfigSource configSource) : base() 150 public OpenSimBase(IConfigSource configSource) : base()
137 { 151 {
152 EnableInitialPluginLoad = true;
153 LoadEstateDataService = true;
138 LoadConfigSettings(configSource); 154 LoadConfigSettings(configSource);
139 } 155 }
140 156
@@ -236,20 +252,25 @@ namespace OpenSim
236 if (String.IsNullOrEmpty(module)) 252 if (String.IsNullOrEmpty(module))
237 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section"); 253 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section");
238 254
239 m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config }); 255 if (LoadEstateDataService)
240 if (m_estateDataService == null) 256 {
241 throw new Exception( 257 m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
242 string.Format( 258 if (m_estateDataService == null)
243 "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.", 259 throw new Exception(
244 module)); 260 string.Format(
261 "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
262 module));
263 }
245 264
246 base.StartupSpecific(); 265 base.StartupSpecific();
247 266
248 LoadPlugins(); 267 if (EnableInitialPluginLoad)
268 LoadPlugins();
269
270 // We still want to post initalize any plugins even if loading has been disabled since a test may have
271 // inserted them manually.
249 foreach (IApplicationPlugin plugin in m_plugins) 272 foreach (IApplicationPlugin plugin in m_plugins)
250 {
251 plugin.PostInitialise(); 273 plugin.PostInitialise();
252 }
253 274
254 if (m_console != null) 275 if (m_console != null)
255 AddPluginCommands(m_console); 276 AddPluginCommands(m_console);
@@ -874,6 +895,9 @@ namespace OpenSim
874 try 895 try
875 { 896 {
876 SceneManager.Close(); 897 SceneManager.Close();
898
899 foreach (IApplicationPlugin plugin in m_plugins)
900 plugin.Dispose();
877 } 901 }
878 catch (Exception e) 902 catch (Exception e)
879 { 903 {
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index 9b0e1f4..ebec9d2 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -316,9 +316,12 @@ namespace OpenSim.Region.CoreModules.Asset
316 /// </summary> 316 /// </summary>
317 public void Close() 317 public void Close()
318 { 318 {
319 m_enabled = false; 319 if (m_enabled)
320 m_cache.Clear(); 320 {
321 m_cache = null; 321 m_enabled = false;
322 m_cache.Clear();
323 m_cache = null;
324 }
322 } 325 }
323 326
324 /// <summary> 327 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ca42d5b..3957ba6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1894,6 +1894,7 @@ namespace OpenSim.Region.Framework.Scenes
1894 RegionInfo.RegionID, 1894 RegionInfo.RegionID,
1895 RegionInfo.RegionLocX, RegionInfo.RegionLocY, 1895 RegionInfo.RegionLocX, RegionInfo.RegionLocY,
1896 RegionInfo.RegionSizeX, RegionInfo.RegionSizeY); 1896 RegionInfo.RegionSizeX, RegionInfo.RegionSizeY);
1897
1897 if (error != String.Empty) 1898 if (error != String.Empty)
1898 throw new Exception(error); 1899 throw new Exception(error);
1899 } 1900 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SharedRegionModuleTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SharedRegionModuleTests.cs
new file mode 100644
index 0000000..d499f87
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SharedRegionModuleTests.cs
@@ -0,0 +1,249 @@
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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using Mono.Addins;
32using Nini.Config;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim;
36using OpenSim.ApplicationPlugins.RegionModulesController;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Tests.Common;
41
42namespace OpenSim.Region.Framework.Scenes.Tests
43{
44 public class SharedRegionModuleTests : OpenSimTestCase
45 {
46 [Test]
47 public void TestLifecycle()
48 {
49 TestHelpers.InMethod();
50// TestHelpers.EnableLogging();
51
52 UUID estateOwnerId = TestHelpers.ParseTail(0x1);
53 UUID regionId = TestHelpers.ParseTail(0x10);
54
55 IConfigSource configSource = new IniConfigSource();
56 configSource.AddConfig("Startup");
57 configSource.AddConfig("Modules");
58
59// // We use this to skip estate questions
60 // Turns out not to be needed is estate owner id is pre-set in region information.
61// IConfig estateConfig = configSource.AddConfig(OpenSimBase.ESTATE_SECTION_NAME);
62// estateConfig.Set("DefaultEstateOwnerName", "Zaphod Beeblebrox");
63// estateConfig.Set("DefaultEstateOwnerUUID", estateOwnerId);
64// estateConfig.Set("DefaultEstateOwnerEMail", "zaphod@galaxy.com");
65// estateConfig.Set("DefaultEstateOwnerPassword", "two heads");
66
67 // For grid servic
68 configSource.AddConfig("GridService");
69 configSource.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
70 configSource.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
71 configSource.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
72 configSource.Configs["GridService"].Set("ConnectionString", "!static");
73
74 LocalGridServicesConnector gridService = new LocalGridServicesConnector();
75//
76 OpenSim sim = new OpenSim(configSource);
77
78 sim.SuppressExit = true;
79 sim.EnableInitialPluginLoad = false;
80 sim.LoadEstateDataService = false;
81 sim.NetServersInfo.HttpListenerPort = 0;
82
83 IRegistryCore reg = sim.ApplicationRegistry;
84
85 RegionInfo ri = new RegionInfo();
86 ri.RegionID = regionId;
87 ri.EstateSettings.EstateOwner = estateOwnerId;
88 ri.InternalEndPoint = new IPEndPoint(0, 0);
89
90 MockRegionModulesControllerPlugin rmcp = new MockRegionModulesControllerPlugin();
91 sim.m_plugins = new List<IApplicationPlugin>() { rmcp };
92 reg.RegisterInterface<IRegionModulesController>(rmcp);
93
94 // XXX: Have to initialize directly for now
95 rmcp.Initialise(sim);
96
97 rmcp.AddNode(gridService);
98
99 TestSharedRegion tsr = new TestSharedRegion();
100 rmcp.AddNode(tsr);
101
102 // FIXME: Want to use the real one eventually but this is currently directly tied into Mono.Addins
103 // which has been written in such a way that makes it impossible to use for regression tests.
104// RegionModulesControllerPlugin rmcp = new RegionModulesControllerPlugin();
105// rmcp.LoadModulesFromAddins = false;
106//// reg.RegisterInterface<IRegionModulesController>(rmcp);
107// rmcp.Initialise(sim);
108// rmcp.PostInitialise();
109// TypeExtensionNode node = new TypeExtensionNode();
110// node.
111// rmcp.AddNode(node, configSource.Configs["Modules"], new Dictionary<RuntimeAddin, IList<int>>());
112
113 sim.Startup();
114 IScene scene;
115 sim.CreateRegion(ri, out scene);
116
117 sim.Shutdown();
118
119 List<string> co = tsr.CallOrder;
120 int expectedEventCount = 6;
121
122 Assert.AreEqual(
123 expectedEventCount,
124 co.Count,
125 "Expected {0} events but only got {1} ({2})",
126 expectedEventCount, co.Count, string.Join(",", co));
127 Assert.AreEqual("Initialise", co[0]);
128 Assert.AreEqual("PostInitialise", co[1]);
129 Assert.AreEqual("AddRegion", co[2]);
130 Assert.AreEqual("RegionLoaded", co[3]);
131 Assert.AreEqual("RemoveRegion", co[4]);
132 Assert.AreEqual("Close", co[5]);
133 }
134 }
135
136 class TestSharedRegion : ISharedRegionModule
137 {
138 // FIXME: Should really use MethodInfo
139 public List<string> CallOrder = new List<string>();
140
141 public string Name { get { return "TestSharedRegion"; } }
142
143 public Type ReplaceableInterface { get { return null; } }
144
145 public void PostInitialise()
146 {
147 CallOrder.Add("PostInitialise");
148 }
149
150 public void Initialise(IConfigSource source)
151 {
152 CallOrder.Add("Initialise");
153 }
154
155 public void Close()
156 {
157 CallOrder.Add("Close");
158 }
159
160 public void AddRegion(Scene scene)
161 {
162 CallOrder.Add("AddRegion");
163 }
164
165 public void RemoveRegion(Scene scene)
166 {
167 CallOrder.Add("RemoveRegion");
168 }
169
170 public void RegionLoaded(Scene scene)
171 {
172 CallOrder.Add("RegionLoaded");
173 }
174 }
175
176 class MockRegionModulesControllerPlugin : IRegionModulesController, IApplicationPlugin
177 {
178 // List of shared module instances, for adding to Scenes
179 private List<ISharedRegionModule> m_sharedInstances = new List<ISharedRegionModule>();
180
181 // Config access
182 private OpenSimBase m_openSim;
183
184 public string Version { get { return "0"; } }
185 public string Name { get { return "MockRegionModulesControllerPlugin"; } }
186
187 public void Initialise() {}
188
189 public void Initialise(OpenSimBase sim)
190 {
191 m_openSim = sim;
192 }
193
194 /// <summary>
195 /// Called when the application loading is completed
196 /// </summary>
197 public void PostInitialise()
198 {
199 foreach (ISharedRegionModule module in m_sharedInstances)
200 module.PostInitialise();
201 }
202
203 public void AddRegionToModules(Scene scene)
204 {
205 List<ISharedRegionModule> sharedlist = new List<ISharedRegionModule>();
206
207 foreach (ISharedRegionModule module in m_sharedInstances)
208 {
209 module.AddRegion(scene);
210 scene.AddRegionModule(module.Name, module);
211
212 sharedlist.Add(module);
213 }
214
215 foreach (ISharedRegionModule module in sharedlist)
216 {
217 module.RegionLoaded(scene);
218 }
219 }
220
221 public void RemoveRegionFromModules(Scene scene)
222 {
223 foreach (IRegionModuleBase module in scene.RegionModules.Values)
224 {
225// m_log.DebugFormat("[REGIONMODULE]: Removing scene {0} from module {1}",
226// scene.RegionInfo.RegionName, module.Name);
227 module.RemoveRegion(scene);
228 }
229
230 scene.RegionModules.Clear();
231 }
232
233 public void AddNode(ISharedRegionModule module)
234 {
235 m_sharedInstances.Add(module);
236 module.Initialise(m_openSim.ConfigSource.Source);
237 }
238
239 public void Dispose()
240 {
241 // We expect that all regions have been removed already
242 while (m_sharedInstances.Count > 0)
243 {
244 m_sharedInstances[0].Close();
245 m_sharedInstances.RemoveAt(0);
246 }
247 }
248 }
249} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/OpenSimTestCase.cs b/OpenSim/Tests/Common/OpenSimTestCase.cs
index 3c47faa..c1415af 100644
--- a/OpenSim/Tests/Common/OpenSimTestCase.cs
+++ b/OpenSim/Tests/Common/OpenSimTestCase.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenSim.Framework;
30using OpenSim.Framework.Servers; 31using OpenSim.Framework.Servers;
31 32
32namespace OpenSim.Tests.Common 33namespace OpenSim.Tests.Common
diff --git a/prebuild.xml b/prebuild.xml
index 0143e26..e2423ae 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3185,8 +3185,11 @@
3185 <Reference name="System.Xml"/> 3185 <Reference name="System.Xml"/>
3186 <Reference name="System.Drawing"/> 3186 <Reference name="System.Drawing"/>
3187 <Reference name="System.Runtime.Remoting"/> 3187 <Reference name="System.Runtime.Remoting"/>
3188 <Reference name="Mono.Addins" path="../../../bin/"/>
3188 <Reference name="OpenMetaverseTypes" path="../../../bin/"/> 3189 <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
3189 <Reference name="OpenMetaverse" path="../../../bin/"/> 3190 <Reference name="OpenMetaverse" path="../../../bin/"/>
3191 <Reference name="OpenSim"/>
3192 <Reference name="OpenSim.ApplicationPlugins.RegionModulesController"/>
3190 <Reference name="OpenSim.Capabilities"/> 3193 <Reference name="OpenSim.Capabilities"/>
3191 <Reference name="OpenSim.Data"/> 3194 <Reference name="OpenSim.Data"/>
3192 <Reference name="OpenSim.Framework"/> 3195 <Reference name="OpenSim.Framework"/>
@@ -3195,6 +3198,7 @@
3195 <Reference name="OpenSim.Framework.Monitoring"/> 3198 <Reference name="OpenSim.Framework.Monitoring"/>
3196 <Reference name="OpenSim.Framework.Servers"/> 3199 <Reference name="OpenSim.Framework.Servers"/>
3197 <Reference name="OpenSim.Framework.Servers.HttpServer"/> 3200 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
3201 <Reference name="OpenSim.Region.ClientStack"/>
3198 <Reference name="OpenSim.Region.ClientStack.LindenCaps"/> 3202 <Reference name="OpenSim.Region.ClientStack.LindenCaps"/>
3199 <Reference name="OpenSim.Region.Framework"/> 3203 <Reference name="OpenSim.Region.Framework"/>
3200 <Reference name="OpenSim.Region.CoreModules"/> 3204 <Reference name="OpenSim.Region.CoreModules"/>