aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
authorJohn Hurliman2010-02-22 14:10:19 -0800
committerJohn Hurliman2010-02-22 14:10:19 -0800
commit71c6559a91a58d93588dcdd8c74b5fce0c1a3780 (patch)
treecca5b1ea88ad4b29156767afdd77e37ec072c8a7 /OpenSim/Tests
parent* Adds CreatorID to asset metadata. This is just the plumbing to support Crea... (diff)
parentMerge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/open... (diff)
downloadopensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.zip
opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.gz
opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.bz2
opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.xz
Merge branch 'presence-refactor' of ssh://opensimulator.org/var/git/opensim into presence-refactor
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs216
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs26
2 files changed, 26 insertions, 216 deletions
diff --git a/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs
deleted file mode 100644
index 5188cf6..0000000
--- a/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs
+++ /dev/null
@@ -1,216 +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.Data;
33
34namespace OpenSim.Tests.Common.Mock
35{
36 /// <summary>
37 /// In memory user data provider. Might be quite useful as a proper user data plugin, though getting mono addins
38 /// to load any plugins when running unit tests has proven impossible so far. Currently no locking since unit
39 /// tests are single threaded.
40 /// </summary>
41 public class TestUserDataPlugin : IUserDataPlugin
42 {
43 public string Version { get { return "0"; } }
44 public string Name { get { return "TestUserDataPlugin"; } }
45
46 /// <summary>
47 /// User profiles keyed by name
48 /// </summary>
49 private Dictionary<string, UserProfileData> m_userProfilesByName = new Dictionary<string, UserProfileData>();
50
51 /// <summary>
52 /// User profiles keyed by uuid
53 /// </summary>
54 private Dictionary<UUID, UserProfileData> m_userProfilesByUuid = new Dictionary<UUID, UserProfileData>();
55
56 /// <summary>
57 /// User profiles and their agents
58 /// </summary>
59 private Dictionary<UUID, UserAgentData> m_agentByProfileUuid = new Dictionary<UUID, UserAgentData>();
60
61 /// <summary>
62 /// Friends list by uuid
63 /// </summary>
64 private Dictionary<UUID, List<FriendListItem>> m_friendsListByUuid = new Dictionary<UUID, List<FriendListItem>>();
65
66 public void Initialise() {}
67 public void Dispose() {}
68
69 public void AddTemporaryUserProfile(UserProfileData userProfile)
70 {
71 // Not interested
72 }
73
74 public void AddNewUserProfile(UserProfileData user)
75 {
76 UpdateUserProfile(user);
77 }
78
79 public UserProfileData GetUserByUUID(UUID user)
80 {
81 UserProfileData userProfile = null;
82 m_userProfilesByUuid.TryGetValue(user, out userProfile);
83
84 return userProfile;
85 }
86
87 public UserProfileData GetUserByName(string fname, string lname)
88 {
89 UserProfileData userProfile = null;
90 m_userProfilesByName.TryGetValue(fname + " " + lname, out userProfile);
91
92 return userProfile;
93 }
94
95 public UserProfileData GetUserByUri(Uri uri) { return null; }
96
97 public bool UpdateUserProfile(UserProfileData user)
98 {
99 m_userProfilesByUuid[user.ID] = user;
100 m_userProfilesByName[user.FirstName + " " + user.SurName] = user;
101
102 return true;
103 }
104
105 public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) { return null; }
106
107 public UserAgentData GetAgentByUUID(UUID user)
108 {
109 UserAgentData userAgent = null;
110 m_agentByProfileUuid.TryGetValue(user, out userAgent);
111
112 return userAgent;
113 }
114
115 public UserAgentData GetAgentByName(string name)
116 {
117 UserProfileData userProfile = null;
118 m_userProfilesByName.TryGetValue(name, out userProfile);
119 UserAgentData userAgent = null;
120 m_agentByProfileUuid.TryGetValue(userProfile.ID, out userAgent);
121
122 return userAgent;
123 }
124
125 public UserAgentData GetAgentByName(string fname, string lname)
126 {
127 UserProfileData userProfile = GetUserByName(fname,lname);
128 UserAgentData userAgent = null;
129 m_agentByProfileUuid.TryGetValue(userProfile.ID, out userAgent);
130
131 return userAgent;
132 }
133
134 public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {}
135
136 public void AddNewUserAgent(UserAgentData agent)
137 {
138 m_agentByProfileUuid[agent.ProfileID] = agent;
139 }
140 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
141 {
142 FriendListItem newfriend = new FriendListItem();
143 newfriend.FriendPerms = perms;
144 newfriend.Friend = friend;
145 newfriend.FriendListOwner = friendlistowner;
146
147 if (!m_friendsListByUuid.ContainsKey(friendlistowner))
148 {
149 List<FriendListItem> friendslist = new List<FriendListItem>();
150 m_friendsListByUuid[friendlistowner] = friendslist;
151
152 }
153 m_friendsListByUuid[friendlistowner].Add(newfriend);
154 }
155
156 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
157 {
158 if (m_friendsListByUuid.ContainsKey(friendlistowner))
159 {
160 List<FriendListItem> friendslist = m_friendsListByUuid[friendlistowner];
161 foreach (FriendListItem frienditem in friendslist)
162 {
163 if (frienditem.Friend == friend)
164 {
165 friendslist.Remove(frienditem);
166 break;
167 }
168 }
169 }
170 }
171
172 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
173 {
174 if (m_friendsListByUuid.ContainsKey(friendlistowner))
175 {
176 List<FriendListItem> friendslist = m_friendsListByUuid[friendlistowner];
177 foreach (FriendListItem frienditem in friendslist)
178 {
179 if (frienditem.Friend == friend)
180 {
181 frienditem.FriendPerms = perms;
182 break;
183 }
184 }
185 }
186 }
187
188 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
189 {
190 if (m_friendsListByUuid.ContainsKey(friendlistowner))
191 {
192 return m_friendsListByUuid[friendlistowner];
193 }
194 else
195 return new List<FriendListItem>();
196
197
198 }
199
200 public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) { return null; }
201
202 public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; }
203
204 public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; }
205
206 public void Initialise(string connect) { return; }
207
208 public AvatarAppearance GetUserAppearance(UUID user) { return null; }
209
210 public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {}
211
212 public void ResetAttachments(UUID userID) {}
213
214 public void LogoutUsers(UUID regionID) {}
215 }
216}
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index e37e137..9e718f6 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.Avatar.Gods;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; 45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset;
46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; 46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
47using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; 47using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
48using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
48using OpenSim.Services.Interfaces; 49using OpenSim.Services.Interfaces;
49using OpenSim.Tests.Common.Mock; 50using OpenSim.Tests.Common.Mock;
50 51
@@ -60,6 +61,7 @@ namespace OpenSim.Tests.Common.Setup
60 private static ISharedRegionModule m_assetService = null; 61 private static ISharedRegionModule m_assetService = null;
61 private static ISharedRegionModule m_inventoryService = null; 62 private static ISharedRegionModule m_inventoryService = null;
62 private static ISharedRegionModule m_gridService = null; 63 private static ISharedRegionModule m_gridService = null;
64 private static ISharedRegionModule m_userAccountService = null;
63 65
64 /// <summary> 66 /// <summary>
65 /// Set up a test scene 67 /// Set up a test scene
@@ -183,6 +185,8 @@ namespace OpenSim.Tests.Common.Setup
183 StartInventoryService(testScene, false); 185 StartInventoryService(testScene, false);
184 if (realServices.Contains("grid")) 186 if (realServices.Contains("grid"))
185 StartGridService(testScene, true); 187 StartGridService(testScene, true);
188 if (realServices.Contains("useraccounts"))
189 StartUserAccountService(testScene, true);
186 190
187 } 191 }
188 // If not, make sure the shared module gets references to this new scene 192 // If not, make sure the shared module gets references to this new scene
@@ -269,6 +273,28 @@ namespace OpenSim.Tests.Common.Setup
269 //testScene.AddRegionModule(m_gridService.Name, m_gridService); 273 //testScene.AddRegionModule(m_gridService.Name, m_gridService);
270 } 274 }
271 275
276 private static void StartUserAccountService(Scene testScene, bool real)
277 {
278 IConfigSource config = new IniConfigSource();
279 config.AddConfig("Modules");
280 config.AddConfig("UserAccountService");
281 config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector");
282 config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
283 if (real)
284 config.Configs["UserAccountService"].Set("LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService");
285 if (m_userAccountService == null)
286 {
287 ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector();
288 userAccountService.Initialise(config);
289 m_userAccountService = userAccountService;
290 }
291 //else
292 // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService");
293 m_userAccountService.AddRegion(testScene);
294 m_userAccountService.RegionLoaded(testScene);
295 //testScene.AddRegionModule(m_gridService.Name, m_gridService);
296 }
297
272 298
273 /// <summary> 299 /// <summary>
274 /// Setup modules for a scene using their default settings. 300 /// Setup modules for a scene using their default settings.