From bdd7849094996392417ea3e5080578a04b69afac Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 May 2011 00:51:14 +0100 Subject: Allow item links to be deleted even when other deletes and purges are disabled. If these links are not deleted, then they will build up in the player's inventory until they can no longer log in. Accidental deletion of links due to bugs or other causes is potentially inconvenient but on a par with items being accidentally moved. When a link is deleted, the target of the link is never touched. This is a general solution that accounts for the use of links anywhere in the user's inventory. --- OpenSim/Data/IXInventoryData.cs | 29 ++++++++++++++++++ OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs | 35 ++++++++++++++-------- OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | 10 +++++++ OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 27 +++++++++++++---- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 10 +++++++ OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | 28 +++++++++++++---- OpenSim/Data/SQLite/SQLiteXInventoryData.cs | 10 +++++++ .../Services/InventoryService/XInventoryService.cs | 34 +++++++++++++++++---- 8 files changed, 153 insertions(+), 30 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs index d85a7ef..85a5c08 100644 --- a/OpenSim/Data/IXInventoryData.cs +++ b/OpenSim/Data/IXInventoryData.cs @@ -74,9 +74,38 @@ namespace OpenSim.Data bool StoreFolder(XInventoryFolder folder); bool StoreItem(XInventoryItem item); + /// + /// Delete folders where field == val + /// + /// + /// + /// true if the delete was successful, false if it was not bool DeleteFolders(string field, string val); + + /// + /// Delete folders where field1 == val1, field2 == val2... + /// + /// + /// + /// true if the delete was successful, false if it was not + bool DeleteFolders(string[] fields, string[] vals); + + /// + /// Delete items where field == val + /// + /// + /// + /// true if the delete was successful, false if it was not bool DeleteItems(string field, string val); + /// + /// Delete items where field1 == val1, field2 == val2... + /// + /// + /// + /// true if the delete was successful, false if it was not + bool DeleteItems(string[] fields, string[] vals); + bool MoveItem(string id, string newParent); XInventoryItem[] GetActiveGestures(UUID principalID); int GetAssetPermissions(UUID principalID, UUID assetID); diff --git a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs index f5492b3..317afac 100644 --- a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs +++ b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs @@ -335,24 +335,35 @@ namespace OpenSim.Data.MSSQL } } - public virtual bool Delete(string field, string val) + public virtual bool Delete(string field, string key) { + return Delete(new string[] { field }, new string[] { key }); + } + + public virtual bool Delete(string[] fields, string[] keys) + { + if (fields.Length != keys.Length) + return false; + + List terms = new List(); + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) using (SqlCommand cmd = new SqlCommand()) { - string deleteCommand = String.Format("DELETE FROM {0} WHERE [{1}] = @{1}", m_Realm, field); - cmd.CommandText = deleteCommand; - - cmd.Parameters.Add(m_database.CreateParameter(field, val)); - cmd.Connection = conn; - conn.Open(); - - if (cmd.ExecuteNonQuery() > 0) + for (int i = 0; i < fields.Length; i++) { - //m_log.Warn("[MSSQLGenericTable]: " + deleteCommand); - return true; + cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i])); + terms.Add("[" + fields[i] + "] = @" + fields[i]); } - return false; + + string where = String.Join(" AND ", terms.ToArray()); + + string query = String.Format("DELETE * FROM {0} WHERE {1}", m_Realm, where); + + cmd.Connection = conn; + cmd.CommandText = query; + conn.Open(); + return cmd.ExecuteNonQuery() > 0; } } } diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs index 5bc4fe4..01689a4 100644 --- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs @@ -79,11 +79,21 @@ namespace OpenSim.Data.MSSQL return m_Folders.Delete(field, val); } + public bool DeleteFolders(string[] fields, string[] vals) + { + return m_Folders.Delete(fields, vals); + } + public bool DeleteItems(string field, string val) { return m_Items.Delete(field, val); } + public bool DeleteItems(string[] fields, string[] vals) + { + return m_Items.Delete(fields, vals); + } + public bool MoveItem(string id, string newParent) { return m_Items.MoveItem(id, newParent); diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index cfffbd8..754cf72 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -264,18 +264,33 @@ namespace OpenSim.Data.MySQL } } - public virtual bool Delete(string field, string val) + public virtual bool Delete(string field, string key) { + return Delete(new string[] { field }, new string[] { key }); + } + + public virtual bool Delete(string[] fields, string[] keys) + { + if (fields.Length != keys.Length) + return false; + + List terms = new List(); + using (MySqlCommand cmd = new MySqlCommand()) { + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.AddWithValue(fields[i], keys[i]); + terms.Add("`" + fields[i] + "` = ?" + fields[i]); + } - cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); - cmd.Parameters.AddWithValue(field, val); + string where = String.Join(" and ", terms.ToArray()); - if (ExecuteNonQuery(cmd) > 0) - return true; + string query = String.Format("delete from {0} where {1}", m_Realm, where); - return false; + cmd.CommandText = query; + + return ExecuteNonQuery(cmd) > 0; } } } diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 481da49..caf18a4 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -85,11 +85,21 @@ namespace OpenSim.Data.MySQL return m_Folders.Delete(field, val); } + public bool DeleteFolders(string[] fields, string[] vals) + { + return m_Folders.Delete(fields, vals); + } + public bool DeleteItems(string field, string val) { return m_Items.Delete(field, val); } + public bool DeleteItems(string[] fields, string[] vals) + { + return m_Items.Delete(fields, vals); + } + public bool MoveItem(string id, string newParent) { return m_Items.MoveItem(id, newParent); diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 0d7b001..3fb2d3f 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs @@ -258,17 +258,33 @@ namespace OpenSim.Data.SQLite return false; } - public bool Delete(string field, string val) + public virtual bool Delete(string field, string key) { + return Delete(new string[] { field }, new string[] { key }); + } + + public bool Delete(string[] fields, string[] keys) + { + if (fields.Length != keys.Length) + return false; + + List terms = new List(); + SqliteCommand cmd = new SqliteCommand(); - cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); - cmd.Parameters.Add(new SqliteParameter(field, val)); + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); + terms.Add("`" + fields[i] + "` = :" + fields[i]); + } + + string where = String.Join(" and ", terms.ToArray()); - if (ExecuteNonQuery(cmd, m_Connection) > 0) - return true; + string query = String.Format("delete * from {0} where {1}", m_Realm, where); - return false; + cmd.CommandText = query; + + return ExecuteNonQuery(cmd, m_Connection) > 0; } } } diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index ccbd86e..02edc30 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs @@ -91,11 +91,21 @@ namespace OpenSim.Data.SQLite return m_Folders.Delete(field, val); } + public bool DeleteFolders(string[] fields, string[] vals) + { + return m_Folders.Delete(fields, vals); + } + public bool DeleteItems(string field, string val) { return m_Items.Delete(field, val); } + public bool DeleteItems(string[] fields, string[] vals) + { + return m_Items.Delete(fields, vals); + } + public bool MoveItem(string id, string newParent) { return m_Items.MoveItem(id, newParent); diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 0af35c8..2282ee8 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -393,6 +393,10 @@ namespace OpenSim.Services.InventoryService public virtual bool UpdateItem(InventoryItemBase item) { + if (!m_AllowDelete) + if (item.AssetType == (sbyte)AssetType.Link || item.AssetType == (sbyte)AssetType.LinkFolder) + return false; + return m_Database.StoreItem(ConvertFromOpenSim(item)); } @@ -411,12 +415,30 @@ namespace OpenSim.Services.InventoryService public virtual bool DeleteItems(UUID principalID, List itemIDs) { if (!m_AllowDelete) - return false; - - // Just use the ID... *facepalms* - // - foreach (UUID id in itemIDs) - m_Database.DeleteItems("inventoryID", id.ToString()); + { + // We must still allow links and links to folders to be deleted, otherwise they will build up + // in the player's inventory until they can no longer log in. Deletions of links due to code bugs or + // similar is inconvenient but on a par with accidental movement of items. The original item is never + // touched. + foreach (UUID id in itemIDs) + { + if (!m_Database.DeleteItems( + new string[] { "inventoryID", "assetType" }, + new string[] { id.ToString(), ((sbyte)AssetType.Link).ToString() })); + { + m_Database.DeleteItems( + new string[] { "inventoryID", "assetType" }, + new string[] { id.ToString(), ((sbyte)AssetType.LinkFolder).ToString() }); + } + } + } + else + { + // Just use the ID... *facepalms* + // + foreach (UUID id in itemIDs) + m_Database.DeleteItems("inventoryID", id.ToString()); + } return true; } -- cgit v1.1 From 926a100652dcd06e012e66e873bf3f8dd63f6369 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 19 May 2011 01:34:11 -0400 Subject: Add stub for llGetLinkNumberOfSides(integer link) --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0240227..cb3bddc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4458,6 +4458,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return result; } + public void llGetLinkNumberOfSides(int link) + { + m_host.AddScriptLPS(1); + NotImplemented("llGetLinkNumberOfSides"); + } + public LSL_Integer llGetNumberOfSides() { m_host.AddScriptLPS(1); -- cgit v1.1 From a2c19847b4bb9b2335622bfc9757e6f7a2971c7d Mon Sep 17 00:00:00 2001 From: Kim King Date: Mon, 16 May 2011 05:57:08 -0400 Subject: ScriptEngine/Shared: Fix bug 5473 (v2). --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 298d664..461b473 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1536,6 +1536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared public struct LSLInteger { public int value; + private static readonly Regex castRegex = new Regex(@"(^[ ]*0[xX][0-9A-Fa-f][0-9A-Fa-f]*)|(^[ ]*(-?|\+?)[0-9][0-9]*)"); #region Constructors public LSLInteger(int i) @@ -1555,9 +1556,10 @@ namespace OpenSim.Region.ScriptEngine.Shared public LSLInteger(string s) { - Regex r = new Regex("(^[ ]*0[xX][0-9A-Fa-f][0-9A-Fa-f]*)|(^[ ]*-?[0-9][0-9]*)"); - Match m = r.Match(s); + Match m = castRegex.Match(s); string v = m.Groups[0].Value; + // Leading plus sign is allowed, but ignored + v = v.Replace("+", ""); if (v == String.Empty) { -- cgit v1.1 From 9fc29e1595f921bda761d71da59162f31cc32799 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 May 2011 20:19:32 +0100 Subject: Implement llGetLinKNumberOfSides(). Based on code in http://opensimulator.org/mantis/view.php?id=5489 Thanks onesong. --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index cb3bddc..1cf03b8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4458,10 +4458,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return result; } - public void llGetLinkNumberOfSides(int link) + public LSL_Integer llGetLinkNumberOfSides(int link) { m_host.AddScriptLPS(1); - NotImplemented("llGetLinkNumberOfSides"); + + SceneObjectPart linkedPart; + + if (link == ScriptBaseClass.LINK_ROOT) + linkedPart = m_host.ParentGroup.RootPart; + else if (link == ScriptBaseClass.LINK_THIS) + linkedPart = m_host; + else + linkedPart = m_host.ParentGroup.GetLinkNumPart(link); + + return GetNumberOfSides(linkedPart); } public LSL_Integer llGetNumberOfSides() -- cgit v1.1 From 7ed419217fc63f7a01c13a7c3320e97edd6bb1b6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 May 2011 23:22:27 +0100 Subject: add test for rezzing an object from a prim item --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 ++ .../Framework/Scenes/Tests/TaskInventoryTests.cs | 45 +++++++++++++++++++++- OpenSim/Tests/Common/Setup/AssetHelpers.cs | 20 ++++++++-- 4 files changed, 66 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9df7340..0722cee 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1971,8 +1971,9 @@ namespace OpenSim.Region.Framework.Scenes /// /// Add a newly created object to the scene. /// - /// + /// /// This method does not send updates to the client - callers need to handle this themselves. + /// /// /// /// Position of the object diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index fc31b65..14b587f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -344,6 +344,9 @@ namespace OpenSim.Region.Framework.Scenes /// Add an object to the scene. This will both update the scene, and send information about the /// new object to all clients interested in the scene. /// + /// + /// The object's stored position, rotation and velocity are used. + /// /// /// /// If true, the object is made persistent into the scene. diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 2aef4b0..73f66cb 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -90,11 +90,54 @@ namespace OpenSim.Region.Framework.Tests return ncItem; } - + + [Test] + public void TestRezObjectFromInventoryItem() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + Scene scene = SceneSetupHelpers.SetupScene(); + UserAccount user1 = CreateUser(scene); + SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); + SceneObjectPart sop1 = sog1.RootPart; + + // Create an object embedded inside the first + UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); + + SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero); + AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); + scene.AssetService.Store(taskSceneObjectAsset); + TaskInventoryItem taskSceneObjectItem + = new TaskInventoryItem + { Name = "tso", AssetID = taskSceneObjectAsset.FullID, ItemID = taskSceneObjectItemId, + Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; + sop1.Inventory.AddInventoryItem(taskSceneObjectItem, true); + + scene.AddSceneObject(sog1); + + Vector3 rezPos = new Vector3(10, 10, 10); + Quaternion rezRot = new Quaternion(0.5f, 0.5f, 0.5f, 0.5f); + Vector3 rezVel = new Vector3(2, 2, 2); + + scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0); + + SceneObjectPart rezzedObjectPart = scene.GetSceneObjectPart("tso"); + + Assert.That(rezzedObjectPart, Is.Not.Null); + Assert.That(rezzedObjectPart.AbsolutePosition, Is.EqualTo(rezPos)); + Assert.That(rezzedObjectPart.RotationOffset, Is.EqualTo(rezRot)); + + // Velocity isn't being set, possibly because we have no physics + //Assert.That(rezzedObjectPart.Velocity, Is.EqualTo(rezVel)); + } + /// /// Test MoveTaskInventoryItem where the item has no parent folder assigned. /// + /// /// This should place it in the most suitable user folder. + /// [Test] public void TestMoveTaskInventoryItem() { diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs index d572249..aa55bcd 100644 --- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs +++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs @@ -56,10 +56,24 @@ namespace OpenSim.Tests.Common AssetBase asset = CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId); scene.AssetService.Store(asset); return asset; - } + } + + /// + /// Create an asset from the given object. + /// + /// + /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" + /// will be used. + /// + /// + /// + public static AssetBase CreateAsset(int assetUuidTail, SceneObjectGroup sog) + { + return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), sog); + } /// - /// Create an asset from the given scene object. + /// Create an asset from the given object. /// /// /// @@ -76,7 +90,7 @@ namespace OpenSim.Tests.Common /// /// Create an asset from the given scene object. /// - /// + /// /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" /// will be used. /// -- cgit v1.1 From 91a9f30b1613fba8c3ff31de5b9390b0e636ad65 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 May 2011 23:34:34 +0100 Subject: implement Scene.GetSceneObjectGroup(UUID fullID) using existing index --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0722cee..f718331 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4279,6 +4279,16 @@ namespace OpenSim.Region.Framework.Scenes // } /// + /// Get a group via its UUID + /// + /// + /// + public SceneObjectGroup GetSceneObjectGroup(UUID fullID) + { + return m_sceneGraph.GetSceneObjectGroup(fullID); + } + + /// /// Get a named prim contained in this scene (will return the first /// found, if there are more than one prim with the same name) /// diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 14b587f..2d547f7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -976,6 +976,22 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// Get a group in the scene + /// + /// UUID of the group + /// null if no such group was found + protected internal SceneObjectGroup GetSceneObjectGroup(UUID fullID) + { + lock (SceneObjectGroupsByFullID) + { + if (SceneObjectGroupsByFullID.ContainsKey(fullID)) + return SceneObjectGroupsByFullID[fullID]; + } + + return null; + } + + /// /// Get a part contained in this scene. /// /// -- cgit v1.1 From 4b0fc4faef657cc819dfa360fb6a266532724455 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 May 2011 23:41:14 +0100 Subject: implement Scene.GetSceneObjectGroup(string name) to match the equivalent GetSOP method --- OpenSim/Region/Framework/Scenes/Scene.cs | 15 +++++++++++-- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 31 ++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f718331..cfb3a5d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4282,14 +4282,25 @@ namespace OpenSim.Region.Framework.Scenes /// Get a group via its UUID /// /// - /// + /// null if no group with that name exists public SceneObjectGroup GetSceneObjectGroup(UUID fullID) { return m_sceneGraph.GetSceneObjectGroup(fullID); } /// - /// Get a named prim contained in this scene (will return the first + /// Get a group by name from the scene (will return the first + /// found, if there are more than one prim with the same name) + /// + /// + /// null if no group with that name exists + public SceneObjectGroup GetSceneObjectGroup(string name) + { + return m_sceneGraph.GetSceneObjectGroup(name); + } + + /// + /// Get a prim by name from the scene (will return the first /// found, if there are more than one prim with the same name) /// /// diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 2d547f7..0cff011 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -992,6 +992,35 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// Get a group by name from the scene (will return the first + /// found, if there are more than one prim with the same name) + /// + /// + /// null if the part was not found + protected internal SceneObjectGroup GetSceneObjectGroup(string name) + { + SceneObjectGroup so = null; + + Entities.Find( + delegate(EntityBase entity) + { + if (entity is SceneObjectGroup) + { + if (entity.Name == name) + { + so = (SceneObjectGroup)entity; + return true; + } + } + + return false; + } + ); + + return so; + } + + /// /// Get a part contained in this scene. /// /// @@ -1005,7 +1034,7 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Get a named prim contained in this scene (will return the first + /// Get a prim by name from the scene (will return the first /// found, if there are more than one prim with the same name) /// /// -- cgit v1.1 From f2095ea2797bd01dc727cdfac052508a17f62dc0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 May 2011 23:45:39 +0100 Subject: refactor TestRezObjectFromInventoryItem() --- OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 73f66cb..4d4974f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -122,14 +122,14 @@ namespace OpenSim.Region.Framework.Tests scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0); - SceneObjectPart rezzedObjectPart = scene.GetSceneObjectPart("tso"); + SceneObjectGroup rezzedObject = scene.GetSceneObjectGroup("tso"); - Assert.That(rezzedObjectPart, Is.Not.Null); - Assert.That(rezzedObjectPart.AbsolutePosition, Is.EqualTo(rezPos)); - Assert.That(rezzedObjectPart.RotationOffset, Is.EqualTo(rezRot)); + Assert.That(rezzedObject, Is.Not.Null); + Assert.That(rezzedObject.AbsolutePosition, Is.EqualTo(rezPos)); + Assert.That(rezzedObject.Velocity, Is.EqualTo(rezVel)); - // Velocity isn't being set, possibly because we have no physics - //Assert.That(rezzedObjectPart.Velocity, Is.EqualTo(rezVel)); + // Confusingly, this isn't the rezzedObject.Rotation + Assert.That(rezzedObject.RootPart.RotationOffset, Is.EqualTo(rezRot)); } /// -- cgit v1.1 From 90567a9eaac717ab86316c078e148f8fe13432ac Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:02:53 +0100 Subject: refactor Scene.RezObject() to use AddNewSceneObject() rather than copy/pasting code with small differences --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 14 +------------- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++--- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 17 +++++++++-------- .../Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 5 ++++- 4 files changed, 17 insertions(+), 25 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7b88f4f..3c47873 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2095,19 +2095,7 @@ namespace OpenSim.Region.Framework.Scenes sourcePart.Inventory.RemoveInventoryItem(item.ItemID); } - AddNewSceneObject(group, true); - - group.AbsolutePosition = pos; - group.Velocity = vel; - - if (rot != null) - group.UpdateGroupRotationR((Quaternion)rot); - - // TODO: This needs to be refactored with the similar code in - // SceneGraph.AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) - // possibly by allowing this method to take a null rotation. - if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) - group.RootPart.ApplyImpulse((vel * group.GetMass()), false); + AddNewSceneObject(group, true, pos, rot, vel); // We can only call this after adding the scene object, since the scene object references the scene // to find out if scripts should be activated at all. diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index cfb3a5d..b9690fe 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1976,12 +1976,12 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - /// Position of the object - /// Rotation of the object + /// Position of the object. If null then the position stored in the object is used. + /// Rotation of the object. If null then the rotation stored in the object is used. /// Velocity of the object. This parameter only has an effect if the object is physical /// public bool AddNewSceneObject( - SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) + SceneObjectGroup sceneObject, bool attachToBackup, Vector3? pos, Quaternion? rot, Vector3 vel) { if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel)) { diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 0cff011..cdb4e41 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -311,25 +311,26 @@ namespace OpenSim.Region.Framework.Scenes /// This method does not send updates to the client - callers need to handle this themselves. /// /// - /// Position of the object - /// Rotation of the object + /// Position of the object. If null then the position stored in the object is used. + /// Rotation of the object. If null then the rotation stored in the object is used. /// Velocity of the object. This parameter only has an effect if the object is physical /// public bool AddNewSceneObject( - SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) + SceneObjectGroup sceneObject, bool attachToBackup, Vector3? pos, Quaternion? rot, Vector3 vel) { AddNewSceneObject(sceneObject, true, false); - // we set it's position in world. - sceneObject.AbsolutePosition = pos; + if (pos != null) + sceneObject.AbsolutePosition = (Vector3)pos; if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) { sceneObject.ClearPartAttachmentData(); } - - sceneObject.UpdateGroupRotationR(rot); - + + if (rot != null) + sceneObject.UpdateGroupRotationR((Quaternion)rot); + //group.ApplyPhysics(m_physicalPrim); if (sceneObject.RootPart.PhysActor != null && sceneObject.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) { diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 4d4974f..222710f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -126,7 +126,10 @@ namespace OpenSim.Region.Framework.Tests Assert.That(rezzedObject, Is.Not.Null); Assert.That(rezzedObject.AbsolutePosition, Is.EqualTo(rezPos)); - Assert.That(rezzedObject.Velocity, Is.EqualTo(rezVel)); + + // Velocity doesn't get applied, probably because there is no physics in tests (yet) +// Assert.That(rezzedObject.Velocity, Is.EqualTo(rezVel)); + Assert.That(rezzedObject.Velocity, Is.EqualTo(Vector3.Zero)); // Confusingly, this isn't the rezzedObject.Rotation Assert.That(rezzedObject.RootPart.RotationOffset, Is.EqualTo(rezRot)); -- cgit v1.1 From bc43cef5816ef5d95de153bcfe00615c5b3f79a7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:05:00 +0100 Subject: minor: remove mono compiler warning --- OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index b74d6e7..ec9f157 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs @@ -278,21 +278,21 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup { string sRegionName; string sRegionLabel; - string prepend; +// string prepend; AutoBackupModuleState state; if (parseDefault) { sRegionName = null; sRegionLabel = "DEFAULT"; - prepend = ""; +// prepend = ""; state = this.m_defaultState; } else { sRegionName = scene.RegionInfo.RegionName; sRegionLabel = sRegionName; - prepend = sRegionName + "."; +// prepend = sRegionName + "."; state = null; } -- cgit v1.1 From 3fed61a5d5e65c36791317cec85dc130bba1cc82 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:07:24 +0100 Subject: refactor: in TaskInventoryTests, use UserProfileTestUtils.CreateUserWithInvetory() --- .../Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 222710f..4f5018a 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -53,15 +53,6 @@ namespace OpenSim.Region.Framework.Tests [TestFixture] public class TaskInventoryTests { - protected UserAccount CreateUser(Scene scene) - { - string userFirstName = "Jock"; - string userLastName = "Stirrup"; - string userPassword = "troll"; - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - return UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); - } - protected SceneObjectGroup CreateSO1(Scene scene, UUID ownerId) { string part1Name = "part1"; @@ -98,7 +89,7 @@ namespace OpenSim.Region.Framework.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount user1 = CreateUser(scene); + UserAccount user1 = UserProfileTestUtils.CreateUserWithInventory(scene); SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; @@ -148,7 +139,7 @@ namespace OpenSim.Region.Framework.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount user1 = CreateUser(scene); + UserAccount user1 = UserProfileTestUtils.CreateUserWithInventory(scene); SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); @@ -174,7 +165,7 @@ namespace OpenSim.Region.Framework.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount user1 = CreateUser(scene); + UserAccount user1 = UserProfileTestUtils.CreateUserWithInventory(scene); SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); -- cgit v1.1 From 534ee52a121c209752101476e031a2c097637d82 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:11:52 +0100 Subject: rename UserProfileTestUtils to UserAccountHelpers to be consistent with other test helper names --- .../Archiver/Tests/InventoryArchiveTestCase.cs | 2 +- .../Archiver/Tests/InventoryArchiverTests.cs | 12 +- .../Avatar/Inventory/Archiver/Tests/PathTests.cs | 16 +-- .../Tests/InventoryAccessModuleTests.cs | 2 +- .../Framework/Scenes/Tests/TaskInventoryTests.cs | 6 +- OpenSim/Tests/Common/Setup/UserAccountHelpers.cs | 145 +++++++++++++++++++++ OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs | 145 --------------------- 7 files changed, 164 insertions(+), 164 deletions(-) create mode 100644 OpenSim/Tests/Common/Setup/UserAccountHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index 5ba08ee..9421f22 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs @@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Scene scene = SceneSetupHelpers.SetupScene(); SceneSetupHelpers.SetupSceneModules(scene, archiverModule); - UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); + UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); MemoryStream archiveWriteStream = new MemoryStream(); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 52232a0..db57d90 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "password"); + UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); InventoryItemBase coaItem @@ -138,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string userLastName = "Stirrup"; string userPassword = "troll"; UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); + UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); // Create asset UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); @@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); + UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream); InventoryItemBase foundItem1 @@ -261,8 +261,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); - UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); + UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); + UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); InventoryItemBase foundItem1 @@ -294,7 +294,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "password"); + UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password"); m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream); InventoryItemBase foundItem1 diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index c7dae52..0446f3b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs @@ -71,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string userLastName = "Stirrup"; string userPassword = "troll"; UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); + UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); // Create asset SceneObjectGroup object1; @@ -184,8 +184,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "meowfood"); - UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); + UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood"); + UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); InventoryItemBase foundItem1 @@ -226,7 +226,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Scene scene = SceneSetupHelpers.SetupScene(); SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password"); + UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); InventoryItemBase foundItem1 @@ -255,7 +255,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string userFirstName = "Jock"; string userLastName = "Stirrup"; UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood"); + UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood"); // Create asset SceneObjectGroup object1; @@ -328,7 +328,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); Dictionary foldersCreated = new Dictionary(); HashSet nodesLoaded = new HashSet(); @@ -395,7 +395,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests //log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); string folder1ExistingName = "a"; string folder2Name = "b"; @@ -446,7 +446,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); string folder1ExistingName = "a"; string folder2Name = "b"; diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index 8d53cf1..75faab0 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests string userFirstName = "Jock"; string userLastName = "Stirrup"; string userPassword = "troll"; - UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword); + UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = m_userId; diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 4f5018a..e830500 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.Framework.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount user1 = UserProfileTestUtils.CreateUserWithInventory(scene); + UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; @@ -139,7 +139,7 @@ namespace OpenSim.Region.Framework.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount user1 = UserProfileTestUtils.CreateUserWithInventory(scene); + UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); @@ -165,7 +165,7 @@ namespace OpenSim.Region.Framework.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene(); - UserAccount user1 = UserProfileTestUtils.CreateUserWithInventory(scene); + UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); diff --git a/OpenSim/Tests/Common/Setup/UserAccountHelpers.cs b/OpenSim/Tests/Common/Setup/UserAccountHelpers.cs new file mode 100644 index 0000000..346f78a --- /dev/null +++ b/OpenSim/Tests/Common/Setup/UserAccountHelpers.cs @@ -0,0 +1,145 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework.Communications; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Tests.Common.Setup +{ + /// + /// Utility functions for carrying out user profile related tests. + /// + public static class UserAccountHelpers + { +// /// +// /// Create a test user with a standard inventory +// /// +// /// +// /// +// /// Callback to invoke when inventory has been loaded. This is required because +// /// loading may be asynchronous, even on standalone +// /// +// /// +// public static CachedUserInfo CreateUserWithInventory( +// CommunicationsManager commsManager, OnInventoryReceivedDelegate callback) +// { +// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); +// return CreateUserWithInventory(commsManager, userId, callback); +// } +// +// /// +// /// Create a test user with a standard inventory +// /// +// /// +// /// User ID +// /// +// /// Callback to invoke when inventory has been loaded. This is required because +// /// loading may be asynchronous, even on standalone +// /// +// /// +// public static CachedUserInfo CreateUserWithInventory( +// CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) +// { +// return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); +// } +// +// /// +// /// Create a test user with a standard inventory +// /// +// /// +// /// First name of user +// /// Last name of user +// /// User ID +// /// +// /// Callback to invoke when inventory has been loaded. This is required because +// /// loading may be asynchronous, even on standalone +// /// +// /// +// public static CachedUserInfo CreateUserWithInventory( +// CommunicationsManager commsManager, string firstName, string lastName, +// UUID userId, OnInventoryReceivedDelegate callback) +// { +// return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); +// } +// +// /// +// /// Create a test user with a standard inventory +// /// +// /// +// /// First name of user +// /// Last name of user +// /// Password +// /// User ID +// /// +// /// Callback to invoke when inventory has been loaded. This is required because +// /// loading may be asynchronous, even on standalone +// /// +// /// +// public static CachedUserInfo CreateUserWithInventory( +// CommunicationsManager commsManager, string firstName, string lastName, string password, +// UUID userId, OnInventoryReceivedDelegate callback) +// { +// LocalUserServices lus = (LocalUserServices)commsManager.UserService; +// lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); +// +// CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); +// userInfo.OnInventoryReceived += callback; +// userInfo.FetchInventory(); +// +// return userInfo; +// } + + public static UserAccount CreateUserWithInventory(Scene scene) + { + return CreateUserWithInventory( + scene, "Bill", "Bailey", UUID.Parse("00000000-0000-0000-0000-000000000099"), "troll"); + } + + public static UserAccount CreateUserWithInventory( + Scene scene, string firstName, string lastName, UUID userId, string pw) + { + UserAccount ua + = new UserAccount(userId) + { FirstName = firstName, LastName = lastName }; + CreateUserWithInventory(scene, ua, pw); + return ua; + } + + public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) + { + // FIXME: This should really be set up by UserAccount itself + ua.ServiceURLs = new Dictionary(); + + scene.UserAccountService.StoreUserAccount(ua); + scene.InventoryService.CreateUserInventory(ua.PrincipalID); + scene.AuthenticationService.SetPassword(ua.PrincipalID, pw); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs deleted file mode 100644 index d01521d..0000000 --- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework.Communications; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common.Setup -{ - /// - /// Utility functions for carrying out user profile related tests. - /// - public static class UserProfileTestUtils - { -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, OnInventoryReceivedDelegate callback) -// { -// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); -// return CreateUserWithInventory(commsManager, userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) -// { -// return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// First name of user -// /// Last name of user -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, string firstName, string lastName, -// UUID userId, OnInventoryReceivedDelegate callback) -// { -// return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// First name of user -// /// Last name of user -// /// Password -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, string firstName, string lastName, string password, -// UUID userId, OnInventoryReceivedDelegate callback) -// { -// LocalUserServices lus = (LocalUserServices)commsManager.UserService; -// lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); -// -// CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); -// userInfo.OnInventoryReceived += callback; -// userInfo.FetchInventory(); -// -// return userInfo; -// } - - public static UserAccount CreateUserWithInventory(Scene scene) - { - return CreateUserWithInventory( - scene, "Bill", "Bailey", UUID.Parse("00000000-0000-0000-0000-000000000099"), "troll"); - } - - public static UserAccount CreateUserWithInventory( - Scene scene, string firstName, string lastName, UUID userId, string pw) - { - UserAccount ua - = new UserAccount(userId) - { FirstName = firstName, LastName = lastName }; - CreateUserWithInventory(scene, ua, pw); - return ua; - } - - public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) - { - // FIXME: This should really be set up by UserAccount itself - ua.ServiceURLs = new Dictionary(); - - scene.UserAccountService.StoreUserAccount(ua); - scene.InventoryService.CreateUserInventory(ua.PrincipalID); - scene.AuthenticationService.SetPassword(ua.PrincipalID, pw); - } - } -} \ No newline at end of file -- cgit v1.1 From 0050bb438c7138d1deb36609faef8dcbe25348e4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:15:22 +0100 Subject: refactor: use SceneSetupHelpers.CreateSceneObject() --- .../Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index e830500..717517b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -53,16 +53,6 @@ namespace OpenSim.Region.Framework.Tests [TestFixture] public class TaskInventoryTests { - protected SceneObjectGroup CreateSO1(Scene scene, UUID ownerId) - { - string part1Name = "part1"; - UUID part1Id = UUID.Parse("10000000-0000-0000-0000-000000000000"); - SceneObjectPart part1 - = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = part1Name, UUID = part1Id }; - return new SceneObjectGroup(part1); - } - protected TaskInventoryItem CreateSOItem1(Scene scene, SceneObjectPart part) { AssetNotecard nc = new AssetNotecard(); @@ -90,7 +80,7 @@ namespace OpenSim.Region.Framework.Tests Scene scene = SceneSetupHelpers.SetupScene(); UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); - SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); + SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; // Create an object embedded inside the first @@ -140,7 +130,7 @@ namespace OpenSim.Region.Framework.Tests Scene scene = SceneSetupHelpers.SetupScene(); UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); - SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); + SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); InventoryFolderBase folder @@ -166,7 +156,7 @@ namespace OpenSim.Region.Framework.Tests Scene scene = SceneSetupHelpers.SetupScene(); UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); - SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); + SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); -- cgit v1.1 From 9103fe84d51c21d58c129fd0245c47b0a2b35c60 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:25:58 +0100 Subject: move test task inventory notecard item creation into a new TastInventoryHelpers class --- .../Framework/Scenes/Tests/TaskInventoryTests.cs | 23 +------- OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs | 68 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 717517b..1c8f078 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -53,25 +53,6 @@ namespace OpenSim.Region.Framework.Tests [TestFixture] public class TaskInventoryTests { - protected TaskInventoryItem CreateSOItem1(Scene scene, SceneObjectPart part) - { - AssetNotecard nc = new AssetNotecard(); - nc.BodyText = "Hello World!"; - nc.Encode(); - UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); - UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); - AssetBase ncAsset - = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); - scene.AssetService.Store(ncAsset); - TaskInventoryItem ncItem - = new TaskInventoryItem - { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, - Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; - part.Inventory.AddInventoryItem(ncItem, true); - - return ncItem; - } - [Test] public void TestRezObjectFromInventoryItem() { @@ -132,7 +113,7 @@ namespace OpenSim.Region.Framework.Tests UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; - TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); + TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); InventoryFolderBase folder = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; @@ -158,7 +139,7 @@ namespace OpenSim.Region.Framework.Tests UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; - TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); + TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); // Perform test scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); diff --git a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs new file mode 100644 index 0000000..48724f4 --- /dev/null +++ b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs @@ -0,0 +1,68 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; +using OpenMetaverse.Assets; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Tests.Common +{ + /// + /// Utility functions for carrying out task inventory tests. + /// + /// + public static class TaskInventoryHelpers + { + /// + /// Add a notecard item to the given part. + /// + /// + /// + /// The item that was added + public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part) + { + AssetNotecard nc = new AssetNotecard(); + nc.BodyText = "Hello World!"; + nc.Encode(); + UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); + UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); + AssetBase ncAsset + = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); + scene.AssetService.Store(ncAsset); + TaskInventoryItem ncItem + = new TaskInventoryItem + { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, + Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; + part.Inventory.AddInventoryItem(ncItem, true); + + return ncItem; + } + } +} \ No newline at end of file -- cgit v1.1 From 084059319c125983ac43534797282ddec394cb59 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:37:20 +0100 Subject: refactor: move scene object item creation code into TaskInventoryHelpers --- .../Framework/Scenes/Tests/TaskInventoryTests.cs | 10 ++-------- OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs | 23 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 1c8f078..32bb068 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -66,15 +66,8 @@ namespace OpenSim.Region.Framework.Tests // Create an object embedded inside the first UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); - - SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero); - AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); - scene.AssetService.Store(taskSceneObjectAsset); TaskInventoryItem taskSceneObjectItem - = new TaskInventoryItem - { Name = "tso", AssetID = taskSceneObjectAsset.FullID, ItemID = taskSceneObjectItemId, - Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; - sop1.Inventory.AddInventoryItem(taskSceneObjectItem, true); + = TaskInventoryHelpers.AddSceneObjectItem(scene, sop1, "tso", taskSceneObjectItemId); scene.AddSceneObject(sog1); @@ -114,6 +107,7 @@ namespace OpenSim.Region.Framework.Tests SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); + InventoryFolderBase folder = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; diff --git a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs index 48724f4..4467573 100644 --- a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs @@ -32,7 +32,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -namespace OpenSim.Tests.Common +namespace OpenSim.Tests.Common.Setup { /// /// Utility functions for carrying out task inventory tests. @@ -64,5 +64,26 @@ namespace OpenSim.Tests.Common return ncItem; } + + /// + /// Add a scene object item to the given part. + /// + /// + /// + /// + /// + public static TaskInventoryItem AddSceneObjectItem(Scene scene, SceneObjectPart sop, string itemName, UUID id) + { + SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero); + AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); + scene.AssetService.Store(taskSceneObjectAsset); + TaskInventoryItem taskSceneObjectItem + = new TaskInventoryItem + { Name = itemName, AssetID = taskSceneObjectAsset.FullID, ItemID = id, + Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; + sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); + + return taskSceneObjectItem; + } } } \ No newline at end of file -- cgit v1.1 From d7e5b76d73fe3e6d3a7d5506989bd2c081ab4fc6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:39:42 +0100 Subject: refactor: rename AddSceneObjectItem to AddSceneObject --- OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 2 +- OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 32bb068..74eab63 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -67,7 +67,7 @@ namespace OpenSim.Region.Framework.Tests // Create an object embedded inside the first UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); TaskInventoryItem taskSceneObjectItem - = TaskInventoryHelpers.AddSceneObjectItem(scene, sop1, "tso", taskSceneObjectItemId); + = TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId); scene.AddSceneObject(sog1); diff --git a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs index 4467573..fbf00d6 100644 --- a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs @@ -72,7 +72,7 @@ namespace OpenSim.Tests.Common.Setup /// /// /// - public static TaskInventoryItem AddSceneObjectItem(Scene scene, SceneObjectPart sop, string itemName, UUID id) + public static TaskInventoryItem AddSceneObject(Scene scene, SceneObjectPart sop, string itemName, UUID id) { SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero); AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); -- cgit v1.1 From 156cc1418b38c4494d3610926c0c2b2bf6c8cc2c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:44:58 +0100 Subject: test helper rename for consistency --- .../Common/Setup/BaseRequestHandlerHelpers.cs | 76 ++++++++++++++++++++++ .../Common/Setup/BaseRequestHandlerTestHelper.cs | 76 ---------------------- 2 files changed, 76 insertions(+), 76 deletions(-) create mode 100644 OpenSim/Tests/Common/Setup/BaseRequestHandlerHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs (limited to 'OpenSim') diff --git a/OpenSim/Tests/Common/Setup/BaseRequestHandlerHelpers.cs b/OpenSim/Tests/Common/Setup/BaseRequestHandlerHelpers.cs new file mode 100644 index 0000000..286e6ff --- /dev/null +++ b/OpenSim/Tests/Common/Setup/BaseRequestHandlerHelpers.cs @@ -0,0 +1,76 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Tests.Common.Setup +{ + public class BaseRequestHandlerHelpers + { + private static string[] m_emptyStringArray = new string[] { }; + + public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath) + { + Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path."); + Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path."); + Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url."); + Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl."); + + Assert.AreEqual(String.Empty, handler.GetParam(assetsPath)); + Assert.AreEqual("/", handler.GetParam(assetsPath + "/")); + Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a")); + Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/")); + Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d")); + Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/")); + } + + public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath) + { + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null."); + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path."); + Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url."); + + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params."); + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash."); + + Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment."); + Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash."); + Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment."); + Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash."); + } + + public static byte[] EmptyByteArray = new byte[] {}; + + } +} diff --git a/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs deleted file mode 100644 index eaf8b39..0000000 --- a/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Tests.Common.Mock; - -namespace OpenSim.Tests.Common.Setup -{ - public class BaseRequestHandlerTestHelper - { - private static string[] m_emptyStringArray = new string[] { }; - - public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath) - { - Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path."); - Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path."); - Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url."); - Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl."); - - Assert.AreEqual(String.Empty, handler.GetParam(assetsPath)); - Assert.AreEqual("/", handler.GetParam(assetsPath + "/")); - Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a")); - Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/")); - Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d")); - Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/")); - } - - public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath) - { - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url."); - - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash."); - - Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment."); - Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash."); - Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment."); - Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash."); - } - - public static byte[] EmptyByteArray = new byte[] {}; - - } -} -- cgit v1.1 From 94553d4753f092bfb25a83a5df01f277834d1088 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:48:01 +0100 Subject: rename UserInventoryTestsUtils -> UserInventoryHelpers for consistency --- .../Avatar/Inventory/Archiver/Tests/PathTests.cs | 8 +- OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs | 115 +++++++++++++++++++++ .../Tests/Common/Setup/UserInventoryTestUtils.cs | 115 --------------------- 3 files changed, 119 insertions(+), 119 deletions(-) create mode 100644 OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index 0446f3b..7e15a3d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs @@ -194,7 +194,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); // Now try loading to a root child folder - UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA"); + UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA"); MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream); @@ -203,7 +203,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); // Now try loading to a more deeply nested folder - UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC"); + UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC"); archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream); @@ -401,7 +401,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string folder2Name = "b"; InventoryFolderBase folder1 - = UserInventoryTestUtils.CreateInventoryFolder( + = UserInventoryHelpers.CreateInventoryFolder( scene.InventoryService, ua1.PrincipalID, folder1ExistingName); string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); @@ -452,7 +452,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string folder2Name = "b"; InventoryFolderBase folder1 - = UserInventoryTestUtils.CreateInventoryFolder( + = UserInventoryHelpers.CreateInventoryFolder( scene.InventoryService, ua1.PrincipalID, folder1ExistingName); string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); diff --git a/OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs new file mode 100644 index 0000000..0419134 --- /dev/null +++ b/OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Tests.Common +{ + /// + /// Utility functions for carrying out user inventory tests. + /// + public static class UserInventoryHelpers + { + public static readonly string PATH_DELIMITER = "/"; + + public static InventoryItemBase CreateInventoryItem( + Scene scene, string itemName, UUID itemId, string folderPath, UUID userId) + { + InventoryItemBase item = new InventoryItemBase(); + item.Name = itemName; + item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID; + item.ID = itemId; + + // Really quite bad since the objs folder could be moved in the future and confuse the tests + InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); + + item.Folder = objsFolder.ID; + scene.AddInventoryItem(item); + + return item; + } + + /// + /// Create inventory folders starting from the user's root folder. + /// + /// + /// Ignores any existing folders with the same name + /// + /// + /// + /// + /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER + /// + /// + /// The folder created. If the path contains multiple folders then the last one created is returned. + /// Will return null if the root folder could not be found. + /// + public static InventoryFolderBase CreateInventoryFolder( + IInventoryService inventoryService, UUID userId, string path) + { + InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); + + if (null == rootFolder) + return null; + + return CreateInventoryFolder(inventoryService, rootFolder, path); + } + + /// + /// Create inventory folders starting from a given parent folder + /// + /// + /// Ignores any existing folders with the same name + /// + /// + /// + /// + /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER + /// + /// + /// The folder created. If the path contains multiple folders then the last one created is returned. + /// + public static InventoryFolderBase CreateInventoryFolder( + IInventoryService inventoryService, InventoryFolderBase parentFolder, string path) + { + string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); + + InventoryFolderBase newFolder + = new InventoryFolderBase(UUID.Random(), components[0], parentFolder.Owner, parentFolder.ID); + inventoryService.AddFolder(newFolder); + + if (components.Length > 1) + return CreateInventoryFolder(inventoryService, newFolder, components[1]); + else + return newFolder; + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs deleted file mode 100644 index 135c50e..0000000 --- a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common -{ - /// - /// Utility functions for carrying out user inventory related tests. - /// - public static class UserInventoryTestUtils - { - public static readonly string PATH_DELIMITER = "/"; - - public static InventoryItemBase CreateInventoryItem( - Scene scene, string itemName, UUID itemId, string folderPath, UUID userId) - { - InventoryItemBase item = new InventoryItemBase(); - item.Name = itemName; - item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID; - item.ID = itemId; - - // Really quite bad since the objs folder could be moved in the future and confuse the tests - InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); - - item.Folder = objsFolder.ID; - scene.AddInventoryItem(item); - - return item; - } - - /// - /// Create inventory folders starting from the user's root folder. - /// - /// - /// Ignores any existing folders with the same name - /// - /// - /// - /// - /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER - /// - /// - /// The folder created. If the path contains multiple folders then the last one created is returned. - /// Will return null if the root folder could not be found. - /// - public static InventoryFolderBase CreateInventoryFolder( - IInventoryService inventoryService, UUID userId, string path) - { - InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); - - if (null == rootFolder) - return null; - - return CreateInventoryFolder(inventoryService, rootFolder, path); - } - - /// - /// Create inventory folders starting from a given parent folder - /// - /// - /// Ignores any existing folders with the same name - /// - /// - /// - /// - /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER - /// - /// - /// The folder created. If the path contains multiple folders then the last one created is returned. - /// - public static InventoryFolderBase CreateInventoryFolder( - IInventoryService inventoryService, InventoryFolderBase parentFolder, string path) - { - string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); - - InventoryFolderBase newFolder - = new InventoryFolderBase(UUID.Random(), components[0], parentFolder.Owner, parentFolder.ID); - inventoryService.AddFolder(newFolder); - - if (components.Length > 1) - return CreateInventoryFolder(inventoryService, newFolder, components[1]); - else - return newFolder; - } - } -} \ No newline at end of file -- cgit v1.1 From 4073f1013346e206131f2f7d40508fd2bf0505d4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 00:51:34 +0100 Subject: rename test helpers enclosing package from Setup to Helpers --- OpenSim/Tests/Common/Helpers/AssetHelpers.cs | 143 ++++++ .../Common/Helpers/BaseRequestHandlerHelpers.cs | 76 ++++ OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs | 483 +++++++++++++++++++++ .../Tests/Common/Helpers/TaskInventoryHelpers.cs | 89 ++++ OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs | 145 +++++++ .../Tests/Common/Helpers/UserInventoryHelpers.cs | 115 +++++ OpenSim/Tests/Common/Setup/AssetHelpers.cs | 143 ------ .../Common/Setup/BaseRequestHandlerHelpers.cs | 76 ---- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 483 --------------------- OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs | 89 ---- OpenSim/Tests/Common/Setup/UserAccountHelpers.cs | 145 ------- OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs | 115 ----- 12 files changed, 1051 insertions(+), 1051 deletions(-) create mode 100644 OpenSim/Tests/Common/Helpers/AssetHelpers.cs create mode 100644 OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs create mode 100644 OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs create mode 100644 OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs create mode 100644 OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs create mode 100644 OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/AssetHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/BaseRequestHandlerHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/UserAccountHelpers.cs delete mode 100644 OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs (limited to 'OpenSim') diff --git a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs new file mode 100644 index 0000000..aa55bcd --- /dev/null +++ b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs @@ -0,0 +1,143 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Text; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Tests.Common +{ + public class AssetHelpers + { + /// + /// Create a notecard asset with a random uuid and dummy text. + /// + /// /param> + /// + public static AssetBase CreateAsset(UUID creatorId) + { + return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId); + } + + /// + /// Create and store a notecard asset with a random uuid and dummy text. + /// + /// /param> + /// + public static AssetBase CreateAsset(Scene scene, UUID creatorId) + { + AssetBase asset = CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId); + scene.AssetService.Store(asset); + return asset; + } + + /// + /// Create an asset from the given object. + /// + /// + /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" + /// will be used. + /// + /// + /// + public static AssetBase CreateAsset(int assetUuidTail, SceneObjectGroup sog) + { + return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), sog); + } + + /// + /// Create an asset from the given object. + /// + /// + /// + /// + public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog) + { + return CreateAsset( + assetUuid, + AssetType.Object, + Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)), + sog.OwnerID); + } + + /// + /// Create an asset from the given scene object. + /// + /// + /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" + /// will be used. + /// + /// + /// + public static AssetBase CreateAsset(int assetUuidTail, CoalescedSceneObjects coa) + { + return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), coa); + } + + /// + /// Create an asset from the given scene object. + /// + /// + /// + /// + public static AssetBase CreateAsset(UUID assetUuid, CoalescedSceneObjects coa) + { + return CreateAsset( + assetUuid, + AssetType.Object, + Encoding.ASCII.GetBytes(CoalescedSceneObjectsSerializer.ToXml(coa)), + coa.CreatorId); + } + + /// + /// Create an asset from the given data. + /// + public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID) + { + return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID); + } + + /// + /// Create an asset from the given data. + /// + public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID) + { + AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString()); + asset.Data = data; + return asset; + } + + public static string ReadAssetAsString(IAssetService assetService, UUID uuid) + { + byte[] assetData = assetService.GetData(uuid.ToString()); + return Encoding.ASCII.GetString(assetData); + } + } +} diff --git a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs new file mode 100644 index 0000000..286e6ff --- /dev/null +++ b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs @@ -0,0 +1,76 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Tests.Common.Setup +{ + public class BaseRequestHandlerHelpers + { + private static string[] m_emptyStringArray = new string[] { }; + + public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath) + { + Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path."); + Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path."); + Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url."); + Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl."); + + Assert.AreEqual(String.Empty, handler.GetParam(assetsPath)); + Assert.AreEqual("/", handler.GetParam(assetsPath + "/")); + Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a")); + Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/")); + Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d")); + Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/")); + } + + public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath) + { + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null."); + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path."); + Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url."); + + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params."); + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash."); + + Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment."); + Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash."); + Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment."); + Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash."); + } + + public static byte[] EmptyByteArray = new byte[] {}; + + } +} diff --git a/OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs new file mode 100644 index 0000000..d122409 --- /dev/null +++ b/OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs @@ -0,0 +1,483 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Net; +using System.Collections.Generic; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Physics.Manager; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.CoreModules.Avatar.Gods; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Tests.Common.Setup +{ + /// + /// Helpers for setting up scenes. + /// + public class SceneSetupHelpers + { + /// + /// Set up a test scene + /// + /// + /// Automatically starts service threads, as would the normal runtime. + /// + /// + public static TestScene SetupScene() + { + return SetupScene("Unit test region", UUID.Random(), 1000, 1000); + } + + /// + /// 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. + /// + /// Name of the region + /// ID of the region + /// X co-ordinate of the region + /// Y co-ordinate of the region + /// This should be the same if simulating two scenes within a standalone + /// + public static TestScene SetupScene(string name, UUID id, uint x, uint y) + { + Console.WriteLine("Setting up test scene {0}", name); + + // We must set up a console otherwise setup of some modules may fail + MainConsole.Instance = new MockConsole("TEST PROMPT"); + + RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); + regInfo.RegionName = name; + regInfo.RegionID = id; + + AgentCircuitManager acm = new AgentCircuitManager(); + SceneCommunicationService scs = new SceneCommunicationService(); + + ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin("OpenSim.Tests.Common.dll", null); + IEstateDataService estateDataService = null; + IConfigSource configSource = new IniConfigSource(); + + TestScene testScene = new TestScene( + regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null); + + IRegionModule godsModule = new GodsModule(); + godsModule.Initialise(testScene, new IniConfigSource()); + testScene.AddModule(godsModule.Name, godsModule); + + LocalAssetServicesConnector assetService = StartAssetService(testScene); + StartAuthenticationService(testScene); + LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); + StartGridService(testScene); + LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); + LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); + + inventoryService.PostInitialise(); + assetService.PostInitialise(); + userAccountService.PostInitialise(); + presenceService.PostInitialise(); + + testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); + testScene.SetModuleInterfaces(); + + testScene.LandChannel = new TestLandChannel(testScene); + testScene.LoadWorldMap(); + + PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); + physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); + testScene.PhysicsScene + = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); + + testScene.RegionInfo.EstateSettings = new EstateSettings(); + testScene.LoginsDisabled = false; + + return testScene; + } + + private static LocalAssetServicesConnector StartAssetService(Scene testScene) + { + LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); + IConfigSource config = new IniConfigSource(); + + config.AddConfig("Modules"); + config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); + config.AddConfig("AssetService"); + config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); + config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); + + assetService.Initialise(config); + assetService.AddRegion(testScene); + assetService.RegionLoaded(testScene); + testScene.AddRegionModule(assetService.Name, assetService); + + return assetService; + } + + private static void StartAuthenticationService(Scene testScene) + { + ISharedRegionModule service = new LocalAuthenticationServicesConnector(); + IConfigSource config = new IniConfigSource(); + + config.AddConfig("Modules"); + config.AddConfig("AuthenticationService"); + config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); + config.Configs["AuthenticationService"].Set( + "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); + config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); + + service.Initialise(config); + service.AddRegion(testScene); + service.RegionLoaded(testScene); + testScene.AddRegionModule(service.Name, service); + //m_authenticationService = service; + } + + private static LocalInventoryServicesConnector StartInventoryService(Scene testScene) + { + LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); + + IConfigSource 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); + + return inventoryService; + } + + private static LocalGridServicesConnector StartGridService(Scene testScene) + { + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.AddConfig("GridService"); + config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); + config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); + config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); + + LocalGridServicesConnector gridService = new LocalGridServicesConnector(); + gridService.Initialise(config); + gridService.AddRegion(testScene); + gridService.RegionLoaded(testScene); + + return gridService; + } + + /// + /// Start a user account service + /// + /// + /// + private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) + { + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.AddConfig("UserAccountService"); + config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector"); + config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); + config.Configs["UserAccountService"].Set( + "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); + + LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); + userAccountService.Initialise(config); + + userAccountService.AddRegion(testScene); + userAccountService.RegionLoaded(testScene); + testScene.AddRegionModule(userAccountService.Name, userAccountService); + + return userAccountService; + } + + /// + /// Start a presence service + /// + /// + private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) + { + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.AddConfig("PresenceService"); + config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); + config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); + config.Configs["PresenceService"].Set( + "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); + + LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); + presenceService.Initialise(config); + + presenceService.AddRegion(testScene); + presenceService.RegionLoaded(testScene); + testScene.AddRegionModule(presenceService.Name, presenceService); + + return presenceService; + } + + /// + /// Setup modules for a scene using their default settings. + /// + /// + /// + public static void SetupSceneModules(Scene scene, params object[] modules) + { + SetupSceneModules(scene, new IniConfigSource(), modules); + } + + /// + /// Setup modules for a scene. + /// + /// + /// + /// + public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) + { + List newModules = new List(); + foreach (object module in modules) + { + if (module is IRegionModule) + { + IRegionModule m = (IRegionModule)module; + m.Initialise(scene, config); + scene.AddModule(m.Name, m); + m.PostInitialise(); + } + else if (module is IRegionModuleBase) + { + // for the new system, everything has to be initialised first, + // shared modules have to be post-initialised, then all get an AddRegion with the scene + IRegionModuleBase m = (IRegionModuleBase)module; + m.Initialise(config); + newModules.Add(m); + } + } + + foreach (IRegionModuleBase module in newModules) + { + if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise(); + } + + foreach (IRegionModuleBase module in newModules) + { + module.AddRegion(scene); + scene.AddRegionModule(module.Name, module); + } + + // RegionLoaded is fired after all modules have been appropriately added to all scenes + foreach (IRegionModuleBase module in newModules) + module.RegionLoaded(scene); + + scene.SetModuleInterfaces(); + } + + /// + /// Generate some standard agent connection data. + /// + /// + /// + public static AgentCircuitData GenerateAgentData(UUID agentId) + { + string firstName = "testfirstname"; + + AgentCircuitData agentData = new AgentCircuitData(); + agentData.AgentID = agentId; + agentData.firstname = firstName; + agentData.lastname = "testlastname"; + agentData.SessionID = UUID.Zero; + agentData.SecureSessionID = UUID.Zero; + agentData.circuitcode = 123; + agentData.BaseFolder = UUID.Zero; + agentData.InventoryFolder = UUID.Zero; + agentData.startpos = Vector3.Zero; + agentData.CapsPath = "http://wibble.com"; + + return agentData; + } + + /// + /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test + /// + /// + /// + /// + public static TestClient AddRootAgent(Scene scene, UUID agentId) + { + return AddRootAgent(scene, GenerateAgentData(agentId)); + } + + /// + /// Add a root agent. + /// + /// + /// This function + /// + /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the + /// userserver if grid) would give initial login data back to the client and separately tell the scene that the + /// agent was coming. + /// + /// 2) Connects the agent with the scene + /// + /// This function performs actions equivalent with notifying the scene that an agent is + /// coming and then actually connecting the agent to the scene. The one step missed out is the very first + /// + /// + /// + /// + public static TestClient AddRootAgent(Scene scene, AgentCircuitData agentData) + { + string reason; + + // We emulate the proper login sequence here by doing things in four stages + + // Stage 0: log the presence + scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); + + // Stage 1: simulate login by telling the scene to expect a new user connection + if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) + Console.WriteLine("NewUserConnection failed: " + reason); + + // Stage 2: add the new client as a child agent to the scene + TestClient client = new TestClient(agentData, scene); + scene.AddNewClient(client); + + // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. + ScenePresence scp = scene.GetScenePresence(agentData.AgentID); + scp.CompleteMovement(client); + //scp.MakeRootAgent(new Vector3(90, 90, 90), true); + + return client; + } + + /// + /// Add a test object + /// + /// + /// + public static SceneObjectPart AddSceneObject(Scene scene) + { + return AddSceneObject(scene, "Test Object"); + } + + /// + /// Add a test object + /// + /// + /// + /// + public static SceneObjectPart AddSceneObject(Scene scene, string name) + { + SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero); + + //part.UpdatePrimFlags(false, false, true); + //part.ObjectFlags |= (uint)PrimFlags.Phantom; + + scene.AddNewSceneObject(new SceneObjectGroup(part), false); + + return part; + } + + /// + /// Create a scene object part. + /// + /// + /// + /// + /// + public static SceneObjectPart CreateSceneObjectPart(string name, UUID id, UUID ownerId) + { + return new SceneObjectPart( + ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; + } + + /// + /// Create a scene object but do not add it to the scene. + /// + /// + /// UUID always starts at 00000000-0000-0000-0000-000000000001 + /// + /// The number of parts that should be in the scene object + /// + /// + public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) + { + return CreateSceneObject(parts, ownerId, "", 0x1); + } + + /// + /// Create a scene object but do not add it to the scene. + /// + /// + /// The number of parts that should be in the scene object + /// + /// + /// + /// The prefix to be given to part names. This will be suffixed with "Part" + /// (e.g. mynamePart0 for the root part) + /// + /// + /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" + /// will be given to the root part, and incremented for each part thereafter. + /// + /// + public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, string partNamePrefix, int uuidTail) + { + string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail); + + SceneObjectGroup sog + = new SceneObjectGroup( + CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId)); + + if (parts > 1) + for (int i = 1; i < parts; i++) + sog.AddPart( + CreateSceneObjectPart( + string.Format("{0}Part{1}", partNamePrefix, i), + new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)), + ownerId)); + + return sog; + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs new file mode 100644 index 0000000..fbf00d6 --- /dev/null +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs @@ -0,0 +1,89 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; +using OpenMetaverse.Assets; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Tests.Common.Setup +{ + /// + /// Utility functions for carrying out task inventory tests. + /// + /// + public static class TaskInventoryHelpers + { + /// + /// Add a notecard item to the given part. + /// + /// + /// + /// The item that was added + public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part) + { + AssetNotecard nc = new AssetNotecard(); + nc.BodyText = "Hello World!"; + nc.Encode(); + UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); + UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); + AssetBase ncAsset + = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); + scene.AssetService.Store(ncAsset); + TaskInventoryItem ncItem + = new TaskInventoryItem + { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, + Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; + part.Inventory.AddInventoryItem(ncItem, true); + + return ncItem; + } + + /// + /// Add a scene object item to the given part. + /// + /// + /// + /// + /// + public static TaskInventoryItem AddSceneObject(Scene scene, SceneObjectPart sop, string itemName, UUID id) + { + SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero); + AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); + scene.AssetService.Store(taskSceneObjectAsset); + TaskInventoryItem taskSceneObjectItem + = new TaskInventoryItem + { Name = itemName, AssetID = taskSceneObjectAsset.FullID, ItemID = id, + Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; + sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); + + return taskSceneObjectItem; + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs new file mode 100644 index 0000000..346f78a --- /dev/null +++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs @@ -0,0 +1,145 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework.Communications; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Tests.Common.Setup +{ + /// + /// Utility functions for carrying out user profile related tests. + /// + public static class UserAccountHelpers + { +// /// +// /// Create a test user with a standard inventory +// /// +// /// +// /// +// /// Callback to invoke when inventory has been loaded. This is required because +// /// loading may be asynchronous, even on standalone +// /// +// /// +// public static CachedUserInfo CreateUserWithInventory( +// CommunicationsManager commsManager, OnInventoryReceivedDelegate callback) +// { +// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); +// return CreateUserWithInventory(commsManager, userId, callback); +// } +// +// /// +// /// Create a test user with a standard inventory +// /// +// /// +// /// User ID +// /// +// /// Callback to invoke when inventory has been loaded. This is required because +// /// loading may be asynchronous, even on standalone +// /// +// /// +// public static CachedUserInfo CreateUserWithInventory( +// CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) +// { +// return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); +// } +// +// /// +// /// Create a test user with a standard inventory +// /// +// /// +// /// First name of user +// /// Last name of user +// /// User ID +// /// +// /// Callback to invoke when inventory has been loaded. This is required because +// /// loading may be asynchronous, even on standalone +// /// +// /// +// public static CachedUserInfo CreateUserWithInventory( +// CommunicationsManager commsManager, string firstName, string lastName, +// UUID userId, OnInventoryReceivedDelegate callback) +// { +// return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); +// } +// +// /// +// /// Create a test user with a standard inventory +// /// +// /// +// /// First name of user +// /// Last name of user +// /// Password +// /// User ID +// /// +// /// Callback to invoke when inventory has been loaded. This is required because +// /// loading may be asynchronous, even on standalone +// /// +// /// +// public static CachedUserInfo CreateUserWithInventory( +// CommunicationsManager commsManager, string firstName, string lastName, string password, +// UUID userId, OnInventoryReceivedDelegate callback) +// { +// LocalUserServices lus = (LocalUserServices)commsManager.UserService; +// lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); +// +// CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); +// userInfo.OnInventoryReceived += callback; +// userInfo.FetchInventory(); +// +// return userInfo; +// } + + public static UserAccount CreateUserWithInventory(Scene scene) + { + return CreateUserWithInventory( + scene, "Bill", "Bailey", UUID.Parse("00000000-0000-0000-0000-000000000099"), "troll"); + } + + public static UserAccount CreateUserWithInventory( + Scene scene, string firstName, string lastName, UUID userId, string pw) + { + UserAccount ua + = new UserAccount(userId) + { FirstName = firstName, LastName = lastName }; + CreateUserWithInventory(scene, ua, pw); + return ua; + } + + public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) + { + // FIXME: This should really be set up by UserAccount itself + ua.ServiceURLs = new Dictionary(); + + scene.UserAccountService.StoreUserAccount(ua); + scene.InventoryService.CreateUserInventory(ua.PrincipalID); + scene.AuthenticationService.SetPassword(ua.PrincipalID, pw); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs new file mode 100644 index 0000000..0419134 --- /dev/null +++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Tests.Common +{ + /// + /// Utility functions for carrying out user inventory tests. + /// + public static class UserInventoryHelpers + { + public static readonly string PATH_DELIMITER = "/"; + + public static InventoryItemBase CreateInventoryItem( + Scene scene, string itemName, UUID itemId, string folderPath, UUID userId) + { + InventoryItemBase item = new InventoryItemBase(); + item.Name = itemName; + item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID; + item.ID = itemId; + + // Really quite bad since the objs folder could be moved in the future and confuse the tests + InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); + + item.Folder = objsFolder.ID; + scene.AddInventoryItem(item); + + return item; + } + + /// + /// Create inventory folders starting from the user's root folder. + /// + /// + /// Ignores any existing folders with the same name + /// + /// + /// + /// + /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER + /// + /// + /// The folder created. If the path contains multiple folders then the last one created is returned. + /// Will return null if the root folder could not be found. + /// + public static InventoryFolderBase CreateInventoryFolder( + IInventoryService inventoryService, UUID userId, string path) + { + InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); + + if (null == rootFolder) + return null; + + return CreateInventoryFolder(inventoryService, rootFolder, path); + } + + /// + /// Create inventory folders starting from a given parent folder + /// + /// + /// Ignores any existing folders with the same name + /// + /// + /// + /// + /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER + /// + /// + /// The folder created. If the path contains multiple folders then the last one created is returned. + /// + public static InventoryFolderBase CreateInventoryFolder( + IInventoryService inventoryService, InventoryFolderBase parentFolder, string path) + { + string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); + + InventoryFolderBase newFolder + = new InventoryFolderBase(UUID.Random(), components[0], parentFolder.Owner, parentFolder.ID); + inventoryService.AddFolder(newFolder); + + if (components.Length > 1) + return CreateInventoryFolder(inventoryService, newFolder, components[1]); + else + return newFolder; + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs deleted file mode 100644 index aa55bcd..0000000 --- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Text; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Serialization; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common -{ - public class AssetHelpers - { - /// - /// Create a notecard asset with a random uuid and dummy text. - /// - /// /param> - /// - public static AssetBase CreateAsset(UUID creatorId) - { - return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId); - } - - /// - /// Create and store a notecard asset with a random uuid and dummy text. - /// - /// /param> - /// - public static AssetBase CreateAsset(Scene scene, UUID creatorId) - { - AssetBase asset = CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId); - scene.AssetService.Store(asset); - return asset; - } - - /// - /// Create an asset from the given object. - /// - /// - /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" - /// will be used. - /// - /// - /// - public static AssetBase CreateAsset(int assetUuidTail, SceneObjectGroup sog) - { - return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), sog); - } - - /// - /// Create an asset from the given object. - /// - /// - /// - /// - public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog) - { - return CreateAsset( - assetUuid, - AssetType.Object, - Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)), - sog.OwnerID); - } - - /// - /// Create an asset from the given scene object. - /// - /// - /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" - /// will be used. - /// - /// - /// - public static AssetBase CreateAsset(int assetUuidTail, CoalescedSceneObjects coa) - { - return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), coa); - } - - /// - /// Create an asset from the given scene object. - /// - /// - /// - /// - public static AssetBase CreateAsset(UUID assetUuid, CoalescedSceneObjects coa) - { - return CreateAsset( - assetUuid, - AssetType.Object, - Encoding.ASCII.GetBytes(CoalescedSceneObjectsSerializer.ToXml(coa)), - coa.CreatorId); - } - - /// - /// Create an asset from the given data. - /// - public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID) - { - return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID); - } - - /// - /// Create an asset from the given data. - /// - public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID) - { - AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString()); - asset.Data = data; - return asset; - } - - public static string ReadAssetAsString(IAssetService assetService, UUID uuid) - { - byte[] assetData = assetService.GetData(uuid.ToString()); - return Encoding.ASCII.GetString(assetData); - } - } -} diff --git a/OpenSim/Tests/Common/Setup/BaseRequestHandlerHelpers.cs b/OpenSim/Tests/Common/Setup/BaseRequestHandlerHelpers.cs deleted file mode 100644 index 286e6ff..0000000 --- a/OpenSim/Tests/Common/Setup/BaseRequestHandlerHelpers.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Tests.Common.Mock; - -namespace OpenSim.Tests.Common.Setup -{ - public class BaseRequestHandlerHelpers - { - private static string[] m_emptyStringArray = new string[] { }; - - public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath) - { - Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path."); - Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path."); - Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url."); - Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl."); - - Assert.AreEqual(String.Empty, handler.GetParam(assetsPath)); - Assert.AreEqual("/", handler.GetParam(assetsPath + "/")); - Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a")); - Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/")); - Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d")); - Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/")); - } - - public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath) - { - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url."); - - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash."); - - Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment."); - Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash."); - Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment."); - Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash."); - } - - public static byte[] EmptyByteArray = new byte[] {}; - - } -} diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs deleted file mode 100644 index d122409..0000000 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ /dev/null @@ -1,483 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Net; -using System.Collections.Generic; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Console; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Physics.Manager; -using OpenSim.Region.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.CoreModules.Avatar.Gods; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common.Mock; - -namespace OpenSim.Tests.Common.Setup -{ - /// - /// Helpers for setting up scenes. - /// - public class SceneSetupHelpers - { - /// - /// Set up a test scene - /// - /// - /// Automatically starts service threads, as would the normal runtime. - /// - /// - public static TestScene SetupScene() - { - return SetupScene("Unit test region", UUID.Random(), 1000, 1000); - } - - /// - /// 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. - /// - /// Name of the region - /// ID of the region - /// X co-ordinate of the region - /// Y co-ordinate of the region - /// This should be the same if simulating two scenes within a standalone - /// - public static TestScene SetupScene(string name, UUID id, uint x, uint y) - { - Console.WriteLine("Setting up test scene {0}", name); - - // We must set up a console otherwise setup of some modules may fail - MainConsole.Instance = new MockConsole("TEST PROMPT"); - - RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); - regInfo.RegionName = name; - regInfo.RegionID = id; - - AgentCircuitManager acm = new AgentCircuitManager(); - SceneCommunicationService scs = new SceneCommunicationService(); - - ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin("OpenSim.Tests.Common.dll", null); - IEstateDataService estateDataService = null; - IConfigSource configSource = new IniConfigSource(); - - TestScene testScene = new TestScene( - regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null); - - IRegionModule godsModule = new GodsModule(); - godsModule.Initialise(testScene, new IniConfigSource()); - testScene.AddModule(godsModule.Name, godsModule); - - LocalAssetServicesConnector assetService = StartAssetService(testScene); - StartAuthenticationService(testScene); - LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); - StartGridService(testScene); - LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); - LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); - - inventoryService.PostInitialise(); - assetService.PostInitialise(); - userAccountService.PostInitialise(); - presenceService.PostInitialise(); - - testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); - testScene.SetModuleInterfaces(); - - testScene.LandChannel = new TestLandChannel(testScene); - testScene.LoadWorldMap(); - - PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); - physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); - testScene.PhysicsScene - = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); - - testScene.RegionInfo.EstateSettings = new EstateSettings(); - testScene.LoginsDisabled = false; - - return testScene; - } - - private static LocalAssetServicesConnector StartAssetService(Scene testScene) - { - LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); - IConfigSource config = new IniConfigSource(); - - config.AddConfig("Modules"); - config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); - config.AddConfig("AssetService"); - config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); - config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); - - assetService.Initialise(config); - assetService.AddRegion(testScene); - assetService.RegionLoaded(testScene); - testScene.AddRegionModule(assetService.Name, assetService); - - return assetService; - } - - private static void StartAuthenticationService(Scene testScene) - { - ISharedRegionModule service = new LocalAuthenticationServicesConnector(); - IConfigSource config = new IniConfigSource(); - - config.AddConfig("Modules"); - config.AddConfig("AuthenticationService"); - config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); - config.Configs["AuthenticationService"].Set( - "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); - config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); - - service.Initialise(config); - service.AddRegion(testScene); - service.RegionLoaded(testScene); - testScene.AddRegionModule(service.Name, service); - //m_authenticationService = service; - } - - private static LocalInventoryServicesConnector StartInventoryService(Scene testScene) - { - LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); - - IConfigSource 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); - - return inventoryService; - } - - private static LocalGridServicesConnector StartGridService(Scene testScene) - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.AddConfig("GridService"); - config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); - config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); - config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); - - LocalGridServicesConnector gridService = new LocalGridServicesConnector(); - gridService.Initialise(config); - gridService.AddRegion(testScene); - gridService.RegionLoaded(testScene); - - return gridService; - } - - /// - /// Start a user account service - /// - /// - /// - private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.AddConfig("UserAccountService"); - config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector"); - config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); - config.Configs["UserAccountService"].Set( - "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); - - LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); - userAccountService.Initialise(config); - - userAccountService.AddRegion(testScene); - userAccountService.RegionLoaded(testScene); - testScene.AddRegionModule(userAccountService.Name, userAccountService); - - return userAccountService; - } - - /// - /// Start a presence service - /// - /// - private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.AddConfig("PresenceService"); - config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); - config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); - config.Configs["PresenceService"].Set( - "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); - - LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); - presenceService.Initialise(config); - - presenceService.AddRegion(testScene); - presenceService.RegionLoaded(testScene); - testScene.AddRegionModule(presenceService.Name, presenceService); - - return presenceService; - } - - /// - /// Setup modules for a scene using their default settings. - /// - /// - /// - public static void SetupSceneModules(Scene scene, params object[] modules) - { - SetupSceneModules(scene, new IniConfigSource(), modules); - } - - /// - /// Setup modules for a scene. - /// - /// - /// - /// - public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) - { - List newModules = new List(); - foreach (object module in modules) - { - if (module is IRegionModule) - { - IRegionModule m = (IRegionModule)module; - m.Initialise(scene, config); - scene.AddModule(m.Name, m); - m.PostInitialise(); - } - else if (module is IRegionModuleBase) - { - // for the new system, everything has to be initialised first, - // shared modules have to be post-initialised, then all get an AddRegion with the scene - IRegionModuleBase m = (IRegionModuleBase)module; - m.Initialise(config); - newModules.Add(m); - } - } - - foreach (IRegionModuleBase module in newModules) - { - if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise(); - } - - foreach (IRegionModuleBase module in newModules) - { - module.AddRegion(scene); - scene.AddRegionModule(module.Name, module); - } - - // RegionLoaded is fired after all modules have been appropriately added to all scenes - foreach (IRegionModuleBase module in newModules) - module.RegionLoaded(scene); - - scene.SetModuleInterfaces(); - } - - /// - /// Generate some standard agent connection data. - /// - /// - /// - public static AgentCircuitData GenerateAgentData(UUID agentId) - { - string firstName = "testfirstname"; - - AgentCircuitData agentData = new AgentCircuitData(); - agentData.AgentID = agentId; - agentData.firstname = firstName; - agentData.lastname = "testlastname"; - agentData.SessionID = UUID.Zero; - agentData.SecureSessionID = UUID.Zero; - agentData.circuitcode = 123; - agentData.BaseFolder = UUID.Zero; - agentData.InventoryFolder = UUID.Zero; - agentData.startpos = Vector3.Zero; - agentData.CapsPath = "http://wibble.com"; - - return agentData; - } - - /// - /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test - /// - /// - /// - /// - public static TestClient AddRootAgent(Scene scene, UUID agentId) - { - return AddRootAgent(scene, GenerateAgentData(agentId)); - } - - /// - /// Add a root agent. - /// - /// - /// This function - /// - /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the - /// userserver if grid) would give initial login data back to the client and separately tell the scene that the - /// agent was coming. - /// - /// 2) Connects the agent with the scene - /// - /// This function performs actions equivalent with notifying the scene that an agent is - /// coming and then actually connecting the agent to the scene. The one step missed out is the very first - /// - /// - /// - /// - public static TestClient AddRootAgent(Scene scene, AgentCircuitData agentData) - { - string reason; - - // We emulate the proper login sequence here by doing things in four stages - - // Stage 0: log the presence - scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); - - // Stage 1: simulate login by telling the scene to expect a new user connection - if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) - Console.WriteLine("NewUserConnection failed: " + reason); - - // Stage 2: add the new client as a child agent to the scene - TestClient client = new TestClient(agentData, scene); - scene.AddNewClient(client); - - // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. - ScenePresence scp = scene.GetScenePresence(agentData.AgentID); - scp.CompleteMovement(client); - //scp.MakeRootAgent(new Vector3(90, 90, 90), true); - - return client; - } - - /// - /// Add a test object - /// - /// - /// - public static SceneObjectPart AddSceneObject(Scene scene) - { - return AddSceneObject(scene, "Test Object"); - } - - /// - /// Add a test object - /// - /// - /// - /// - public static SceneObjectPart AddSceneObject(Scene scene, string name) - { - SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero); - - //part.UpdatePrimFlags(false, false, true); - //part.ObjectFlags |= (uint)PrimFlags.Phantom; - - scene.AddNewSceneObject(new SceneObjectGroup(part), false); - - return part; - } - - /// - /// Create a scene object part. - /// - /// - /// - /// - /// - public static SceneObjectPart CreateSceneObjectPart(string name, UUID id, UUID ownerId) - { - return new SceneObjectPart( - ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; - } - - /// - /// Create a scene object but do not add it to the scene. - /// - /// - /// UUID always starts at 00000000-0000-0000-0000-000000000001 - /// - /// The number of parts that should be in the scene object - /// - /// - public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) - { - return CreateSceneObject(parts, ownerId, "", 0x1); - } - - /// - /// Create a scene object but do not add it to the scene. - /// - /// - /// The number of parts that should be in the scene object - /// - /// - /// - /// The prefix to be given to part names. This will be suffixed with "Part" - /// (e.g. mynamePart0 for the root part) - /// - /// - /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" - /// will be given to the root part, and incremented for each part thereafter. - /// - /// - public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, string partNamePrefix, int uuidTail) - { - string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail); - - SceneObjectGroup sog - = new SceneObjectGroup( - CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId)); - - if (parts > 1) - for (int i = 1; i < parts; i++) - sog.AddPart( - CreateSceneObjectPart( - string.Format("{0}Part{1}", partNamePrefix, i), - new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)), - ownerId)); - - return sog; - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs deleted file mode 100644 index fbf00d6..0000000 --- a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common.Setup -{ - /// - /// Utility functions for carrying out task inventory tests. - /// - /// - public static class TaskInventoryHelpers - { - /// - /// Add a notecard item to the given part. - /// - /// - /// - /// The item that was added - public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part) - { - AssetNotecard nc = new AssetNotecard(); - nc.BodyText = "Hello World!"; - nc.Encode(); - UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); - UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); - AssetBase ncAsset - = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); - scene.AssetService.Store(ncAsset); - TaskInventoryItem ncItem - = new TaskInventoryItem - { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, - Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; - part.Inventory.AddInventoryItem(ncItem, true); - - return ncItem; - } - - /// - /// Add a scene object item to the given part. - /// - /// - /// - /// - /// - public static TaskInventoryItem AddSceneObject(Scene scene, SceneObjectPart sop, string itemName, UUID id) - { - SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero); - AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); - scene.AssetService.Store(taskSceneObjectAsset); - TaskInventoryItem taskSceneObjectItem - = new TaskInventoryItem - { Name = itemName, AssetID = taskSceneObjectAsset.FullID, ItemID = id, - Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; - sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); - - return taskSceneObjectItem; - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Setup/UserAccountHelpers.cs b/OpenSim/Tests/Common/Setup/UserAccountHelpers.cs deleted file mode 100644 index 346f78a..0000000 --- a/OpenSim/Tests/Common/Setup/UserAccountHelpers.cs +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework.Communications; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common.Setup -{ - /// - /// Utility functions for carrying out user profile related tests. - /// - public static class UserAccountHelpers - { -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, OnInventoryReceivedDelegate callback) -// { -// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); -// return CreateUserWithInventory(commsManager, userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) -// { -// return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// First name of user -// /// Last name of user -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, string firstName, string lastName, -// UUID userId, OnInventoryReceivedDelegate callback) -// { -// return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// First name of user -// /// Last name of user -// /// Password -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, string firstName, string lastName, string password, -// UUID userId, OnInventoryReceivedDelegate callback) -// { -// LocalUserServices lus = (LocalUserServices)commsManager.UserService; -// lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); -// -// CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); -// userInfo.OnInventoryReceived += callback; -// userInfo.FetchInventory(); -// -// return userInfo; -// } - - public static UserAccount CreateUserWithInventory(Scene scene) - { - return CreateUserWithInventory( - scene, "Bill", "Bailey", UUID.Parse("00000000-0000-0000-0000-000000000099"), "troll"); - } - - public static UserAccount CreateUserWithInventory( - Scene scene, string firstName, string lastName, UUID userId, string pw) - { - UserAccount ua - = new UserAccount(userId) - { FirstName = firstName, LastName = lastName }; - CreateUserWithInventory(scene, ua, pw); - return ua; - } - - public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) - { - // FIXME: This should really be set up by UserAccount itself - ua.ServiceURLs = new Dictionary(); - - scene.UserAccountService.StoreUserAccount(ua); - scene.InventoryService.CreateUserInventory(ua.PrincipalID); - scene.AuthenticationService.SetPassword(ua.PrincipalID, pw); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs deleted file mode 100644 index 0419134..0000000 --- a/OpenSim/Tests/Common/Setup/UserInventoryHelpers.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common -{ - /// - /// Utility functions for carrying out user inventory tests. - /// - public static class UserInventoryHelpers - { - public static readonly string PATH_DELIMITER = "/"; - - public static InventoryItemBase CreateInventoryItem( - Scene scene, string itemName, UUID itemId, string folderPath, UUID userId) - { - InventoryItemBase item = new InventoryItemBase(); - item.Name = itemName; - item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID; - item.ID = itemId; - - // Really quite bad since the objs folder could be moved in the future and confuse the tests - InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); - - item.Folder = objsFolder.ID; - scene.AddInventoryItem(item); - - return item; - } - - /// - /// Create inventory folders starting from the user's root folder. - /// - /// - /// Ignores any existing folders with the same name - /// - /// - /// - /// - /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER - /// - /// - /// The folder created. If the path contains multiple folders then the last one created is returned. - /// Will return null if the root folder could not be found. - /// - public static InventoryFolderBase CreateInventoryFolder( - IInventoryService inventoryService, UUID userId, string path) - { - InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); - - if (null == rootFolder) - return null; - - return CreateInventoryFolder(inventoryService, rootFolder, path); - } - - /// - /// Create inventory folders starting from a given parent folder - /// - /// - /// Ignores any existing folders with the same name - /// - /// - /// - /// - /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER - /// - /// - /// The folder created. If the path contains multiple folders then the last one created is returned. - /// - public static InventoryFolderBase CreateInventoryFolder( - IInventoryService inventoryService, InventoryFolderBase parentFolder, string path) - { - string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); - - InventoryFolderBase newFolder - = new InventoryFolderBase(UUID.Random(), components[0], parentFolder.Owner, parentFolder.ID); - inventoryService.AddFolder(newFolder); - - if (components.Length > 1) - return CreateInventoryFolder(inventoryService, newFolder, components[1]); - else - return newFolder; - } - } -} \ No newline at end of file -- cgit v1.1 From bb9b317f1521720a6da98c6f21735126d9c060ce Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 21 May 2011 01:05:20 +0100 Subject: Get rid of OpenSim.Tests.Common.Setup subpackage in favour of just OpenSim.Tests.Common instead --- OpenSim/Framework/Tests/AnimationTests.cs | 1 - .../Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | 1 - .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 1 - OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs | 1 - .../Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | 1 - .../CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | 1 - .../ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | 1 - OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | 1 - OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs | 1 - OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | 1 - OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 1 - OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | 1 - .../OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | 1 - OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 1 - OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | 1 - OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs | 2 +- OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs | 2 +- OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | 2 +- OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs | 2 +- 30 files changed, 4 insertions(+), 30 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs index 9aa95af..aa4c6aa 100644 --- a/OpenSim/Framework/Tests/AnimationTests.cs +++ b/OpenSim/Framework/Tests/AnimationTests.cs @@ -33,7 +33,6 @@ using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; using Animation = OpenSim.Framework.Animation; namespace OpenSim.Framework.Tests diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index 9421f22..aadeedb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs @@ -44,7 +44,6 @@ using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index db57d90..d97311a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -44,7 +44,6 @@ using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index 7e15a3d..127d5f8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs @@ -44,7 +44,6 @@ using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index 75faab0..733ad25 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs @@ -45,7 +45,6 @@ using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 18db9fa..c044407 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -40,7 +40,6 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; using OpenSim.Region.Framework.Scenes; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Tests.Common; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index e471f75..4556df3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs @@ -40,7 +40,6 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; using OpenSim.Region.Framework.Scenes; using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; using OpenSim.Tests.Common; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests { diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 729e9f7..2eb2861 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -43,7 +43,6 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; using ArchiveConstants = OpenSim.Framework.Serialization.ArchiveConstants; using TarArchiveReader = OpenSim.Framework.Serialization.TarArchiveReader; using TarArchiveWriter = OpenSim.Framework.Serialization.TarArchiveWriter; diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 67b00ac..a3aa38d 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -37,7 +37,6 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.World.Land.Tests { diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index 5b85830..d5b7082 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs @@ -40,7 +40,6 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests { diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index a866fd9..4f752ab 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -35,7 +35,6 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Tests.Common; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.World.Serialiser.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs index 855b589..cff649b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs @@ -43,7 +43,6 @@ using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Scenes.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index 667b74e..f69a4b4 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs @@ -37,7 +37,6 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Scenes.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index ca635d7..895f2bb 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs @@ -34,7 +34,6 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Scenes.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index a6a95ef..0a82c4f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -34,7 +34,6 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Scenes.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 0d26026..5357a06 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs @@ -37,7 +37,6 @@ using OpenSim.Region.CoreModules.World.Permissions; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Scenes.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index bdfcd1d..cb1d531 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs @@ -35,7 +35,6 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; using log4net; namespace OpenSim.Region.Framework.Scenes.Tests diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index 8876a43..77bd4c2 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs @@ -40,7 +40,6 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Scenes.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index efb757f..03ac252 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs @@ -44,7 +44,6 @@ using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Scenes.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index abcce66..13d93f9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs @@ -43,7 +43,6 @@ using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Scenes.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs index dd28416..1b5a54e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs @@ -36,7 +36,6 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; using System.Threading; namespace OpenSim.Region.Framework.Scenes.Tests diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 74eab63..f4e14d4 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -46,7 +46,6 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.Framework.Tests { diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index dbf9e0f..4da8df1 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -33,7 +33,6 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; -using OpenSim.Tests.Common.Setup; using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Scenes.Tests diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index 6de97b7..ee52a39 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs @@ -35,7 +35,6 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests { diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 1d55b95..80b60a4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -29,7 +29,6 @@ using System.Collections.Generic; using NUnit.Framework; using OpenSim.Tests.Common; using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Tests.Common.Setup; using OpenSim.Region.Framework.Scenes; using Nini.Config; using OpenSim.Region.ScriptEngine.Shared.Api; diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index 045abb4..b635d5c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using Nini.Config; using NUnit.Framework; -using OpenSim.Tests.Common.Setup; using OpenSim.Tests.Common.Mock; using OpenSim.Region.Framework.Scenes; using OpenMetaverse; diff --git a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs index 286e6ff..49c99c5 100644 --- a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs @@ -34,7 +34,7 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Tests.Common.Mock; -namespace OpenSim.Tests.Common.Setup +namespace OpenSim.Tests.Common { public class BaseRequestHandlerHelpers { diff --git a/OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs index d122409..bef0481 100644 --- a/OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneSetupHelpers.cs @@ -49,7 +49,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common.Mock; -namespace OpenSim.Tests.Common.Setup +namespace OpenSim.Tests.Common { /// /// Helpers for setting up scenes. diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index fbf00d6..5215c34 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs @@ -32,7 +32,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -namespace OpenSim.Tests.Common.Setup +namespace OpenSim.Tests.Common { /// /// Utility functions for carrying out task inventory tests. diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs index 346f78a..8cfad79 100644 --- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs @@ -31,7 +31,7 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -namespace OpenSim.Tests.Common.Setup +namespace OpenSim.Tests.Common { /// /// Utility functions for carrying out user profile related tests. -- cgit v1.1