2008-11-14 20:06:44 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
2009-06-01 06:37:14 +00:00
|
|
|
* * Neither the name of the OpenSimulator Project nor the
|
2008-11-14 20:06:44 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2009-03-12 18:13:51 +00:00
|
|
|
using System;
|
2009-01-15 21:27:55 +00:00
|
|
|
using System.Net;
|
2009-04-13 21:23:33 +00:00
|
|
|
using System.Collections.Generic;
|
2008-11-14 20:06:44 +00:00
|
|
|
using Nini.Config;
|
|
|
|
using OpenMetaverse;
|
|
|
|
using OpenSim.Framework;
|
|
|
|
using OpenSim.Framework.Communications;
|
2009-08-10 15:55:53 +00:00
|
|
|
using OpenSim.Framework.Console;
|
2008-11-19 20:13:51 +00:00
|
|
|
using OpenSim.Framework.Servers;
|
2009-07-10 03:54:22 +00:00
|
|
|
using OpenSim.Framework.Servers.HttpServer;
|
2008-11-20 16:58:40 +00:00
|
|
|
using OpenSim.Region.Physics.Manager;
|
2009-02-06 16:55:34 +00:00
|
|
|
using OpenSim.Region.Framework;
|
|
|
|
using OpenSim.Region.Framework.Interfaces;
|
|
|
|
using OpenSim.Region.Framework.Scenes;
|
2009-03-30 19:09:57 +00:00
|
|
|
using OpenSim.Region.CoreModules.Avatar.Gods;
|
2011-08-30 00:58:32 +00:00
|
|
|
using OpenSim.Region.CoreModules.Asset;
|
2009-06-14 19:44:56 +00:00
|
|
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset;
|
2010-05-28 22:14:24 +00:00
|
|
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication;
|
2009-06-14 19:44:56 +00:00
|
|
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
|
2009-09-29 00:33:34 +00:00
|
|
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
|
2010-02-22 03:11:48 +00:00
|
|
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
|
2010-08-20 18:09:02 +00:00
|
|
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
|
2009-05-15 05:00:25 +00:00
|
|
|
using OpenSim.Services.Interfaces;
|
2008-12-11 18:07:23 +00:00
|
|
|
using OpenSim.Tests.Common.Mock;
|
2008-11-14 20:06:44 +00:00
|
|
|
|
2011-05-21 00:05:20 +00:00
|
|
|
namespace OpenSim.Tests.Common
|
2009-02-26 21:29:16 +00:00
|
|
|
{
|
2008-11-14 20:06:44 +00:00
|
|
|
/// <summary>
|
2009-01-23 17:32:38 +00:00
|
|
|
/// Helpers for setting up scenes.
|
2008-11-14 20:06:44 +00:00
|
|
|
/// </summary>
|
2011-08-05 23:26:37 +00:00
|
|
|
public class SceneHelpers
|
2009-02-26 21:29:16 +00:00
|
|
|
{
|
2011-08-30 00:58:32 +00:00
|
|
|
public static TestScene SetupScene()
|
|
|
|
{
|
|
|
|
return SetupScene(null);
|
|
|
|
}
|
|
|
|
|
2008-11-14 20:06:44 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Set up a test scene
|
|
|
|
/// </summary>
|
2011-03-09 01:31:47 +00:00
|
|
|
/// <remarks>
|
2009-04-14 18:49:45 +00:00
|
|
|
/// Automatically starts service threads, as would the normal runtime.
|
2011-03-09 01:31:47 +00:00
|
|
|
/// </remarks>
|
2008-11-19 20:13:51 +00:00
|
|
|
/// <returns></returns>
|
2011-08-30 00:58:32 +00:00
|
|
|
public static TestScene SetupScene(CoreAssetCache cache)
|
2008-11-14 20:06:44 +00:00
|
|
|
{
|
2011-08-30 00:58:32 +00:00
|
|
|
return SetupScene("Unit test region", UUID.Random(), 1000, 1000, cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static TestScene SetupScene(string name, UUID id, uint x, uint y)
|
|
|
|
{
|
|
|
|
return SetupScene(name, id, x, y, null);
|
2009-01-15 21:27:55 +00:00
|
|
|
}
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2009-01-15 21:27:55 +00:00
|
|
|
/// <summary>
|
2009-08-11 15:24:41 +00:00
|
|
|
/// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
|
|
|
|
/// or a different, to get a brand new scene with new shared region modules.
|
2009-01-15 21:27:55 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="name">Name of the region</param>
|
|
|
|
/// <param name="id">ID of the region</param>
|
|
|
|
/// <param name="x">X co-ordinate of the region</param>
|
|
|
|
/// <param name="y">Y co-ordinate of the region</param>
|
|
|
|
/// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
|
|
|
|
/// <returns></returns>
|
2011-08-30 00:58:32 +00:00
|
|
|
public static TestScene SetupScene(string name, UUID id, uint x, uint y, CoreAssetCache cache)
|
2009-01-15 21:27:55 +00:00
|
|
|
{
|
2009-03-12 18:13:51 +00:00
|
|
|
Console.WriteLine("Setting up test scene {0}", name);
|
2010-01-11 15:45:47 +00:00
|
|
|
|
2009-08-10 15:55:53 +00:00
|
|
|
// We must set up a console otherwise setup of some modules may fail
|
2011-02-19 00:07:16 +00:00
|
|
|
MainConsole.Instance = new MockConsole("TEST PROMPT");
|
|
|
|
|
2009-01-15 21:27:55 +00:00
|
|
|
RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
|
|
|
|
regInfo.RegionName = name;
|
|
|
|
regInfo.RegionID = id;
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2008-11-14 20:06:44 +00:00
|
|
|
AgentCircuitManager acm = new AgentCircuitManager();
|
2010-01-11 15:45:47 +00:00
|
|
|
SceneCommunicationService scs = new SceneCommunicationService();
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2010-09-12 22:04:51 +00:00
|
|
|
ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
|
2010-09-12 21:20:26 +00:00
|
|
|
IEstateDataService estateDataService = null;
|
2008-11-14 20:06:44 +00:00
|
|
|
IConfigSource configSource = new IniConfigSource();
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2008-11-19 20:13:51 +00:00
|
|
|
TestScene testScene = new TestScene(
|
2010-09-12 21:20:26 +00:00
|
|
|
regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null);
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2009-03-30 19:09:57 +00:00
|
|
|
IRegionModule godsModule = new GodsModule();
|
|
|
|
godsModule.Initialise(testScene, new IniConfigSource());
|
|
|
|
testScene.AddModule(godsModule.Name, godsModule);
|
2011-02-19 00:07:16 +00:00
|
|
|
|
2011-08-30 00:58:32 +00:00
|
|
|
LocalAssetServicesConnector assetService = StartAssetService(testScene, cache);
|
2011-04-15 00:26:07 +00:00
|
|
|
StartAuthenticationService(testScene);
|
2011-04-15 00:10:26 +00:00
|
|
|
LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene);
|
2011-04-15 00:30:49 +00:00
|
|
|
StartGridService(testScene);
|
2011-03-09 01:31:47 +00:00
|
|
|
LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene);
|
|
|
|
LocalPresenceServicesConnector presenceService = StartPresenceService(testScene);
|
2010-09-12 17:43:49 +00:00
|
|
|
|
2011-03-09 01:37:31 +00:00
|
|
|
inventoryService.PostInitialise();
|
2011-03-09 01:31:47 +00:00
|
|
|
assetService.PostInitialise();
|
|
|
|
userAccountService.PostInitialise();
|
|
|
|
presenceService.PostInitialise();
|
|
|
|
|
2010-05-05 02:13:25 +00:00
|
|
|
testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random();
|
* Improves SceneSetupHelper to allow the tester to choose a real or mock, inventory and asset, service modules. The boolean startServices was replaced with realServices string. If the string contains the word asset, it will start a real asset module, if it contains inventory, it starts a real inventory. Otherwise, it use mock (NullPlugin-like) objects, for tests that don't really need functionality.
* SetupScene is now actually sharing the asset and inventory modules if the tester wishes to have multiple regions connected. To link regions, just start SetupScene with the same CommunicationManager for all scenes. SceneSetupHelper will hold a static reference to the modules and won't initialize them again, just run the scenes through the modules AddRegion, RegionLoaded and PostInitialize.
* With the recent changes, both asset and inventory (and in the future, user) services should always be asked from the scene, not instantiated alone. The tests should reflect this new behavior and always start a scene.
2009-08-11 15:07:54 +00:00
|
|
|
testScene.SetModuleInterfaces();
|
|
|
|
|
2009-10-02 09:26:45 +00:00
|
|
|
testScene.LandChannel = new TestLandChannel(testScene);
|
* Improves SceneSetupHelper to allow the tester to choose a real or mock, inventory and asset, service modules. The boolean startServices was replaced with realServices string. If the string contains the word asset, it will start a real asset module, if it contains inventory, it starts a real inventory. Otherwise, it use mock (NullPlugin-like) objects, for tests that don't really need functionality.
* SetupScene is now actually sharing the asset and inventory modules if the tester wishes to have multiple regions connected. To link regions, just start SetupScene with the same CommunicationManager for all scenes. SceneSetupHelper will hold a static reference to the modules and won't initialize them again, just run the scenes through the modules AddRegion, RegionLoaded and PostInitialize.
* With the recent changes, both asset and inventory (and in the future, user) services should always be asked from the scene, not instantiated alone. The tests should reflect this new behavior and always start a scene.
2009-08-11 15:07:54 +00:00
|
|
|
testScene.LoadWorldMap();
|
|
|
|
|
|
|
|
PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
|
|
|
|
physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
|
|
|
|
testScene.PhysicsScene
|
2009-08-16 16:14:49 +00:00
|
|
|
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
|
2010-03-12 19:31:14 +00:00
|
|
|
|
2010-08-20 18:09:02 +00:00
|
|
|
testScene.RegionInfo.EstateSettings = new EstateSettings();
|
|
|
|
testScene.LoginsDisabled = false;
|
|
|
|
|
* Improves SceneSetupHelper to allow the tester to choose a real or mock, inventory and asset, service modules. The boolean startServices was replaced with realServices string. If the string contains the word asset, it will start a real asset module, if it contains inventory, it starts a real inventory. Otherwise, it use mock (NullPlugin-like) objects, for tests that don't really need functionality.
* SetupScene is now actually sharing the asset and inventory modules if the tester wishes to have multiple regions connected. To link regions, just start SetupScene with the same CommunicationManager for all scenes. SceneSetupHelper will hold a static reference to the modules and won't initialize them again, just run the scenes through the modules AddRegion, RegionLoaded and PostInitialize.
* With the recent changes, both asset and inventory (and in the future, user) services should always be asked from the scene, not instantiated alone. The tests should reflect this new behavior and always start a scene.
2009-08-11 15:07:54 +00:00
|
|
|
return testScene;
|
|
|
|
}
|
2009-05-15 05:00:25 +00:00
|
|
|
|
2011-08-30 00:58:32 +00:00
|
|
|
private static LocalAssetServicesConnector StartAssetService(Scene testScene, CoreAssetCache cache)
|
* Improves SceneSetupHelper to allow the tester to choose a real or mock, inventory and asset, service modules. The boolean startServices was replaced with realServices string. If the string contains the word asset, it will start a real asset module, if it contains inventory, it starts a real inventory. Otherwise, it use mock (NullPlugin-like) objects, for tests that don't really need functionality.
* SetupScene is now actually sharing the asset and inventory modules if the tester wishes to have multiple regions connected. To link regions, just start SetupScene with the same CommunicationManager for all scenes. SceneSetupHelper will hold a static reference to the modules and won't initialize them again, just run the scenes through the modules AddRegion, RegionLoaded and PostInitialize.
* With the recent changes, both asset and inventory (and in the future, user) services should always be asked from the scene, not instantiated alone. The tests should reflect this new behavior and always start a scene.
2009-08-11 15:07:54 +00:00
|
|
|
{
|
2011-03-09 01:31:47 +00:00
|
|
|
LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
|
2009-08-16 16:14:49 +00:00
|
|
|
IConfigSource config = new IniConfigSource();
|
2011-04-14 23:42:06 +00:00
|
|
|
|
2011-04-15 00:23:26 +00:00
|
|
|
config.AddConfig("Modules");
|
|
|
|
config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
|
2011-04-14 23:42:06 +00:00
|
|
|
config.AddConfig("AssetService");
|
2011-04-15 00:23:26 +00:00
|
|
|
config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
|
2009-05-18 17:46:14 +00:00
|
|
|
config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
|
2011-04-14 23:42:06 +00:00
|
|
|
|
2010-09-12 17:43:49 +00:00
|
|
|
assetService.Initialise(config);
|
2009-05-15 05:00:25 +00:00
|
|
|
assetService.AddRegion(testScene);
|
2011-08-30 00:58:32 +00:00
|
|
|
|
|
|
|
if (cache != null)
|
|
|
|
{
|
|
|
|
IConfigSource cacheConfig = new IniConfigSource();
|
|
|
|
cacheConfig.AddConfig("Modules");
|
|
|
|
cacheConfig.Configs["Modules"].Set("AssetCaching", "CoreAssetCache");
|
|
|
|
cacheConfig.AddConfig("AssetCache");
|
|
|
|
|
|
|
|
cache.Initialise(cacheConfig);
|
|
|
|
cache.AddRegion(testScene);
|
|
|
|
cache.RegionLoaded(testScene);
|
|
|
|
testScene.AddRegionModule(cache.Name, cache);
|
|
|
|
}
|
|
|
|
|
2009-05-15 05:00:25 +00:00
|
|
|
assetService.RegionLoaded(testScene);
|
2009-05-18 17:46:14 +00:00
|
|
|
testScene.AddRegionModule(assetService.Name, assetService);
|
2011-03-09 01:31:47 +00:00
|
|
|
|
|
|
|
return assetService;
|
* Improves SceneSetupHelper to allow the tester to choose a real or mock, inventory and asset, service modules. The boolean startServices was replaced with realServices string. If the string contains the word asset, it will start a real asset module, if it contains inventory, it starts a real inventory. Otherwise, it use mock (NullPlugin-like) objects, for tests that don't really need functionality.
* SetupScene is now actually sharing the asset and inventory modules if the tester wishes to have multiple regions connected. To link regions, just start SetupScene with the same CommunicationManager for all scenes. SceneSetupHelper will hold a static reference to the modules and won't initialize them again, just run the scenes through the modules AddRegion, RegionLoaded and PostInitialize.
* With the recent changes, both asset and inventory (and in the future, user) services should always be asked from the scene, not instantiated alone. The tests should reflect this new behavior and always start a scene.
2009-08-11 15:07:54 +00:00
|
|
|
}
|
2009-06-10 13:46:38 +00:00
|
|
|
|
2011-04-15 00:26:07 +00:00
|
|
|
private static void StartAuthenticationService(Scene testScene)
|
2010-05-28 22:14:24 +00:00
|
|
|
{
|
|
|
|
ISharedRegionModule service = new LocalAuthenticationServicesConnector();
|
|
|
|
IConfigSource config = new IniConfigSource();
|
2011-04-15 00:26:07 +00:00
|
|
|
|
2010-05-28 22:14:24 +00:00
|
|
|
config.AddConfig("Modules");
|
|
|
|
config.AddConfig("AuthenticationService");
|
|
|
|
config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector");
|
2011-04-15 00:26:07 +00:00
|
|
|
config.Configs["AuthenticationService"].Set(
|
|
|
|
"LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService");
|
2010-05-28 22:14:24 +00:00
|
|
|
config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
2011-04-15 00:26:07 +00:00
|
|
|
|
2010-05-28 22:14:24 +00:00
|
|
|
service.Initialise(config);
|
|
|
|
service.AddRegion(testScene);
|
|
|
|
service.RegionLoaded(testScene);
|
|
|
|
testScene.AddRegionModule(service.Name, service);
|
|
|
|
//m_authenticationService = service;
|
|
|
|
}
|
2010-09-12 17:43:49 +00:00
|
|
|
|
2011-04-15 00:10:26 +00:00
|
|
|
private static LocalInventoryServicesConnector StartInventoryService(Scene testScene)
|
* Improves SceneSetupHelper to allow the tester to choose a real or mock, inventory and asset, service modules. The boolean startServices was replaced with realServices string. If the string contains the word asset, it will start a real asset module, if it contains inventory, it starts a real inventory. Otherwise, it use mock (NullPlugin-like) objects, for tests that don't really need functionality.
* SetupScene is now actually sharing the asset and inventory modules if the tester wishes to have multiple regions connected. To link regions, just start SetupScene with the same CommunicationManager for all scenes. SceneSetupHelper will hold a static reference to the modules and won't initialize them again, just run the scenes through the modules AddRegion, RegionLoaded and PostInitialize.
* With the recent changes, both asset and inventory (and in the future, user) services should always be asked from the scene, not instantiated alone. The tests should reflect this new behavior and always start a scene.
2009-08-11 15:07:54 +00:00
|
|
|
{
|
2011-03-09 01:37:31 +00:00
|
|
|
LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
|
2011-04-15 00:10:26 +00:00
|
|
|
|
|
|
|
IConfigSource config = new IniConfigSource();
|
2009-06-10 13:46:38 +00:00
|
|
|
config.AddConfig("Modules");
|
|
|
|
config.AddConfig("InventoryService");
|
|
|
|
config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
|
2011-04-15 00:10:26 +00:00
|
|
|
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
|
2009-06-10 13:46:38 +00:00
|
|
|
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
|
2011-04-15 00:10:26 +00:00
|
|
|
|
2009-06-10 14:15:50 +00:00
|
|
|
inventoryService.Initialise(config);
|
|
|
|
inventoryService.AddRegion(testScene);
|
|
|
|
inventoryService.RegionLoaded(testScene);
|
2009-06-10 13:46:38 +00:00
|
|
|
testScene.AddRegionModule(inventoryService.Name, inventoryService);
|
2011-03-09 01:37:31 +00:00
|
|
|
|
|
|
|
return inventoryService;
|
2009-02-26 21:29:16 +00:00
|
|
|
}
|
|
|
|
|
2011-04-15 00:30:49 +00:00
|
|
|
private static LocalGridServicesConnector StartGridService(Scene testScene)
|
2009-09-29 00:33:34 +00:00
|
|
|
{
|
|
|
|
IConfigSource config = new IniConfigSource();
|
|
|
|
config.AddConfig("Modules");
|
|
|
|
config.AddConfig("GridService");
|
|
|
|
config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
|
2009-09-29 00:42:35 +00:00
|
|
|
config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
|
2011-04-15 00:30:49 +00:00
|
|
|
config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
|
2011-03-09 01:31:47 +00:00
|
|
|
|
|
|
|
LocalGridServicesConnector gridService = new LocalGridServicesConnector();
|
|
|
|
gridService.Initialise(config);
|
|
|
|
gridService.AddRegion(testScene);
|
|
|
|
gridService.RegionLoaded(testScene);
|
|
|
|
|
|
|
|
return gridService;
|
2009-09-29 00:33:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-12 19:31:14 +00:00
|
|
|
/// <summary>
|
2010-06-04 19:56:24 +00:00
|
|
|
/// Start a user account service
|
2010-03-12 19:31:14 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="testScene"></param>
|
2011-03-09 01:31:47 +00:00
|
|
|
/// <returns></returns>
|
|
|
|
private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene)
|
2010-02-22 03:11:48 +00:00
|
|
|
{
|
|
|
|
IConfigSource config = new IniConfigSource();
|
|
|
|
config.AddConfig("Modules");
|
|
|
|
config.AddConfig("UserAccountService");
|
|
|
|
config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector");
|
|
|
|
config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
2010-06-04 19:56:24 +00:00
|
|
|
config.Configs["UserAccountService"].Set(
|
|
|
|
"LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService");
|
2010-09-12 17:43:49 +00:00
|
|
|
|
2011-03-09 01:31:47 +00:00
|
|
|
LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector();
|
|
|
|
userAccountService.Initialise(config);
|
2010-09-12 17:43:49 +00:00
|
|
|
|
2011-03-09 01:31:47 +00:00
|
|
|
userAccountService.AddRegion(testScene);
|
|
|
|
userAccountService.RegionLoaded(testScene);
|
|
|
|
testScene.AddRegionModule(userAccountService.Name, userAccountService);
|
|
|
|
|
|
|
|
return userAccountService;
|
2010-02-22 03:11:48 +00:00
|
|
|
}
|
|
|
|
|
2010-08-20 18:09:02 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Start a presence service
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="testScene"></param>
|
2011-03-09 01:31:47 +00:00
|
|
|
private static LocalPresenceServicesConnector StartPresenceService(Scene testScene)
|
2010-08-20 18:09:02 +00:00
|
|
|
{
|
|
|
|
IConfigSource config = new IniConfigSource();
|
|
|
|
config.AddConfig("Modules");
|
|
|
|
config.AddConfig("PresenceService");
|
|
|
|
config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector");
|
|
|
|
config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
|
|
|
config.Configs["PresenceService"].Set(
|
|
|
|
"LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService");
|
|
|
|
|
2011-03-09 01:31:47 +00:00
|
|
|
LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector();
|
|
|
|
presenceService.Initialise(config);
|
2010-08-20 18:09:02 +00:00
|
|
|
|
2011-03-09 01:31:47 +00:00
|
|
|
presenceService.AddRegion(testScene);
|
|
|
|
presenceService.RegionLoaded(testScene);
|
|
|
|
testScene.AddRegionModule(presenceService.Name, presenceService);
|
|
|
|
|
|
|
|
return presenceService;
|
2010-08-20 18:09:02 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 19:24:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Setup modules for a scene using their default settings.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="scene"></param>
|
|
|
|
/// <param name="modules"></param>
|
2009-04-13 21:23:33 +00:00
|
|
|
public static void SetupSceneModules(Scene scene, params object[] modules)
|
2009-01-23 19:24:36 +00:00
|
|
|
{
|
2009-09-01 09:33:10 +00:00
|
|
|
SetupSceneModules(scene, new IniConfigSource(), modules);
|
2009-02-26 21:29:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 17:55:29 +00:00
|
|
|
/// <summary>
|
2009-01-23 19:24:36 +00:00
|
|
|
/// Setup modules for a scene.
|
2009-01-23 17:55:29 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="scene"></param>
|
|
|
|
/// <param name="config"></param>
|
|
|
|
/// <param name="modules"></param>
|
2009-04-13 21:23:33 +00:00
|
|
|
public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules)
|
2009-01-23 17:55:29 +00:00
|
|
|
{
|
2009-04-13 21:23:33 +00:00
|
|
|
List<IRegionModuleBase> newModules = new List<IRegionModuleBase>();
|
|
|
|
foreach (object module in modules)
|
2009-01-23 17:55:29 +00:00
|
|
|
{
|
2009-04-13 21:23:33 +00:00
|
|
|
if (module is IRegionModule)
|
|
|
|
{
|
|
|
|
IRegionModule m = (IRegionModule)module;
|
|
|
|
m.Initialise(scene, config);
|
|
|
|
scene.AddModule(m.Name, m);
|
2009-05-22 19:59:45 +00:00
|
|
|
m.PostInitialise();
|
2009-04-13 21:23:33 +00:00
|
|
|
}
|
2009-04-14 11:38:33 +00:00
|
|
|
else if (module is IRegionModuleBase)
|
2009-04-13 21:23:33 +00:00
|
|
|
{
|
|
|
|
// for the new system, everything has to be initialised first,
|
|
|
|
// shared modules have to be post-initialised, then all get an AddRegion with the scene
|
|
|
|
IRegionModuleBase m = (IRegionModuleBase)module;
|
|
|
|
m.Initialise(config);
|
|
|
|
newModules.Add(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (IRegionModuleBase module in newModules)
|
|
|
|
{
|
|
|
|
if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise();
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (IRegionModuleBase module in newModules)
|
|
|
|
{
|
|
|
|
module.AddRegion(scene);
|
|
|
|
scene.AddRegionModule(module.Name, module);
|
2009-01-23 17:55:29 +00:00
|
|
|
}
|
2010-12-14 23:36:34 +00:00
|
|
|
|
|
|
|
// RegionLoaded is fired after all modules have been appropriately added to all scenes
|
|
|
|
foreach (IRegionModuleBase module in newModules)
|
|
|
|
module.RegionLoaded(scene);
|
2009-02-26 21:29:16 +00:00
|
|
|
|
|
|
|
scene.SetModuleInterfaces();
|
2009-01-23 17:55:29 +00:00
|
|
|
}
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2008-11-20 17:18:39 +00:00
|
|
|
/// <summary>
|
2009-01-22 19:46:31 +00:00
|
|
|
/// Generate some standard agent connection data.
|
2008-11-20 17:18:39 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="agentId"></param>
|
2009-01-22 19:46:31 +00:00
|
|
|
/// <returns></returns>
|
|
|
|
public static AgentCircuitData GenerateAgentData(UUID agentId)
|
2008-11-20 17:18:39 +00:00
|
|
|
{
|
|
|
|
string firstName = "testfirstname";
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2009-01-22 19:46:31 +00:00
|
|
|
AgentCircuitData agentData = new AgentCircuitData();
|
|
|
|
agentData.AgentID = agentId;
|
|
|
|
agentData.firstname = firstName;
|
|
|
|
agentData.lastname = "testlastname";
|
|
|
|
agentData.SessionID = UUID.Zero;
|
|
|
|
agentData.SecureSessionID = UUID.Zero;
|
|
|
|
agentData.circuitcode = 123;
|
|
|
|
agentData.BaseFolder = UUID.Zero;
|
|
|
|
agentData.InventoryFolder = UUID.Zero;
|
|
|
|
agentData.startpos = Vector3.Zero;
|
|
|
|
agentData.CapsPath = "http://wibble.com";
|
2011-08-18 23:45:22 +00:00
|
|
|
agentData.ServiceURLs = new Dictionary<string, object>();
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2009-01-22 19:46:31 +00:00
|
|
|
return agentData;
|
|
|
|
}
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2009-01-22 19:46:31 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="scene"></param>
|
|
|
|
/// <param name="agentId"></param>
|
|
|
|
/// <returns></returns>
|
2011-08-06 01:17:41 +00:00
|
|
|
public static ScenePresence AddScenePresence(Scene scene, UUID agentId)
|
2009-02-26 21:29:16 +00:00
|
|
|
{
|
2011-08-06 01:17:41 +00:00
|
|
|
return AddScenePresence(scene, GenerateAgentData(agentId));
|
2009-02-26 21:29:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-22 19:46:31 +00:00
|
|
|
/// <summary>
|
2009-02-26 21:29:16 +00:00
|
|
|
/// Add a root agent.
|
2009-01-22 19:46:31 +00:00
|
|
|
/// </summary>
|
2011-03-09 01:37:31 +00:00
|
|
|
/// <remarks>
|
2009-01-22 19:46:31 +00:00
|
|
|
/// This function
|
2009-02-26 21:29:16 +00:00
|
|
|
///
|
2009-01-22 19:46:31 +00:00
|
|
|
/// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the
|
|
|
|
/// userserver if grid) would give initial login data back to the client and separately tell the scene that the
|
|
|
|
/// agent was coming.
|
2009-02-26 21:29:16 +00:00
|
|
|
///
|
2009-01-22 19:46:31 +00:00
|
|
|
/// 2) Connects the agent with the scene
|
2009-02-26 21:29:16 +00:00
|
|
|
///
|
2009-01-22 19:46:31 +00:00
|
|
|
/// This function performs actions equivalent with notifying the scene that an agent is
|
|
|
|
/// coming and then actually connecting the agent to the scene. The one step missed out is the very first
|
2011-03-09 01:37:31 +00:00
|
|
|
/// </remarks>
|
2009-01-22 19:46:31 +00:00
|
|
|
/// <param name="scene"></param>
|
|
|
|
/// <param name="agentData"></param>
|
2009-02-26 21:29:16 +00:00
|
|
|
/// <returns></returns>
|
2011-08-06 01:17:41 +00:00
|
|
|
public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
|
2009-02-26 21:29:16 +00:00
|
|
|
{
|
2009-05-05 16:17:52 +00:00
|
|
|
string reason;
|
|
|
|
|
2010-08-20 18:09:02 +00:00
|
|
|
// We emulate the proper login sequence here by doing things in four stages
|
|
|
|
|
|
|
|
// Stage 0: log the presence
|
|
|
|
scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
|
|
|
|
|
2008-11-28 20:11:17 +00:00
|
|
|
// Stage 1: simulate login by telling the scene to expect a new user connection
|
2010-08-20 18:09:02 +00:00
|
|
|
if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason))
|
|
|
|
Console.WriteLine("NewUserConnection failed: " + reason);
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2008-11-28 20:11:17 +00:00
|
|
|
// Stage 2: add the new client as a child agent to the scene
|
2009-01-22 19:46:31 +00:00
|
|
|
TestClient client = new TestClient(agentData, scene);
|
2011-08-17 23:53:05 +00:00
|
|
|
scene.AddNewClient(client, PresenceType.User);
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2011-02-18 22:49:19 +00:00
|
|
|
// Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
|
2009-02-26 21:29:16 +00:00
|
|
|
ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
|
2011-08-09 22:11:07 +00:00
|
|
|
scp.CompleteMovement(client, true);
|
2011-02-18 22:49:19 +00:00
|
|
|
//scp.MakeRootAgent(new Vector3(90, 90, 90), true);
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2011-08-06 01:17:41 +00:00
|
|
|
return scp;
|
2008-11-20 17:18:39 +00:00
|
|
|
}
|
2008-11-28 20:58:12 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Add a test object
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="scene"></param>
|
2009-02-26 21:29:16 +00:00
|
|
|
/// <returns></returns>
|
2008-11-28 20:58:12 +00:00
|
|
|
public static SceneObjectPart AddSceneObject(Scene scene)
|
|
|
|
{
|
2009-01-30 18:38:32 +00:00
|
|
|
return AddSceneObject(scene, "Test Object");
|
2008-11-28 20:58:12 +00:00
|
|
|
}
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2008-11-14 20:06:44 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Add a test object
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="scene"></param>
|
2008-11-28 20:58:12 +00:00
|
|
|
/// <param name="name"></param>
|
2008-11-14 20:06:44 +00:00
|
|
|
/// <returns></returns>
|
2008-11-28 20:58:12 +00:00
|
|
|
public static SceneObjectPart AddSceneObject(Scene scene, string name)
|
2009-02-26 21:29:16 +00:00
|
|
|
{
|
2011-03-23 22:40:23 +00:00
|
|
|
SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero);
|
2009-02-26 21:29:16 +00:00
|
|
|
|
|
|
|
//part.UpdatePrimFlags(false, false, true);
|
|
|
|
//part.ObjectFlags |= (uint)PrimFlags.Phantom;
|
2009-01-30 18:38:32 +00:00
|
|
|
|
|
|
|
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
|
2009-02-26 21:29:16 +00:00
|
|
|
|
2008-11-14 20:06:44 +00:00
|
|
|
return part;
|
|
|
|
}
|
2011-03-23 22:29:27 +00:00
|
|
|
|
2011-03-23 22:40:23 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Create a scene object part.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="name"></param>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="ownerId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static SceneObjectPart CreateSceneObjectPart(string name, UUID id, UUID ownerId)
|
2011-04-14 19:21:44 +00:00
|
|
|
{
|
2011-03-23 22:40:23 +00:00
|
|
|
return new SceneObjectPart(
|
|
|
|
ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
|
2011-04-14 19:21:44 +00:00
|
|
|
{ Name = name, UUID = id, Scale = new Vector3(1, 1, 1) };
|
2011-03-23 22:40:23 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 22:29:27 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Create a scene object but do not add it to the scene.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// UUID always starts at 00000000-0000-0000-0000-000000000001
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="parts">The number of parts that should be in the scene object</param>
|
|
|
|
/// <param name="ownerId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId)
|
2011-03-23 23:14:55 +00:00
|
|
|
{
|
2011-04-06 17:57:50 +00:00
|
|
|
return CreateSceneObject(parts, ownerId, "", 0x1);
|
2011-03-23 23:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a scene object but do not add it to the scene.
|
|
|
|
/// </summary>
|
2011-04-06 17:57:50 +00:00
|
|
|
/// <param name="parts">
|
|
|
|
/// The number of parts that should be in the scene object
|
|
|
|
/// </param>
|
2011-03-23 23:14:55 +00:00
|
|
|
/// <param name="ownerId"></param>
|
2011-04-06 17:57:50 +00:00
|
|
|
/// <param name="partNamePrefix">
|
|
|
|
/// The prefix to be given to part names. This will be suffixed with "Part<part no>"
|
|
|
|
/// (e.g. mynamePart0 for the root part)
|
|
|
|
/// </param>
|
2011-03-23 23:14:55 +00:00
|
|
|
/// <param name="uuidTail">
|
|
|
|
/// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
|
|
|
|
/// will be given to the root part, and incremented for each part thereafter.
|
|
|
|
/// </param>
|
|
|
|
/// <returns></returns>
|
2011-04-06 17:57:50 +00:00
|
|
|
public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, string partNamePrefix, int uuidTail)
|
2011-03-23 23:14:55 +00:00
|
|
|
{
|
|
|
|
string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail);
|
|
|
|
|
2011-03-23 22:40:23 +00:00
|
|
|
SceneObjectGroup sog
|
|
|
|
= new SceneObjectGroup(
|
2011-04-06 17:57:50 +00:00
|
|
|
CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId));
|
2011-03-23 22:29:27 +00:00
|
|
|
|
|
|
|
if (parts > 1)
|
2011-03-23 23:14:55 +00:00
|
|
|
for (int i = 1; i < parts; i++)
|
2011-03-23 22:29:27 +00:00
|
|
|
sog.AddPart(
|
2011-03-23 22:40:23 +00:00
|
|
|
CreateSceneObjectPart(
|
2011-04-06 17:57:50 +00:00
|
|
|
string.Format("{0}Part{1}", partNamePrefix, i),
|
2011-03-23 23:14:55 +00:00
|
|
|
new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)),
|
2011-03-23 22:40:23 +00:00
|
|
|
ownerId));
|
2011-03-23 22:29:27 +00:00
|
|
|
|
|
|
|
return sog;
|
2011-03-23 23:14:55 +00:00
|
|
|
}
|
2008-11-14 20:06:44 +00:00
|
|
|
}
|
2011-03-23 22:40:23 +00:00
|
|
|
}
|