mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 18:55:58 +08:00
Merged with origin, and resolved one conflict in LoginServiceTests.cs
This commit is contained in:
@@ -49,16 +49,24 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems);
|
||||
|
||||
public delegate void OnItemReceivedDelegate(UUID itemID);
|
||||
public delegate void OnInventoryReceivedDelegate(UUID userID);
|
||||
|
||||
/// <summary>
|
||||
/// Stores user profile and inventory data received from backend services for a particular user.
|
||||
/// </summary>
|
||||
public class CachedUserInfo
|
||||
{
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
//// <value>
|
||||
/// Fired when a particular item has been received from the inventory service
|
||||
/// </value>
|
||||
public event OnItemReceivedDelegate OnItemReceived;
|
||||
|
||||
private static readonly ILog m_log
|
||||
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
/// <value>
|
||||
/// Fired once the entire inventory has been received for the user
|
||||
/// </value>
|
||||
public event OnInventoryReceivedDelegate OnInventoryReceived;
|
||||
|
||||
/// <summary>
|
||||
/// The comms manager holds references to services (user, grid, inventory, etc.)
|
||||
@@ -133,7 +141,9 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
UUID parentFolderId = folder.ParentID;
|
||||
|
||||
if (dictionary.ContainsKey(parentFolderId))
|
||||
{
|
||||
dictionary[parentFolderId].Add(folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
|
||||
@@ -299,6 +309,9 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
request.Execute();
|
||||
}
|
||||
}
|
||||
|
||||
if (OnInventoryReceived != null)
|
||||
OnInventoryReceived(UserProfile.ID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -43,6 +43,18 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
[TestFixture]
|
||||
public class UserProfileCacheServiceTests
|
||||
{
|
||||
/// <value>Used by tests to indicate whether an async operation timed out</value>
|
||||
private bool timedOut;
|
||||
|
||||
private void InventoryReceived(UUID userId)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
timedOut = false;
|
||||
Monitor.PulseAll(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetUserDetails()
|
||||
{
|
||||
@@ -54,6 +66,7 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
CachedUserInfo nonExistingUserInfo;
|
||||
|
||||
TestCommunicationsManager commsManager = new TestCommunicationsManager();
|
||||
Scene myScene = SceneSetupHelpers.SetupScene(commsManager, "");
|
||||
|
||||
// Check we can't retrieve info before it exists by uuid
|
||||
nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
|
||||
@@ -116,15 +129,16 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
|
||||
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)");
|
||||
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
|
||||
|
||||
timedOut = true;
|
||||
lock (this)
|
||||
{
|
||||
UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
|
||||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
|
||||
Assert.That(timedOut, Is.False, "Timed out");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -132,15 +146,14 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
|
||||
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);
|
||||
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
|
||||
CachedUserInfo userInfo;
|
||||
|
||||
lock (this)
|
||||
{
|
||||
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
|
||||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
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);
|
||||
@@ -154,15 +167,14 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
|
||||
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);
|
||||
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
|
||||
CachedUserInfo userInfo;
|
||||
|
||||
lock (this)
|
||||
{
|
||||
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
|
||||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
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);
|
||||
@@ -190,15 +202,14 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
|
||||
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);
|
||||
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
|
||||
CachedUserInfo userInfo;
|
||||
|
||||
lock (this)
|
||||
{
|
||||
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
|
||||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
|
||||
|
||||
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
|
||||
InventoryFolderImpl rootFolder = userInfo.RootFolder;
|
||||
@@ -256,15 +267,14 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
|
||||
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);
|
||||
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
|
||||
CachedUserInfo userInfo;
|
||||
|
||||
lock (this)
|
||||
{
|
||||
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
|
||||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
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");
|
||||
@@ -297,15 +307,14 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
TestHelper.InMethod();
|
||||
//log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
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);
|
||||
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
|
||||
CachedUserInfo userInfo;
|
||||
|
||||
lock (this)
|
||||
{
|
||||
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
|
||||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
|
||||
|
||||
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
|
||||
InventoryFolderImpl rootFolder = userInfo.RootFolder;
|
||||
@@ -322,4 +331,4 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ using Nwc.XmlRpc;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Communications.Services;
|
||||
using OpenSim.Region.Communications.Local;
|
||||
using OpenSim.Tests.Common.Setup;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
using OpenSim.Client.Linden;
|
||||
using OpenSim.Tests.Common;
|
||||
@@ -57,11 +58,12 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
private string m_regionExternalName = "localhost";
|
||||
|
||||
private IPEndPoint m_capsEndPoint;
|
||||
private CommunicationsManager m_commsManager;
|
||||
private TestCommunicationsManager m_commsManager;
|
||||
private TestLoginToRegionConnector m_regionConnector;
|
||||
private LocalUserServices m_localUserServices;
|
||||
private LoginService m_loginService;
|
||||
private UserProfileData m_userProfileData;
|
||||
private TestScene m_testScene;
|
||||
|
||||
[SetUp]
|
||||
public void SetUpLoginEnviroment()
|
||||
@@ -69,13 +71,16 @@ namespace OpenSim.Framework.Communications.Tests
|
||||
m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123);
|
||||
m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43));
|
||||
m_regionConnector = new TestLoginToRegionConnector();
|
||||
m_testScene = SceneSetupHelpers.SetupScene(m_commsManager, "");
|
||||
|
||||
m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName));
|
||||
|
||||
//IInventoryService m_inventoryService = new TestInventoryService();
|
||||
|
||||
m_localUserServices = (LocalUserServices) m_commsManager.UserService;
|
||||
m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43);
|
||||
|
||||
m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", new TestInventoryService(),
|
||||
m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", m_testScene.InventoryService,
|
||||
m_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector);
|
||||
|
||||
m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName);
|
||||
|
||||
@@ -698,7 +698,7 @@ namespace OpenSim.Framework.Communications
|
||||
if (rootfolder != null)
|
||||
userProf.RootInventoryFolderID = rootfolder.ID;
|
||||
}
|
||||
else if (m_commsManager.InterServiceInventoryService != null)
|
||||
else
|
||||
{
|
||||
// used by the user server
|
||||
m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory");
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace OpenSim.Framework.Servers
|
||||
protected string m_startupDirectory = Environment.CurrentDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// Server version information. Usually VersionInfo + information about svn revision, operating system, etc.
|
||||
/// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
|
||||
/// </summary>
|
||||
protected string m_version;
|
||||
|
||||
@@ -422,6 +422,16 @@ namespace OpenSim.Framework.Servers
|
||||
{
|
||||
string buildVersion = string.Empty;
|
||||
|
||||
// Add commit hash and date information if available
|
||||
// The commit hash and date are stored in a file bin/.version
|
||||
// This file can automatically created by a post
|
||||
// commit script in the opensim git master repository or
|
||||
// by issuing the follwoing command from the top level
|
||||
// directory of the opensim repository
|
||||
// git log -n 1 --pretty="format:%h: %ci" >bin/.version
|
||||
// For the full git commit hash use %H instead of %h
|
||||
//
|
||||
// The subversion information is deprecated and will be removed at a later date
|
||||
// Add subversion revision information if available
|
||||
// Try file "svn_revision" in the current directory first, then the .svn info.
|
||||
// This allows to make the revision available in simulators not running from the source tree.
|
||||
@@ -429,39 +439,53 @@ namespace OpenSim.Framework.Servers
|
||||
// elsewhere as well
|
||||
string svnRevisionFileName = "svn_revision";
|
||||
string svnFileName = ".svn/entries";
|
||||
string gitCommitFileName = ".version";
|
||||
string inputLine;
|
||||
int strcmp;
|
||||
|
||||
if (File.Exists(svnRevisionFileName))
|
||||
if (File.Exists( gitCommitFileName))
|
||||
{
|
||||
StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
|
||||
buildVersion = RevisionFile.ReadLine();
|
||||
buildVersion.Trim();
|
||||
RevisionFile.Close();
|
||||
StreamReader CommitFile = File.OpenText(gitCommitFileName);
|
||||
buildVersion = Environment.NewLine + "git# " + CommitFile.ReadLine();
|
||||
CommitFile.Close();
|
||||
m_version += buildVersion ?? "";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
|
||||
// Remove the else logic when subversion mirror is no longer used
|
||||
else
|
||||
{
|
||||
StreamReader EntriesFile = File.OpenText(svnFileName);
|
||||
inputLine = EntriesFile.ReadLine();
|
||||
while (inputLine != null)
|
||||
if (File.Exists(svnRevisionFileName))
|
||||
{
|
||||
// using the dir svn revision at the top of entries file
|
||||
strcmp = String.Compare(inputLine, "dir");
|
||||
if (strcmp == 0)
|
||||
{
|
||||
buildVersion = EntriesFile.ReadLine();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputLine = EntriesFile.ReadLine();
|
||||
}
|
||||
}
|
||||
EntriesFile.Close();
|
||||
}
|
||||
StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
|
||||
buildVersion = RevisionFile.ReadLine();
|
||||
buildVersion.Trim();
|
||||
RevisionFile.Close();
|
||||
|
||||
m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
|
||||
{
|
||||
StreamReader EntriesFile = File.OpenText(svnFileName);
|
||||
inputLine = EntriesFile.ReadLine();
|
||||
while (inputLine != null)
|
||||
{
|
||||
// using the dir svn revision at the top of entries file
|
||||
strcmp = String.Compare(inputLine, "dir");
|
||||
if (strcmp == 0)
|
||||
{
|
||||
buildVersion = EntriesFile.ReadLine();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputLine = EntriesFile.ReadLine();
|
||||
}
|
||||
}
|
||||
EntriesFile.Close();
|
||||
}
|
||||
|
||||
m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CreatePIDFile(string path)
|
||||
|
||||
@@ -114,6 +114,11 @@ namespace OpenSim.Framework
|
||||
/// </summary>
|
||||
private uint m_profileWantDoMask; // Profile window "I want to" mask
|
||||
|
||||
/// <summary>
|
||||
/// The profile url for an avatar
|
||||
/// </summary>
|
||||
private string m_profileUrl;
|
||||
|
||||
private UUID m_rootInventoryFolderId;
|
||||
|
||||
/// <summary>
|
||||
@@ -349,6 +354,12 @@ namespace OpenSim.Framework
|
||||
set { m_profileFirstText = value; }
|
||||
}
|
||||
|
||||
public string ProfileUrl
|
||||
{
|
||||
get { return m_profileUrl; }
|
||||
set { m_profileUrl = value; }
|
||||
}
|
||||
|
||||
public UUID Image
|
||||
{
|
||||
get { return m_profileImage; }
|
||||
|
||||
Reference in New Issue
Block a user