mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 03:06:05 +08:00
Fix tests broken in 88771aeed3
Adds MockUserAccountService and connects it up Stops services being carried over between tests since this leads to hard to find bugs Improves information and error reporting when loading plugins
This commit is contained in:
45
OpenSim/Tests/Common/Mock/MockUserAccountService.cs
Normal file
45
OpenSim/Tests/Common/Mock/MockUserAccountService.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.Tests.Common.Mock
|
||||
{
|
||||
public class MockUserAccountService : IUserAccountService
|
||||
{
|
||||
public MockUserAccountService(IConfigSource config) {}
|
||||
|
||||
public UserAccount GetUserAccount(UUID scopeID, UUID userID) { return new UserAccount(); }
|
||||
public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) { return new UserAccount(); }
|
||||
public UserAccount GetUserAccount(UUID scopeID, string Email) { return new UserAccount(); }
|
||||
public List<UserAccount> GetUserAccounts(UUID scopeID, string query) { return new List<UserAccount>(); }
|
||||
public bool StoreUserAccount(UserAccount data) { return true; }
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,6 @@ namespace OpenSim.Tests.Common.Mock
|
||||
public AsyncSceneObjectGroupDeleter SceneObjectGroupDeleter
|
||||
{
|
||||
get { return m_asyncSceneObjectDeleter; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace OpenSim.Tests.Common.Setup
|
||||
/// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
|
||||
/// <returns></returns>
|
||||
public static TestScene SetupScene(
|
||||
string name, UUID id, uint x, uint y, String realServices)
|
||||
string name, UUID id, uint x, uint y, String realServices)
|
||||
{
|
||||
bool newScene = false;
|
||||
|
||||
@@ -179,15 +179,16 @@ namespace OpenSim.Tests.Common.Setup
|
||||
StartAssetService(testScene, true);
|
||||
else
|
||||
StartAssetService(testScene, false);
|
||||
|
||||
if (realServices.Contains("inventory"))
|
||||
StartInventoryService(testScene, true);
|
||||
else
|
||||
StartInventoryService(testScene, false);
|
||||
|
||||
if (realServices.Contains("grid"))
|
||||
StartGridService(testScene, true);
|
||||
if (realServices.Contains("useraccounts"))
|
||||
StartUserAccountService(testScene, true);
|
||||
|
||||
|
||||
StartUserAccountService(testScene, realServices.Contains("useraccounts"));
|
||||
}
|
||||
// If not, make sure the shared module gets references to this new scene
|
||||
else
|
||||
@@ -196,9 +197,13 @@ namespace OpenSim.Tests.Common.Setup
|
||||
m_assetService.RegionLoaded(testScene);
|
||||
m_inventoryService.AddRegion(testScene);
|
||||
m_inventoryService.RegionLoaded(testScene);
|
||||
m_userAccountService.AddRegion(testScene);
|
||||
m_userAccountService.RegionLoaded(testScene);
|
||||
}
|
||||
|
||||
m_inventoryService.PostInitialise();
|
||||
m_assetService.PostInitialise();
|
||||
m_userAccountService.PostInitialise();
|
||||
|
||||
testScene.SetModuleInterfaces();
|
||||
|
||||
@@ -209,6 +214,11 @@ namespace OpenSim.Tests.Common.Setup
|
||||
physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
|
||||
testScene.PhysicsScene
|
||||
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
|
||||
|
||||
m_assetService = null;
|
||||
m_inventoryService = null;
|
||||
m_gridService = null;
|
||||
m_userAccountService = null;
|
||||
|
||||
return testScene;
|
||||
}
|
||||
@@ -273,6 +283,11 @@ namespace OpenSim.Tests.Common.Setup
|
||||
//testScene.AddRegionModule(m_gridService.Name, m_gridService);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a user account service, whether real or mock
|
||||
/// </summary>
|
||||
/// <param name="testScene"></param>
|
||||
/// <param name="real">Starts a real service if true, a mock service if not</param>
|
||||
private static void StartUserAccountService(Scene testScene, bool real)
|
||||
{
|
||||
IConfigSource config = new IniConfigSource();
|
||||
@@ -280,8 +295,14 @@ namespace OpenSim.Tests.Common.Setup
|
||||
config.AddConfig("UserAccountService");
|
||||
config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector");
|
||||
config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
||||
|
||||
if (real)
|
||||
config.Configs["UserAccountService"].Set("LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService");
|
||||
config.Configs["UserAccountService"].Set(
|
||||
"LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService");
|
||||
else
|
||||
config.Configs["UserAccountService"].Set(
|
||||
"LocalServiceModule", "OpenSim.Tests.Common.dll:MockUserAccountService");
|
||||
|
||||
if (m_userAccountService == null)
|
||||
{
|
||||
ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector();
|
||||
@@ -292,10 +313,9 @@ namespace OpenSim.Tests.Common.Setup
|
||||
// config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService");
|
||||
m_userAccountService.AddRegion(testScene);
|
||||
m_userAccountService.RegionLoaded(testScene);
|
||||
//testScene.AddRegionModule(m_gridService.Name, m_gridService);
|
||||
testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Setup modules for a scene using their default settings.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user