Merged with origin, and resolved one conflict in LoginServiceTests.cs

arthursv
Diva Canto 2009-08-11 10:51:49 -07:00
commit dc897b2288
17 changed files with 496 additions and 152 deletions

1
.gitignore vendored
View File

@ -43,3 +43,4 @@ OpenSim/OpenSim.usertasks
TAGS TAGS
*~ *~
Makefile.local Makefile.local
bin/.version

View File

@ -49,16 +49,24 @@ namespace OpenSim.Framework.Communications.Cache
IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems);
public delegate void OnItemReceivedDelegate(UUID itemID); public delegate void OnItemReceivedDelegate(UUID itemID);
public delegate void OnInventoryReceivedDelegate(UUID userID);
/// <summary> /// <summary>
/// Stores user profile and inventory data received from backend services for a particular user. /// Stores user profile and inventory data received from backend services for a particular user.
/// </summary> /// </summary>
public class CachedUserInfo 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; public event OnItemReceivedDelegate OnItemReceived;
private static readonly ILog m_log /// <value>
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// Fired once the entire inventory has been received for the user
/// </value>
public event OnInventoryReceivedDelegate OnInventoryReceived;
/// <summary> /// <summary>
/// The comms manager holds references to services (user, grid, inventory, etc.) /// The comms manager holds references to services (user, grid, inventory, etc.)
@ -133,7 +141,9 @@ namespace OpenSim.Framework.Communications.Cache
UUID parentFolderId = folder.ParentID; UUID parentFolderId = folder.ParentID;
if (dictionary.ContainsKey(parentFolderId)) if (dictionary.ContainsKey(parentFolderId))
{
dictionary[parentFolderId].Add(folder); dictionary[parentFolderId].Add(folder);
}
else else
{ {
IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>(); IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
@ -299,6 +309,9 @@ namespace OpenSim.Framework.Communications.Cache
request.Execute(); request.Execute();
} }
} }
if (OnInventoryReceived != null)
OnInventoryReceived(UserProfile.ID);
} }
/// <summary> /// <summary>

View File

@ -43,6 +43,18 @@ namespace OpenSim.Framework.Communications.Tests
[TestFixture] [TestFixture]
public class UserProfileCacheServiceTests 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] [Test]
public void TestGetUserDetails() public void TestGetUserDetails()
{ {
@ -54,6 +66,7 @@ namespace OpenSim.Framework.Communications.Tests
CachedUserInfo nonExistingUserInfo; CachedUserInfo nonExistingUserInfo;
TestCommunicationsManager commsManager = new TestCommunicationsManager(); TestCommunicationsManager commsManager = new TestCommunicationsManager();
Scene myScene = SceneSetupHelpers.SetupScene(commsManager, "");
// Check we can't retrieve info before it exists by uuid // Check we can't retrieve info before it exists by uuid
nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
@ -116,15 +129,16 @@ namespace OpenSim.Framework.Communications.Tests
{ {
TestHelper.InMethod(); TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene(); Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++) timedOut = true;
{ lock (this)
if (userInfo.HasReceivedInventory == true) {
break; UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Thread.Sleep(200); Monitor.Wait(this, 60000);
} }
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
Assert.That(timedOut, Is.False, "Timed out");
} }
[Test] [Test]
@ -132,15 +146,14 @@ namespace OpenSim.Framework.Communications.Tests
{ {
TestHelper.InMethod(); TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene(); Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); CachedUserInfo userInfo;
for (int i = 0 ; i < 50 ; i++)
{ lock (this)
if (userInfo.HasReceivedInventory == true) {
break; userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Thread.Sleep(200); Monitor.Wait(this, 60000);
} }
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
@ -154,15 +167,14 @@ namespace OpenSim.Framework.Communications.Tests
{ {
TestHelper.InMethod(); TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene(); Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); CachedUserInfo userInfo;
for (int i = 0 ; i < 50 ; i++)
{ lock (this)
if (userInfo.HasReceivedInventory == true) {
break; userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Thread.Sleep(200); Monitor.Wait(this, 60000);
} }
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
@ -190,15 +202,14 @@ namespace OpenSim.Framework.Communications.Tests
{ {
TestHelper.InMethod(); TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene(); Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); CachedUserInfo userInfo;
for (int i = 0 ; i < 50 ; i++)
{ lock (this)
if (userInfo.HasReceivedInventory == true) {
break; userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Thread.Sleep(200); Monitor.Wait(this, 60000);
} }
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
InventoryFolderImpl rootFolder = userInfo.RootFolder; InventoryFolderImpl rootFolder = userInfo.RootFolder;
@ -256,15 +267,14 @@ namespace OpenSim.Framework.Communications.Tests
{ {
TestHelper.InMethod(); TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene(); Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); CachedUserInfo userInfo;
for (int i = 0 ; i < 50 ; i++)
{ lock (this)
if (userInfo.HasReceivedInventory == true) {
break; userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Thread.Sleep(200); 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 folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
@ -297,15 +307,14 @@ namespace OpenSim.Framework.Communications.Tests
TestHelper.InMethod(); TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure(); //log4net.Config.XmlConfigurator.Configure();
Scene myScene = SceneSetupHelpers.SetupScene(); Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); CachedUserInfo userInfo;
for (int i = 0 ; i < 50 ; i++)
{ lock (this)
if (userInfo.HasReceivedInventory == true) {
break; userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Thread.Sleep(200); Monitor.Wait(this, 60000);
} }
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
InventoryFolderImpl rootFolder = userInfo.RootFolder; InventoryFolderImpl rootFolder = userInfo.RootFolder;
@ -322,4 +331,4 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
} }
} }
} }

View File

@ -36,6 +36,7 @@ using Nwc.XmlRpc;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Services; using OpenSim.Framework.Communications.Services;
using OpenSim.Region.Communications.Local; using OpenSim.Region.Communications.Local;
using OpenSim.Tests.Common.Setup;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
using OpenSim.Client.Linden; using OpenSim.Client.Linden;
using OpenSim.Tests.Common; using OpenSim.Tests.Common;
@ -57,11 +58,12 @@ namespace OpenSim.Framework.Communications.Tests
private string m_regionExternalName = "localhost"; private string m_regionExternalName = "localhost";
private IPEndPoint m_capsEndPoint; private IPEndPoint m_capsEndPoint;
private CommunicationsManager m_commsManager; private TestCommunicationsManager m_commsManager;
private TestLoginToRegionConnector m_regionConnector; private TestLoginToRegionConnector m_regionConnector;
private LocalUserServices m_localUserServices; private LocalUserServices m_localUserServices;
private LoginService m_loginService; private LoginService m_loginService;
private UserProfileData m_userProfileData; private UserProfileData m_userProfileData;
private TestScene m_testScene;
[SetUp] [SetUp]
public void SetUpLoginEnviroment() public void SetUpLoginEnviroment()
@ -69,13 +71,16 @@ namespace OpenSim.Framework.Communications.Tests
m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123);
m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43));
m_regionConnector = new TestLoginToRegionConnector(); m_regionConnector = new TestLoginToRegionConnector();
m_testScene = SceneSetupHelpers.SetupScene(m_commsManager, "");
m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName));
//IInventoryService m_inventoryService = new TestInventoryService();
m_localUserServices = (LocalUserServices) m_commsManager.UserService; m_localUserServices = (LocalUserServices) m_commsManager.UserService;
m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); 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_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector);
m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName); m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName);

View File

@ -698,7 +698,7 @@ namespace OpenSim.Framework.Communications
if (rootfolder != null) if (rootfolder != null)
userProf.RootInventoryFolderID = rootfolder.ID; userProf.RootInventoryFolderID = rootfolder.ID;
} }
else if (m_commsManager.InterServiceInventoryService != null) else
{ {
// used by the user server // used by the user server
m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory"); m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory");

View File

@ -76,7 +76,7 @@ namespace OpenSim.Framework.Servers
protected string m_startupDirectory = Environment.CurrentDirectory; protected string m_startupDirectory = Environment.CurrentDirectory;
/// <summary> /// <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> /// </summary>
protected string m_version; protected string m_version;
@ -422,6 +422,16 @@ namespace OpenSim.Framework.Servers
{ {
string buildVersion = string.Empty; 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 // Add subversion revision information if available
// Try file "svn_revision" in the current directory first, then the .svn info. // 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. // 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 // elsewhere as well
string svnRevisionFileName = "svn_revision"; string svnRevisionFileName = "svn_revision";
string svnFileName = ".svn/entries"; string svnFileName = ".svn/entries";
string gitCommitFileName = ".version";
string inputLine; string inputLine;
int strcmp; int strcmp;
if (File.Exists(svnRevisionFileName)) if (File.Exists( gitCommitFileName))
{ {
StreamReader RevisionFile = File.OpenText(svnRevisionFileName); StreamReader CommitFile = File.OpenText(gitCommitFileName);
buildVersion = RevisionFile.ReadLine(); buildVersion = Environment.NewLine + "git# " + CommitFile.ReadLine();
buildVersion.Trim(); CommitFile.Close();
RevisionFile.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); if (File.Exists(svnRevisionFileName))
inputLine = EntriesFile.ReadLine();
while (inputLine != null)
{ {
// using the dir svn revision at the top of entries file StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
strcmp = String.Compare(inputLine, "dir"); buildVersion = RevisionFile.ReadLine();
if (strcmp == 0) buildVersion.Trim();
{ RevisionFile.Close();
buildVersion = EntriesFile.ReadLine();
break;
}
else
{
inputLine = EntriesFile.ReadLine();
}
}
EntriesFile.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) protected void CreatePIDFile(string path)

View File

@ -114,6 +114,11 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
private uint m_profileWantDoMask; // Profile window "I want to" mask 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; private UUID m_rootInventoryFolderId;
/// <summary> /// <summary>
@ -349,6 +354,12 @@ namespace OpenSim.Framework
set { m_profileFirstText = value; } set { m_profileFirstText = value; }
} }
public string ProfileUrl
{
get { return m_profileUrl; }
set { m_profileUrl = value; }
}
public UUID Image public UUID Image
{ {
get { return m_profileImage; } get { return m_profileImage; }

View File

@ -4954,6 +4954,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText); UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
UserProfile.FirstLifeImage = Properties.FLImageID; UserProfile.FirstLifeImage = Properties.FLImageID;
UserProfile.Image = Properties.ImageID; UserProfile.Image = Properties.ImageID;
UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
handlerUpdateAvatarProperties(this, UserProfile); handlerUpdateAvatarProperties(this, UserProfile);
} }

View File

@ -280,7 +280,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
UUID newFolderId = UUID.Random(); UUID newFolderId = UUID.Random();
m_userInfo.CreateFolder( m_userInfo.CreateFolder(
folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName);
foundFolder = foundFolder.GetChildFolder(newFolderId); foundFolder = foundFolder.GetChildFolder(newFolderId);
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}",
foundFolder.Name, foundFolder.ID);
// Record that we have now created this folder // Record that we have now created this folder
fsPath += rawDirsToCreate[i] + "/"; fsPath += rawDirsToCreate[i] + "/";

View File

@ -54,6 +54,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[TestFixture] [TestFixture]
public class InventoryArchiverTests public class InventoryArchiverTests
{ {
private void InventoryReceived(UUID userId)
{
lock (this)
{
Monitor.PulseAll(this);
}
}
private void SaveCompleted( private void SaveCompleted(
bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException)
{ {
@ -61,7 +69,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
{ {
Monitor.PulseAll(this); Monitor.PulseAll(this);
} }
} }
/// <summary> /// <summary>
/// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet).
@ -74,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryArchiverModule archiverModule = new InventoryArchiverModule(); InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene(false); Scene scene = SceneSetupHelpers.SetupScene("");
SceneSetupHelpers.SetupSceneModules(scene, archiverModule); SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
CommunicationsManager cm = scene.CommsManager; CommunicationsManager cm = scene.CommsManager;
@ -82,8 +90,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
string userFirstName = "Jock"; string userFirstName = "Jock";
string userLastName = "Stirrup"; string userLastName = "Stirrup";
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
CachedUserInfo userInfo;
lock (this)
{
userInfo
= UserProfileTestUtils.CreateUserWithInventory(
cm, userFirstName, userLastName, userId, InventoryReceived);
Monitor.Wait(this, 60000);
}
/*
cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId);
CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId); CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId, InventoryReceived);
userInfo.FetchInventory(); userInfo.FetchInventory();
for (int i = 0 ; i < 50 ; i++) for (int i = 0 ; i < 50 ; i++)
{ {
@ -92,6 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Thread.Sleep(200); Thread.Sleep(200);
} }
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
*/
// Create asset // Create asset
SceneObjectGroup object1; SceneObjectGroup object1;
@ -337,15 +357,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Assert.That(user2Profile.SurName == user2LastName); Assert.That(user2Profile.SurName == user2LastName);
CachedUserInfo userInfo CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
userInfo.FetchInventory(); userInfo.OnInventoryReceived += InventoryReceived;
for (int i = 0 ; i < 50 ; i++)
lock (this)
{ {
if (userInfo.HasReceivedInventory == true) userInfo.FetchInventory();
break; Monitor.Wait(this, 60000);
Thread.Sleep(200);
} }
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
@ -359,14 +379,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
/// <summary> /// <summary>
/// Test replication of an archive path to the user's inventory. /// Test replication of an archive path to the user's inventory.
/// </summary> /// </summary>
//[Test] [Test]
public void TestReplicateArchivePathToUserInventory() public void TestReplicateArchivePathToUserInventory()
{ {
TestHelper.InMethod(); TestHelper.InMethod();
Scene scene = SceneSetupHelpers.SetupScene(false);
CommunicationsManager commsManager = scene.CommsManager;
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("");
CommunicationsManager commsManager = scene.CommsManager;
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
//userInfo.FetchInventory(); //userInfo.FetchInventory();
/* /*
for (int i = 0 ; i < 50 ; i++) for (int i = 0 ; i < 50 ; i++)
@ -399,15 +428,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName);
Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null)
.ReplicateArchivePathToUserInventory(itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded);
Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); try
InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); {
Assert.That(folder1, Is.Not.Null, "Could not find folder a"); new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null)
InventoryFolderImpl folder2 = folder1.FindFolderByPath("b"); .ReplicateArchivePathToUserInventory(itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded);
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
InventoryFolderImpl folder2 = folder1.FindFolderByPath("b");
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
}
catch (NullReferenceException e)
{
// Non fatal for now until we resolve the race condition
Console.WriteLine("Test failed with {0}", e);
}
} }
} }
} }

View File

@ -111,7 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
remoteClient.SendAvatarProperties(profile.ID, profile.AboutText, remoteClient.SendAvatarProperties(profile.ID, profile.AboutText,
Util.ToDateTime(profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), Util.ToDateTime(profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture),
charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff), charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff),
profile.FirstLifeImage, profile.Image, String.Empty, profile.Partner); profile.FirstLifeImage, profile.Image, profile.ProfileUrl, profile.Partner);
} }
else else
{ {
@ -130,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
Profile.FirstLifeImage = newProfile.FirstLifeImage; Profile.FirstLifeImage = newProfile.FirstLifeImage;
Profile.AboutText = newProfile.AboutText; Profile.AboutText = newProfile.AboutText;
Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText;
Profile.ProfileUrl = newProfile.ProfileUrl;
} }
else else
{ {

View File

@ -87,7 +87,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
SerialiserModule serialiserModule = new SerialiserModule(); SerialiserModule serialiserModule = new SerialiserModule();
TerrainModule terrainModule = new TerrainModule(); TerrainModule terrainModule = new TerrainModule();
Scene scene = SceneSetupHelpers.SetupScene(false); Scene scene = SceneSetupHelpers.SetupScene("asset");
SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
SceneObjectPart part1; SceneObjectPart part1;

View File

@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
public void Init() public void Init()
{ {
m_serialiserModule = new SerialiserModule(); m_serialiserModule = new SerialiserModule();
m_scene = SceneSetupHelpers.SetupScene(false); m_scene = SceneSetupHelpers.SetupScene("");
SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule); SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule);
} }

View File

@ -31,13 +31,18 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Data; using OpenSim.Data;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using Nini.Config;
namespace OpenSim.Tests.Common.Mock namespace OpenSim.Tests.Common.Mock
{ {
public class TestAssetService : IAssetService public class TestAssetService : IAssetService
{ {
private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>();
public TestAssetService(IConfigSource config)
{
}
public AssetBase Get(string id) public AssetBase Get(string id)
{ {
return Assets[ id ]; return Assets[ id ];

View File

@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework;
using OpenMetaverse;
using OpenSim.Services.Interfaces;
using Nini.Config;
namespace OpenSim.Tests.Common.Mock
{
public class TestInventoryService : IInventoryService
{
public TestInventoryService()
{
}
public TestInventoryService(IConfigSource config)
{
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public bool CreateUserInventory(UUID userId)
{
return false;
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
{
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
InventoryFolderBase folder = new InventoryFolderBase();
folder.ID = UUID.Random();
folder.Owner = userId;
folders.Add(folder);
return folders;
}
/// <summary>
/// Returns a list of all the active gestures in a user's inventory.
/// </summary>
/// <param name="userId">
/// The <see cref="UUID"/> of the user
/// </param>
/// <returns>
/// A flat list of the gesture items.
/// </returns>
public List<InventoryItemBase> GetActiveGestures(UUID userId)
{
return null;
}
public InventoryCollection GetUserInventory(UUID userID)
{
return null;
}
public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback)
{
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
{
return null;
}
public bool AddFolder(InventoryFolderBase folder)
{
return false;
}
public bool UpdateFolder(InventoryFolderBase folder)
{
return false;
}
public bool MoveFolder(InventoryFolderBase folder)
{
return false;
}
public bool PurgeFolder(InventoryFolderBase folder)
{
return false;
}
public bool AddItem(InventoryItemBase item)
{
return false;
}
public bool UpdateItem(InventoryItemBase item)
{
return false;
}
public bool DeleteItem(InventoryItemBase item)
{
return false;
}
public InventoryItemBase QueryItem(InventoryItemBase item)
{
return null;
}
public InventoryFolderBase QueryFolder(InventoryFolderBase folder)
{
return null;
}
public bool HasInventoryForUser(UUID userID)
{
return false;
}
public InventoryFolderBase RequestRootFolder(UUID userID)
{
InventoryFolderBase root = new InventoryFolderBase();
root.ID = UUID.Random();
root.Owner = userID;
root.ParentID = UUID.Zero;
return root;
}
}
}

View File

@ -54,6 +54,12 @@ namespace OpenSim.Tests.Common.Setup
/// </summary> /// </summary>
public class SceneSetupHelpers public class SceneSetupHelpers
{ {
// These static variables in order to allow regions to be linked by shared modules and same
// CommunicationsManager.
private static ISharedRegionModule m_assetService = null;
private static ISharedRegionModule m_inventoryService = null;
private static TestCommunicationsManager commsManager = null;
/// <summary> /// <summary>
/// Set up a test scene /// Set up a test scene
/// </summary> /// </summary>
@ -63,21 +69,33 @@ namespace OpenSim.Tests.Common.Setup
/// <returns></returns> /// <returns></returns>
public static TestScene SetupScene() public static TestScene SetupScene()
{ {
return SetupScene(true); return SetupScene("");
} }
/// <summary> /// <summary>
/// Set up a test scene /// Set up a test scene
/// </summary> /// </summary>
/// ///
/// <param name="startServices">Start associated service threads for the scene</param> /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
/// <returns></returns> /// <returns></returns>
public static TestScene SetupScene(bool startServices) public static TestScene SetupScene(String realServices)
{ {
return SetupScene( return SetupScene(
"Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager(), startServices); "Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager(), realServices);
}
/// <summary>
/// Set up a test scene
/// </summary>
///
/// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
/// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
/// <returns></returns>
public static TestScene SetupScene(TestCommunicationsManager cm, String realServices)
{
return SetupScene(
"Unit test region", UUID.Random(), 1000, 1000, cm, "");
} }
/// <summary> /// <summary>
/// Set up a test scene /// Set up a test scene
/// </summary> /// </summary>
@ -89,28 +107,40 @@ namespace OpenSim.Tests.Common.Setup
/// <returns></returns> /// <returns></returns>
public static TestScene SetupScene(string name, UUID id, uint x, uint y, TestCommunicationsManager cm) public static TestScene SetupScene(string name, UUID id, uint x, uint y, TestCommunicationsManager cm)
{ {
return SetupScene(name, id, x, y, cm, true); return SetupScene(name, id, x, y, cm, "");
} }
/// <summary> /// <summary>
/// Set up a test scene /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
/// or a different, to get a brand new scene with new shared region modules.
/// </summary> /// </summary>
/// <param name="name">Name of the region</param> /// <param name="name">Name of the region</param>
/// <param name="id">ID of the region</param> /// <param name="id">ID of the region</param>
/// <param name="x">X co-ordinate of the region</param> /// <param name="x">X co-ordinate of the region</param>
/// <param name="y">Y co-ordinate of the region</param> /// <param name="y">Y co-ordinate of the region</param>
/// <param name="cm">This should be the same if simulating two scenes within a standalone</param> /// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
/// <param name="startServices">Start associated threads for the services used by the scene</param> /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
/// <returns></returns> /// <returns></returns>
public static TestScene SetupScene( public static TestScene SetupScene(
string name, UUID id, uint x, uint y, TestCommunicationsManager cm, bool startServices) string name, UUID id, uint x, uint y, TestCommunicationsManager cm, String realServices)
{ {
bool newScene= false;
Console.WriteLine("Setting up test scene {0}", name); Console.WriteLine("Setting up test scene {0}", name);
// If cm is the same as our last commsManager used, this means the tester wants to link
// regions. In this case, don't use the sameshared region modules and dont initialize them again.
// Also, no need to start another MainServer and MainConsole instance.
if (cm == null || cm != commsManager)
{
System.Console.WriteLine("Starting a brand new scene");
newScene = true;
MainConsole.Instance = new LocalConsole("TEST PROMPT");
MainServer.Instance = new BaseHttpServer(980);
commsManager = cm;
}
// We must set up a console otherwise setup of some modules may fail // We must set up a console otherwise setup of some modules may fail
MainConsole.Instance = new LocalConsole("TEST PROMPT");
MainServer.Instance = new BaseHttpServer(980);
RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
regInfo.RegionName = name; regInfo.RegionName = name;
regInfo.RegionID = id; regInfo.RegionID = id;
@ -132,33 +162,34 @@ namespace OpenSim.Tests.Common.Setup
IRegionModule godsModule = new GodsModule(); IRegionModule godsModule = new GodsModule();
godsModule.Initialise(testScene, new IniConfigSource()); godsModule.Initialise(testScene, new IniConfigSource());
testScene.AddModule(godsModule.Name, godsModule); testScene.AddModule(godsModule.Name, godsModule);
realServices = realServices.ToLower();
ISharedRegionModule assetService = new LocalAssetServicesConnector();
IniConfigSource config = new IniConfigSource(); IniConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("AssetService"); // If we have a brand new scene, need to initialize shared region modules
config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); if ((m_assetService == null && m_inventoryService == null) || newScene)
config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); {
config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); if (realServices.Contains("asset"))
assetService.Initialise(config); StartAssetService(testScene, true);
assetService.AddRegion(testScene); else
assetService.RegionLoaded(testScene); StartAssetService(testScene, false);
testScene.AddRegionModule(assetService.Name, assetService); if (realServices.Contains("inventory"))
assetService.PostInitialise(); StartInventoryService(testScene, true);
else
StartInventoryService(testScene, false);
}
// If not, make sure the shared module gets references to this new scene
else
{
m_assetService.AddRegion(testScene);
m_assetService.RegionLoaded(testScene);
m_inventoryService.AddRegion(testScene);
m_inventoryService.RegionLoaded(testScene);
}
m_inventoryService.PostInitialise();
m_assetService.PostInitialise();
testScene.CommsManager.UserService.SetInventoryService(testScene.InventoryService);
ISharedRegionModule inventoryService = new LocalInventoryServicesConnector();
config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("InventoryService");
config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
inventoryService.Initialise(config);
inventoryService.AddRegion(testScene);
inventoryService.RegionLoaded(testScene);
testScene.AddRegionModule(inventoryService.Name, inventoryService);
inventoryService.PostInitialise();
testScene.SetModuleInterfaces(); testScene.SetModuleInterfaces();
testScene.LandChannel = new TestLandChannel(); testScene.LandChannel = new TestLandChannel();
@ -168,10 +199,48 @@ namespace OpenSim.Tests.Common.Setup
physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
testScene.PhysicsScene testScene.PhysicsScene
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test");
return testScene; return testScene;
} }
private static void StartAssetService(Scene testScene, bool real)
{
ISharedRegionModule assetService = new LocalAssetServicesConnector();
IniConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("AssetService");
config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
if (real)
config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
else
config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestAssetService");
config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
assetService.Initialise(config);
assetService.AddRegion(testScene);
assetService.RegionLoaded(testScene);
testScene.AddRegionModule(assetService.Name, assetService);
m_assetService = assetService;
}
private static void StartInventoryService(Scene testScene, bool real)
{
ISharedRegionModule inventoryService = new LocalInventoryServicesConnector();
IniConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("InventoryService");
config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
if (real)
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
else
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestInventoryService");
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
inventoryService.Initialise(config);
inventoryService.AddRegion(testScene);
inventoryService.RegionLoaded(testScene);
testScene.AddRegionModule(inventoryService.Name, inventoryService);
m_inventoryService = inventoryService;
}
/// <summary> /// <summary>
/// Setup modules for a scene using their default settings. /// Setup modules for a scene using their default settings.
/// </summary> /// </summary>

View File

@ -41,28 +41,58 @@ namespace OpenSim.Tests.Common.Setup
/// Create a test user with a standard inventory /// Create a test user with a standard inventory
/// </summary> /// </summary>
/// <param name="commsManager"></param> /// <param name="commsManager"></param>
/// <param name="callback">
/// Callback to invoke when inventory has been loaded. This is required because
/// loading may be asynchronous, even on standalone
/// </param>
/// <returns></returns> /// <returns></returns>
public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager) public static CachedUserInfo CreateUserWithInventory(
CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
{ {
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
return CreateUserWithInventory(commsManager, userId); return CreateUserWithInventory(commsManager, userId, callback);
} }
/// <summary> /// <summary>
/// Create a test user with a standard inventory /// Create a test user with a standard inventory
/// </summary> /// </summary>
/// <param name="commsManager"></param> /// <param name="commsManager"></param>
/// <param name="userId">Explicit user id to use for user creation</param> /// <param name="userId">User ID</param>
/// <param name="callback">
/// Callback to invoke when inventory has been loaded. This is required because
/// loading may be asynchronous, even on standalone
/// </param>
/// <returns></returns> /// <returns></returns>
public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId) public static CachedUserInfo CreateUserWithInventory(
CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
{
return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
}
/// <summary>
/// Create a test user with a standard inventory
/// </summary>
/// <param name="commsManager"></param>
/// <param name="firstName">First name of user</param>
/// <param name="lastName">Last name of user</param>
/// <param name="userId">User ID</param>
/// <param name="callback">
/// Callback to invoke when inventory has been loaded. This is required because
/// loading may be asynchronous, even on standalone
/// </param>
/// <returns></returns>
public static CachedUserInfo CreateUserWithInventory(
CommunicationsManager commsManager, string firstName, string lastName,
UUID userId, OnInventoryReceivedDelegate callback)
{ {
LocalUserServices lus = (LocalUserServices)commsManager.UserService; LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
userInfo.OnInventoryReceived += callback;
userInfo.FetchInventory(); userInfo.FetchInventory();
return userInfo; return userInfo;
} }
} }
} }