aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Clients/Presence/OpenSim.Server.ini33
-rw-r--r--OpenSim/Tests/Clients/Presence/PresenceClient.cs128
-rw-r--r--OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini33
-rw-r--r--OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs120
-rw-r--r--OpenSim/Tests/Common/Mock/MockUserService.cs149
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs6
-rw-r--r--OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs70
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs8
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs68
-rw-r--r--OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs150
10 files changed, 433 insertions, 332 deletions
diff --git a/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini b/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini
new file mode 100644
index 0000000..47e73f9
--- /dev/null
+++ b/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini
@@ -0,0 +1,33 @@
1; * Run a ROBUST server shell like this, from bin:
2; * $ OpenSim.Server.exe -inifile ../OpenSim/Tests/Clients/Presence/OpenSim.Server.ini
3; *
4; * Then run this client like this, from bin:
5; * $ OpenSim.Tests.Clients.PresenceClient.exe
6; *
7; *
8
9[Startup]
10ServiceConnectors = "OpenSim.Server.Handlers.dll:PresenceServiceConnector"
11
12; * This is common for all services, it's the network setup for the entire
13; * server instance
14; *
15[Network]
16port = 8003
17
18; * The following are for the remote console
19; * They have no effect for the local or basic console types
20; * Leave commented to diable logins to the console
21;ConsoleUser = Test
22;ConsolePass = secret
23
24; * As an example, the below configuration precisely mimicks the legacy
25; * asset server. It is read by the asset IN connector (defined above)
26; * and it then loads the OUT connector (a local database module). That,
27; * in turn, reads the asset loader and database connection information
28; *
29[PresenceService]
30 LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService"
31 StorageProvider = "OpenSim.Data.MySQL.dll"
32 ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;"
33
diff --git a/OpenSim/Tests/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Clients/Presence/PresenceClient.cs
new file mode 100644
index 0000000..4f959f6
--- /dev/null
+++ b/OpenSim/Tests/Clients/Presence/PresenceClient.cs
@@ -0,0 +1,128 @@
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.Text;
31using System.Reflection;
32
33using OpenMetaverse;
34using log4net;
35using log4net.Appender;
36using log4net.Layout;
37
38using OpenSim.Framework;
39using OpenSim.Services.Interfaces;
40using OpenSim.Services.Connectors;
41
42namespace OpenSim.Tests.Clients.PresenceClient
43{
44 public class PresenceClient
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 public static void Main(string[] args)
51 {
52 ConsoleAppender consoleAppender = new ConsoleAppender();
53 consoleAppender.Layout =
54 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
55 log4net.Config.BasicConfigurator.Configure(consoleAppender);
56
57 string serverURI = "http://127.0.0.1:8003";
58 PresenceServicesConnector m_Connector = new PresenceServicesConnector(serverURI);
59
60 UUID user1 = UUID.Random();
61 UUID session1 = UUID.Random();
62 UUID region1 = UUID.Random();
63
64 bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero);
65 if (success)
66 m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged in user {0} with session {1}", user1, session1);
67 else
68 m_log.InfoFormat("[PRESENCE CLIENT]: failed to login user {0}", user1);
69
70 System.Console.WriteLine("\n");
71
72 PresenceInfo pinfo = m_Connector.GetAgent(session1);
73 if (pinfo == null)
74 m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0}", user1);
75 else
76 m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}",
77 pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID);
78
79 System.Console.WriteLine("\n");
80 success = m_Connector.ReportAgent(session1, region1, new Vector3(128, 128, 128), new Vector3(4, 5, 6));
81 if (success)
82 m_log.InfoFormat("[PRESENCE CLIENT]: Successfully reported session {0} in region {1}", user1, region1);
83 else
84 m_log.InfoFormat("[PRESENCE CLIENT]: failed to report session {0}", session1);
85 pinfo = m_Connector.GetAgent(session1);
86 if (pinfo == null)
87 m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for second time", user1);
88 else
89 m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}",
90 pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID);
91
92 System.Console.WriteLine("\n");
93 success = m_Connector.SetHomeLocation(user1.ToString(), region1, new Vector3(128, 128, 128), new Vector3(4, 5, 6));
94 if (success)
95 m_log.InfoFormat("[PRESENCE CLIENT]: Successfully set home for user {0} in region {1}", user1, region1);
96 else
97 m_log.InfoFormat("[PRESENCE CLIENT]: failed to set home for user {0}", user1);
98 pinfo = m_Connector.GetAgent(session1);
99 if (pinfo == null)
100 m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for third time", user1);
101 else
102 m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}",
103 pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID);
104
105 System.Console.WriteLine("\n");
106 success = m_Connector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY);
107 if (success)
108 m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged out user {0}", user1);
109 else
110 m_log.InfoFormat("[PRESENCE CLIENT]: failed to logout user {0}", user1);
111 pinfo = m_Connector.GetAgent(session1);
112 if (pinfo == null)
113 m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for fourth time", user1);
114 else
115 m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}",
116 pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID);
117
118 System.Console.WriteLine("\n");
119 success = m_Connector.ReportAgent(session1, UUID.Random(), Vector3.Zero, Vector3.Zero);
120 if (success)
121 m_log.InfoFormat("[PRESENCE CLIENT]: Report agent succeeded, but this is wrong");
122 else
123 m_log.InfoFormat("[PRESENCE CLIENT]: failed to report agent, as it should because user is not logged in");
124
125 }
126
127 }
128}
diff --git a/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini b/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini
new file mode 100644
index 0000000..eb1f473
--- /dev/null
+++ b/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini
@@ -0,0 +1,33 @@
1; * Run a ROBUST server shell like this, from bin:
2; * $ OpenSim.Server.exe -inifile ../OpenSim/Tests/Clients/Presence/OpenSim.Server.ini
3; *
4; * Then run this client like this, from bin:
5; * $ OpenSim.Tests.Clients.UserAccountClient.exe
6; *
7; *
8
9[Startup]
10ServiceConnectors = "OpenSim.Server.Handlers.dll:UserAccountServiceConnector"
11
12; * This is common for all services, it's the network setup for the entire
13; * server instance
14; *
15[Network]
16port = 8003
17
18; * The following are for the remote console
19; * They have no effect for the local or basic console types
20; * Leave commented to diable logins to the console
21;ConsoleUser = Test
22;ConsolePass = secret
23
24; * As an example, the below configuration precisely mimicks the legacy
25; * asset server. It is read by the asset IN connector (defined above)
26; * and it then loads the OUT connector (a local database module). That,
27; * in turn, reads the asset loader and database connection information
28; *
29[UserAccountService]
30 LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
31 StorageProvider = "OpenSim.Data.MySQL.dll"
32 ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;"
33
diff --git a/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs b/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs
new file mode 100644
index 0000000..56195b1
--- /dev/null
+++ b/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs
@@ -0,0 +1,120 @@
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.Text;
31using System.Reflection;
32
33using OpenMetaverse;
34using log4net;
35using log4net.Appender;
36using log4net.Layout;
37
38using OpenSim.Framework;
39using OpenSim.Services.Interfaces;
40using OpenSim.Services.Connectors;
41
42namespace OpenSim.Tests.Clients.PresenceClient
43{
44 public class UserAccountsClient
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 public static void Main(string[] args)
51 {
52 ConsoleAppender consoleAppender = new ConsoleAppender();
53 consoleAppender.Layout =
54 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
55 log4net.Config.BasicConfigurator.Configure(consoleAppender);
56
57 string serverURI = "http://127.0.0.1:8003";
58 UserAccountServicesConnector m_Connector = new UserAccountServicesConnector(serverURI);
59
60 UUID user1 = UUID.Random();
61 string first = "Completely";
62 string last = "Clueless";
63 string email = "foo@bar.com";
64
65 UserAccount account = new UserAccount(user1);
66 account.FirstName = first;
67 account.LastName = last;
68 account.Email = email;
69 account.ServiceURLs = new Dictionary<string, object>();
70 account.ServiceURLs.Add("InventoryServerURI", "http://cnn.com");
71 account.ServiceURLs.Add("AssetServerURI", "http://cnn.com");
72
73 bool success = m_Connector.StoreUserAccount(account);
74 if (success)
75 m_log.InfoFormat("[USER CLIENT]: Successfully created account for user {0} {1}", account.FirstName, account.LastName);
76 else
77 m_log.InfoFormat("[USER CLIENT]: failed to create user {0} {1}", account.FirstName, account.LastName);
78
79 System.Console.WriteLine("\n");
80
81 account = m_Connector.GetUserAccount(UUID.Zero, user1);
82 if (account == null)
83 m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by UUID for {0}", user1);
84 else
85 {
86 m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}",
87 account.PrincipalID, account.FirstName, account.LastName, account.Email);
88 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
89 m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value);
90 }
91
92 System.Console.WriteLine("\n");
93
94 account = m_Connector.GetUserAccount(UUID.Zero, first, last);
95 if (account == null)
96 m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by name for {0}", user1);
97 else
98 {
99 m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}",
100 account.PrincipalID, account.FirstName, account.LastName, account.Email);
101 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
102 m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value);
103 }
104
105 System.Console.WriteLine("\n");
106 account = m_Connector.GetUserAccount(UUID.Zero, email);
107 if (account == null)
108 m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by email for {0}", user1);
109 else
110 {
111 m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}",
112 account.PrincipalID, account.FirstName, account.LastName, account.Email);
113 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
114 m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value);
115 }
116
117 }
118
119 }
120}
diff --git a/OpenSim/Tests/Common/Mock/MockUserService.cs b/OpenSim/Tests/Common/Mock/MockUserService.cs
deleted file mode 100644
index 396ef25..0000000
--- a/OpenSim/Tests/Common/Mock/MockUserService.cs
+++ /dev/null
@@ -1,149 +0,0 @@
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 OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Framework.Communications;
33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Services.Interfaces;
35
36namespace OpenSim.Tests.Common
37{
38 public class MockUserService : IUserService
39 {
40 public void AddTemporaryUserProfile(UserProfileData userProfile)
41 {
42 throw new NotImplementedException();
43 }
44
45 public UserProfileData GetUserProfile(string firstName, string lastName)
46 {
47 throw new NotImplementedException();
48 }
49
50 public UserProfileData GetUserProfile(UUID userId)
51 {
52 throw new NotImplementedException();
53 }
54
55 public UserProfileData GetUserProfile(Uri uri)
56 {
57 UserProfileData userProfile = new UserProfileData();
58
59// userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret));
60
61 return userProfile;
62 }
63
64 public Uri GetUserUri(UserProfileData userProfile)
65 {
66 throw new NotImplementedException();
67 }
68
69 public UserAgentData GetAgentByUUID(UUID userId)
70 {
71 throw new NotImplementedException();
72 }
73
74 public void ClearUserAgent(UUID avatarID)
75 {
76 throw new NotImplementedException();
77 }
78
79 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID QueryID, string Query)
80 {
81 throw new NotImplementedException();
82 }
83
84 public UserProfileData SetupMasterUser(string firstName, string lastName)
85 {
86 throw new NotImplementedException();
87 }
88
89 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
90 {
91 throw new NotImplementedException();
92 }
93
94 public UserProfileData SetupMasterUser(UUID userId)
95 {
96 throw new NotImplementedException();
97 }
98
99 public bool UpdateUserProfile(UserProfileData data)
100 {
101 throw new NotImplementedException();
102 }
103
104 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
105 {
106 throw new NotImplementedException();
107 }
108
109 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
110 {
111 throw new NotImplementedException();
112 }
113
114 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
115 {
116 throw new NotImplementedException();
117 }
118
119 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
120 {
121 throw new NotImplementedException();
122 }
123
124 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
125 {
126 throw new NotImplementedException();
127 }
128
129 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
130 {
131 throw new NotImplementedException();
132 }
133
134 public bool VerifySession(UUID userID, UUID sessionID)
135 {
136 return true;
137 }
138
139 public void SetInventoryService(IInventoryService inv)
140 {
141 throw new NotImplementedException();
142 }
143
144 public virtual bool AuthenticateUserByPassword(UUID userID, string password)
145 {
146 throw new NotImplementedException();
147 }
148 }
149}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 7dab6a1..873b3ac 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -367,7 +367,11 @@ namespace OpenSim.Tests.Common.Mock
367 get { return true; } 367 get { return true; }
368 set { } 368 set { }
369 } 369 }
370 370 public bool IsLoggingOut
371 {
372 get { return false; }
373 set { }
374 }
371 public UUID ActiveGroupId 375 public UUID ActiveGroupId
372 { 376 {
373 get { return UUID.Zero; } 377 get { return UUID.Zero; }
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
deleted file mode 100644
index 013462e..0000000
--- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
+++ /dev/null
@@ -1,70 +0,0 @@
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 OpenSim.Framework;
29using OpenSim.Framework.Communications;
30using OpenSim.Framework.Communications.Cache;
31using OpenSim.Framework.Servers;
32using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Region.Communications.Local;
34using OpenSim.Data;
35
36namespace OpenSim.Tests.Common.Mock
37{
38 public class TestCommunicationsManager : CommunicationsManager
39 {
40 public IUserDataPlugin UserDataPlugin
41 {
42 get { return m_userDataPlugin; }
43 }
44 private IUserDataPlugin m_userDataPlugin;
45
46 // public IInventoryDataPlugin InventoryDataPlugin
47 // {
48 // get { return m_inventoryDataPlugin; }
49 // }
50 // private IInventoryDataPlugin m_inventoryDataPlugin;
51
52 public TestCommunicationsManager()
53 : this(null)
54 {
55 }
56
57 public TestCommunicationsManager(NetworkServersInfo serversInfo)
58 : base(serversInfo, null)
59 {
60
61 LocalUserServices lus = new LocalUserServices(991, 992, this);
62 lus.AddPlugin(new TemporaryUserProfilePlugin());
63 m_userDataPlugin = new TestUserDataPlugin();
64 lus.AddPlugin(m_userDataPlugin);
65 m_userService = lus;
66 m_userAdminService = lus;
67
68 }
69 }
70}
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index 22cfa2c..076cb7a 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -29,7 +29,7 @@ using System;
29using Nini.Config; 29using Nini.Config;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Framework.Communications; 31using OpenSim.Framework.Communications;
32using OpenSim.Framework.Communications.Cache; 32
33using OpenSim.Framework.Servers; 33using OpenSim.Framework.Servers;
34using OpenSim.Region.Framework; 34using OpenSim.Region.Framework;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
@@ -40,10 +40,10 @@ namespace OpenSim.Tests.Common.Mock
40 { 40 {
41 public TestScene( 41 public TestScene(
42 RegionInfo regInfo, AgentCircuitManager authen, 42 RegionInfo regInfo, AgentCircuitManager authen,
43 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, StorageManager storeManager, 43 SceneCommunicationService sceneGridService, StorageManager storeManager,
44 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, 44 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
45 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) 45 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
46 : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader, 46 : base(regInfo, authen, sceneGridService, storeManager, moduleLoader,
47 dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion) 47 dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
48 { 48 {
49 } 49 }
@@ -56,7 +56,7 @@ namespace OpenSim.Tests.Common.Mock
56 /// 56 ///
57 /// <param name="agent"></param> 57 /// <param name="agent"></param>
58 /// <returns></returns> 58 /// <returns></returns>
59 public override bool AuthenticateUser(AgentCircuitData agent, out string reason) 59 public override bool VerifyUserPresence(AgentCircuitData agent, out string reason)
60 { 60 {
61 reason = String.Empty; 61 reason = String.Empty;
62 return true; 62 return true;
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index b13e8dd..e37e137 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -32,7 +32,7 @@ using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
@@ -60,7 +60,6 @@ namespace OpenSim.Tests.Common.Setup
60 private static ISharedRegionModule m_assetService = null; 60 private static ISharedRegionModule m_assetService = null;
61 private static ISharedRegionModule m_inventoryService = null; 61 private static ISharedRegionModule m_inventoryService = null;
62 private static ISharedRegionModule m_gridService = null; 62 private static ISharedRegionModule m_gridService = null;
63 private static TestCommunicationsManager commsManager = null;
64 63
65 /// <summary> 64 /// <summary>
66 /// Set up a test scene 65 /// Set up a test scene
@@ -83,21 +82,23 @@ namespace OpenSim.Tests.Common.Setup
83 public static TestScene SetupScene(String realServices) 82 public static TestScene SetupScene(String realServices)
84 { 83 {
85 return SetupScene( 84 return SetupScene(
86 "Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager(), realServices); 85 "Unit test region", UUID.Random(), 1000, 1000, realServices);
87 } 86 }
88 87
89 /// <summary> 88 // REFACTORING PROBLEM. No idea what the difference is with the previous one
90 /// Set up a test scene 89 ///// <summary>
91 /// </summary> 90 ///// Set up a test scene
92 /// 91 ///// </summary>
93 /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> 92 /////
94 /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> 93 ///// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
95 /// <returns></returns> 94 ///// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
96 public static TestScene SetupScene(TestCommunicationsManager cm, String realServices) 95 ///// <returns></returns>
97 { 96 //public static TestScene SetupScene(String realServices)
98 return SetupScene( 97 //{
99 "Unit test region", UUID.Random(), 1000, 1000, cm, ""); 98 // return SetupScene(
100 } 99 // "Unit test region", UUID.Random(), 1000, 1000, "");
100 //}
101
101 /// <summary> 102 /// <summary>
102 /// Set up a test scene 103 /// Set up a test scene
103 /// </summary> 104 /// </summary>
@@ -107,9 +108,9 @@ namespace OpenSim.Tests.Common.Setup
107 /// <param name="y">Y co-ordinate of the region</param> 108 /// <param name="y">Y co-ordinate of the region</param>
108 /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> 109 /// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
109 /// <returns></returns> 110 /// <returns></returns>
110 public static TestScene SetupScene(string name, UUID id, uint x, uint y, TestCommunicationsManager cm) 111 public static TestScene SetupScene(string name, UUID id, uint x, uint y)
111 { 112 {
112 return SetupScene(name, id, x, y, cm, ""); 113 return SetupScene(name, id, x, y,"");
113 } 114 }
114 115
115 116
@@ -125,23 +126,24 @@ namespace OpenSim.Tests.Common.Setup
125 /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> 126 /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
126 /// <returns></returns> 127 /// <returns></returns>
127 public static TestScene SetupScene( 128 public static TestScene SetupScene(
128 string name, UUID id, uint x, uint y, TestCommunicationsManager cm, String realServices) 129 string name, UUID id, uint x, uint y, String realServices)
129 { 130 {
130 bool newScene = false; 131 bool newScene = false;
131 132
132 Console.WriteLine("Setting up test scene {0}", name); 133 Console.WriteLine("Setting up test scene {0}", name);
133 134
134 // If cm is the same as our last commsManager used, this means the tester wants to link 135 // REFACTORING PROBLEM!
135 // regions. In this case, don't use the sameshared region modules and dont initialize them again. 136 //// If cm is the same as our last commsManager used, this means the tester wants to link
136 // Also, no need to start another MainServer and MainConsole instance. 137 //// regions. In this case, don't use the sameshared region modules and dont initialize them again.
137 if (cm == null || cm != commsManager) 138 //// Also, no need to start another MainServer and MainConsole instance.
138 { 139 //if (cm == null || cm != commsManager)
139 System.Console.WriteLine("Starting a brand new scene"); 140 //{
140 newScene = true; 141 // System.Console.WriteLine("Starting a brand new scene");
141 MainConsole.Instance = new LocalConsole("TEST PROMPT"); 142 // newScene = true;
142 MainServer.Instance = new BaseHttpServer(980); 143 // MainConsole.Instance = new LocalConsole("TEST PROMPT");
143 commsManager = cm; 144 // MainServer.Instance = new BaseHttpServer(980);
144 } 145 // commsManager = cm;
146 //}
145 147
146 // We must set up a console otherwise setup of some modules may fail 148 // We must set up a console otherwise setup of some modules may fail
147 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); 149 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
@@ -149,13 +151,13 @@ namespace OpenSim.Tests.Common.Setup
149 regInfo.RegionID = id; 151 regInfo.RegionID = id;
150 152
151 AgentCircuitManager acm = new AgentCircuitManager(); 153 AgentCircuitManager acm = new AgentCircuitManager();
152 SceneCommunicationService scs = new SceneCommunicationService(cm); 154 SceneCommunicationService scs = new SceneCommunicationService();
153 155
154 StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", ""); 156 StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", "");
155 IConfigSource configSource = new IniConfigSource(); 157 IConfigSource configSource = new IniConfigSource();
156 158
157 TestScene testScene = new TestScene( 159 TestScene testScene = new TestScene(
158 regInfo, acm, cm, scs, sm, null, false, false, false, configSource, null); 160 regInfo, acm, scs, sm, null, false, false, false, configSource, null);
159 161
160 INonSharedRegionModule capsModule = new CapabilitiesModule(); 162 INonSharedRegionModule capsModule = new CapabilitiesModule();
161 capsModule.Initialise(new IniConfigSource()); 163 capsModule.Initialise(new IniConfigSource());
@@ -194,8 +196,6 @@ namespace OpenSim.Tests.Common.Setup
194 m_inventoryService.PostInitialise(); 196 m_inventoryService.PostInitialise();
195 m_assetService.PostInitialise(); 197 m_assetService.PostInitialise();
196 198
197 testScene.CommsManager.UserService.SetInventoryService(testScene.InventoryService);
198
199 testScene.SetModuleInterfaces(); 199 testScene.SetModuleInterfaces();
200 200
201 testScene.LandChannel = new TestLandChannel(testScene); 201 testScene.LandChannel = new TestLandChannel(testScene);
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
index cb76bc1..cd61fa6 100644
--- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
@@ -27,8 +27,7 @@
27 27
28using OpenMetaverse; 28using OpenMetaverse;
29using OpenSim.Framework.Communications; 29using OpenSim.Framework.Communications;
30using OpenSim.Framework.Communications.Cache; 30
31using OpenSim.Region.Communications.Local;
32 31
33namespace OpenSim.Tests.Common.Setup 32namespace OpenSim.Tests.Common.Setup
34{ 33{
@@ -37,82 +36,85 @@ namespace OpenSim.Tests.Common.Setup
37 /// </summary> 36 /// </summary>
38 public static class UserProfileTestUtils 37 public static class UserProfileTestUtils
39 { 38 {
40 /// <summary> 39 // REFACTORING PROBLEM
41 /// Create a test user with a standard inventory 40 // This needs to be rewritten
42 /// </summary> 41
43 /// <param name="commsManager"></param> 42 ///// <summary>
44 /// <param name="callback"> 43 ///// Create a test user with a standard inventory
45 /// Callback to invoke when inventory has been loaded. This is required because 44 ///// </summary>
46 /// loading may be asynchronous, even on standalone 45 ///// <param name="commsManager"></param>
47 /// </param> 46 ///// <param name="callback">
48 /// <returns></returns> 47 ///// Callback to invoke when inventory has been loaded. This is required because
49 public static CachedUserInfo CreateUserWithInventory( 48 ///// loading may be asynchronous, even on standalone
50 CommunicationsManager commsManager, OnInventoryReceivedDelegate callback) 49 ///// </param>
51 { 50 ///// <returns></returns>
52 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); 51 //public static CachedUserInfo CreateUserWithInventory(
53 return CreateUserWithInventory(commsManager, userId, callback); 52 // CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
54 } 53 //{
54 // UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
55 // return CreateUserWithInventory(commsManager, userId, callback);
56 //}
55 57
56 /// <summary> 58 ///// <summary>
57 /// Create a test user with a standard inventory 59 ///// Create a test user with a standard inventory
58 /// </summary> 60 ///// </summary>
59 /// <param name="commsManager"></param> 61 ///// <param name="commsManager"></param>
60 /// <param name="userId">User ID</param> 62 ///// <param name="userId">User ID</param>
61 /// <param name="callback"> 63 ///// <param name="callback">
62 /// Callback to invoke when inventory has been loaded. This is required because 64 ///// Callback to invoke when inventory has been loaded. This is required because
63 /// loading may be asynchronous, even on standalone 65 ///// loading may be asynchronous, even on standalone
64 /// </param> 66 ///// </param>
65 /// <returns></returns> 67 ///// <returns></returns>
66 public static CachedUserInfo CreateUserWithInventory( 68 //public static CachedUserInfo CreateUserWithInventory(
67 CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) 69 // CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
68 { 70 //{
69 return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); 71 // return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
70 } 72 //}
71 73
72 /// <summary> 74 ///// <summary>
73 /// Create a test user with a standard inventory 75 ///// Create a test user with a standard inventory
74 /// </summary> 76 ///// </summary>
75 /// <param name="commsManager"></param> 77 ///// <param name="commsManager"></param>
76 /// <param name="firstName">First name of user</param> 78 ///// <param name="firstName">First name of user</param>
77 /// <param name="lastName">Last name of user</param> 79 ///// <param name="lastName">Last name of user</param>
78 /// <param name="userId">User ID</param> 80 ///// <param name="userId">User ID</param>
79 /// <param name="callback"> 81 ///// <param name="callback">
80 /// Callback to invoke when inventory has been loaded. This is required because 82 ///// Callback to invoke when inventory has been loaded. This is required because
81 /// loading may be asynchronous, even on standalone 83 ///// loading may be asynchronous, even on standalone
82 /// </param> 84 ///// </param>
83 /// <returns></returns> 85 ///// <returns></returns>
84 public static CachedUserInfo CreateUserWithInventory( 86 //public static CachedUserInfo CreateUserWithInventory(
85 CommunicationsManager commsManager, string firstName, string lastName, 87 // CommunicationsManager commsManager, string firstName, string lastName,
86 UUID userId, OnInventoryReceivedDelegate callback) 88 // UUID userId, OnInventoryReceivedDelegate callback)
87 { 89 //{
88 return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); 90 // return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback);
89 } 91 //}
90 92
91 /// <summary> 93 ///// <summary>
92 /// Create a test user with a standard inventory 94 ///// Create a test user with a standard inventory
93 /// </summary> 95 ///// </summary>
94 /// <param name="commsManager"></param> 96 ///// <param name="commsManager"></param>
95 /// <param name="firstName">First name of user</param> 97 ///// <param name="firstName">First name of user</param>
96 /// <param name="lastName">Last name of user</param> 98 ///// <param name="lastName">Last name of user</param>
97 /// <param name="password">Password</param> 99 ///// <param name="password">Password</param>
98 /// <param name="userId">User ID</param> 100 ///// <param name="userId">User ID</param>
99 /// <param name="callback"> 101 ///// <param name="callback">
100 /// Callback to invoke when inventory has been loaded. This is required because 102 ///// Callback to invoke when inventory has been loaded. This is required because
101 /// loading may be asynchronous, even on standalone 103 ///// loading may be asynchronous, even on standalone
102 /// </param> 104 ///// </param>
103 /// <returns></returns> 105 ///// <returns></returns>
104 public static CachedUserInfo CreateUserWithInventory( 106 //public static CachedUserInfo CreateUserWithInventory(
105 CommunicationsManager commsManager, string firstName, string lastName, string password, 107 // CommunicationsManager commsManager, string firstName, string lastName, string password,
106 UUID userId, OnInventoryReceivedDelegate callback) 108 // UUID userId, OnInventoryReceivedDelegate callback)
107 { 109 //{
108 LocalUserServices lus = (LocalUserServices)commsManager.UserService; 110 // LocalUserServices lus = (LocalUserServices)commsManager.UserService;
109 lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); 111 // lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId);
110 112
111 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); 113 // CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
112 userInfo.OnInventoryReceived += callback; 114 // userInfo.OnInventoryReceived += callback;
113 userInfo.FetchInventory(); 115 // userInfo.FetchInventory();
114 116
115 return userInfo; 117 // return userInfo;
116 } 118 //}
117 } 119 }
118} 120}