aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Tests/Cache
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-08-11 16:45:16 +0100
committerJustin Clark-Casey (justincc)2009-08-11 16:45:16 +0100
commit226c082ed417f4a5f2295595e45eca2fcb1e42c9 (patch)
tree4bbe2f59176589e497a2f4fd16b3adfe3989c5cd /OpenSim/Framework/Communications/Tests/Cache
parentAdded some needed comments to SceneSetupHelper (actually just retriggering pa... (diff)
downloadopensim-SC_OLD-226c082ed417f4a5f2295595e45eca2fcb1e42c9.zip
opensim-SC_OLD-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.gz
opensim-SC_OLD-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.bz2
opensim-SC_OLD-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.xz
Establish CachedUserInfo.OnInventoryReceived event so that region/test inventory code can be written with the async inventory fetch
Diffstat (limited to 'OpenSim/Framework/Communications/Tests/Cache')
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs96
1 files changed, 52 insertions, 44 deletions
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
index 0402883..fe88cf5 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
@@ -43,6 +43,18 @@ namespace OpenSim.Framework.Communications.Tests
43 [TestFixture] 43 [TestFixture]
44 public class UserProfileCacheServiceTests 44 public class UserProfileCacheServiceTests
45 { 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
46 [Test] 58 [Test]
47 public void TestGetUserDetails() 59 public void TestGetUserDetails()
48 { 60 {
@@ -118,14 +130,15 @@ namespace OpenSim.Framework.Communications.Tests
118 TestHelper.InMethod(); 130 TestHelper.InMethod();
119 131
120 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 132 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
121 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 133
122 for (int i = 0 ; i < 50 ; i++) 134 timedOut = true;
123 { 135 lock (this)
124 if (userInfo.HasReceivedInventory == true) 136 {
125 break; 137 UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
126 Thread.Sleep(200); 138 Monitor.Wait(this, 60000);
127 } 139 }
128 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); 140
141 Assert.That(timedOut, Is.False, "Timed out");
129 } 142 }
130 143
131 [Test] 144 [Test]
@@ -134,14 +147,13 @@ namespace OpenSim.Framework.Communications.Tests
134 TestHelper.InMethod(); 147 TestHelper.InMethod();
135 148
136 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 149 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
137 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 150 CachedUserInfo userInfo;
138 for (int i = 0 ; i < 50 ; i++) 151
139 { 152 lock (this)
140 if (userInfo.HasReceivedInventory == true) 153 {
141 break; 154 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
142 Thread.Sleep(200); 155 Monitor.Wait(this, 60000);
143 } 156 }
144 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
145 157
146 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); 158 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
147 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); 159 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
@@ -156,14 +168,13 @@ namespace OpenSim.Framework.Communications.Tests
156 TestHelper.InMethod(); 168 TestHelper.InMethod();
157 169
158 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 170 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
159 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 171 CachedUserInfo userInfo;
160 for (int i = 0 ; i < 50 ; i++) 172
161 { 173 lock (this)
162 if (userInfo.HasReceivedInventory == true) 174 {
163 break; 175 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
164 Thread.Sleep(200); 176 Monitor.Wait(this, 60000);
165 } 177 }
166 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
167 178
168 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); 179 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
169 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); 180 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
@@ -192,14 +203,13 @@ namespace OpenSim.Framework.Communications.Tests
192 TestHelper.InMethod(); 203 TestHelper.InMethod();
193 204
194 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 205 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
195 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 206 CachedUserInfo userInfo;
196 for (int i = 0 ; i < 50 ; i++) 207
197 { 208 lock (this)
198 if (userInfo.HasReceivedInventory == true) 209 {
199 break; 210 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
200 Thread.Sleep(200); 211 Monitor.Wait(this, 60000);
201 } 212 }
202 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
203 213
204 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 214 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
205 InventoryFolderImpl rootFolder = userInfo.RootFolder; 215 InventoryFolderImpl rootFolder = userInfo.RootFolder;
@@ -258,14 +268,13 @@ namespace OpenSim.Framework.Communications.Tests
258 TestHelper.InMethod(); 268 TestHelper.InMethod();
259 269
260 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 270 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
261 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 271 CachedUserInfo userInfo;
262 for (int i = 0 ; i < 50 ; i++) 272
263 { 273 lock (this)
264 if (userInfo.HasReceivedInventory == true) 274 {
265 break; 275 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
266 Thread.Sleep(200); 276 Monitor.Wait(this, 60000);
267 } 277 }
268 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
269 278
270 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); 279 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
271 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); 280 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
@@ -299,14 +308,13 @@ namespace OpenSim.Framework.Communications.Tests
299 //log4net.Config.XmlConfigurator.Configure(); 308 //log4net.Config.XmlConfigurator.Configure();
300 309
301 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 310 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
302 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 311 CachedUserInfo userInfo;
303 for (int i = 0 ; i < 50 ; i++) 312
304 { 313 lock (this)
305 if (userInfo.HasReceivedInventory == true) 314 {
306 break; 315 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
307 Thread.Sleep(200); 316 Monitor.Wait(this, 60000);
308 } 317 }
309 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
310 318
311 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); 319 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
312 InventoryFolderImpl rootFolder = userInfo.RootFolder; 320 InventoryFolderImpl rootFolder = userInfo.RootFolder;
@@ -323,4 +331,4 @@ namespace OpenSim.Framework.Communications.Tests
323 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); 331 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
324 } 332 }
325 } 333 }
326} 334} \ No newline at end of file