From f347d25675dbe84345d4b1bfbad041303c75e293 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 20 Aug 2010 11:09:02 -0700 Subject: Unit test breakage fix. --- OpenSim/Framework/Capabilities/Caps.cs | 4 +- OpenSim/Framework/Capabilities/CapsHandlers.cs | 2 +- .../Agent/Capabilities/CapabilitiesModule.cs | 6 +-- .../Scenes/Tests/SceneObjectBasicTests.cs | 8 ++-- .../Framework/Scenes/Tests/ScenePresenceTests.cs | 9 +++- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 56 ++++++++++++++++++---- 6 files changed, 65 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index da953bb..0db7bb9 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs @@ -142,7 +142,7 @@ namespace OpenSim.Framework.Capabilities m_httpListenPort = httpPort; - if (httpServer.UseSSL) + if (httpServer != null && httpServer.UseSSL) { m_httpListenPort = httpServer.SSLPort; httpListen = httpServer.SSLCommonName; @@ -151,7 +151,7 @@ namespace OpenSim.Framework.Capabilities m_agentID = agent; m_dumpAssetsToFile = dumpAssetsToFile; - m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, httpServer.UseSSL); + m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL); m_regionName = regionName; } diff --git a/OpenSim/Framework/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Capabilities/CapsHandlers.cs index f000aed..864e6dd 100644 --- a/OpenSim/Framework/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Capabilities/CapsHandlers.cs @@ -74,7 +74,7 @@ namespace OpenSim.Framework.Capabilities m_httpListenerHostName = httpListenerHostname; m_httpListenerPort = httpListenerPort; m_useSSL = https; - if (m_useSSL) + if (httpListener != null && m_useSSL) { m_httpListenerHostName = httpListener.SSLCommonName; m_httpListenerPort = httpListener.SSLPort; diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs index a6f5d97..c023a6f 100644 --- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs @@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities Caps caps = new Caps(m_scene, m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName, - MainServer.Instance.Port, + (MainServer.Instance == null) ? 0: MainServer.Instance.Port, capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName); - + caps.RegisterHandlers(); m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); @@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset; caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS; caps.GetClient = m_scene.SceneContents.GetControllingClient; - + m_capsHandlers[agentId] = caps; } diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index d4f9f18..54b3260 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -130,11 +130,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests { TestHelper.InMethod(); //log4net.Config.XmlConfigurator.Configure(); - + UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); - + TestScene scene = SceneSetupHelpers.SetupScene(); - + // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; sogd.Enabled = false; @@ -147,7 +147,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); Assert.That(retrievedPart, Is.Not.Null); - + sogd.InventoryDeQueueAndDelete(); SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index 501207e..e39a362 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs @@ -104,8 +104,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests agent.AgentID = agent1; agent.firstname = firstName; agent.lastname = "testlastname"; - agent.SessionID = UUID.Zero; - agent.SecureSessionID = UUID.Zero; + agent.SessionID = UUID.Random(); + agent.SecureSessionID = UUID.Random(); agent.circuitcode = 123; agent.BaseFolder = UUID.Zero; agent.InventoryFolder = UUID.Zero; @@ -114,6 +114,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests agent.ChildrenCapSeeds = new Dictionary(); agent.child = true; + if (scene.PresenceService == null) + Console.WriteLine("Presence Service is null"); + + scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); + string reason; scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason); testclient = new TestClient(agent, scene); diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 4a356e2..eaa0d33 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -46,6 +46,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common.Mock; @@ -63,6 +64,7 @@ namespace OpenSim.Tests.Common.Setup private static ISharedRegionModule m_inventoryService = null; private static ISharedRegionModule m_gridService = null; private static ISharedRegionModule m_userAccountService = null; + private static ISharedRegionModule m_presenceService = null; /// /// Set up a test scene @@ -180,7 +182,7 @@ namespace OpenSim.Tests.Common.Setup else StartAssetService(testScene, false); - // For now, always started a 'real' authenication service + // For now, always started a 'real' authentication service StartAuthenticationService(testScene, true); if (realServices.Contains("inventory")) @@ -188,10 +190,9 @@ namespace OpenSim.Tests.Common.Setup else StartInventoryService(testScene, false); - if (realServices.Contains("grid")) - StartGridService(testScene, true); - + StartGridService(testScene, true); StartUserAccountService(testScene); + StartPresenceService(testScene); } // If not, make sure the shared module gets references to this new scene else @@ -202,11 +203,15 @@ namespace OpenSim.Tests.Common.Setup m_inventoryService.RegionLoaded(testScene); m_userAccountService.AddRegion(testScene); m_userAccountService.RegionLoaded(testScene); + m_presenceService.AddRegion(testScene); + m_presenceService.RegionLoaded(testScene); + } m_inventoryService.PostInitialise(); m_assetService.PostInitialise(); m_userAccountService.PostInitialise(); + m_presenceService.PostInitialise(); testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); testScene.SetModuleInterfaces(); @@ -225,7 +230,11 @@ namespace OpenSim.Tests.Common.Setup m_inventoryService = null; m_gridService = null; m_userAccountService = null; - + m_presenceService = null; + + testScene.RegionInfo.EstateSettings = new EstateSettings(); + testScene.LoginsDisabled = false; + return testScene; } @@ -337,6 +346,32 @@ namespace OpenSim.Tests.Common.Setup } /// + /// Start a presence service + /// + /// + private static void StartPresenceService(Scene testScene) + { + 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"); + + if (m_presenceService == null) + { + ISharedRegionModule presenceService = new LocalPresenceServicesConnector(); + presenceService.Initialise(config); + m_presenceService = presenceService; + } + + m_presenceService.AddRegion(testScene); + m_presenceService.RegionLoaded(testScene); + testScene.AddRegionModule(m_presenceService.Name, m_presenceService); + } + + /// /// Setup modules for a scene using their default settings. /// /// @@ -446,9 +481,14 @@ namespace OpenSim.Tests.Common.Setup { string reason; - // We emulate the proper login sequence here by doing things in three stages + // 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); + // Stage 1: simulate login by telling the scene to expect a new user connection - scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason); + if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) + Console.WriteLine("NewUserConnection failed: " + reason); // Stage 2: add the new client as a child agent to the scene TestClient client = new TestClient(agentData, scene); @@ -459,7 +499,7 @@ namespace OpenSim.Tests.Common.Setup //scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE ScenePresence scp = scene.GetScenePresence(agentData.AgentID); - scp.MakeRootAgent(new Vector3(90,90,90), true); + scp.MakeRootAgent(new Vector3(90, 90, 90), true); return client; } -- cgit v1.1