* Add the ability to update profiles via the cache, so that cached profiles don't become stale
* Add corresponding unit test0.6.5-rc1
parent
f31a60bad7
commit
d2d0b9877f
|
@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
private readonly CommunicationsManager m_commsManager;
|
private readonly CommunicationsManager m_commsManager;
|
||||||
|
|
||||||
public UserProfileData UserProfile { get { return m_userProfile; } }
|
public UserProfileData UserProfile { get { return m_userProfile; } }
|
||||||
private readonly UserProfileData m_userProfile;
|
protected internal UserProfileData m_userProfile;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Have we received the user's inventory from the inventory service?
|
/// Have we received the user's inventory from the inventory service?
|
||||||
|
|
|
@ -168,6 +168,29 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update an existing profile
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userProfile"></param>
|
||||||
|
/// <returns>true if a user profile was found to update, false otherwise</returns>
|
||||||
|
public bool UpdateProfile(UserProfileData userProfile)
|
||||||
|
{
|
||||||
|
lock (m_userProfilesById)
|
||||||
|
{
|
||||||
|
CachedUserInfo userInfo = GetUserDetails(userProfile.ID);
|
||||||
|
|
||||||
|
if (userInfo != null)
|
||||||
|
{
|
||||||
|
userInfo.m_userProfile = userProfile;
|
||||||
|
m_commsManager.UserService.UpdateUserProfile(userProfile);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Populate caches with the given user profile
|
/// Populate caches with the given user profile
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -29,6 +29,7 @@ using NUnit.Framework;
|
||||||
using NUnit.Framework.SyntaxHelpers;
|
using NUnit.Framework.SyntaxHelpers;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
using OpenSim.Region.Communications.Local;
|
using OpenSim.Region.Communications.Local;
|
||||||
using OpenSim.Tests.Common.Mock;
|
using OpenSim.Tests.Common.Mock;
|
||||||
|
@ -69,6 +70,34 @@ namespace OpenSim.Framework.Communications.Tests
|
||||||
existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
|
existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
|
||||||
Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name");
|
Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestUpdateProfile()
|
||||||
|
{
|
||||||
|
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292");
|
||||||
|
string firstName = "Inspector";
|
||||||
|
string originalLastName = "Morse";
|
||||||
|
string newLastName = "Gadget";
|
||||||
|
|
||||||
|
UserProfileData newProfile = new UserProfileData();
|
||||||
|
newProfile.ID = userId;
|
||||||
|
newProfile.FirstName = firstName;
|
||||||
|
newProfile.SurName = newLastName;
|
||||||
|
|
||||||
|
TestCommunicationsManager commsManager = new TestCommunicationsManager();
|
||||||
|
UserProfileCacheService userCacheService = commsManager.UserProfileCacheService;
|
||||||
|
|
||||||
|
// Check that we can't update info before it exists
|
||||||
|
Assert.That(userCacheService.UpdateProfile(newProfile), Is.False);
|
||||||
|
|
||||||
|
// Check that we can update a profile once it exists
|
||||||
|
LocalUserServices lus = (LocalUserServices)commsManager.UserService;
|
||||||
|
lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId);
|
||||||
|
|
||||||
|
Assert.That(userCacheService.UpdateProfile(newProfile), Is.True);
|
||||||
|
UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile;
|
||||||
|
Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestFetchInventory()
|
public void TestFetchInventory()
|
||||||
|
|
Loading…
Reference in New Issue