From 7c6c776ff783b30dfc26a065e63c267e46edc53b Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 27 Nov 2008 19:28:04 +0000
Subject: * test: Add the ability to add a plugin directory to the user and
inventory services in order to extend unit tests for user and inventory
information * I can't spend any longer in trying to get Mono.Addins to work
with the unit tests, so this is not a proper plugin at this time
---
.../Communications/CommunicationsManager.cs | 1 -
.../Communications/InventoryServiceBase.cs | 19 +++-
.../Framework/Communications/UserManagerBase.cs | 32 +++++--
OpenSim/Framework/PluginLoader.cs | 103 +++++++++++----------
OpenSim/Region/Environment/Scenes/Scene.cs | 2 +
.../Environment/Scenes/Tests/SceneObjectTests.cs | 14 ++-
.../Environment/Scenes/Tests/ScenePresenceTests.cs | 4 +-
.../Scenes/Tests/TestCommunicationsManager.cs | 4 +-
8 files changed, 111 insertions(+), 68 deletions(-)
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index 3f46776..bcf9bed 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -110,7 +110,6 @@ namespace OpenSim.Framework.Communications
///
protected IUserServiceAdmin m_userServiceAdmin;
-
public BaseHttpServer HttpServer
{
get { return m_httpServer; }
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index 5841151..777e15b 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -48,20 +48,29 @@ namespace OpenSim.Framework.Communications
#region Plugin methods
///
- /// Adds a new user server plugin - plugins will be requested in the order they were loaded.
+ /// Add a new inventory data plugin - plugins will be requested in the order they were added.
///
- /// The filename to the user server plugin DLL
+ /// The plugin that will provide data
+ public void AddPlugin(IInventoryDataPlugin plugin)
+ {
+ m_plugins.Add(plugin);
+ }
+
+ ///
+ /// Adds a new inventory data plugin - plugins will be requested in the order they were loaded.
+ ///
+ /// The filename of the inventory server plugin DLL
public void AddPlugin(string provider, string connect)
{
PluginLoader loader =
- new PluginLoader (new InventoryDataInitialiser (connect));
+ new PluginLoader (new InventoryDataInitialiser(connect));
// loader will try to load all providers (MySQL, MSSQL, etc)
// unless it is constrainted to the correct "Provider" entry in the addin.xml
- loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider));
+ loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter(provider));
loader.Load();
- m_plugins = loader.Plugins;
+ m_plugins.AddRange(loader.Plugins);
}
#endregion
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index 2a66260..a929317 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -48,12 +48,24 @@ namespace OpenSim.Framework.Communications
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// List of plugins to search for user data
+ ///
private List _plugins = new List();
+
+ ///
+ /// Add a new user data plugin - plugins will be requested in the order they were added.
+ ///
+ /// The plugin that will provide user data
+ public void AddPlugin(IUserDataPlugin plugin)
+ {
+ _plugins.Add(plugin);
+ }
///
- /// Adds a new user server plugin - user servers will be requested in the order they were loaded.
+ /// Add a new user data plugin - plugins will be requested in the order they were added.
///
- /// The filename to the user server plugin DLL
+ /// The filename to the user data plugin DLL
///
public void AddPlugin(string provider, string connect)
{
@@ -65,7 +77,7 @@ namespace OpenSim.Framework.Communications
loader.Add("/OpenSim/UserData", new PluginProviderFilter(provider));
loader.Load();
- _plugins = loader.Plugins;
+ _plugins.AddRange(loader.Plugins);
}
#region Get UserProfile
@@ -637,7 +649,7 @@ namespace OpenSim.Framework.Communications
}
catch (Exception e)
{
- m_log.Info("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")");
+ m_log.Error("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")");
}
}
@@ -696,8 +708,11 @@ namespace OpenSim.Framework.Communications
return false;
}
- /// Appearance
- /// TODO: stubs for now to get us to a compiling state gently
+ ///
+ /// Get avatar appearance information
+ ///
+ ///
+ ///
public AvatarAppearance GetUserAppearance(UUID user)
{
foreach (IUserDataPlugin plugin in _plugins)
@@ -714,6 +729,11 @@ namespace OpenSim.Framework.Communications
return null;
}
+ ///
+ /// Update avatar appearance information
+ ///
+ ///
+ ///
public void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
{
foreach (IUserDataPlugin plugin in _plugins)
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs
index 440e0d5..baf9c57 100644
--- a/OpenSim/Framework/PluginLoader.cs
+++ b/OpenSim/Framework/PluginLoader.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Framework
public interface IPluginConstraint
{
string Message { get; }
- bool Apply (string extpoint);
+ bool Apply(string extpoint);
}
///
@@ -60,7 +60,7 @@ namespace OpenSim.Framework
///
public interface IPluginFilter
{
- bool Apply (PluginExtensionNode plugin);
+ bool Apply(PluginExtensionNode plugin);
}
///
@@ -99,89 +99,90 @@ namespace OpenSim.Framework
get { return (loaded.Count == 1)? loaded [0] : default (T); }
}
- public PluginLoader ()
+ public PluginLoader()
{
Initialiser = new PluginInitialiserBase();
- initialise_plugin_dir_ (".");
+ initialise_plugin_dir_(".");
}
- public PluginLoader (PluginInitialiserBase init)
+ public PluginLoader(PluginInitialiserBase init)
{
Initialiser = init;
- initialise_plugin_dir_ (".");
+ initialise_plugin_dir_(".");
}
- public PluginLoader (PluginInitialiserBase init, string dir)
+ public PluginLoader(PluginInitialiserBase init, string dir)
{
Initialiser = init;
- initialise_plugin_dir_ (dir);
+ initialise_plugin_dir_(dir);
}
- public void Add (string extpoint)
+ public void Add(string extpoint)
{
- if (extpoints.Contains (extpoint))
+ if (extpoints.Contains(extpoint))
return;
- extpoints.Add (extpoint);
+ extpoints.Add(extpoint);
}
- public void Add (string extpoint, IPluginConstraint cons)
+ public void Add(string extpoint, IPluginConstraint cons)
{
- Add (extpoint);
- AddConstraint (extpoint, cons);
+ Add(extpoint);
+ AddConstraint(extpoint, cons);
}
- public void Add (string extpoint, IPluginFilter filter)
+ public void Add(string extpoint, IPluginFilter filter)
{
- Add (extpoint);
- AddFilter (extpoint, filter);
+ Add(extpoint);
+ AddFilter(extpoint, filter);
}
- public void AddConstraint (string extpoint, IPluginConstraint cons)
+ public void AddConstraint(string extpoint, IPluginConstraint cons)
{
- constraints.Add (extpoint, cons);
+ constraints.Add(extpoint, cons);
}
- public void AddFilter (string extpoint, IPluginFilter filter)
+ public void AddFilter(string extpoint, IPluginFilter filter)
{
- filters.Add (extpoint, filter);
+ filters.Add(extpoint, filter);
}
- public void Load (string extpoint)
+ public void Load(string extpoint)
{
- Add (extpoint);
+ Add(extpoint);
Load();
}
- public void Load ()
+ public void Load()
{
foreach (string ext in extpoints)
{
log.Info("[PLUGINS]: Loading extension point " + ext);
- if (constraints.ContainsKey (ext))
+ if (constraints.ContainsKey(ext))
{
- IPluginConstraint cons = constraints [ext];
- if (cons.Apply (ext))
- log.Error ("[PLUGINS]: " + ext + " failed constraint: " + cons.Message);
+ IPluginConstraint cons = constraints[ext];
+ if (cons.Apply(ext))
+ log.Error("[PLUGINS]: " + ext + " failed constraint: " + cons.Message);
}
IPluginFilter filter = null;
- if (filters.ContainsKey (ext))
- filter = filters [ext];
+ if (filters.ContainsKey(ext))
+ filter = filters[ext];
List loadedPlugins = new List();
- foreach (PluginExtensionNode node in AddinManager.GetExtensionNodes (ext))
+ foreach (PluginExtensionNode node in AddinManager.GetExtensionNodes(ext))
{
log.Info("[PLUGINS]: Trying plugin " + node.Path);
- if ((filter != null) && (filter.Apply (node) == false))
+ if ((filter != null) && (filter.Apply(node) == false))
continue;
- T plugin = (T) node.CreateInstance();
+ T plugin = (T)node.CreateInstance();
loadedPlugins.Add(plugin);
}
+
// We do Initialise() in a second loop after CreateInstance
// So that modules who need init before others can do it
// Example: Script Engine Component System needs to load its components before RegionLoader starts
@@ -193,28 +194,28 @@ namespace OpenSim.Framework
}
}
- public void Dispose ()
+ public void Dispose()
{
foreach (T plugin in Plugins)
- plugin.Dispose ();
+ plugin.Dispose();
}
- private void initialise_plugin_dir_ (string dir)
+ private void initialise_plugin_dir_(string dir)
{
if (AddinManager.IsInitialized == true)
return;
- log.Info("[PLUGINS]: Initializing");
+ log.Info("[PLUGINS]: Initializing addin manager");
AddinManager.AddinLoadError += on_addinloaderror_;
AddinManager.AddinLoaded += on_addinloaded_;
clear_registry_();
- suppress_console_output_ (true);
- AddinManager.Initialize (dir);
- AddinManager.Registry.Update (null);
- suppress_console_output_ (false);
+ suppress_console_output_(true);
+ AddinManager.Initialize(dir);
+ AddinManager.Registry.Update(null);
+ suppress_console_output_(false);
}
private void on_addinloaded_(object sender, AddinEventArgs args)
@@ -233,7 +234,7 @@ namespace OpenSim.Framework
+ args.Exception.StackTrace);
}
- private void clear_registry_ ()
+ private void clear_registry_()
{
// The Mono addin manager (in Mono.Addins.dll version 0.2.0.0)
// occasionally seems to corrupt its addin cache
@@ -259,7 +260,7 @@ namespace OpenSim.Framework
}
private static TextWriter prev_console_;
- public void suppress_console_output_ (bool save)
+ public void suppress_console_output_(bool save)
{
if (save)
{
@@ -295,15 +296,15 @@ namespace OpenSim.Framework
return typeobj;
if (type.Length == 0)
- throw new InvalidOperationException ("Type name not specified.");
+ throw new InvalidOperationException("Type name not specified.");
- return typeobj = Addin.GetType (type, true);
+ return typeobj = Addin.GetType(type, true);
}
}
- public object CreateInstance ()
+ public object CreateInstance()
{
- return Activator.CreateInstance (TypeObject);
+ return Activator.CreateInstance(TypeObject);
}
}
@@ -315,13 +316,13 @@ namespace OpenSim.Framework
private int min;
private int max;
- public PluginCountConstraint (int exact)
+ public PluginCountConstraint(int exact)
{
min = exact;
max = exact;
}
- public PluginCountConstraint (int minimum, int maximum)
+ public PluginCountConstraint(int minimum, int maximum)
{
min = minimum;
max = maximum;
@@ -338,10 +339,10 @@ namespace OpenSim.Framework
public bool Apply (string extpoint)
{
- int count = AddinManager.GetExtensionNodes (extpoint).Count;
+ int count = AddinManager.GetExtensionNodes(extpoint).Count;
if ((count < min) || (count > max))
- throw new PluginConstraintViolatedException (Message);
+ throw new PluginConstraintViolatedException(Message);
return true;
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 71ef524..3e34ffb 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -2789,8 +2789,10 @@ namespace OpenSim.Region.Environment.Scenes
}
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
+
// rewrite session_id
CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID);
+
if (userinfo != null)
{
userinfo.SessionID = agent.SessionID;
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
index a24161e..216dce5 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
@@ -31,6 +31,8 @@ using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
+using OpenSim.Framework.Communications.Cache;
+using OpenSim.Region.Communications.Local;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Scenes.Tests
@@ -57,7 +59,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests
///
/// Test adding an object to a scene.
///
- [Test]
+ [Test]
public void TestAddSceneObject()
{
Scene scene = SceneTestUtils.SetupScene();
@@ -99,6 +101,11 @@ namespace OpenSim.Region.Environment.Scenes.Tests
SceneObjectPart part = SceneTestUtils.AddSceneObject(scene);
+ ((LocalUserServices)scene.CommsManager.UserService).AddPlugin(new TestUserDataPlugin());
+// Assert.That(
+// scene.CommsManager.AddUser("Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId),
+// Is.EqualTo(agentId));
+
IClientAPI client = SceneTestUtils.AddRootAgent(scene, agentId);
scene.DeRezObject(client, part.LocalId, UUID.Zero, 9, UUID.Zero);
@@ -107,7 +114,10 @@ namespace OpenSim.Region.Environment.Scenes.Tests
sogd.InventoryDeQueueAndDelete();
SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
- Assert.That(retrievedPart2, Is.Null);
+ Assert.That(retrievedPart2, Is.Null);
+
+// CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId);
+// Assert.That(userInfo, Is.Not.Null);
// TODO: test that the object actually made it successfully into inventory
}
diff --git a/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
index fcc6c41..587d288 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
@@ -85,8 +85,8 @@ namespace OpenSim.Region.Environment.Scenes.Tests
///
/// Test removing an uncrossed root agent from a scene.
- ///
- [Test]
+ ///
+ [Test]
public void TestRemoveRootAgent()
{
Scene scene = SceneTestUtils.SetupScene();
diff --git a/OpenSim/Region/Environment/Scenes/Tests/TestCommunicationsManager.cs b/OpenSim/Region/Environment/Scenes/Tests/TestCommunicationsManager.cs
index 2225edd..9b2046b 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/TestCommunicationsManager.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/TestCommunicationsManager.cs
@@ -38,7 +38,9 @@ namespace OpenSim.Region.Environment.Scenes.Tests
public TestCommunicationsManager()
: base(null, null, null, false, null)
{
- m_userService = new LocalUserServices(null, 991, 992, null);
+ LocalUserServices lus = new LocalUserServices(null, 991, 992, null);
+ m_userService = lus;
+ m_userServiceAdmin = lus;
}
}
}
--
cgit v1.1