From 18aa2ea0c5ebd8d5131902ed9856e68f46e76e11 Mon Sep 17 00:00:00 2001
From: Arthur Valadares
Date: Tue, 11 Aug 2009 12:07:54 -0300
Subject: * 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.
---
.../Tests/Cache/UserProfileCacheServiceTests.cs | 13 ++-
.../Communications/Tests/LoginServiceTests.cs | 128 ++-------------------
2 files changed, 14 insertions(+), 127 deletions(-)
(limited to 'OpenSim/Framework/Communications/Tests')
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
index fdc20dd..0402883 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
@@ -54,6 +54,7 @@ namespace OpenSim.Framework.Communications.Tests
CachedUserInfo nonExistingUserInfo;
TestCommunicationsManager commsManager = new TestCommunicationsManager();
+ Scene myScene = SceneSetupHelpers.SetupScene(commsManager, "");
// Check we can't retrieve info before it exists by uuid
nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
@@ -116,7 +117,7 @@ namespace OpenSim.Framework.Communications.Tests
{
TestHelper.InMethod();
- Scene myScene = SceneSetupHelpers.SetupScene();
+ Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
@@ -132,7 +133,7 @@ namespace OpenSim.Framework.Communications.Tests
{
TestHelper.InMethod();
- Scene myScene = SceneSetupHelpers.SetupScene();
+ Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
@@ -154,7 +155,7 @@ namespace OpenSim.Framework.Communications.Tests
{
TestHelper.InMethod();
- Scene myScene = SceneSetupHelpers.SetupScene();
+ Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
@@ -190,7 +191,7 @@ namespace OpenSim.Framework.Communications.Tests
{
TestHelper.InMethod();
- Scene myScene = SceneSetupHelpers.SetupScene();
+ Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
@@ -256,7 +257,7 @@ namespace OpenSim.Framework.Communications.Tests
{
TestHelper.InMethod();
- Scene myScene = SceneSetupHelpers.SetupScene();
+ Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
@@ -297,7 +298,7 @@ namespace OpenSim.Framework.Communications.Tests
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
- Scene myScene = SceneSetupHelpers.SetupScene();
+ Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
index 47e0293..9e181f3 100644
--- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
@@ -36,6 +36,7 @@ using Nwc.XmlRpc;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Services;
using OpenSim.Region.Communications.Local;
+using OpenSim.Tests.Common.Setup;
using OpenSim.Tests.Common.Mock;
using OpenSim.Client.Linden;
using OpenSim.Tests.Common;
@@ -57,11 +58,12 @@ namespace OpenSim.Framework.Communications.Tests
private string m_regionExternalName = "localhost";
private IPEndPoint m_capsEndPoint;
- private CommunicationsManager m_commsManager;
+ private TestCommunicationsManager m_commsManager;
private TestLoginToRegionConnector m_regionConnector;
private LocalUserServices m_localUserServices;
private LoginService m_loginService;
private UserProfileData m_userProfileData;
+ private TestScene m_testScene;
[SetUp]
public void SetUpLoginEnviroment()
@@ -69,13 +71,16 @@ namespace OpenSim.Framework.Communications.Tests
m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123);
m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43));
m_regionConnector = new TestLoginToRegionConnector();
+ m_testScene = SceneSetupHelpers.SetupScene(m_commsManager, "");
m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName));
+ //IInventoryService m_inventoryService = new TestInventoryService();
+
m_localUserServices = (LocalUserServices) m_commsManager.UserService;
m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43);
- m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", new TestInventoryService(),
+ m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", m_testScene.InventoryService,
m_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector);
m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName);
@@ -442,123 +447,4 @@ namespace OpenSim.Framework.Communications.Tests
#endregion
}
}
-
- class TestInventoryService : IInventoryService
- {
- public TestInventoryService()
- {
- }
-
- ///
- ///
- ///
- ///
- ///
- public bool CreateUserInventory(UUID userId)
- {
- return false;
- }
-
- ///
- ///
- ///
- ///
- ///
- public List GetInventorySkeleton(UUID userId)
- {
- List folders = new List();
- InventoryFolderBase folder = new InventoryFolderBase();
- folder.ID = UUID.Random();
- folder.Owner = userId;
- folders.Add(folder);
- return folders;
- }
-
- ///
- /// Returns a list of all the active gestures in a user's inventory.
- ///
- ///
- /// The of the user
- ///
- ///
- /// A flat list of the gesture items.
- ///
- public List GetActiveGestures(UUID userId)
- {
- return null;
- }
-
- public InventoryCollection GetUserInventory(UUID userID)
- {
- return null;
- }
-
- public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback)
- {
- }
-
- public List GetFolderItems(UUID userID, UUID folderID)
- {
- return null;
- }
-
- public bool AddFolder(InventoryFolderBase folder)
- {
- return false;
- }
-
- public bool UpdateFolder(InventoryFolderBase folder)
- {
- return false;
- }
-
- public bool MoveFolder(InventoryFolderBase folder)
- {
- return false;
- }
-
- public bool PurgeFolder(InventoryFolderBase folder)
- {
- return false;
- }
-
- public bool AddItem(InventoryItemBase item)
- {
- return false;
- }
-
- public bool UpdateItem(InventoryItemBase item)
- {
- return false;
- }
-
- public bool DeleteItem(InventoryItemBase item)
- {
- return false;
- }
-
- public InventoryItemBase QueryItem(InventoryItemBase item)
- {
- return null;
- }
-
- public InventoryFolderBase QueryFolder(InventoryFolderBase folder)
- {
- return null;
- }
-
- public bool HasInventoryForUser(UUID userID)
- {
- return false;
- }
-
- public InventoryFolderBase RequestRootFolder(UUID userID)
- {
- InventoryFolderBase root = new InventoryFolderBase();
- root.ID = UUID.Random();
- root.Owner = userID;
- root.ParentID = UUID.Zero;
- return root;
- }
- }
}
--
cgit v1.1