OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
PresenceConnectorsTests.cs
Go to the documentation of this file.
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 
28 using System;
29 using System.Collections.Generic;
30 using System.IO;
31 using System.Reflection;
32 using System.Threading;
33 using log4net.Config;
34 using NUnit.Framework;
35 using OpenMetaverse;
36 using OpenSim.Framework;
37 using Nini.Config;
38 using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
39 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Tests.Common;
42 
43 namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests
44 {
45  [TestFixture]
47  {
48  LocalPresenceServicesConnector m_LocalConnector;
49 
50  public override void SetUp()
51  {
52  base.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");
60 
61  m_LocalConnector = new LocalPresenceServicesConnector();
62  m_LocalConnector.Initialise(config);
63 
64  // Let's stick in a test presence
65  m_LocalConnector.m_PresenceService.LoginAgent(UUID.Zero.ToString(), UUID.Zero, UUID.Zero);
66  }
67 
71  [Test]
72  public void TestPresenceV0_1()
73  {
74  SetUp();
75 
76  // Let's stick in a test presence
77  /*
78  PresenceData p = new PresenceData();
79  p.SessionID = UUID.Zero;
80  p.UserID = UUID.Zero.ToString();
81  p.Data = new Dictionary<string, string>();
82  p.Data["Online"] = true.ToString();
83  m_presenceData.Add(UUID.Zero, p);
84  */
85 
86  string user1 = UUID.Zero.ToString();
87  UUID session1 = UUID.Zero;
88 
89  // this is not implemented by this connector
90  //m_LocalConnector.LoginAgent(user1, session1, UUID.Zero);
91  PresenceInfo result = m_LocalConnector.GetAgent(session1);
92  Assert.IsNotNull(result, "Retrieved GetAgent is null");
93  Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match");
94 
95  UUID region1 = UUID.Random();
96  bool r = m_LocalConnector.ReportAgent(session1, region1);
97  Assert.IsTrue(r, "First ReportAgent returned false");
98  result = m_LocalConnector.GetAgent(session1);
99  Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)");
100 
101  UUID region2 = UUID.Random();
102  r = m_LocalConnector.ReportAgent(session1, region2);
103  Assert.IsTrue(r, "Second ReportAgent returned false");
104  result = m_LocalConnector.GetAgent(session1);
105  Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)");
106 
107  r = m_LocalConnector.LogoutAgent(session1);
108  Assert.IsTrue(r, "LogoutAgent returned false");
109  result = m_LocalConnector.GetAgent(session1);
110  Assert.IsNull(result, "Agent session is still stored after logout");
111 
112  r = m_LocalConnector.ReportAgent(session1, region1);
113  Assert.IsFalse(r, "ReportAgent of non-logged in user returned true");
114  }
115  }
116 }
Interactive OpenSim region server
Definition: OpenSim.cs:55
OpenSim.Services.Interfaces.PresenceInfo PresenceInfo
OpenSim.Services.Interfaces.PresenceInfo PresenceInfo