diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 0b0a6385d0..94e2da4d25 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -47,6 +47,11 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private object m_dbLock = new object(); + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + #region IPlugin Members public override string Version { get { return "1.0.0.0"; } } @@ -66,13 +71,10 @@ namespace OpenSim.Data.MySQL { m_connectionString = connect; - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - Migration m = new Migration(dbcon, assem, "AssetStore"); + Migration m = new Migration(dbcon, Assembly, "AssetStore"); m.Update(); } } diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 5056aee6c1..8d82f61bda 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Reflection; using System.Data; using OpenMetaverse; using OpenSim.Framework; @@ -42,6 +43,11 @@ namespace OpenSim.Data.MySQL private int m_LastExpire; // private string m_connectionString; + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySqlAuthenticationData(string connectionString, string realm) : base(connectionString) { @@ -51,7 +57,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); + Migration m = new Migration(dbcon, Assembly, "AuthStore"); m.Update(); } } diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index c42c687ed9..de72a6a931 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -54,6 +54,11 @@ namespace OpenSim.Data.MySQL private Dictionary m_FieldMap = new Dictionary(); + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySQLEstateStore() { } @@ -82,8 +87,7 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - Assembly assem = GetType().Assembly; - Migration m = new Migration(dbcon, assem, "EstateStore"); + Migration m = new Migration(dbcon, Assembly, "EstateStore"); m.Update(); Type t = typeof(EstateSettings); diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 7c23a47d04..8efe4e9bd6 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -46,6 +46,11 @@ namespace OpenSim.Data.MySQL protected string m_Realm; protected FieldInfo m_DataField = null; + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySQLGenericTableHandler(string connectionString, string realm, string storeName) : base(connectionString) { @@ -57,7 +62,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - Migration m = new Migration(dbcon, GetType().Assembly, storeName); + Migration m = new Migration(dbcon, Assembly, storeName); m.Update(); } } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index d04e3dc996..c20c39263a 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -29,6 +29,8 @@ using System; using System.Collections; using System.Collections.Generic; using System.Data; +using System.Reflection; + using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; @@ -42,6 +44,11 @@ namespace OpenSim.Data.MySQL private List m_ColumnNames; //private string m_connectionString; + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySqlRegionData(string connectionString, string realm) : base(connectionString) { @@ -51,7 +58,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - Migration m = new Migration(dbcon, GetType().Assembly, "GridStore"); + Migration m = new Migration(dbcon, Assembly, "GridStore"); m.Update(); } } diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 02997b3278..e14d775b45 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -52,6 +52,11 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private object m_dbLock = new object(); + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySQLSimulationData() { } @@ -71,8 +76,7 @@ namespace OpenSim.Data.MySQL // Apply new Migrations // - Assembly assem = GetType().Assembly; - Migration m = new Migration(dbcon, assem, "RegionStore"); + Migration m = new Migration(dbcon, Assembly, "RegionStore"); m.Update(); // Clean dropped attachments diff --git a/OpenSim/Data/Null/NullUserAccountData.cs b/OpenSim/Data/Null/NullUserAccountData.cs index 772d821731..241616ba3c 100644 --- a/OpenSim/Data/Null/NullUserAccountData.cs +++ b/OpenSim/Data/Null/NullUserAccountData.cs @@ -28,6 +28,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Reflection; +using System.Text; +using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; @@ -36,12 +39,17 @@ namespace OpenSim.Data.Null { public class NullUserAccountData : IUserAccountData { - private static Dictionary m_DataByUUID = new Dictionary(); - private static Dictionary m_DataByName = new Dictionary(); - private static Dictionary m_DataByEmail = new Dictionary(); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Dictionary m_DataByUUID = new Dictionary(); + private Dictionary m_DataByName = new Dictionary(); + private Dictionary m_DataByEmail = new Dictionary(); public NullUserAccountData(string connectionString, string realm) { +// m_log.DebugFormat( +// "[NULL USER ACCOUNT DATA]: Initializing new NullUserAccountData with connectionString [{0}], realm [{1}]", +// connectionString, realm); } /// @@ -54,6 +62,15 @@ namespace OpenSim.Data.Null /// public UserAccountData[] Get(string[] fields, string[] values) { +// if (m_log.IsDebugEnabled) +// { +// m_log.DebugFormat( +// "[NULL USER ACCOUNT DATA]: Called Get with fields [{0}], values [{1}]", +// string.Join(", ", fields), string.Join(", ", values)); +// } + + UserAccountData[] userAccounts = new UserAccountData[0]; + List fieldsLst = new List(fields); if (fieldsLst.Contains("PrincipalID")) { @@ -61,41 +78,61 @@ namespace OpenSim.Data.Null UUID id = UUID.Zero; if (UUID.TryParse(values[i], out id)) if (m_DataByUUID.ContainsKey(id)) - return new UserAccountData[] { m_DataByUUID[id] }; - } - if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName")) + userAccounts = new UserAccountData[] { m_DataByUUID[id] }; + } + else if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName")) { int findex = fieldsLst.IndexOf("FirstName"); int lindex = fieldsLst.IndexOf("LastName"); if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex])) - return new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] }; - } - if (fieldsLst.Contains("Email")) + { + userAccounts = new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] }; + } + } + else if (fieldsLst.Contains("Email")) { int i = fieldsLst.IndexOf("Email"); if (m_DataByEmail.ContainsKey(values[i])) - return new UserAccountData[] { m_DataByEmail[values[i]] }; + userAccounts = new UserAccountData[] { m_DataByEmail[values[i]] }; } - - // Fail - return new UserAccountData[0]; + +// if (m_log.IsDebugEnabled) +// { +// StringBuilder sb = new StringBuilder(); +// foreach (UserAccountData uad in userAccounts) +// sb.AppendFormat("({0} {1} {2}) ", uad.FirstName, uad.LastName, uad.PrincipalID); +// +// m_log.DebugFormat( +// "[NULL USER ACCOUNT DATA]: Returning {0} user accounts out of {1}: [{2}]", userAccounts.Length, m_DataByName.Count, sb); +// } + + return userAccounts; } public bool Store(UserAccountData data) { if (data == null) return false; - + + m_log.DebugFormat( + "[NULL USER ACCOUNT DATA]: Storing user account {0} {1} {2} {3}", + data.FirstName, data.LastName, data.PrincipalID, this.GetHashCode()); + m_DataByUUID[data.PrincipalID] = data; m_DataByName[data.FirstName + " " + data.LastName] = data; if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty) m_DataByEmail[data.Data["Email"]] = data; + +// m_log.DebugFormat("m_DataByUUID count is {0}, m_DataByName count is {1}", m_DataByUUID.Count, m_DataByName.Count); return true; } public UserAccountData[] GetUsers(UUID scopeID, string query) { +// m_log.DebugFormat( +// "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query); + string[] words = query.Split(new char[] { ' ' }); for (int i = 0; i < words.Length; i++) diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs index 800b9bfba2..32f74a9b1e 100644 --- a/OpenSim/Data/Tests/AssetTests.cs +++ b/OpenSim/Data/Tests/AssetTests.cs @@ -35,10 +35,6 @@ using OpenSim.Framework; using System.Data.Common; using log4net; -#if !NUNIT25 -using NUnit.Framework.SyntaxHelpers; -#endif - // DBMS-specific: using MySql.Data.MySqlClient; using OpenSim.Data.MySQL; @@ -51,15 +47,6 @@ using OpenSim.Data.SQLite; namespace OpenSim.Data.Tests { - -#if NUNIT25 - - [TestFixture(typeof(MySqlConnection), typeof(MySQLAssetData), Description="Basic Asset store tests (MySQL)")] - [TestFixture(typeof(SqlConnection), typeof(MSSQLAssetData), Description = "Basic Asset store tests (MS SQL Server)")] - [TestFixture(typeof(SqliteConnection), typeof(SQLiteAssetData), Description = "Basic Asset store tests (SQLite)")] - -#else - [TestFixture(Description = "Asset store tests (SQLite)")] public class SQLiteAssetTests : AssetTests { @@ -75,9 +62,6 @@ namespace OpenSim.Data.Tests { } -#endif - - public class AssetTests : BasicDataServiceTest where TConn : DbConnection, new() where TAssetData : AssetDataBase, new() @@ -218,4 +202,4 @@ namespace OpenSim.Data.Tests Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs index fbf8ba658e..3354e284da 100644 --- a/OpenSim/Data/Tests/EstateTests.cs +++ b/OpenSim/Data/Tests/EstateTests.cs @@ -28,7 +28,6 @@ using System; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -49,15 +48,6 @@ using OpenSim.Data.SQLite; namespace OpenSim.Data.Tests { - -#if NUNIT25 - - [TestFixture(typeof(MySqlConnection), typeof(MySQLEstateStore), Description = "Estate store tests (MySQL)")] - [TestFixture(typeof(SqlConnection), typeof(MSSQLEstateStore), Description = "Estate store tests (MS SQL Server)")] - [TestFixture(typeof(SqliteConnection), typeof(SQLiteEstateStore), Description = "Estate store tests (SQLite)")] - -#else - [TestFixture(Description = "Estate store tests (SQLite)")] public class SQLiteEstateTests : EstateTests { @@ -73,8 +63,6 @@ namespace OpenSim.Data.Tests { } -#endif - public class EstateTests : BasicDataServiceTest where TConn : DbConnection, new() where TEstateStore : class, IEstateDataStore, new() @@ -520,6 +508,5 @@ namespace OpenSim.Data.Tests } #endregion - } -} +} \ No newline at end of file diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs index 9c2a2d6fd5..758f9704b7 100644 --- a/OpenSim/Data/Tests/InventoryTests.cs +++ b/OpenSim/Data/Tests/InventoryTests.cs @@ -25,12 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// #define NUNIT25 - using System; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using log4net; @@ -49,14 +46,6 @@ using OpenSim.Data.SQLite; namespace OpenSim.Data.Tests { -#if NUNIT25 - - [TestFixture(typeof(SqliteConnection), typeof(SQLiteInventoryStore), Description = "Inventory store tests (SQLite)")] - [TestFixture(typeof(MySqlConnection), typeof(MySQLInventoryData), Description = "Inventory store tests (MySQL)")] - [TestFixture(typeof(SqlConnection), typeof(MSSQLInventoryData), Description = "Inventory store tests (MS SQL Server)")] - -#else - [TestFixture(Description = "Inventory store tests (SQLite)")] public class SQLiteInventoryTests : InventoryTests { @@ -71,7 +60,6 @@ namespace OpenSim.Data.Tests public class MSSQLInventoryTests : InventoryTests { } -#endif public class InventoryTests : BasicDataServiceTest where TConn : DbConnection, new() diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs index f3d41df586..6c79bda9ec 100644 --- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs +++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs @@ -34,7 +34,6 @@ using System.Linq.Expressions; using System.Reflection; using NUnit.Framework; using NUnit.Framework.Constraints; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs index 132294ad30..c5d40c2373 100644 --- a/OpenSim/Data/Tests/PropertyScrambler.cs +++ b/OpenSim/Data/Tests/PropertyScrambler.cs @@ -32,13 +32,11 @@ using System.Linq.Expressions; using System.Reflection; using System.Text; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; namespace OpenSim.Data.Tests { - //This is generic so that the lambda expressions will work right in IDEs. public class PropertyScrambler { diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs index 23d498d6fa..9598716e0d 100644 --- a/OpenSim/Data/Tests/RegionTests.cs +++ b/OpenSim/Data/Tests/RegionTests.cs @@ -31,7 +31,6 @@ using System.Drawing; using System.Text; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -52,14 +51,6 @@ using OpenSim.Data.SQLite; namespace OpenSim.Data.Tests { -#if NUNIT25 - - [TestFixture(typeof(SqliteConnection), typeof(SQLiteRegionData), Description = "Region store tests (SQLite)")] - [TestFixture(typeof(MySqlConnection), typeof(MySqlRegionData), Description = "Region store tests (MySQL)")] - [TestFixture(typeof(SqlConnection), typeof(MSSQLRegionData), Description = "Region store tests (MS SQL Server)")] - -#else - [TestFixture(Description = "Region store tests (SQLite)")] public class SQLiteRegionTests : RegionTests { @@ -75,8 +66,6 @@ namespace OpenSim.Data.Tests { } -#endif - public class RegionTests : BasicDataServiceTest where TConn : DbConnection, new() where TRegStore : class, ISimulationDataStore, new() diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 9a38f23bc4..44f484e73d 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -250,7 +250,7 @@ namespace OpenSim.Framework { get { - //m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); +// m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); } catch { } diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs index 7e3dd1b79b..d31d27c4a6 100644 --- a/OpenSim/Framework/Serialization/External/OspResolver.cs +++ b/OpenSim/Framework/Serialization/External/OspResolver.cs @@ -66,6 +66,8 @@ namespace OpenSim.Framework.Serialization UserAccount account = userService.GetUserAccount(UUID.Zero, userId); if (account != null) return MakeOspa(account.FirstName, account.LastName); +// else +// m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId); return null; } @@ -77,6 +79,8 @@ namespace OpenSim.Framework.Serialization /// public static string MakeOspa(string firstName, string lastName) { +// m_log.DebugFormat("[OSP RESOLVER]: Making OSPA for {0} {1}", firstName, lastName); + return OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; } @@ -97,7 +101,10 @@ namespace OpenSim.Framework.Serialization public static UUID ResolveOspa(string ospa, IUserAccountService userService) { if (!ospa.StartsWith(OSPA_PREFIX)) - return UUID.Zero; + { +// m_log.DebugFormat("[OSP RESOLVER]: ResolveOspa() got unrecognized format [{0}]", ospa); + return UUID.Zero; + } // m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); @@ -161,7 +168,17 @@ namespace OpenSim.Framework.Serialization UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); if (account != null) + { +// m_log.DebugFormat( +// "[OSP RESOLVER]: Found user account with uuid {0} for {1} {2}", +// account.PrincipalID, firstName, lastName); + return account.PrincipalID; + } +// else +// { +// m_log.DebugFormat("[OSP RESOLVER]: No resolved OSPA user account for {0}", name); +// } // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc /* diff --git a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs index e62407adfa..dc4eb8f4bf 100644 --- a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs +++ b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs @@ -34,7 +34,6 @@ using System.Text; using HttpServer; using HttpServer.FormDecoders; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Framework.Servers.Tests diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs index 719ddce306..9aa95afa43 100644 --- a/OpenSim/Framework/Tests/AnimationTests.cs +++ b/OpenSim/Framework/Tests/AnimationTests.cs @@ -28,7 +28,6 @@ using System; using System.Reflection; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenSim.Framework; diff --git a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs index d741f9116d..36bc6e75f9 100644 --- a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs +++ b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs @@ -28,7 +28,6 @@ using System; using System.Reflection; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenSim.Framework; @@ -38,8 +37,6 @@ namespace OpenSim.Framework.Tests [TestFixture] public class PrimeNumberHelperTests { - - [Test] public void TestGetPrime() { diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index 89f5c0cba9..5eac411944 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs @@ -27,7 +27,6 @@ using System; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Tests.Common; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 603070614c..7849d88320 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -400,6 +400,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); if (UUID.Zero != ospResolvedId) // The user exists in this grid { +// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId); + item.CreatorIdAsUuid = ospResolvedId; // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index a71def7e04..613f0ed148 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver scene.AddCommand( this, "load iar", - "load iar [--merge] []", + "load iar [-m|--merge] []", "Load user inventory archive (IAR).", - "--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" + "-m|--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" + " is user's first name." + Environment.NewLine + " is user's last name." + Environment.NewLine + " is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine @@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver catch (EntryPointNotFoundException e) { m_log.ErrorFormat( - "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); m_log.Error(e); @@ -221,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver catch (EntryPointNotFoundException e) { m_log.ErrorFormat( - "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); m_log.Error(e); @@ -269,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver catch (EntryPointNotFoundException e) { m_log.ErrorFormat( - "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); m_log.Error(e); @@ -317,7 +317,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver catch (EntryPointNotFoundException e) { m_log.ErrorFormat( - "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); m_log.Error(e); @@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (mainParams.Count < 6) { m_log.Error( - "[INVENTORY ARCHIVER]: usage is load iar [--merge] []"); + "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] []"); return; } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs new file mode 100644 index 0000000000..dcafc49ee4 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs @@ -0,0 +1,155 @@ +/* + * 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.IO; +using System.Reflection; +using System.Threading; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Serialization; +using OpenSim.Framework.Serialization.External; +using OpenSim.Framework.Communications; +using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; +using OpenSim.Region.CoreModules.World.Serialiser; +using OpenSim.Region.Framework.Scenes; +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 +{ + [TestFixture] + public class InventoryArchiveTestCase + { + protected ManualResetEvent mre = new ManualResetEvent(false); + + /// + /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test. + /// + protected byte[] m_iarStreamBytes; + + /// + /// Stream of data representing a common IAR for load tests. + /// + protected MemoryStream m_iarStream; + + protected UserAccount m_ua1 + = new UserAccount { + PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), + FirstName = "Mr", + LastName = "Tiddles" }; + protected UserAccount m_ua2 + = new UserAccount { + PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), + FirstName = "Lord", + LastName = "Lucan" }; + protected UserAccount m_ua3 + = new UserAccount { + PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"), + FirstName = "Lord", + LastName = "Lucan" }; + protected string m_item1Name = "Ray Gun Item"; + + [SetUp] + public void SetUp() + { + m_iarStream = new MemoryStream(m_iarStreamBytes); + } + + [TestFixtureSetUp] + public void FixtureSetup() + { + ConstructDefaultIarBytesForTestLoad(); + } + + protected void ConstructDefaultIarBytesForTestLoad() + { +// log4net.Config.XmlConfigurator.Configure(); + + Scene scene = SceneSetupHelpers.SetupScene("Inventory"); + UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); + + MemoryStream archiveWriteStream = new MemoryStream(); + TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); + + // Create asset + SceneObjectGroup object1; + SceneObjectPart part1; + { + string partName = "Ray Gun Object"; + UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); + PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); + Vector3 groupPosition = new Vector3(10, 20, 30); + Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); + Vector3 offsetPosition = new Vector3(5, 10, 15); + + part1 + = new SceneObjectPart( + ownerId, shape, groupPosition, rotationOffset, offsetPosition); + part1.Name = partName; + + object1 = new SceneObjectGroup(part1); + scene.AddNewSceneObject(object1, false); + } + + UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); + AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); + scene.AssetService.Store(asset1); + + // Create item + InventoryItemBase item1 = new InventoryItemBase(); + item1.Name = m_item1Name; + item1.AssetID = asset1.FullID; + item1.GroupID = UUID.Random(); + item1.CreatorIdAsUuid = m_ua2.PrincipalID; + item1.Owner = UUID.Zero; + + string archiveItem1Name = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random()); + string archiveItem1Path = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItem1Name); + tar.WriteFile( + archiveItem1Path, + UserInventoryItemSerializer.Serialize( + item1, new Dictionary(), scene.UserAccountService)); + tar.Close(); + + m_iarStreamBytes = archiveWriteStream.ToArray(); + } + + protected void SaveCompleted( + Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, + Exception reportedException) + { + mre.Set(); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 76d0b85774..b52014b12a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -31,7 +31,6 @@ using System.IO; using System.Reflection; using System.Threading; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Data; using OpenSim.Framework; @@ -50,184 +49,8 @@ using OpenSim.Tests.Common.Setup; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { [TestFixture] - public class InventoryArchiverTests - { - protected ManualResetEvent mre = new ManualResetEvent(false); - - /// - /// Stream of data representing a common IAR that can be reused in load tests. - /// - protected MemoryStream m_iarStream; - - protected UserAccount m_ua1 - = new UserAccount { - PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), - FirstName = "Mr", - LastName = "Tiddles" }; - protected UserAccount m_ua2 - = new UserAccount { - PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), - FirstName = "Lord", - LastName = "Lucan" }; - string m_item1Name = "b.lsl"; - - private void SaveCompleted( - Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, - Exception reportedException) - { - mre.Set(); - } - - [SetUp] - public void Init() - { - ConstructDefaultIarForTestLoad(); - } - - protected void ConstructDefaultIarForTestLoad() - { - string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random()); - - MemoryStream archiveWriteStream = new MemoryStream(); - TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); - - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = m_item1Name; - item1.AssetID = UUID.Random(); - item1.GroupID = UUID.Random(); - //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName); - //item1.CreatorId = userUuid.ToString(); - item1.CreatorId = m_ua2.PrincipalID.ToString(); - item1.Owner = UUID.Zero; - - Scene scene = SceneSetupHelpers.SetupScene("Inventory"); - UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); - - string item1FileName - = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); - tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary(), scene.UserAccountService)); - tar.Close(); - m_iarStream = new MemoryStream(archiveWriteStream.ToArray()); - } - - /// - /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive - /// (subject to change since there is no fixed format yet). - /// - [Test] - public void TestSavePathToIarV0_1() - { - TestHelper.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - - Scene scene = SceneSetupHelpers.SetupScene("Inventory"); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule); - - // Create user - string userFirstName = "Jock"; - string userLastName = "Stirrup"; - string userPassword = "troll"; - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); - - // Create asset - SceneObjectGroup object1; - SceneObjectPart part1; - { - string partName = "My Little Dog Object"; - UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); - PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); - Vector3 groupPosition = new Vector3(10, 20, 30); - Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); - Vector3 offsetPosition = new Vector3(5, 10, 15); - - part1 - = new SceneObjectPart( - ownerId, shape, groupPosition, rotationOffset, offsetPosition); - part1.Name = partName; - - object1 = new SceneObjectGroup(part1); - scene.AddNewSceneObject(object1, false); - } - - UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); - scene.AssetService.Store(asset1); - - // Create item - UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = "My Little Dog"; - item1.AssetID = asset1.FullID; - item1.ID = item1Id; - InventoryFolderBase objsFolder - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; - item1.Folder = objsFolder.ID; - scene.AddInventoryItem(item1); - - MemoryStream archiveWriteStream = new MemoryStream(); - archiverModule.OnInventoryArchiveSaved += SaveCompleted; - - // Test saving a particular path - mre.Reset(); - archiverModule.ArchiveInventory( - Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); - mre.WaitOne(60000, false); - - byte[] archive = archiveWriteStream.ToArray(); - MemoryStream archiveReadStream = new MemoryStream(archive); - TarArchiveReader tar = new TarArchiveReader(archiveReadStream); - - //bool gotControlFile = false; - bool gotObject1File = false; - //bool gotObject2File = false; - string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); - string expectedObject1FilePath = string.Format( - "{0}{1}{2}", - ArchiveConstants.INVENTORY_PATH, - InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), - expectedObject1FileName); - - string filePath; - TarArchiveReader.TarEntryType tarEntryType; - -// Console.WriteLine("Reading archive"); - - while (tar.ReadEntry(out filePath, out tarEntryType) != null) - { -// Console.WriteLine("Got {0}", filePath); - -// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) -// { -// gotControlFile = true; -// } - - if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) - { -// string fileName = filePath.Remove(0, "Objects/".Length); -// -// if (fileName.StartsWith(part1.Name)) -// { - Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); - gotObject1File = true; -// } -// else if (fileName.StartsWith(part2.Name)) -// { -// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); -// gotObject2File = true; -// } - } - } - -// Assert.That(gotControlFile, Is.True, "No control file in archive"); - Assert.That(gotObject1File, Is.True, "No item1 file in archive"); -// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); - - // TODO: Test presence of more files and contents of files. - } - + public class InventoryArchiverTests : InventoryArchiveTestCase + { /// /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive /// (subject to change since there is no fixed format yet). @@ -346,41 +169,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } /// - /// Test that things work when the load path specified starts with a slash + /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where + /// an account exists with the same name as the creator, though not the same id. /// [Test] - public void TestLoadIarPathStartsWithSlash() + public void TestLoadIarV0_1SameNameCreator() { TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - SerialiserModule serialiserModule = new SerialiserModule(); - InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - Scene scene = SceneSetupHelpers.SetupScene("inventory"); - SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - - UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password"); - archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream); - - InventoryItemBase foundItem1 - = InventoryArchiveUtils.FindItemByPath( - scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); - - Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); - } - - /// - /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where - /// an account exists with the creator name. - /// - /// - /// This test also does some deeper probing of loading into nested inventory structures - [Test] - public void TestLoadIarV0_1ExistingUsers() - { - TestHelper.InMethod(); - //log4net.Config.XmlConfigurator.Configure(); - SerialiserModule serialiserModule = new SerialiserModule(); InventoryArchiverModule archiverModule = new InventoryArchiverModule(); @@ -390,14 +187,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); - UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); + UserProfileTestUtils.CreateUserWithInventory(scene, m_ua3, "hampshire"); - archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); - + archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); InventoryItemBase foundItem1 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); - - Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); // We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the // UUID, not the OSPA itself. @@ -405,415 +199,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), // "Loaded item non-uuid creator doesn't match original"); Assert.That( - foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()), - "Loaded item non-uuid creator doesn't match original"); - + foundItem1.CreatorId, Is.EqualTo(m_ua3.PrincipalID.ToString()), + "Loaded item non-uuid creator doesn't match original"); Assert.That( - foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID), + foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua3.PrincipalID), "Loaded item uuid creator doesn't match original"); Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), "Loaded item owner doesn't match inventory reciever"); - - // Now try loading to a root child folder - UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA"); - MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); - archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream); - - InventoryItemBase foundItem2 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name); - 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_ua1.PrincipalID, "xB/xC"); - archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); - archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream); - - InventoryItemBase foundItem3 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name); - Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); - } - - [Test] - public void TestIarV0_1WithEscapedChars() - { - TestHelper.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - string itemName = "You & you are a mean/man/"; - string humanEscapedItemName = @"You & you are a mean\/man\/"; - string userPassword = "meowfood"; - - InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - - Scene scene = SceneSetupHelpers.SetupScene("Inventory"); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule); - - // Create user - string userFirstName = "Jock"; - string userLastName = "Stirrup"; - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood"); - - // Create asset - SceneObjectGroup object1; - SceneObjectPart part1; - { - string partName = "part name"; - UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); - PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); - Vector3 groupPosition = new Vector3(10, 20, 30); - Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); - Vector3 offsetPosition = new Vector3(5, 10, 15); - - part1 - = new SceneObjectPart( - ownerId, shape, groupPosition, rotationOffset, offsetPosition); - part1.Name = partName; - - object1 = new SceneObjectGroup(part1); - scene.AddNewSceneObject(object1, false); - } - - UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); - scene.AssetService.Store(asset1); - - // Create item - UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = itemName; - item1.AssetID = asset1.FullID; - item1.ID = item1Id; - InventoryFolderBase objsFolder - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; - item1.Folder = objsFolder.ID; - scene.AddInventoryItem(item1); - - MemoryStream archiveWriteStream = new MemoryStream(); - archiverModule.OnInventoryArchiveSaved += SaveCompleted; - - mre.Reset(); - archiverModule.ArchiveInventory( - Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); - mre.WaitOne(60000, false); - - // LOAD ITEM - MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); - - archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); - - InventoryItemBase foundItem1 - = InventoryArchiveUtils.FindItemByPath( - scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); - - Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); -// Assert.That( -// foundItem1.CreatorId, Is.EqualTo(userUuid), -// "Loaded item non-uuid creator doesn't match that of the loading user"); - Assert.That( - foundItem1.Name, Is.EqualTo(itemName), - "Loaded item name doesn't match saved name"); } /// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where - /// embedded creators do not exist in the system + /// the creator or an account with the creator's name does not exist within the system. /// - /// - /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature - /// (as tested in the a later commented out test) - /// This test is currently disabled [Test] - public void TestLoadIarV0_1AbsentUsers() + public void TestLoadIarV0_1AbsentCreator() { TestHelper.InMethod(); - //log4net.Config.XmlConfigurator.Configure(); +// log4net.Config.XmlConfigurator.Configure(); - string userFirstName = "Charlie"; - string userLastName = "Chan"; - UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999"); - string userItemCreatorFirstName = "Bat"; - string userItemCreatorLastName = "Man"; - //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888"); - - string itemName = "b.lsl"; - string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); - - MemoryStream archiveWriteStream = new MemoryStream(); - TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); - - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = itemName; - item1.AssetID = UUID.Random(); - item1.GroupID = UUID.Random(); - item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); - //item1.CreatorId = userUuid.ToString(); - //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; - item1.Owner = UUID.Zero; - - string item1FileName - = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); - tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary(), null)); - tar.Close(); - - MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); SerialiserModule serialiserModule = new SerialiserModule(); InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - - // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene Scene scene = SceneSetupHelpers.SetupScene("inventory"); - SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood"); - archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); + UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password"); + archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "password", m_iarStream); InventoryItemBase foundItem1 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName); + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); // Assert.That( // foundItem1.CreatorId, Is.EqualTo(userUuid), // "Loaded item non-uuid creator doesn't match that of the loading user"); Assert.That( - foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), + foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua1.PrincipalID), "Loaded item uuid creator doesn't match that of the loading user"); } - - /// - /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where - /// no account exists with the creator name - /// - /// Disabled since temporary profiles have not yet been implemented. - /// - //[Test] - //public void TestLoadIarV0_1TempProfiles() - //{ - // TestHelper.InMethod(); - - // //log4net.Config.XmlConfigurator.Configure(); - - // string userFirstName = "Dennis"; - // string userLastName = "Menace"; - // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); - // string user2FirstName = "Walter"; - // string user2LastName = "Mitty"; - - // string itemName = "b.lsl"; - // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); - - // MemoryStream archiveWriteStream = new MemoryStream(); - // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); - - // InventoryItemBase item1 = new InventoryItemBase(); - // item1.Name = itemName; - // item1.AssetID = UUID.Random(); - // item1.GroupID = UUID.Random(); - // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName); - // item1.Owner = UUID.Zero; - - // string item1FileName - // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); - // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); - // tar.Close(); - - // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); - // SerialiserModule serialiserModule = new SerialiserModule(); - // InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - - // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene - // Scene scene = SceneSetupHelpers.SetupScene(); - // IUserAdminService userAdminService = scene.CommsManager.UserAdminService; - - // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - // userAdminService.AddUser( - // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); - - // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); - - // // Check that a suitable temporary user profile has been created. - // UserProfileData user2Profile - // = scene.CommsManager.UserService.GetUserProfile( - // OspResolver.HashName(user2FirstName + " " + user2LastName)); - // Assert.That(user2Profile, Is.Not.Null); - // Assert.That(user2Profile.FirstName == user2FirstName); - // Assert.That(user2Profile.SurName == user2LastName); - - // CachedUserInfo userInfo - // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); - // userInfo.OnInventoryReceived += InventoryReceived; - - // lock (this) - // { - // userInfo.FetchInventory(); - // Monitor.Wait(this, 60000); - // } - - // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); - - // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); - // Assert.That( - // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName))); - // Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); - - // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); - //} - - /// - /// Test replication of an archive path to the user's inventory. - /// - [Test] - public void TestNewIarPath() - { - TestHelper.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - Scene scene = SceneSetupHelpers.SetupScene("inventory"); - UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); - - Dictionary foldersCreated = new Dictionary(); - HashSet nodesLoaded = new HashSet(); - - string folder1Name = "1"; - string folder2aName = "2a"; - string folder2bName = "2b"; - - string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); - string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random()); - string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random()); - - string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName }); - string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName }); - - { - // Test replication of path1 - new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) - .ReplicateArchivePathToUserInventory( - iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), - foldersCreated, nodesLoaded); - - List folder1Candidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); - Assert.That(folder1Candidates.Count, Is.EqualTo(1)); - - InventoryFolderBase folder1 = folder1Candidates[0]; - List folder2aCandidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); - Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); - } - - { - // Test replication of path2 - new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) - .ReplicateArchivePathToUserInventory( - iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), - foldersCreated, nodesLoaded); - - List folder1Candidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); - Assert.That(folder1Candidates.Count, Is.EqualTo(1)); - - InventoryFolderBase folder1 = folder1Candidates[0]; - - List folder2aCandidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); - Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); - - List folder2bCandidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName); - Assert.That(folder2bCandidates.Count, Is.EqualTo(1)); - } - } - - /// - /// Test replication of a partly existing archive path to the user's inventory. This should create - /// a duplicate path without the merge option. - /// - [Test] - public void TestPartExistingIarPath() - { - TestHelper.InMethod(); - //log4net.Config.XmlConfigurator.Configure(); - - Scene scene = SceneSetupHelpers.SetupScene("inventory"); - UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); - - string folder1ExistingName = "a"; - string folder2Name = "b"; - - InventoryFolderBase folder1 - = UserInventoryTestUtils.CreateInventoryFolder( - scene.InventoryService, ua1.PrincipalID, folder1ExistingName); - - string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); - string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); - - string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); - - new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) - .ReplicateArchivePathToUserInventory( - itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), - new Dictionary(), new HashSet()); - - List folder1PostCandidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); - Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); - - // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. - InventoryFolderBase folder1Post = null; - foreach (InventoryFolderBase folder in folder1PostCandidates) - { - if (folder.ID != folder1.ID) - { - folder1Post = folder; - break; - } - } -// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); - - List folder2PostCandidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); - Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); - } - - /// - /// Test replication of a partly existing archive path to the user's inventory. This should create - /// a merged path. - /// - [Test] - public void TestMergeIarPath() - { - TestHelper.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - Scene scene = SceneSetupHelpers.SetupScene("inventory"); - UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); - - string folder1ExistingName = "a"; - string folder2Name = "b"; - - InventoryFolderBase folder1 - = UserInventoryTestUtils.CreateInventoryFolder( - scene.InventoryService, ua1.PrincipalID, folder1ExistingName); - - string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); - string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); - - string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); - - new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true) - .ReplicateArchivePathToUserInventory( - itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), - new Dictionary(), new HashSet()); - - List folder1PostCandidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); - Assert.That(folder1PostCandidates.Count, Is.EqualTo(1)); - Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID)); - - List folder2PostCandidates - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b"); - Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); - } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs new file mode 100644 index 0000000000..1220a7090a --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs @@ -0,0 +1,480 @@ +/* + * 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.IO; +using System.Reflection; +using System.Threading; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Serialization; +using OpenSim.Framework.Serialization.External; +using OpenSim.Framework.Communications; +using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; +using OpenSim.Region.CoreModules.World.Serialiser; +using OpenSim.Region.Framework.Scenes; +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 +{ + [TestFixture] + public class PathTests : InventoryArchiveTestCase + { + /// + /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive + /// (subject to change since there is no fixed format yet). + /// + [Test] + public void TestSavePathToIarV0_1() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + InventoryArchiverModule archiverModule = new InventoryArchiverModule(); + + Scene scene = SceneSetupHelpers.SetupScene("Inventory"); + SceneSetupHelpers.SetupSceneModules(scene, archiverModule); + + // Create user + string userFirstName = "Jock"; + string userLastName = "Stirrup"; + string userPassword = "troll"; + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); + UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); + + // Create asset + SceneObjectGroup object1; + SceneObjectPart part1; + { + string partName = "My Little Dog Object"; + UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); + PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); + Vector3 groupPosition = new Vector3(10, 20, 30); + Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); + Vector3 offsetPosition = new Vector3(5, 10, 15); + + part1 + = new SceneObjectPart( + ownerId, shape, groupPosition, rotationOffset, offsetPosition); + part1.Name = partName; + + object1 = new SceneObjectGroup(part1); + scene.AddNewSceneObject(object1, false); + } + + UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); + AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); + scene.AssetService.Store(asset1); + + // Create item + UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); + InventoryItemBase item1 = new InventoryItemBase(); + item1.Name = "My Little Dog"; + item1.AssetID = asset1.FullID; + item1.ID = item1Id; + InventoryFolderBase objsFolder + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; + item1.Folder = objsFolder.ID; + scene.AddInventoryItem(item1); + + MemoryStream archiveWriteStream = new MemoryStream(); + archiverModule.OnInventoryArchiveSaved += SaveCompleted; + + // Test saving a particular path + mre.Reset(); + archiverModule.ArchiveInventory( + Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); + mre.WaitOne(60000, false); + + byte[] archive = archiveWriteStream.ToArray(); + MemoryStream archiveReadStream = new MemoryStream(archive); + TarArchiveReader tar = new TarArchiveReader(archiveReadStream); + + //bool gotControlFile = false; + bool gotObject1File = false; + //bool gotObject2File = false; + string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); + string expectedObject1FilePath = string.Format( + "{0}{1}{2}", + ArchiveConstants.INVENTORY_PATH, + InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), + expectedObject1FileName); + + string filePath; + TarArchiveReader.TarEntryType tarEntryType; + +// Console.WriteLine("Reading archive"); + + while (tar.ReadEntry(out filePath, out tarEntryType) != null) + { +// Console.WriteLine("Got {0}", filePath); + +// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) +// { +// gotControlFile = true; +// } + + if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) + { +// string fileName = filePath.Remove(0, "Objects/".Length); +// +// if (fileName.StartsWith(part1.Name)) +// { + Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); + gotObject1File = true; +// } +// else if (fileName.StartsWith(part2.Name)) +// { +// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); +// gotObject2File = true; +// } + } + } + +// Assert.That(gotControlFile, Is.True, "No control file in archive"); + Assert.That(gotObject1File, Is.True, "No item1 file in archive"); +// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); + + // TODO: Test presence of more files and contents of files. + } + + /// + /// Test loading an IAR to various different inventory paths. + /// + [Test] + public void TestLoadIarToInventoryPaths() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + SerialiserModule serialiserModule = new SerialiserModule(); + InventoryArchiverModule archiverModule = new InventoryArchiverModule(); + + // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene + Scene scene = SceneSetupHelpers.SetupScene("inventory"); + + SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); + + UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); + UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); + + archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); + InventoryItemBase foundItem1 + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); + + 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_ua1.PrincipalID, "xA"); + MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); + archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream); + + InventoryItemBase foundItem2 + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name); + 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_ua1.PrincipalID, "xB/xC"); + archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); + archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream); + + InventoryItemBase foundItem3 + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name); + Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); + } + + /// + /// Test that things work when the load path specified starts with a slash + /// + [Test] + public void TestLoadIarPathStartsWithSlash() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + SerialiserModule serialiserModule = new SerialiserModule(); + InventoryArchiverModule archiverModule = new InventoryArchiverModule(); + Scene scene = SceneSetupHelpers.SetupScene("inventory"); + SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); + + UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password"); + archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream); + + InventoryItemBase foundItem1 + = InventoryArchiveUtils.FindItemByPath( + scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); + + Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); + } + + [Test] + public void TestLoadIarPathWithEscapedChars() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + string itemName = "You & you are a mean/man/"; + string humanEscapedItemName = @"You & you are a mean\/man\/"; + string userPassword = "meowfood"; + + InventoryArchiverModule archiverModule = new InventoryArchiverModule(); + + Scene scene = SceneSetupHelpers.SetupScene("Inventory"); + SceneSetupHelpers.SetupSceneModules(scene, archiverModule); + + // Create user + string userFirstName = "Jock"; + string userLastName = "Stirrup"; + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); + UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood"); + + // Create asset + SceneObjectGroup object1; + SceneObjectPart part1; + { + string partName = "part name"; + UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); + PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); + Vector3 groupPosition = new Vector3(10, 20, 30); + Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); + Vector3 offsetPosition = new Vector3(5, 10, 15); + + part1 + = new SceneObjectPart( + ownerId, shape, groupPosition, rotationOffset, offsetPosition); + part1.Name = partName; + + object1 = new SceneObjectGroup(part1); + scene.AddNewSceneObject(object1, false); + } + + UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); + AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); + scene.AssetService.Store(asset1); + + // Create item + UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); + InventoryItemBase item1 = new InventoryItemBase(); + item1.Name = itemName; + item1.AssetID = asset1.FullID; + item1.ID = item1Id; + InventoryFolderBase objsFolder + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; + item1.Folder = objsFolder.ID; + scene.AddInventoryItem(item1); + + MemoryStream archiveWriteStream = new MemoryStream(); + archiverModule.OnInventoryArchiveSaved += SaveCompleted; + + mre.Reset(); + archiverModule.ArchiveInventory( + Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); + mre.WaitOne(60000, false); + + // LOAD ITEM + MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); + + archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); + + InventoryItemBase foundItem1 + = InventoryArchiveUtils.FindItemByPath( + scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); + + Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); +// Assert.That( +// foundItem1.CreatorId, Is.EqualTo(userUuid), +// "Loaded item non-uuid creator doesn't match that of the loading user"); + Assert.That( + foundItem1.Name, Is.EqualTo(itemName), + "Loaded item name doesn't match saved name"); + } + + /// + /// Test replication of an archive path to the user's inventory. + /// + [Test] + public void TestNewIarPath() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + Scene scene = SceneSetupHelpers.SetupScene("inventory"); + UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); + + Dictionary foldersCreated = new Dictionary(); + HashSet nodesLoaded = new HashSet(); + + string folder1Name = "1"; + string folder2aName = "2a"; + string folder2bName = "2b"; + + string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); + string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random()); + string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random()); + + string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName }); + string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName }); + + { + // Test replication of path1 + new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) + .ReplicateArchivePathToUserInventory( + iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), + foldersCreated, nodesLoaded); + + List folder1Candidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); + Assert.That(folder1Candidates.Count, Is.EqualTo(1)); + + InventoryFolderBase folder1 = folder1Candidates[0]; + List folder2aCandidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); + Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); + } + + { + // Test replication of path2 + new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) + .ReplicateArchivePathToUserInventory( + iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), + foldersCreated, nodesLoaded); + + List folder1Candidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); + Assert.That(folder1Candidates.Count, Is.EqualTo(1)); + + InventoryFolderBase folder1 = folder1Candidates[0]; + + List folder2aCandidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); + Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); + + List folder2bCandidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName); + Assert.That(folder2bCandidates.Count, Is.EqualTo(1)); + } + } + + /// + /// Test replication of a partly existing archive path to the user's inventory. This should create + /// a duplicate path without the merge option. + /// + [Test] + public void TestPartExistingIarPath() + { + TestHelper.InMethod(); + //log4net.Config.XmlConfigurator.Configure(); + + Scene scene = SceneSetupHelpers.SetupScene("inventory"); + UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); + + string folder1ExistingName = "a"; + string folder2Name = "b"; + + InventoryFolderBase folder1 + = UserInventoryTestUtils.CreateInventoryFolder( + scene.InventoryService, ua1.PrincipalID, folder1ExistingName); + + string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); + string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); + + string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); + + new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) + .ReplicateArchivePathToUserInventory( + itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), + new Dictionary(), new HashSet()); + + List folder1PostCandidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); + Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); + + // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. + InventoryFolderBase folder1Post = null; + foreach (InventoryFolderBase folder in folder1PostCandidates) + { + if (folder.ID != folder1.ID) + { + folder1Post = folder; + break; + } + } +// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); + + List folder2PostCandidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); + Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); + } + + /// + /// Test replication of a partly existing archive path to the user's inventory. This should create + /// a merged path. + /// + [Test] + public void TestMergeIarPath() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + Scene scene = SceneSetupHelpers.SetupScene("inventory"); + UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); + + string folder1ExistingName = "a"; + string folder2Name = "b"; + + InventoryFolderBase folder1 + = UserInventoryTestUtils.CreateInventoryFolder( + scene.InventoryService, ua1.PrincipalID, folder1ExistingName); + + string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); + string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); + + string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); + + new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true) + .ReplicateArchivePathToUserInventory( + itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), + new Dictionary(), new HashSet()); + + List folder1PostCandidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); + Assert.That(folder1PostCandidates.Count, Is.EqualTo(1)); + Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID)); + + List folder2PostCandidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b"); + Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index e622e0ca8a..138556fc93 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -400,6 +400,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!UpdateAgent(reg, finalDestination, agent)) { // Region doesn't take it + m_log.WarnFormat( + "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.", + sp.Name, finalDestination.RegionName); + Fail(sp, finalDestination); return; } @@ -426,16 +430,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // that the client contacted the destination before we send the attachments and close things here. if (!WaitForCallback(sp.UUID)) { - Fail(sp, finalDestination); + m_log.WarnFormat( + "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.", + sp.Name, finalDestination.RegionName); + + Fail(sp, finalDestination); return; } - // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it CrossAttachmentsIntoNewRegion(finalDestination, sp, true); // Well, this is it. The agent is over there. - KillEntity(sp.Scene, sp.LocalId); // May need to logout or other cleanup diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index ebfba2b83a..7128d2b295 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -32,7 +32,6 @@ using System.Reflection; using System.Threading; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using Nini.Config; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index ef910f4c26..e471f756d0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs @@ -32,7 +32,6 @@ using System.Reflection; using System.Threading; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using Nini.Config; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index e1eee3b128..97833f3a9b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -192,15 +192,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; // Try local first - if (m_localBackend.UpdateAgent(destination, cAgentData)) - return true; - - // else do the remote thing - if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.UpdateAgent(destination, cAgentData); - - return false; + if (m_localBackend.IsLocalRegion(destination.RegionHandle)) + return m_localBackend.UpdateAgent(destination, cAgentData); + return m_remoteConnector.UpdateAgent(destination, cAgentData); } public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) @@ -209,15 +204,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; // Try local first - if (m_localBackend.UpdateAgent(destination, cAgentData)) - return true; - - // else do the remote thing - if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.UpdateAgent(destination, cAgentData); - - return false; + if (m_localBackend.IsLocalRegion(destination.RegionHandle)) + return m_localBackend.UpdateAgent(destination, cAgentData); + return m_remoteConnector.UpdateAgent(destination, cAgentData); } public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 04b6e3d3f9..e2760a2065 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -32,7 +32,6 @@ using System.Reflection; using System.Threading; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenMetaverse.Assets; using OpenSim.Framework; diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 7c5d044347..898ca4a4c3 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -50,7 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps; using OSDArray = OpenMetaverse.StructuredData.OSDArray; using OSDMap = OpenMetaverse.StructuredData.OSDMap; -namespace OpenSim.Region.CoreModules.Media.Moap +namespace OpenSim.Region.CoreModules.World.Media.Moap { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] public class MoapModule : INonSharedRegionModule, IMoapModule @@ -225,24 +225,62 @@ namespace OpenSim.Region.CoreModules.Media.Moap return me; } + /// + /// Set the media entry on the face of the given part. + /// + /// /param> + /// + /// If null, then the media entry is cleared. public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) { +// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face); + CheckFaceParam(part, face); if (null == part.Shape.Media) - part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); - + { + if (me == null) + return; + else + part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); + } + lock (part.Shape.Media) - part.Shape.Media[face] = me; + part.Shape.Media[face] = me; UpdateMediaUrl(part, UUID.Zero); + + SetPartMediaFlags(part, face, me != null); + part.ScheduleFullUpdate(); part.TriggerScriptChangedEvent(Changed.MEDIA); } + /// + /// Clear the media entry from the face of the given part. + /// + /// + /// public void ClearMediaEntry(SceneObjectPart part, int face) { - SetMediaEntry(part, face, null); + SetMediaEntry(part, face, null); + } + + /// + /// Set the media flags on the texture face of the given part. + /// + /// + /// The fact that we need a separate function to do what should be a simple one line operation is BUTT UGLY. + /// + /// + /// + /// + protected void SetPartMediaFlags(SceneObjectPart part, int face, bool flag) + { + Primitive.TextureEntry te = part.Shape.Textures; + Primitive.TextureEntryFace teFace = te.CreateFace((uint)face); + teFace.MediaFlags = flag; + part.Shape.Textures = te; } /// @@ -333,7 +371,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap } // m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); - +// // for (int i = 0; i < omu.FaceMedia.Length; i++) // { // MediaEntry me = omu.FaceMedia[i]; @@ -368,10 +406,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap // FIXME: Race condition here since some other texture entry manipulator may overwrite/get // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry // directly. - Primitive.TextureEntry te = part.Shape.Textures; - Primitive.TextureEntryFace face = te.CreateFace((uint)i); - face.MediaFlags = true; - part.Shape.Textures = te; + SetPartMediaFlags(part, i, true); // m_log.DebugFormat( // "[MOAP]: Media flags for face {0} is {1}", // i, part.Shape.Textures.FaceTextures[i].MediaFlags); @@ -380,6 +415,8 @@ namespace OpenSim.Region.CoreModules.Media.Moap } else { +// m_log.DebugFormat("[MOAP]: Setting existing media list for {0}", part.Name); + // We need to go through the media textures one at a time to make sure that we have permission // to change them @@ -401,8 +438,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap if (null == media[i]) continue; - Primitive.TextureEntryFace face = te.CreateFace((uint)i); - face.MediaFlags = true; + SetPartMediaFlags(part, i, true); // m_log.DebugFormat( // "[MOAP]: Media flags for face {0} is {1}", diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs new file mode 100644 index 0000000000..5b85830f5f --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs @@ -0,0 +1,102 @@ +/* + * 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.IO; +using System.Reflection; +using System.Threading; +using log4net.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenMetaverse.Assets; +using OpenSim.Framework; +using OpenSim.Region.CoreModules.World.Media.Moap; +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 +{ + [TestFixture] + public class MoapTests + { + protected TestScene m_scene; + protected MoapModule m_module; + + [SetUp] + public void SetUp() + { + m_module = new MoapModule(); + m_scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(m_scene, m_module); + } + + [Test] + public void TestClearMediaUrl() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene); + MediaEntry me = new MediaEntry(); + + m_module.SetMediaEntry(part, 1, me); + m_module.ClearMediaEntry(part, 1); + + Assert.That(part.Shape.Media[1], Is.EqualTo(null)); + + // Although we've cleared one face, other faces may still be present. So we need to check for an + // update media url version + Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero)); + + // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture. + // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot. + // Not at all confusing, eh? + Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null); + } + + [Test] + public void TestSetMediaUrl() + { + TestHelper.InMethod(); + + string homeUrl = "opensimulator.org"; + + SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene); + MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; + + m_module.SetMediaEntry(part, 1, me); + + Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl)); + Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero)); + Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index f10e848f68..dafaa0c107 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -30,7 +30,6 @@ using System.IO; using System.Xml; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs index af4464081b..855b5894b6 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs @@ -34,7 +34,6 @@ using System.Timers; using Timer=System.Timers.Timer; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index b3c3e22af6..667b74ea95 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs @@ -32,7 +32,6 @@ using System.Text; using System.Collections.Generic; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index 9244bc3461..ca635d708d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs @@ -28,7 +28,6 @@ using System; using System.Reflection; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 4969b09149..a6a95ef885 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -28,7 +28,6 @@ using System; using System.Reflection; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 39116b6615..0d260266ef 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs @@ -30,7 +30,6 @@ using System.Collections.Generic; using System.Reflection; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index b84298f2fa..bdfcd1dc29 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Reflection; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index c78038f7a7..8876a435b6 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs @@ -30,7 +30,6 @@ using System.Collections.Generic; using System.Reflection; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index fd2d6fab2d..efb757fa6c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs @@ -34,7 +34,6 @@ using System.Timers; using Timer=System.Timers.Timer; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index 9aba8a8bfc..abcce66e23 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs @@ -34,7 +34,6 @@ using System.Timers; using Timer=System.Timers.Timer; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs index cafe48afdd..8588f7f599 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs @@ -29,7 +29,6 @@ using System; using System.Reflection; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index fe59d4f031..8138bcc19a 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -34,7 +34,6 @@ using System.Timers; using Timer=System.Timers.Timer; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenMetaverse.Assets; using OpenSim.Framework; diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 5e6124b4f9..6b70865533 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -28,7 +28,6 @@ using System.Collections.Generic; using System.Text; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index dfeecb1bbc..6a24cc1092 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] public class LindenUDPInfoModule : ISharedRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Dictionary m_scenes = new Dictionary(); diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index d75e25d353..7deb32f47c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static string m_freeSwitchUrlResetPassword; private uint m_freeSwitchServicePort; private string m_openSimWellKnownHTTPAddress; - private string m_freeSwitchContext; +// private string m_freeSwitchContext; private readonly Dictionary m_UUIDName = new Dictionary(); private Dictionary m_ParcelAddress = new Dictionary(); @@ -144,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); m_freeSwitchUrlResetPassword = String.Empty; - m_freeSwitchContext = map["Context"].AsString(); +// m_freeSwitchContext = map["Context"].AsString(); if (String.IsNullOrEmpty(m_freeSwitchRealm) || String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) @@ -662,7 +662,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice resp.Append(""); response["str_response_string"] = resp.ToString(); - Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); +// Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); return response; @@ -670,10 +670,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) { -// m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); - string requestbody = (string)request["body"]; - string uri = (string)request["uri"]; - string contenttype = (string)request["content-type"]; + //m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); +// string requestbody = (string)request["body"]; +// string uri = (string)request["uri"]; +// string contenttype = (string)request["content-type"]; Hashtable requestBody = ParseRequestBody((string)request["body"]); diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 81725c55c7..02751eafa7 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs @@ -712,7 +712,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); GroupMembershipData data = null; - bool foundData = false; +// bool foundData = false; OSDMap UserGroupMemberInfo; if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo)) diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index bc55b04743..6de97b7269 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs @@ -29,7 +29,6 @@ using System; using System.Reflection; using Nini.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 3c5ecc5316..1c31402af6 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -79,9 +79,6 @@ namespace OpenSim.Services.Connectors.Simulation return "agent/"; } - /// - /// - /// public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) { // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); @@ -109,6 +106,9 @@ namespace OpenSim.Services.Connectors.Simulation if (result["Success"].AsBoolean()) return true; + m_log.WarnFormat( + "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {1}", + aCircuit.firstname, aCircuit.lastname, destination.RegionName); reason = result["Message"] != null ? result["Message"].AsString() : "error"; return false; } diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 12dda48164..09e785fd39 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -253,7 +253,7 @@ namespace OpenSim.Services.HypergridService TravelingAgentInfo travel = m_TravelingAgents[sessionID]; - return travel.GridExternalName == thisGridExternalName; + return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower(); } public bool VerifyClient(UUID sessionID, string reportedIP) diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 5bb24c5e82..f2184fc816 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -40,6 +40,13 @@ namespace OpenSim.Services.Interfaces #region Agents + /// + /// Ask the simulator hosting the destination to create an agent on that region. + /// + /// + /// + /// + /// Reason message in the event of a failure. bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason); /// diff --git a/OpenSim/Tests/Common/DoubleToleranceConstraint.cs b/OpenSim/Tests/Common/DoubleToleranceConstraint.cs index c397a6230b..b2f20571ae 100644 --- a/OpenSim/Tests/Common/DoubleToleranceConstraint.cs +++ b/OpenSim/Tests/Common/DoubleToleranceConstraint.cs @@ -27,6 +27,7 @@ using System; using NUnit.Framework; +using NUnit.Framework.Constraints; namespace OpenSim.Tests.Common { diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 5be70bc710..aa4b285981 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -57,21 +57,12 @@ namespace OpenSim.Tests.Common.Setup /// public class SceneSetupHelpers { - // These static variables in order to allow regions to be linked by shared modules and same - // CommunicationsManager. - private static ISharedRegionModule m_assetService = null; -// private static ISharedRegionModule m_authenticationService = null; - private static ISharedRegionModule m_inventoryService = null; - private static ISharedRegionModule m_gridService = null; - private static ISharedRegionModule m_userAccountService = null; - private static ISharedRegionModule m_presenceService = null; - /// /// Set up a test scene /// - /// + /// /// Automatically starts service threads, as would the normal runtime. - /// + /// /// public static TestScene SetupScene() { @@ -86,24 +77,9 @@ namespace OpenSim.Tests.Common.Setup /// public static TestScene SetupScene(String realServices) { - return SetupScene( - "Unit test region", UUID.Random(), 1000, 1000, realServices); + return SetupScene("Unit test region", UUID.Random(), 1000, 1000, realServices); } - // REFACTORING PROBLEM. No idea what the difference is with the previous one - ///// - ///// Set up a test scene - ///// - ///// - ///// Starts real inventory and asset services, as opposed to mock ones, if true - ///// This should be the same if simulating two scenes within a standalone - ///// - //public static TestScene SetupScene(String realServices) - //{ - // return SetupScene( - // "Unit test region", UUID.Random(), 1000, 1000, ""); - //} - /// /// Set up a test scene /// @@ -115,7 +91,7 @@ namespace OpenSim.Tests.Common.Setup /// public static TestScene SetupScene(string name, UUID id, uint x, uint y) { - return SetupScene(name, id, x, y,""); + return SetupScene(name, id, x, y, ""); } /// @@ -156,27 +132,21 @@ namespace OpenSim.Tests.Common.Setup testScene.AddModule(godsModule.Name, godsModule); realServices = realServices.ToLower(); - if (realServices.Contains("asset")) - StartAssetService(testScene, true); - else - StartAssetService(testScene, false); + LocalAssetServicesConnector assetService = StartAssetService(testScene, realServices.Contains("asset")); // For now, always started a 'real' authentication service StartAuthenticationService(testScene, true); - if (realServices.Contains("inventory")) - StartInventoryService(testScene, true); - else - StartInventoryService(testScene, false); + LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene, realServices.Contains("inventory")); + StartGridService(testScene, true); + LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); + LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); - StartGridService(testScene, true); - StartUserAccountService(testScene); - StartPresenceService(testScene); - - m_inventoryService.PostInitialise(); - m_assetService.PostInitialise(); - m_userAccountService.PostInitialise(); - m_presenceService.PostInitialise(); + inventoryService.PostInitialise(); + assetService.PostInitialise(); + userAccountService.PostInitialise(); + presenceService.PostInitialise(); + testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); testScene.SetModuleInterfaces(); @@ -188,24 +158,15 @@ namespace OpenSim.Tests.Common.Setup testScene.PhysicsScene = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); - // It's really not a good idea to use static variables as they carry over between tests, leading to - // problems that are extremely hard to debug. Really, these static fields need to be eliminated - - // tests using multiple regions that need to share modules need to find another solution. - m_assetService = null; - m_inventoryService = null; - m_gridService = null; - m_userAccountService = null; - m_presenceService = null; - testScene.RegionInfo.EstateSettings = new EstateSettings(); testScene.LoginsDisabled = false; return testScene; } - private static void StartAssetService(Scene testScene, bool real) + private static LocalAssetServicesConnector StartAssetService(Scene testScene, bool real) { - ISharedRegionModule assetService = new LocalAssetServicesConnector(); + LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); IConfigSource config = new IniConfigSource(); config.AddConfig("Modules"); config.AddConfig("AssetService"); @@ -219,7 +180,8 @@ namespace OpenSim.Tests.Common.Setup assetService.AddRegion(testScene); assetService.RegionLoaded(testScene); testScene.AddRegionModule(assetService.Name, assetService); - m_assetService = assetService; + + return assetService; } private static void StartAuthenticationService(Scene testScene, bool real) @@ -243,9 +205,9 @@ namespace OpenSim.Tests.Common.Setup //m_authenticationService = service; } - private static void StartInventoryService(Scene testScene, bool real) + private static LocalInventoryServicesConnector StartInventoryService(Scene testScene, bool real) { - ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); + LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); IConfigSource config = new IniConfigSource(); config.AddConfig("Modules"); config.AddConfig("InventoryService"); @@ -265,10 +227,11 @@ namespace OpenSim.Tests.Common.Setup inventoryService.AddRegion(testScene); inventoryService.RegionLoaded(testScene); testScene.AddRegionModule(inventoryService.Name, inventoryService); - m_inventoryService = inventoryService; + + return inventoryService; } - private static void StartGridService(Scene testScene, bool real) + private static LocalGridServicesConnector StartGridService(Scene testScene, bool real) { IConfigSource config = new IniConfigSource(); config.AddConfig("Modules"); @@ -277,24 +240,25 @@ namespace OpenSim.Tests.Common.Setup config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); if (real) config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); - if (m_gridService == null) - { - ISharedRegionModule gridService = new LocalGridServicesConnector(); - gridService.Initialise(config); - m_gridService = gridService; - } + + LocalGridServicesConnector gridService = new LocalGridServicesConnector(); + gridService.Initialise(config); + //else // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService"); - m_gridService.AddRegion(testScene); - m_gridService.RegionLoaded(testScene); + gridService.AddRegion(testScene); + gridService.RegionLoaded(testScene); //testScene.AddRegionModule(m_gridService.Name, m_gridService); + + return gridService; } /// /// Start a user account service /// /// - private static void StartUserAccountService(Scene testScene) + /// + private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) { IConfigSource config = new IniConfigSource(); config.AddConfig("Modules"); @@ -304,23 +268,21 @@ namespace OpenSim.Tests.Common.Setup config.Configs["UserAccountService"].Set( "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); - if (m_userAccountService == null) - { - ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector(); - userAccountService.Initialise(config); - m_userAccountService = userAccountService; - } + LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); + userAccountService.Initialise(config); - m_userAccountService.AddRegion(testScene); - m_userAccountService.RegionLoaded(testScene); - testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService); + userAccountService.AddRegion(testScene); + userAccountService.RegionLoaded(testScene); + testScene.AddRegionModule(userAccountService.Name, userAccountService); + + return userAccountService; } /// /// Start a presence service /// /// - private static void StartPresenceService(Scene testScene) + private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) { IConfigSource config = new IniConfigSource(); config.AddConfig("Modules"); @@ -330,16 +292,14 @@ namespace OpenSim.Tests.Common.Setup config.Configs["PresenceService"].Set( "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); - if (m_presenceService == null) - { - ISharedRegionModule presenceService = new LocalPresenceServicesConnector(); - presenceService.Initialise(config); - m_presenceService = presenceService; - } + LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); + presenceService.Initialise(config); - m_presenceService.AddRegion(testScene); - m_presenceService.RegionLoaded(testScene); - testScene.AddRegionModule(m_presenceService.Name, m_presenceService); + presenceService.AddRegion(testScene); + presenceService.RegionLoaded(testScene); + testScene.AddRegionModule(presenceService.Name, presenceService); + + return presenceService; } /// @@ -436,7 +396,7 @@ namespace OpenSim.Tests.Common.Setup /// /// Add a root agent. /// - /// + /// /// This function /// /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the @@ -447,7 +407,7 @@ namespace OpenSim.Tests.Common.Setup /// /// 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 - /// + /// /// /// /// diff --git a/OpenSim/Tests/Common/TestHelper.cs b/OpenSim/Tests/Common/TestHelper.cs index 9d530635f3..1722e59864 100644 --- a/OpenSim/Tests/Common/TestHelper.cs +++ b/OpenSim/Tests/Common/TestHelper.cs @@ -27,11 +27,10 @@ using System; using System.Diagnostics; +using NUnit.Framework; namespace OpenSim.Tests.Common { - public delegate void TestDelegate(); - public class TestHelper { public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) diff --git a/OpenSim/Tests/Common/VectorToleranceConstraint.cs b/OpenSim/Tests/Common/VectorToleranceConstraint.cs index 118cc707f8..2fa20edec9 100644 --- a/OpenSim/Tests/Common/VectorToleranceConstraint.cs +++ b/OpenSim/Tests/Common/VectorToleranceConstraint.cs @@ -28,6 +28,7 @@ using System; using OpenMetaverse; using NUnit.Framework; +using NUnit.Framework.Constraints; namespace OpenSim.Tests.Common { diff --git a/bin/MySql.Data.dll b/bin/MySql.Data.dll index c28c618f23..992aa5621c 100644 Binary files a/bin/MySql.Data.dll and b/bin/MySql.Data.dll differ diff --git a/bin/nunit.framework.dll b/bin/nunit.framework.dll index d68d9f20c5..875e098420 100644 Binary files a/bin/nunit.framework.dll and b/bin/nunit.framework.dll differ diff --git a/prebuild.xml b/prebuild.xml index bf6c1cc1da..fc94e75ad5 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2959,6 +2959,7 @@ +