* Reinstating UserProfileCacheServiceTests. One test still fails (TestUpdateFolder)

0.6.6-post-fixes
Arthur Valadares 2009-06-11 18:27:12 +00:00
parent 57c4b69916
commit c13f3649d2
3 changed files with 100 additions and 55 deletions

View File

@ -27,10 +27,12 @@
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using System.Threading;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Communications.Local;
using OpenSim.Tests.Common.Mock;
using OpenSim.Tests.Common.Setup;
@ -109,59 +111,77 @@ namespace OpenSim.Framework.Communications.Tests
}
*/
//[Test]
[Test]
public void TestFetchInventory()
{
TestHelper.InMethod();
TestCommunicationsManager commsManager = new TestCommunicationsManager();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
Assert.That(userInfo.HasReceivedInventory, Is.True);
Scene myScene = SceneSetupHelpers.SetupScene();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
}
//[Test]
[Test]
public void TestGetChildFolder()
{
TestHelper.InMethod();
TestCommunicationsManager commsManager = new TestCommunicationsManager();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
Scene myScene = SceneSetupHelpers.SetupScene();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID);
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null);
}
//[Test]
[Test]
public void TestCreateFolder()
{
TestHelper.InMethod();
TestCommunicationsManager commsManager = new TestCommunicationsManager();
IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin;
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
Scene myScene = SceneSetupHelpers.SetupScene();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
// 1: Try a folder create that should fail because the parent id given does not exist
UUID missingFolderId = UUID.Random();
InventoryFolderBase myFolder = new InventoryFolderBase();
myFolder.ID = folderId;
Assert.That(
userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False);
Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Null);
Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False);
Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null);
// 2: Try a folder create that should work
Assert.That(
userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True);
Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null);
Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Not.Null);
Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True);
}
@ -170,13 +190,20 @@ namespace OpenSim.Framework.Communications.Tests
{
TestHelper.InMethod();
TestCommunicationsManager commsManager = new TestCommunicationsManager();
IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin;
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
Scene myScene = SceneSetupHelpers.SetupScene();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
InventoryFolderImpl rootFolder = userInfo.RootFolder;
InventoryFolderBase myFolder = new InventoryFolderBase();
myFolder.ID = folder1Id;
userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
@ -190,7 +217,7 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(newFolderName1, Is.EqualTo(folder1.Name));
Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type));
InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id);
InventoryFolderBase dataFolder1 = myScene.InventoryService.QueryFolder(myFolder);
Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name));
Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type));
}
@ -201,6 +228,9 @@ namespace OpenSim.Framework.Communications.Tests
userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID);
InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id);
InventoryFolderBase myFolder2 = new InventoryFolderBase();
myFolder2.ID = folder2Id;
string newFolderName2 = "newFolderName2";
ushort folderType2 = (ushort)AssetType.Bodypart;
userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id);
@ -213,7 +243,7 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True);
Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False);
InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id);
InventoryFolderBase dataFolder1 = myScene.InventoryService.QueryFolder(myFolder2);
Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name));
Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type));
Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID));
@ -221,15 +251,20 @@ namespace OpenSim.Framework.Communications.Tests
}
//[Test]
[Test]
public void TestMoveFolder()
{
TestHelper.InMethod();
TestCommunicationsManager commsManager = new TestCommunicationsManager();
IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin;
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
Scene myScene = SceneSetupHelpers.SetupScene();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
@ -248,34 +283,43 @@ namespace OpenSim.Framework.Communications.Tests
userInfo.MoveFolder(folderToMoveId, folder2Id);
// Check folder is now in folder2 and no trace remains in folder1
InventoryFolderBase myFolder = new InventoryFolderBase();
myFolder.ID = folderToMoveId;
Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True);
Assert.That(inventoryDataPlugin.getInventoryFolder(folderToMoveId).ParentID, Is.EqualTo(folder2Id));
Assert.That(myScene.InventoryService.QueryFolder(myFolder).ParentID, Is.EqualTo(folder2Id));
Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False);
}
//[Test]
[Test]
public void TestPurgeFolder()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
TestCommunicationsManager commsManager = new TestCommunicationsManager();
IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin;
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
Scene myScene = SceneSetupHelpers.SetupScene();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
InventoryFolderImpl rootFolder = userInfo.RootFolder;
InventoryFolderBase myFolder = new InventoryFolderBase();
myFolder.ID = folder1Id;
userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Not.Null);
Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Not.Null);
// Test purge
userInfo.PurgeFolder(rootFolder.ID);
Assert.That(rootFolder.RequestListOfFolders(), Is.Empty);
Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Null);
Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
}
}
}

View File

@ -122,7 +122,7 @@ namespace OpenSim.Tests.Common.Mock
public InventoryFolderBase queryInventoryFolder(UUID folderID)
{
return null;
return getInventoryFolder(folderID);
}
public void addInventoryFolder(InventoryFolderBase folder)

View File

@ -3556,6 +3556,7 @@
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.Communications.Local"/>
<Reference name="OpenSim.Tests.Common"/>