aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Tests')
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs152
1 files changed, 98 insertions, 54 deletions
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
index 55893ab..fdc20dd 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
@@ -27,10 +27,12 @@
27 27
28using NUnit.Framework; 28using NUnit.Framework;
29using NUnit.Framework.SyntaxHelpers; 29using NUnit.Framework.SyntaxHelpers;
30using System.Threading;
30using OpenMetaverse; 31using OpenMetaverse;
31using OpenSim.Data; 32using OpenSim.Data;
32using OpenSim.Framework; 33using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.Communications.Local; 36using OpenSim.Region.Communications.Local;
35using OpenSim.Tests.Common.Mock; 37using OpenSim.Tests.Common.Mock;
36using OpenSim.Tests.Common.Setup; 38using OpenSim.Tests.Common.Setup;
@@ -48,33 +50,33 @@ namespace OpenSim.Framework.Communications.Tests
48 50
49 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002"); 51 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002");
50 string firstName = "Bill"; 52 string firstName = "Bill";
51 string lastName = "Bailey"; 53 string lastName = "Bailey";
52 CachedUserInfo nonExistingUserInfo; 54 CachedUserInfo nonExistingUserInfo;
53 55
54 TestCommunicationsManager commsManager = new TestCommunicationsManager(); 56 TestCommunicationsManager commsManager = new TestCommunicationsManager();
55 57
56 // Check we can't retrieve info before it exists by uuid 58 // Check we can't retrieve info before it exists by uuid
57 nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); 59 nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
58 Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation"); 60 Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation");
59 61
60 // Check we can't retrieve info before it exists by name 62 // Check we can't retrieve info before it exists by name
61 nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); 63 nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
62 Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation"); 64 Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation");
63 65
64 LocalUserServices lus = (LocalUserServices)commsManager.UserService; 66 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
65 lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); 67 lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
66 68
67 CachedUserInfo existingUserInfo; 69 CachedUserInfo existingUserInfo;
68 70
69 // Check we can retrieve info by uuid 71 // Check we can retrieve info by uuid
70 existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); 72 existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
71 Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid"); 73 Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid");
72 74
73 // Check we can retrieve info by name 75 // Check we can retrieve info by name
74 existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); 76 existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
75 Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); 77 Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name");
76 } 78 }
77 79
78 /** 80 /**
79 * Disabled as not fully implemented 81 * Disabled as not fully implemented
80 [Test] 82 [Test]
@@ -82,26 +84,26 @@ namespace OpenSim.Framework.Communications.Tests
82 { 84 {
83 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292"); 85 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292");
84 string firstName = "Inspector"; 86 string firstName = "Inspector";
85 string originalLastName = "Morse"; 87 string originalLastName = "Morse";
86 string newLastName = "Gadget"; 88 string newLastName = "Gadget";
87 89
88 UserProfileData newProfile = new UserProfileData(); 90 UserProfileData newProfile = new UserProfileData();
89 newProfile.ID = userId; 91 newProfile.ID = userId;
90 newProfile.FirstName = firstName; 92 newProfile.FirstName = firstName;
91 newProfile.SurName = newLastName; 93 newProfile.SurName = newLastName;
92 94
93 TestCommunicationsManager commsManager = new TestCommunicationsManager(); 95 TestCommunicationsManager commsManager = new TestCommunicationsManager();
94 UserProfileCacheService userCacheService = commsManager.UserProfileCacheService; 96 UserProfileCacheService userCacheService = commsManager.UserProfileCacheService;
95 IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; 97 IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin;
96 98
97 // Check that we can't update info before it exists 99 // Check that we can't update info before it exists
98 Assert.That(userCacheService.UpdateProfile(newProfile), Is.False); 100 Assert.That(userCacheService.UpdateProfile(newProfile), Is.False);
99 Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); 101 Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null);
100 102
101 // Check that we can update a profile once it exists 103 // Check that we can update a profile once it exists
102 LocalUserServices lus = (LocalUserServices)commsManager.UserService; 104 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
103 lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); 105 lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId);
104 106
105 Assert.That(userCacheService.UpdateProfile(newProfile), Is.True); 107 Assert.That(userCacheService.UpdateProfile(newProfile), Is.True);
106 UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; 108 UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile;
107 Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); 109 Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName));
@@ -109,59 +111,77 @@ namespace OpenSim.Framework.Communications.Tests
109 } 111 }
110 */ 112 */
111 113
112 //[Test] 114 [Test]
113 public void TestFetchInventory() 115 public void TestFetchInventory()
114 { 116 {
115 TestHelper.InMethod(); 117 TestHelper.InMethod();
116 118
117 TestCommunicationsManager commsManager = new TestCommunicationsManager(); 119 Scene myScene = SceneSetupHelpers.SetupScene();
118 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); 120 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
119 121 for (int i = 0 ; i < 50 ; i++)
120 Assert.That(userInfo.HasReceivedInventory, Is.True); 122 {
123 if (userInfo.HasReceivedInventory == true)
124 break;
125 Thread.Sleep(200);
126 }
127 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
121 } 128 }
122 129
123 //[Test] 130 [Test]
124 public void TestGetChildFolder() 131 public void TestGetChildFolder()
125 { 132 {
126 TestHelper.InMethod(); 133 TestHelper.InMethod();
127 134
128 TestCommunicationsManager commsManager = new TestCommunicationsManager(); 135 Scene myScene = SceneSetupHelpers.SetupScene();
129 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); 136 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
137 for (int i = 0 ; i < 50 ; i++)
138 {
139 if (userInfo.HasReceivedInventory == true)
140 break;
141 Thread.Sleep(200);
142 }
143 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
130 144
131 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); 145 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
132
133 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); 146 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
134 userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); 147 userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID);
135 148
136 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); 149 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null);
137 } 150 }
138 151
139 //[Test] 152 [Test]
140 public void TestCreateFolder() 153 public void TestCreateFolder()
141 { 154 {
142 TestHelper.InMethod(); 155 TestHelper.InMethod();
143 156
144 TestCommunicationsManager commsManager = new TestCommunicationsManager(); 157 Scene myScene = SceneSetupHelpers.SetupScene();
145 IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; 158 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
146 159 for (int i = 0 ; i < 50 ; i++)
147 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); 160 {
161 if (userInfo.HasReceivedInventory == true)
162 break;
163 Thread.Sleep(200);
164 }
165 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
148 166
149 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); 167 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
150 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); 168 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
151 169
152 // 1: Try a folder create that should fail because the parent id given does not exist 170 // 1: Try a folder create that should fail because the parent id given does not exist
153 UUID missingFolderId = UUID.Random(); 171 UUID missingFolderId = UUID.Random();
172 InventoryFolderBase myFolder = new InventoryFolderBase();
173 myFolder.ID = folderId;
154 174
155 Assert.That( 175 Assert.That(
156 userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False); 176 userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False);
157 Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Null); 177 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
158 Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False); 178 Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False);
159 Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null); 179 Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null);
160 180
161 // 2: Try a folder create that should work 181 // 2: Try a folder create that should work
162 Assert.That( 182 Assert.That(
163 userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True); 183 userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True);
164 Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); 184 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Not.Null);
165 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); 185 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True);
166 } 186 }
167 187
@@ -170,13 +190,20 @@ namespace OpenSim.Framework.Communications.Tests
170 { 190 {
171 TestHelper.InMethod(); 191 TestHelper.InMethod();
172 192
173 TestCommunicationsManager commsManager = new TestCommunicationsManager(); 193 Scene myScene = SceneSetupHelpers.SetupScene();
174 IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; 194 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
175 195 for (int i = 0 ; i < 50 ; i++)
176 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); 196 {
197 if (userInfo.HasReceivedInventory == true)
198 break;
199 Thread.Sleep(200);
200 }
201 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
177 202
178 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 203 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
179 InventoryFolderImpl rootFolder = userInfo.RootFolder; 204 InventoryFolderImpl rootFolder = userInfo.RootFolder;
205 InventoryFolderBase myFolder = new InventoryFolderBase();
206 myFolder.ID = folder1Id;
180 207
181 userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); 208 userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
182 209
@@ -190,7 +217,7 @@ namespace OpenSim.Framework.Communications.Tests
190 Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); 217 Assert.That(newFolderName1, Is.EqualTo(folder1.Name));
191 Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); 218 Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type));
192 219
193 InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); 220 InventoryFolderBase dataFolder1 = myScene.InventoryService.QueryFolder(myFolder);
194 Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); 221 Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name));
195 Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); 222 Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type));
196 } 223 }
@@ -201,6 +228,9 @@ namespace OpenSim.Framework.Communications.Tests
201 userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); 228 userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID);
202 InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); 229 InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id);
203 230
231 InventoryFolderBase myFolder2 = new InventoryFolderBase();
232 myFolder2.ID = folder2Id;
233
204 string newFolderName2 = "newFolderName2"; 234 string newFolderName2 = "newFolderName2";
205 ushort folderType2 = (ushort)AssetType.Bodypart; 235 ushort folderType2 = (ushort)AssetType.Bodypart;
206 userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id); 236 userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id);
@@ -213,7 +243,7 @@ namespace OpenSim.Framework.Communications.Tests
213 Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True); 243 Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True);
214 Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False); 244 Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False);
215 245
216 InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); 246 InventoryFolderBase dataFolder1 = myScene.InventoryService.QueryFolder(myFolder2);
217 Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name)); 247 Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name));
218 Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); 248 Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type));
219 Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID)); 249 Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID));
@@ -221,15 +251,20 @@ namespace OpenSim.Framework.Communications.Tests
221 251
222 } 252 }
223 253
224 //[Test] 254 [Test]
225 public void TestMoveFolder() 255 public void TestMoveFolder()
226 { 256 {
227 TestHelper.InMethod(); 257 TestHelper.InMethod();
228 258
229 TestCommunicationsManager commsManager = new TestCommunicationsManager(); 259 Scene myScene = SceneSetupHelpers.SetupScene();
230 IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; 260 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
231 261 for (int i = 0 ; i < 50 ; i++)
232 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); 262 {
263 if (userInfo.HasReceivedInventory == true)
264 break;
265 Thread.Sleep(200);
266 }
267 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
233 268
234 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); 269 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
235 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); 270 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
@@ -248,34 +283,43 @@ namespace OpenSim.Framework.Communications.Tests
248 userInfo.MoveFolder(folderToMoveId, folder2Id); 283 userInfo.MoveFolder(folderToMoveId, folder2Id);
249 284
250 // Check folder is now in folder2 and no trace remains in folder1 285 // Check folder is now in folder2 and no trace remains in folder1
286 InventoryFolderBase myFolder = new InventoryFolderBase();
287 myFolder.ID = folderToMoveId;
251 Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True); 288 Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True);
252 Assert.That(inventoryDataPlugin.getInventoryFolder(folderToMoveId).ParentID, Is.EqualTo(folder2Id)); 289 Assert.That(myScene.InventoryService.QueryFolder(myFolder).ParentID, Is.EqualTo(folder2Id));
253 290
254 Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); 291 Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False);
255 } 292 }
256 293
257 //[Test] 294 [Test]
258 public void TestPurgeFolder() 295 public void TestPurgeFolder()
259 { 296 {
260 TestHelper.InMethod(); 297 TestHelper.InMethod();
261 //log4net.Config.XmlConfigurator.Configure(); 298 //log4net.Config.XmlConfigurator.Configure();
262 299
263 TestCommunicationsManager commsManager = new TestCommunicationsManager(); 300 Scene myScene = SceneSetupHelpers.SetupScene();
264 IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; 301 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
265 302 for (int i = 0 ; i < 50 ; i++)
266 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); 303 {
304 if (userInfo.HasReceivedInventory == true)
305 break;
306 Thread.Sleep(200);
307 }
308 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
267 309
268 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); 310 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
269 InventoryFolderImpl rootFolder = userInfo.RootFolder; 311 InventoryFolderImpl rootFolder = userInfo.RootFolder;
312 InventoryFolderBase myFolder = new InventoryFolderBase();
313 myFolder.ID = folder1Id;
270 314
271 userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); 315 userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
272 Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Not.Null); 316 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Not.Null);
273 317
274 // Test purge 318 // Test purge
275 userInfo.PurgeFolder(rootFolder.ID); 319 userInfo.PurgeFolder(rootFolder.ID);
276 320
277 Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); 321 Assert.That(rootFolder.RequestListOfFolders(), Is.Empty);
278 Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Null); 322 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
279 } 323 }
280 } 324 }
281} 325}