diff options
author | Diva Canto | 2010-01-08 10:43:34 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-08 10:43:34 -0800 |
commit | b63405c1a796b44b58081857d01f726372467628 (patch) | |
tree | 564d03059ed55f7b0740fd00e6dd7d1e34edea5d /OpenSim/Framework | |
parent | * Finished SimulationServiceConnector (diff) | |
download | opensim-SC_OLD-b63405c1a796b44b58081857d01f726372467628.zip opensim-SC_OLD-b63405c1a796b44b58081857d01f726372467628.tar.gz opensim-SC_OLD-b63405c1a796b44b58081857d01f726372467628.tar.bz2 opensim-SC_OLD-b63405c1a796b44b58081857d01f726372467628.tar.xz |
Inching ahead... This compiles, but very likely does not run.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 345 |
1 files changed, 0 insertions, 345 deletions
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs deleted file mode 100644 index 830c877..0000000 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ /dev/null | |||
@@ -1,345 +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 | |||
28 | using NUnit.Framework; | ||
29 | using NUnit.Framework.SyntaxHelpers; | ||
30 | using System.Threading; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | using OpenSim.Tests.Common.Setup; | ||
39 | using OpenSim.Tests.Common; | ||
40 | |||
41 | namespace OpenSim.Framework.Communications.Tests | ||
42 | { | ||
43 | [TestFixture] | ||
44 | public class UserProfileCacheServiceTests | ||
45 | { | ||
46 | /// <value>Used by tests to indicate whether an async operation timed out</value> | ||
47 | private bool timedOut; | ||
48 | |||
49 | private void InventoryReceived(UUID userId) | ||
50 | { | ||
51 | lock (this) | ||
52 | { | ||
53 | timedOut = false; | ||
54 | Monitor.PulseAll(this); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | [Test] | ||
59 | public void TestGetUserDetails() | ||
60 | { | ||
61 | TestHelper.InMethod(); | ||
62 | |||
63 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002"); | ||
64 | string firstName = "Bill"; | ||
65 | string lastName = "Bailey"; | ||
66 | CachedUserInfo nonExistingUserInfo; | ||
67 | |||
68 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); | ||
69 | // Scene myScene = SceneSetupHelpers.SetupScene(commsManager, ""); | ||
70 | |||
71 | // Check we can't retrieve info before it exists by uuid | ||
72 | nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); | ||
73 | Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation"); | ||
74 | |||
75 | // Check we can't retrieve info before it exists by name | ||
76 | nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | ||
77 | Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation"); | ||
78 | |||
79 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; | ||
80 | lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); | ||
81 | |||
82 | CachedUserInfo existingUserInfo; | ||
83 | |||
84 | // Check we can retrieve info by uuid | ||
85 | existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); | ||
86 | Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid"); | ||
87 | |||
88 | // Check we can retrieve info by name | ||
89 | existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | ||
90 | Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * Disabled as not fully implemented | ||
95 | [Test] | ||
96 | public void TestUpdateProfile() | ||
97 | { | ||
98 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292"); | ||
99 | string firstName = "Inspector"; | ||
100 | string originalLastName = "Morse"; | ||
101 | string newLastName = "Gadget"; | ||
102 | |||
103 | UserProfileData newProfile = new UserProfileData(); | ||
104 | newProfile.ID = userId; | ||
105 | newProfile.FirstName = firstName; | ||
106 | newProfile.SurName = newLastName; | ||
107 | |||
108 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); | ||
109 | UserProfileCacheService userCacheService = commsManager.UserProfileCacheService; | ||
110 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
111 | |||
112 | // Check that we can't update info before it exists | ||
113 | Assert.That(userCacheService.StoreProfile(newProfile), Is.False); | ||
114 | Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); | ||
115 | |||
116 | // Check that we can update a profile once it exists | ||
117 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; | ||
118 | lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); | ||
119 | |||
120 | Assert.That(userCacheService.StoreProfile(newProfile), Is.True); | ||
121 | UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; | ||
122 | Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); | ||
123 | Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); | ||
124 | } | ||
125 | */ | ||
126 | |||
127 | [Test] | ||
128 | public void TestFetchInventory() | ||
129 | { | ||
130 | TestHelper.InMethod(); | ||
131 | |||
132 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
133 | |||
134 | timedOut = true; | ||
135 | lock (this) | ||
136 | { | ||
137 | UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
138 | Monitor.Wait(this, 60000); | ||
139 | } | ||
140 | |||
141 | Assert.That(timedOut, Is.False, "Timed out"); | ||
142 | } | ||
143 | |||
144 | [Test] | ||
145 | public void TestGetChildFolder() | ||
146 | { | ||
147 | TestHelper.InMethod(); | ||
148 | |||
149 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
150 | CachedUserInfo userInfo; | ||
151 | |||
152 | lock (this) | ||
153 | { | ||
154 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
155 | Monitor.Wait(this, 60000); | ||
156 | } | ||
157 | |||
158 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); | ||
159 | Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); | ||
160 | userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); | ||
161 | |||
162 | Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); | ||
163 | } | ||
164 | |||
165 | [Test] | ||
166 | public void TestCreateFolder() | ||
167 | { | ||
168 | TestHelper.InMethod(); | ||
169 | |||
170 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
171 | CachedUserInfo userInfo; | ||
172 | |||
173 | lock (this) | ||
174 | { | ||
175 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
176 | Monitor.Wait(this, 60000); | ||
177 | } | ||
178 | |||
179 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); | ||
180 | Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); | ||
181 | |||
182 | // 1: Try a folder create that should fail because the parent id given does not exist | ||
183 | UUID missingFolderId = UUID.Random(); | ||
184 | InventoryFolderBase myFolder = new InventoryFolderBase(); | ||
185 | myFolder.ID = folderId; | ||
186 | |||
187 | Assert.That( | ||
188 | userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False); | ||
189 | Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); | ||
190 | Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False); | ||
191 | Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null); | ||
192 | |||
193 | // 2: Try a folder create that should work | ||
194 | Assert.That( | ||
195 | userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True); | ||
196 | Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null); | ||
197 | Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); | ||
198 | } | ||
199 | |||
200 | //[Test] | ||
201 | public void TestUpdateFolder() | ||
202 | { | ||
203 | TestHelper.InMethod(); | ||
204 | |||
205 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
206 | CachedUserInfo userInfo; | ||
207 | |||
208 | lock (this) | ||
209 | { | ||
210 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
211 | Monitor.Wait(this, 60000); | ||
212 | } | ||
213 | |||
214 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
215 | InventoryFolderImpl rootFolder = userInfo.RootFolder; | ||
216 | InventoryFolderBase myFolder = new InventoryFolderBase(); | ||
217 | myFolder.ID = folder1Id; | ||
218 | |||
219 | userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
220 | |||
221 | // 1: Test updates that don't involve moving the folder | ||
222 | { | ||
223 | string newFolderName1 = "newFolderName1"; | ||
224 | ushort folderType1 = (ushort)AssetType.Texture; | ||
225 | userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID); | ||
226 | |||
227 | InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); | ||
228 | Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); | ||
229 | Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); | ||
230 | |||
231 | InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder); | ||
232 | Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); | ||
233 | Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); | ||
234 | } | ||
235 | |||
236 | // 2: Test an update that also involves moving the folder | ||
237 | { | ||
238 | UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000061"); | ||
239 | userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
240 | InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); | ||
241 | |||
242 | InventoryFolderBase myFolder2 = new InventoryFolderBase(); | ||
243 | myFolder2.ID = folder2Id; | ||
244 | |||
245 | string newFolderName2 = "newFolderName2"; | ||
246 | ushort folderType2 = (ushort)AssetType.Bodypart; | ||
247 | userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id); | ||
248 | |||
249 | InventoryFolderImpl folder1 = folder2.GetChildFolder(folder1Id); | ||
250 | Assert.That(newFolderName2, Is.EqualTo(folder1.Name)); | ||
251 | Assert.That(folderType2, Is.EqualTo((ushort)folder1.Type)); | ||
252 | Assert.That(folder2Id, Is.EqualTo(folder1.ParentID)); | ||
253 | |||
254 | Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True); | ||
255 | Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False); | ||
256 | |||
257 | InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder2); | ||
258 | Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name)); | ||
259 | Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); | ||
260 | Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID)); | ||
261 | } | ||
262 | |||
263 | } | ||
264 | |||
265 | [Test] | ||
266 | public void TestMoveFolder() | ||
267 | { | ||
268 | TestHelper.InMethod(); | ||
269 | |||
270 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
271 | CachedUserInfo userInfo; | ||
272 | |||
273 | lock (this) | ||
274 | { | ||
275 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
276 | Monitor.Wait(this, 60000); | ||
277 | } | ||
278 | |||
279 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
280 | UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); | ||
281 | UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030"); | ||
282 | InventoryFolderImpl rootFolder = userInfo.RootFolder; | ||
283 | |||
284 | userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
285 | InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); | ||
286 | userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
287 | InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); | ||
288 | |||
289 | // Check folder is currently in folder1 | ||
290 | userInfo.CreateFolder("folderToMove", folderToMoveId, (ushort)AssetType.Animation, folder1Id); | ||
291 | Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.True); | ||
292 | |||
293 | userInfo.MoveFolder(folderToMoveId, folder2Id); | ||
294 | |||
295 | // Check folder is now in folder2 and no trace remains in folder1 | ||
296 | InventoryFolderBase myFolder = new InventoryFolderBase(); | ||
297 | myFolder.ID = folderToMoveId; | ||
298 | Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True); | ||
299 | Assert.That(myScene.InventoryService.GetFolder(myFolder).ParentID, Is.EqualTo(folder2Id)); | ||
300 | |||
301 | Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); | ||
302 | } | ||
303 | |||
304 | [Test] | ||
305 | public void TestPurgeFolder() | ||
306 | { | ||
307 | TestHelper.InMethod(); | ||
308 | //log4net.Config.XmlConfigurator.Configure(); | ||
309 | |||
310 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
311 | CachedUserInfo userInfo; | ||
312 | |||
313 | lock (this) | ||
314 | { | ||
315 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
316 | Monitor.Wait(this, 60000); | ||
317 | } | ||
318 | |||
319 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); | ||
320 | InventoryFolderImpl rootFolder = userInfo.RootFolder; | ||
321 | InventoryFolderBase myFolder = new InventoryFolderBase(); | ||
322 | myFolder.ID = folder1Id; | ||
323 | |||
324 | userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
325 | Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null); | ||
326 | |||
327 | // Test purge | ||
328 | userInfo.PurgeFolder(rootFolder.ID); | ||
329 | |||
330 | Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); | ||
331 | Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); | ||
332 | } | ||
333 | |||
334 | [TearDown] | ||
335 | public void TearDown() | ||
336 | { | ||
337 | try | ||
338 | { | ||
339 | if (MainServer.Instance != null) MainServer.Instance.Stop(); | ||
340 | } | ||
341 | catch (System.NullReferenceException) | ||
342 | { } | ||
343 | } | ||
344 | } | ||
345 | } \ No newline at end of file | ||