aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2009-12-30 14:17:18 -0800
committerDiva Canto2009-12-30 14:17:18 -0800
commit1d2a332b96794e2011b0527cf590c3ceedcd8af4 (patch)
treeba5f0c01661ef6a60247e35fb15d6d48e12e2fa0 /OpenSim/Region
parentMerge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/open... (diff)
downloadopensim-SC_OLD-1d2a332b96794e2011b0527cf590c3ceedcd8af4.zip
opensim-SC_OLD-1d2a332b96794e2011b0527cf590c3ceedcd8af4.tar.gz
opensim-SC_OLD-1d2a332b96794e2011b0527cf590c3ceedcd8af4.tar.bz2
opensim-SC_OLD-1d2a332b96794e2011b0527cf590c3ceedcd8af4.tar.xz
Unit tests for presence. They helped fix a couple of wrongnesses.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs13
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs104
2 files changed, 115 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
index 644d755..2cb18c7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
@@ -44,13 +44,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 #region ISharedRegionModule
48
49 private bool m_Enabled = false; 47 private bool m_Enabled = false;
50 48
51 private PresenceDetector m_PresenceDetector; 49 private PresenceDetector m_PresenceDetector;
52 private IPresenceService m_PresenceService; 50 private IPresenceService m_PresenceService;
53 51
52 public LocalPresenceServicesConnector()
53 {
54 }
55
56 public LocalPresenceServicesConnector(IConfigSource source)
57 {
58 Initialise(source);
59 }
60
61 #region ISharedRegionModule
62
54 public Type ReplaceableInterface 63 public Type ReplaceableInterface
55 { 64 {
56 get { return null; } 65 get { return null; }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
new file mode 100644
index 0000000..ebb2c3e
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
@@ -0,0 +1,104 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using log4net.Config;
34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse;
37using OpenSim.Framework;
38using Nini.Config;
39
40using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
41using OpenSim.Region.Framework.Scenes;
42using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
43using OpenSim.Tests.Common;
44using OpenSim.Tests.Common.Setup;
45
46namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests
47{
48 [TestFixture]
49 public class PresenceConnectorsTests
50 {
51 LocalPresenceServicesConnector m_LocalConnector;
52 private void SetUp()
53 {
54 IConfigSource config = new IniConfigSource();
55 config.AddConfig("Modules");
56 config.AddConfig("PresenceService");
57 config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector");
58 config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService");
59 config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData");
60
61 m_LocalConnector = new LocalPresenceServicesConnector(config);
62 }
63
64 /// <summary>
65 /// Test OpenSim Presence.
66 /// </summary>
67 [Test]
68 public void TestPresenceV0_1()
69 {
70 SetUp();
71
72 string user1 = UUID.Zero.ToString();
73 UUID session1 = UUID.Zero;
74
75 // this is not implemented by this connector
76 //m_LocalConnector.LoginAgent(user1, session1, UUID.Zero);
77 PresenceInfo result = m_LocalConnector.GetAgent(session1);
78 Assert.IsNotNull(result, "Retrieved GetAgent is null");
79 Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match");
80 Assert.IsTrue(result.Online, "Agent just logged in but is offline");
81
82 UUID region1 = UUID.Random();
83 bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero);
84 Assert.IsTrue(r, "First ReportAgent returned false");
85 result = m_LocalConnector.GetAgent(session1);
86 Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)");
87
88 UUID region2 = UUID.Random();
89 r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero);
90 Assert.IsTrue(r, "Second ReportAgent returned false");
91 result = m_LocalConnector.GetAgent(session1);
92 Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)");
93
94 r = m_LocalConnector.LogoutAgent(session1);
95 Assert.IsTrue(r, "LogoutAgent returned false");
96 result = m_LocalConnector.GetAgent(session1);
97 Assert.IsNotNull(result, "Agent session disappeared from storage after logout");
98 Assert.IsFalse(result.Online, "Agent is reported to be Online after logout");
99
100 r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero);
101 Assert.IsFalse(r, "ReportAgent of non-logged in user returned true");
102 }
103 }
104}