From 4eeab4097a4edb773ac0bc17417943b8032d70e5 Mon Sep 17 00:00:00 2001
From: Teravus Ovares (Dan Olivares)
Date: Sun, 16 Aug 2009 12:10:06 -0400
Subject: * minor: comments
---
OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 7142c8c..8195f33 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -70,6 +70,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
+ ///
+ /// When an object gets paid by an avatar and generates the paid event,
+ /// this will pipe it to the script engine
+ ///
+ /// Object ID that got paid
+ /// Agent Id that did the paying
+ /// Amount paid
private void HandleObjectPaid(UUID objectID, UUID agentID,
int amount)
{
@@ -93,6 +100,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
+ ///
+ /// Handles piping the proper stuff to The script engine for touching
+ /// Including DetectedParams
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public void touch_start(uint localID, uint originalID, Vector3 offsetPos,
IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
{
--
cgit v1.1
From 5e391b9f7c62e0d9328d09135521f65400e31283 Mon Sep 17 00:00:00 2001
From: Teravus Ovares (Dan Olivares)
Date: Sun, 16 Aug 2009 12:14:49 -0400
Subject: * ShortVersion, another attempt at fixing the test thread death that
randomly occurs. * LongVersion nIni may be causing the test thread death.
Pausing OpenSimulator during startup causes a nIni error that makes debugging
startup operations difficult for users. It might be because when it's in
pause mode, something else reads from the nini config passed? If it is, it
might not be fixable.. however, if it's concurrency that causes nini death
it would make sense to give each section of the tests a new IConfigSource so
that they don't read from the same configsource at the same time.
---
.../Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs | 1 +
OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | 2 +-
OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 3 ++-
OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 11 ++++++-----
4 files changed, 10 insertions(+), 7 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
index bd11d97..9fb1041 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
@@ -34,6 +34,7 @@ using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Tests.Common;
+using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index 88452d2..8ec14c7 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm);
ISharedRegionModule interregionComms = new RESTInterregionComms();
- interregionComms.Initialise(new IniConfigSource());
+ interregionComms.Initialise( new IniConfigSource());
interregionComms.PostInitialise();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index f290dd7..358ce22 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -35,6 +35,7 @@ using Nini.Config;
using OpenSim.Region.ScriptEngine.Shared.Api;
using OpenMetaverse;
using System;
+using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ScriptEngine.Shared.Tests
{
@@ -52,7 +53,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
public void SetUp()
{
- IniConfigSource initConfigSource = new IniConfigSource();
+ IConfigSource initConfigSource = new IniConfigSource();
IConfig config = initConfigSource.AddConfig("XEngine");
config.Set("Enabled", "true");
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index b1b32cc..f418252 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -154,7 +154,7 @@ namespace OpenSim.Tests.Common.Setup
TestScene testScene = new TestScene(
regInfo, acm, cm, scs, sm, null, false, false, false, configSource, null);
- INonSharedRegionModule capsModule = new CapabilitiesModule();
+ INonSharedRegionModule capsModule = new CapabilitiesModule();
capsModule.Initialise(new IniConfigSource());
testScene.AddRegionModule(capsModule.Name, capsModule);
capsModule.AddRegion(testScene);
@@ -163,7 +163,7 @@ namespace OpenSim.Tests.Common.Setup
godsModule.Initialise(testScene, new IniConfigSource());
testScene.AddModule(godsModule.Name, godsModule);
realServices = realServices.ToLower();
- IniConfigSource config = new IniConfigSource();
+ IConfigSource config = new IniConfigSource();
// If we have a brand new scene, need to initialize shared region modules
if ((m_assetService == null && m_inventoryService == null) || newScene)
@@ -198,7 +198,7 @@ namespace OpenSim.Tests.Common.Setup
PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
testScene.PhysicsScene
- = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test");
+ = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
return testScene;
}
@@ -206,7 +206,7 @@ namespace OpenSim.Tests.Common.Setup
private static void StartAssetService(Scene testScene, bool real)
{
ISharedRegionModule assetService = new LocalAssetServicesConnector();
- IniConfigSource config = new IniConfigSource();
+ IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("AssetService");
config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
@@ -225,7 +225,7 @@ namespace OpenSim.Tests.Common.Setup
private static void StartInventoryService(Scene testScene, bool real)
{
ISharedRegionModule inventoryService = new LocalInventoryServicesConnector();
- IniConfigSource config = new IniConfigSource();
+ IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("InventoryService");
config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
@@ -418,4 +418,5 @@ namespace OpenSim.Tests.Common.Setup
sogd.InventoryDeQueueAndDelete();
}
}
+
}
--
cgit v1.1
From fa921ec147cae620f3126c01b1db94a8f6e90c7e Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Mon, 17 Aug 2009 02:25:00 +1000
Subject: * Implements AppDomain Security for MRM Scripts. * Added
permissionLevel attribute to [MRM] section in OpenSim.ini. Default is
'Internet', however may be any of the following (case sensitive), FullTrust,
SkipVerification, Execution, Nothing, LocalIntranet, Internet, Everything.
For previous functionality, set to FullTrust or Execution.
---
.../Scripting/Minimodule/MRMModule.cs | 103 ++++++++++++++++++++-
1 file changed, 101 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index 6daae29..9042e0d 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -27,9 +27,14 @@
using System;
using System.CodeDom.Compiler;
+using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
using System.Text;
using log4net;
using Microsoft.CSharp;
@@ -54,6 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
private readonly MicroScheduler m_microthreads = new MicroScheduler();
+
+ private IConfig m_config;
+
public void RegisterExtension(T instance)
{
m_extensions[typeof (T)] = instance;
@@ -63,6 +71,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
if (source.Configs["MRM"] != null)
{
+ m_config = source.Configs["MRM"];
+
if (source.Configs["MRM"].GetBoolean("Enabled", false))
{
m_log.Info("[MRM] Enabling MRM Module");
@@ -112,6 +122,91 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
return script;
}
+ ///
+ /// Create an AppDomain that contains policy restricting code to execute
+ /// with only the permissions granted by a named permission set
+ ///
+ /// name of the permission set to restrict to
+ /// 'friendly' name of the appdomain to be created
+ ///
+ /// if is null
+ ///
+ ///
+ /// if is empty
+ ///
+ /// AppDomain with a restricted security policy
+ /// Substantial portions of this function from: http://blogs.msdn.com/shawnfa/archive/2004/10/25/247379.aspx
+ /// Valid permissionSetName values are:
+ /// * FullTrust
+ /// * SkipVerification
+ /// * Execution
+ /// * Nothing
+ /// * LocalIntranet
+ /// * Internet
+ /// * Everything
+ ///
+ public static AppDomain CreateRestrictedDomain(string permissionSetName, string appDomainName)
+ {
+ if (permissionSetName == null)
+ throw new ArgumentNullException("permissionSetName");
+ if (permissionSetName.Length == 0)
+ throw new ArgumentOutOfRangeException("permissionSetName", permissionSetName,
+ "Cannot have an empty permission set name");
+
+ // Default to all code getting nothing
+ PolicyStatement emptyPolicy = new PolicyStatement(new PermissionSet(PermissionState.None));
+ UnionCodeGroup policyRoot = new UnionCodeGroup(new AllMembershipCondition(), emptyPolicy);
+
+ bool foundName = false;
+ PermissionSet setIntersection = new PermissionSet(PermissionState.Unrestricted);
+
+ // iterate over each policy level
+ IEnumerator levelEnumerator = SecurityManager.PolicyHierarchy();
+ while (levelEnumerator.MoveNext())
+ {
+ PolicyLevel level = levelEnumerator.Current as PolicyLevel;
+
+ // if this level has defined a named permission set with the
+ // given name, then intersect it with what we've retrieved
+ // from all the previous levels
+ if (level != null)
+ {
+ PermissionSet levelSet = level.GetNamedPermissionSet(permissionSetName);
+ if (levelSet != null)
+ {
+ foundName = true;
+ if (setIntersection != null)
+ setIntersection = setIntersection.Intersect(levelSet);
+ }
+ }
+ }
+
+ // Intersect() can return null for an empty set, so convert that
+ // to an empty set object. Also return an empty set if we didn't find
+ // the named permission set we were looking for
+ if (setIntersection == null || !foundName)
+ setIntersection = new PermissionSet(PermissionState.None);
+ else
+ setIntersection = new NamedPermissionSet(permissionSetName, setIntersection);
+
+ // if no named permission sets were found, return an empty set,
+ // otherwise return the set that was found
+ PolicyStatement permissions = new PolicyStatement(setIntersection);
+ policyRoot.AddChild(new UnionCodeGroup(new AllMembershipCondition(), permissions));
+
+ // create an AppDomain policy level for the policy tree
+ PolicyLevel appDomainLevel = PolicyLevel.CreateAppDomainLevel();
+ appDomainLevel.RootCodeGroup = policyRoot;
+
+ // create an AppDomain where this policy will be in effect
+ string domainName = appDomainName;
+ AppDomain restrictedDomain = AppDomain.CreateDomain(domainName);
+ restrictedDomain.SetAppDomainPolicy(appDomainLevel);
+
+ return restrictedDomain;
+ }
+
+
void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
{
if (script.StartsWith("//MRM:C#"))
@@ -125,9 +220,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
try
{
- m_log.Info("[MRM] Found C# MRM");
+ m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " + m_config.GetString("permissionLevel", "Internet") + "-level security.");
+
+ string domainName = UUID.Random().ToString();
+ AppDomain target = CreateRestrictedDomain(m_config.GetString("permissionLevel", "Internet"),
+ domainName);
- MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(
+ MRMBase mmb = (MRMBase) target.CreateInstanceFromAndUnwrap(
CompileFromDotNetText(script, itemID.ToString()),
"OpenSim.MiniModule");
--
cgit v1.1
From ad02aefaee803a0a2118eff6bfaa436f3099e121 Mon Sep 17 00:00:00 2001
From: Jeff Ames
Date: Mon, 17 Aug 2009 01:45:48 +0900
Subject: Fix argument index in log4net call. (fixes #4003)
---
.../ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
index 20671e0..bce160a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
@@ -123,7 +123,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Land
public LandData GetLandData(ulong regionHandle, uint x, uint y)
{
- m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {2}",
+ m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {1}",
regionHandle, m_Scenes.Count);
foreach (Scene s in m_Scenes)
{
--
cgit v1.1
From 58d2775ff29c1a4faa26302515c7a6cbd8bdb764 Mon Sep 17 00:00:00 2001
From: Jeff Ames
Date: Mon, 17 Aug 2009 02:05:12 +0900
Subject: Add copyright header. Formatting cleanup.
---
.../Framework/Scenes/Tests/ScenePresenceTests.cs | 2 +-
.../Minimodule/Interfaces/IAvatarAttachment.cs | 27 ++++++++++++++++++++++
.../Scripting/Minimodule/SOPObject.cs | 4 ++--
3 files changed, 30 insertions(+), 3 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index 8ec14c7..88452d2 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm);
ISharedRegionModule interregionComms = new RESTInterregionComms();
- interregionComms.Initialise( new IniConfigSource());
+ interregionComms.Initialise(new IniConfigSource());
interregionComms.PostInitialise();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
index 22b4605..1993948 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
@@ -1,3 +1,30 @@
+/*
+ * 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.
+ */
+
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
public interface IAvatarAttachment
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index 35b0a0f..292e345 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
private bool CanEdit()
{
- if(!m_security.CanEditObject(this))
+ if (!m_security.CanEditObject(this))
{
throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]");
}
@@ -672,7 +672,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
get { return m_sculptType; }
set
{
- if(!CanEdit())
+ if (!CanEdit())
return;
m_sculptType = value;
--
cgit v1.1
From 23d478f2fa06d1dedabfb24cf6ff763b586173ce Mon Sep 17 00:00:00 2001
From: Kunnis
Date: Sun, 9 Aug 2009 02:01:21 -0500
Subject: Adding in Reflection-based testing, to ensure that all properties are
covered.
---
OpenSim/Data/MySQL/MySQLAssetData.cs | 1 +
OpenSim/Data/MySQL/MySQLInventoryData.cs | 11 ++--
OpenSim/Data/MySQL/MySQLRegionData.cs | 17 +++---
OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 8 +++
OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 12 +++-
OpenSim/Data/Tests/BasicAssetTest.cs | 19 ++++---
OpenSim/Data/Tests/BasicEstateTest.cs | 18 ++++++
OpenSim/Data/Tests/BasicGridTest.cs | 79 +++++---------------------
OpenSim/Data/Tests/BasicInventoryTest.cs | 37 ++++++++----
OpenSim/Data/Tests/BasicRegionTest.cs | 47 +++++++++++++++
OpenSim/Data/Tests/BasicUserTest.cs | 30 +++++++---
11 files changed, 174 insertions(+), 105 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 26cdd06..5d87649 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -168,6 +168,7 @@ namespace OpenSim.Data.MySQL
}
asset.Name = (string) dbReader["name"];
asset.Type = (sbyte) dbReader["assetType"];
+ asset.Temporary = (bool)dbReader["temporary"];
}
dbReader.Close();
cmd.Dispose();
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index a4b8663..121ef7a 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -342,7 +342,7 @@ namespace OpenSim.Data.MySQL
item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
item.GroupPermissions = (uint) reader["inventoryGroupPermissions"];
item.SalePrice = (int) reader["salePrice"];
- item.SaleType = Convert.ToByte(reader["saleType"]);
+ item.SaleType = unchecked((byte)(Convert.ToSByte(reader["saleType"])));
item.CreationDate = (int) reader["creationDate"];
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
item.Flags = (uint) reader["flags"];
@@ -423,7 +423,7 @@ namespace OpenSim.Data.MySQL
///
/// Returns a specified inventory folder
///
- /// The folder to return
+ /// The folder to return
/// A folder class
public InventoryFolderBase getInventoryFolder(UUID folderID)
{
@@ -438,8 +438,9 @@ namespace OpenSim.Data.MySQL
result.Parameters.AddWithValue("?uuid", folderID.ToString());
MySqlDataReader reader = result.ExecuteReader();
- reader.Read();
- InventoryFolderBase folder = readInventoryFolder(reader);
+ InventoryFolderBase folder = null;
+ if(reader.Read())
+ folder = readInventoryFolder(reader);
reader.Close();
result.Dispose();
@@ -506,7 +507,7 @@ namespace OpenSim.Data.MySQL
result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
result.Parameters.AddWithValue("?salePrice", item.SalePrice);
- result.Parameters.AddWithValue("?saleType", item.SaleType);
+ result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
result.Parameters.AddWithValue("?creationDate", item.CreationDate);
result.Parameters.AddWithValue("?groupID", item.GroupID);
result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 2166845..9c2ee4a 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -834,7 +834,10 @@ namespace OpenSim.Data.MySQL
// explicit conversion of integers is required, which sort
// of sucks. No idea if there is a shortcut here or not.
prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
- prim.Name = (String) row["Name"];
+ if (row["Name"] != DBNull.Value)
+ prim.Name = (String)row["Name"];
+ else
+ prim.Name = string.Empty;
// various text fields
prim.Text = (String) row["Text"];
prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
@@ -945,12 +948,12 @@ namespace OpenSim.Data.MySQL
prim.DIE_AT_EDGE = true;
prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
- prim.ObjectSaleType = Convert.ToByte(row["SaleType"]);
+ prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"]));
- prim.Material = Convert.ToByte(row["Material"]);
+ prim.Material = unchecked((byte)Convert.ToSByte(row["Material"]));
if (!(row["ClickAction"] is DBNull))
- prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]);
+ prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"]));
prim.CollisionSound = new UUID(row["CollisionSound"].ToString());
prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]);
@@ -1277,12 +1280,12 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("DieAtEdge", 0);
cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice);
- cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType));
+ cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType)));
byte clickAction = prim.ClickAction;
- cmd.Parameters.AddWithValue("ClickAction", clickAction);
+ cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction)));
- cmd.Parameters.AddWithValue("Material", prim.Material);
+ cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material)));
cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString());
cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume);
diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
index 7c36375..d1d5c2a 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
+++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
@@ -62,11 +62,18 @@ namespace OpenSim.Data.MySQL.Tests
m_log.Error("Exception {0}", e);
Assert.Ignore();
}
+
+ // This actually does the roll forward assembly stuff
+ Assembly assem = GetType().Assembly;
+ Migration m = new Migration(database.Connection, assem, "GridStore");
+
+ m.Update();
}
[TestFixtureTearDown]
public void Cleanup()
{
+ m_log.Warn("Cleaning up.");
if (db != null)
{
db.Dispose();
@@ -74,6 +81,7 @@ namespace OpenSim.Data.MySQL.Tests
// if a new table is added, it has to be dropped here
if (database != null)
{
+ database.ExecuteSql("drop table migrations");
database.ExecuteSql("drop table regions");
}
}
diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
index 23c1ec5..a3a32dc 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
+++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Data.MySQL.Tests
try
{
database = new MySQLManager(connect);
+ DropTables();
db = new MySQLInventoryData();
db.Initialise(connect);
}
@@ -72,10 +73,15 @@ namespace OpenSim.Data.MySQL.Tests
}
if (database != null)
{
- database.ExecuteSql("drop table inventoryitems");
- database.ExecuteSql("drop table inventoryfolders");
- database.ExecuteSql("drop table migrations");
+ DropTables();
}
}
+
+ private void DropTables()
+ {
+ database.ExecuteSql("drop table IF EXISTS inventoryitems");
+ database.ExecuteSql("drop table IF EXISTS inventoryfolders");
+ database.ExecuteSql("drop table IF EXISTS migrations");
+ }
}
}
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs
index e85a6a7..eddb999 100644
--- a/OpenSim/Data/Tests/BasicAssetTest.cs
+++ b/OpenSim/Data/Tests/BasicAssetTest.cs
@@ -32,7 +32,6 @@ using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
using OpenSim.Framework;
using log4net;
-using System.Reflection;
namespace OpenSim.Data.Tests
{
@@ -77,25 +76,31 @@ namespace OpenSim.Data.Tests
AssetBase a1 = new AssetBase(uuid1, "asset one");
AssetBase a2 = new AssetBase(uuid2, "asset two");
AssetBase a3 = new AssetBase(uuid3, "asset three");
+
+ ScrambleForTesting.Scramble(a1);
+ ScrambleForTesting.Scramble(a2);
+ ScrambleForTesting.Scramble(a3);
+
a1.Data = asset1;
a2.Data = asset1;
a3.Data = asset1;
+ a1.FullID = uuid1;
+ a2.FullID = uuid2;
+ a3.FullID = uuid3;
+
db.CreateAsset(a1);
db.CreateAsset(a2);
db.CreateAsset(a3);
AssetBase a1a = db.FetchAsset(uuid1);
- Assert.That(a1.ID, Is.EqualTo(a1a.ID), "Assert.That(a1.ID, Is.EqualTo(a1a.ID))");
- Assert.That(a1.Name, Is.EqualTo(a1a.Name), "Assert.That(a1.Name, Is.EqualTo(a1a.Name))");
+ Assert.That(a1, Constraints.PropertyCompareConstraint(a1a));
AssetBase a2a = db.FetchAsset(uuid2);
- Assert.That(a2.ID, Is.EqualTo(a2a.ID), "Assert.That(a2.ID, Is.EqualTo(a2a.ID))");
- Assert.That(a2.Name, Is.EqualTo(a2a.Name), "Assert.That(a2.Name, Is.EqualTo(a2a.Name))");
+ Assert.That(a2, Constraints.PropertyCompareConstraint(a2a));
AssetBase a3a = db.FetchAsset(uuid3);
- Assert.That(a3.ID, Is.EqualTo(a3a.ID), "Assert.That(a3.ID, Is.EqualTo(a3a.ID))");
- Assert.That(a3.Name, Is.EqualTo(a3a.Name), "Assert.That(a3.Name, Is.EqualTo(a3a.Name))");
+ Assert.That(a3, Constraints.PropertyCompareConstraint(a3a));
}
[Test]
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs
index a0266b3..b702e2a 100644
--- a/OpenSim/Data/Tests/BasicEstateTest.cs
+++ b/OpenSim/Data/Tests/BasicEstateTest.cs
@@ -163,6 +163,24 @@ namespace OpenSim.Data.Tests
}
[Test]
+ private void T012_EstateSettingsRandomStorage()
+ {
+
+ // Letting estate store generate rows to database for us
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
+ ScrambleForTesting.Scramble(originalSettings);
+
+ // Saving settings.
+ db.StoreEstateSettings(originalSettings);
+
+ // Loading settings to another instance variable.
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
+
+ // Checking that loaded values are correct.
+ Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
+ }
+
+ [Test]
public void T020_EstateSettingsManagerList()
{
// Letting estate store generate rows to database for us
diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs
index 85273c5..b0ee4a0 100644
--- a/OpenSim/Data/Tests/BasicGridTest.cs
+++ b/OpenSim/Data/Tests/BasicGridTest.cs
@@ -49,9 +49,13 @@ namespace OpenSim.Data.Tests
public void removeAllRegions()
{
// Clean up all the regions.
- foreach (RegionProfileData region in db.GetRegionsByName("", 100))
+ List regions = db.GetRegionsByName("", 100);
+ if(regions != null)
{
- db.DeleteProfile(region.Uuid.ToString());
+ foreach (RegionProfileData region in regions)
+ {
+ db.DeleteProfile(region.Uuid.ToString());
+ }
}
}
@@ -74,35 +78,9 @@ namespace OpenSim.Data.Tests
protected RegionProfileData createRegion(UUID regionUUID, string regionName)
{
RegionProfileData reg = new RegionProfileData();
+ ScrambleForTesting.Scramble(reg);
reg.Uuid = regionUUID;
reg.RegionName = regionName;
- reg.RegionHandle = (ulong) random.Next();
- reg.RegionLocX = (uint) random.Next();
- reg.RegionLocY = (uint) random.Next();
- reg.RegionLocZ = (uint) random.Next();
- reg.RegionSendKey = RandomName();
- reg.RegionRecvKey = RandomName();
- reg.RegionSecret = RandomName();
- reg.RegionOnline = false;
- reg.ServerIP = RandomName();
- reg.ServerPort = (uint) random.Next();
- reg.ServerURI = RandomName();
- reg.ServerHttpPort = (uint) random.Next();
- reg.ServerRemotingPort = (uint) random.Next();
- reg.NorthOverrideHandle = (ulong) random.Next();
- reg.SouthOverrideHandle = (ulong) random.Next();
- reg.EastOverrideHandle = (ulong) random.Next();
- reg.WestOverrideHandle = (ulong) random.Next();
- reg.RegionDataURI = RandomName();
- reg.RegionAssetURI = RandomName();
- reg.RegionAssetSendKey = RandomName();
- reg.RegionAssetRecvKey = RandomName();
- reg.RegionUserURI = RandomName();
- reg.RegionUserSendKey = RandomName();
- reg.RegionUserRecvKey = RandomName();
- reg.RegionMapTextureID = UUID.Random();
- reg.Owner_uuid = UUID.Random();
- reg.OriginUUID = UUID.Random();
db.AddProfile(reg);
@@ -119,47 +97,12 @@ namespace OpenSim.Data.Tests
}
[Test]
- public void T999_StillNull()
- {
- Assert.That(db.GetProfileByUUID(zero),Is.Null);
- }
-
- [Test]
public void T011_AddRetrieveCompleteTest()
{
RegionProfileData newreg = createRegion(region2, "||");
RegionProfileData retreg = db.GetProfileByUUID(region2);
- Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName), "Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName))");
- Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
- Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle), "Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle))");
- Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX), "Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX))");
- Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY), "Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY))");
- Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ), "Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ))");
- Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey), "Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey))");
- Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey), "Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey))");
- Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret), "Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret))");
- Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline), "Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline))");
- Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID), "Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID))");
- Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP), "Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP))");
- Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort), "Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort))");
- Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI), "Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI))");
- Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort), "Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort))");
- Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort), "Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort))");
- Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle), "Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle))");
- Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle), "Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle))");
- Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle), "Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle))");
- Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle), "Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle))");
- Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI), "Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI))");
- Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI), "Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI))");
- Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey), "Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey))");
- Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey), "Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey))");
- Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI), "Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI))");
- Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey), "Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey))");
- Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey), "Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey))");
- Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID), "Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID))");
- Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid), "Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid))");
- Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID), "Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID))");
+ Assert.That(retreg, Constraints.PropertyCompareConstraint(newreg).IgnoreProperty(x => x.RegionOnline));
retreg = db.GetProfileByHandle(newreg.RegionHandle);
Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
@@ -220,6 +163,12 @@ namespace OpenSim.Data.Tests
Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))");
}
+ [Test]
+ public void T999_StillNull()
+ {
+ Assert.That(db.GetProfileByUUID(zero), Is.Null);
+ }
+
protected static string RandomName()
{
StringBuilder name = new StringBuilder();
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs
index e13ed89..3c33bb4 100644
--- a/OpenSim/Data/Tests/BasicInventoryTest.cs
+++ b/OpenSim/Data/Tests/BasicInventoryTest.cs
@@ -115,16 +115,6 @@ namespace OpenSim.Data.Tests
Assert.That(db.getUserRootFolder(owner1), Is.Null);
}
- [Test]
- public void T999_StillNull()
- {
- // After all tests are run, these should still return no results
- Assert.That(db.getInventoryFolder(zero), Is.Null);
- Assert.That(db.getInventoryItem(zero), Is.Null);
- Assert.That(db.getUserRootFolder(zero), Is.Null);
- Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
- }
-
// 01x - folder tests
[Test]
public void T010_FolderNonParent()
@@ -248,7 +238,7 @@ namespace OpenSim.Data.Tests
}
[Test]
- public void T103UpdateItem()
+ public void T103_UpdateItem()
{
// TODO: probably shouldn't have the ability to have an
// owner of an item in a folder not owned by the user
@@ -265,6 +255,31 @@ namespace OpenSim.Data.Tests
Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))");
}
+ [Test]
+ public void T104_RandomUpdateItem()
+ {
+ InventoryItemBase expected = db.getInventoryItem(item1);
+ ScrambleForTesting.Scramble(expected);
+ expected.ID = item1;
+ db.updateInventoryItem(expected);
+
+ InventoryItemBase actual = db.getInventoryItem(item1);
+ Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
+ .IgnoreProperty(x=>x.InvType)
+ .IgnoreProperty(x=>x.Description)
+ .IgnoreProperty(x=>x.CreatorId));
+ }
+
+ [Test]
+ public void T999_StillNull()
+ {
+ // After all tests are run, these should still return no results
+ Assert.That(db.getInventoryFolder(zero), Is.Null);
+ Assert.That(db.getInventoryItem(zero), Is.Null);
+ Assert.That(db.getUserRootFolder(zero), Is.Null);
+ Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
+ }
+
private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset)
{
InventoryItemBase i = new InventoryItemBase();
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs
index 836da78..a746ef0 100644
--- a/OpenSim/Data/Tests/BasicRegionTest.cs
+++ b/OpenSim/Data/Tests/BasicRegionTest.cs
@@ -532,6 +532,53 @@ namespace OpenSim.Data.Tests
Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))");
}
}
+
+ [Test]
+ public void T016_RandomSogWithSceneParts()
+ {
+ UUID tmpSog = UUID.Random();
+ UUID tmp1 = UUID.Random();
+ UUID tmp2 = UUID.Random();
+ UUID tmp3 = UUID.Random();
+ UUID newregion = UUID.Random();
+ SceneObjectPart p1 = new SceneObjectPart();
+ SceneObjectPart p2 = new SceneObjectPart();
+ SceneObjectPart p3 = new SceneObjectPart();
+ p1.Shape = PrimitiveBaseShape.Default;
+ p2.Shape = PrimitiveBaseShape.Default;
+ p3.Shape = PrimitiveBaseShape.Default;
+ ScrambleForTesting.Scramble(p1);
+ ScrambleForTesting.Scramble(p2);
+ ScrambleForTesting.Scramble(p3);
+ p1.UUID = tmp1;
+ p2.UUID = tmp2;
+ p3.UUID = tmp3;
+ SceneObjectGroup sog = NewSOG("Sop 0", tmpSog, newregion);
+ ScrambleForTesting.Scramble(sog);
+ sog.UUID = tmpSog;
+ sog.AddPart(p1);
+ sog.AddPart(p2);
+ sog.AddPart(p3);
+
+ SceneObjectPart[] parts = sog.GetParts();
+ Assert.That(parts.Length, Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))");
+
+ db.StoreObject(sog, newregion);
+ List sogs = db.LoadObjects(newregion);
+ Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))");
+ SceneObjectGroup newsog = sogs[0];
+
+ SceneObjectPart[] newparts = newsog.GetParts();
+ Assert.That(newparts.Length, Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))");
+
+ Assert.That(newsog, Constraints.PropertyCompareConstraint(sog)
+ .IgnoreProperty(x=>x.LocalId)
+ .IgnoreProperty(x=>x.HasGroupChanged)
+ .IgnoreProperty(x=>x.IsSelected)
+ .IgnoreProperty(x=>x.RegionHandle)
+ .IgnoreProperty(x=>x.Scene)
+ .IgnoreProperty(x=>x.RootPart.InventorySerial));
+ }
[Test]
public void T020_PrimInventoryEmpty()
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs
index 4e4ddc8..21d1a7e 100644
--- a/OpenSim/Data/Tests/BasicUserTest.cs
+++ b/OpenSim/Data/Tests/BasicUserTest.cs
@@ -118,13 +118,6 @@ namespace OpenSim.Data.Tests
}
[Test]
- public void T999_StillNull()
- {
- Assert.That(db.GetUserByUUID(zero), Is.Null);
- Assert.That(db.GetAgentByUUID(zero), Is.Null);
- }
-
- [Test]
public void T010_CreateUser()
{
UserProfileData u1 = NewUser(user1,fname1,lname1);
@@ -396,6 +389,22 @@ namespace OpenSim.Data.Tests
Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))");
Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))");
}
+
+ [Test]
+ public void T017_UserUpdateRandomPersistency()
+ {
+ UUID id = user5;
+ UserProfileData u = db.GetUserByUUID(id);
+ ScrambleForTesting.Scramble(u);
+ u.ID = id;
+
+ db.UpdateUserProfile(u);
+ UserProfileData u1a = db.GetUserByUUID(id);
+ Assert.That(u1a, Constraints.PropertyCompareConstraint(u)
+ .IgnoreProperty(x=>x.HomeRegionX)
+ .IgnoreProperty(x=>x.HomeRegionY)
+ );
+ }
[Test]
public void T020_CreateAgent()
@@ -660,6 +669,13 @@ namespace OpenSim.Data.Tests
Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))");
}
+ [Test]
+ public void T999_StillNull()
+ {
+ Assert.That(db.GetUserByUUID(zero), Is.Null);
+ Assert.That(db.GetAgentByUUID(zero), Is.Null);
+ }
+
public UserProfileData NewUser(UUID id,string fname,string lname)
{
UserProfileData u = new UserProfileData();
--
cgit v1.1
From f6251ce810e0bebe68d08a8e4b20a9dfc3fe1af6 Mon Sep 17 00:00:00 2001
From: Kunnis
Date: Sat, 15 Aug 2009 06:08:36 -0500
Subject: * Modified SQLite/SQLiteInventoryStore.cs to not throw if the
inventory row does not exist, to match the mysql behavior. * Modified
SQLite/SQLiteRegionData.cs to only persist temporary items following the same
rules mysql uses. * Added another ignore to the inventory test that was
missing. * Added a few more ignores to the RegionTest that the first version
of my test were missing. * Added ignoring the root Folder ID, which is set by
the inventory system. * Added several improvements to the
PropertyCompareConstraint: Protection against infinite loops, added
IComparable (for UUID) and moved IComparable before the property matching.
* Fixed a bug where I was saving the inside of the ignore expression instead
of the outside of it.
---
OpenSim/Data/SQLite/SQLiteInventoryStore.cs | 3 +-
OpenSim/Data/SQLite/SQLiteRegionData.cs | 29 ++--
OpenSim/Data/Tests/BasicInventoryTest.cs | 1 +
OpenSim/Data/Tests/BasicRegionTest.cs | 4 +-
OpenSim/Data/Tests/BasicUserTest.cs | 1 +
OpenSim/Data/Tests/PropertyCompareConstraint.cs | 180 ++++++++++++++++++------
6 files changed, 154 insertions(+), 64 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
index 97c40ba..557dec7 100644
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
@@ -301,7 +301,8 @@ namespace OpenSim.Data.SQLite
DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString());
- inventoryRow["version"] = (int)inventoryRow["version"] + 1;
+ if(inventoryRow != null) //MySQL doesn't throw an exception here, so sqlite shouldn't either.
+ inventoryRow["version"] = (int)inventoryRow["version"] + 1;
invFoldersDa.Update(ds, "inventoryfolders");
}
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index d2548c2..0259ac5 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -307,26 +307,21 @@ namespace OpenSim.Data.SQLite
/// the region UUID
public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
{
+ uint flags = obj.RootPart.GetEffectiveObjectFlags();
+
+ // Eligibility check
+ //
+ if ((flags & (uint)PrimFlags.Temporary) != 0)
+ return;
+ if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
+ return;
+
lock (ds)
{
foreach (SceneObjectPart prim in obj.Children.Values)
{
- if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0
- && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0)
- {
- m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
- addPrim(prim, obj.UUID, regionUUID);
- }
- else if (prim.Stopped)
- {
- //m_log.Info("[DATASTORE]: " +
- //"Adding stopped obj: " + obj.UUID + " to region: " + regionUUID);
- //addPrim(prim, obj.UUID.ToString(), regionUUID.ToString());
- }
- else
- {
- // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
- }
+ m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
+ addPrim(prim, obj.UUID, regionUUID);
}
}
@@ -1130,7 +1125,7 @@ namespace OpenSim.Data.SQLite
// explicit conversion of integers is required, which sort
// of sucks. No idea if there is a shortcut here or not.
prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
- prim.Name = (String) row["Name"];
+ prim.Name = row["Name"] == DBNull.Value ? string.Empty : (string)row["Name"];
// various text fields
prim.Text = (String) row["Text"];
prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs
index 3c33bb4..967c6e7 100644
--- a/OpenSim/Data/Tests/BasicInventoryTest.cs
+++ b/OpenSim/Data/Tests/BasicInventoryTest.cs
@@ -266,6 +266,7 @@ namespace OpenSim.Data.Tests
InventoryItemBase actual = db.getInventoryItem(item1);
Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
.IgnoreProperty(x=>x.InvType)
+ .IgnoreProperty(x=>x.CreatorIdAsUuid)
.IgnoreProperty(x=>x.Description)
.IgnoreProperty(x=>x.CreatorId));
}
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs
index a746ef0..8373922 100644
--- a/OpenSim/Data/Tests/BasicRegionTest.cs
+++ b/OpenSim/Data/Tests/BasicRegionTest.cs
@@ -576,8 +576,10 @@ namespace OpenSim.Data.Tests
.IgnoreProperty(x=>x.HasGroupChanged)
.IgnoreProperty(x=>x.IsSelected)
.IgnoreProperty(x=>x.RegionHandle)
+ .IgnoreProperty(x=>x.RegionUUID)
.IgnoreProperty(x=>x.Scene)
- .IgnoreProperty(x=>x.RootPart.InventorySerial));
+ .IgnoreProperty(x=>x.Children)
+ .IgnoreProperty(x=>x.RootPart));
}
[Test]
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs
index 21d1a7e..a3c125d 100644
--- a/OpenSim/Data/Tests/BasicUserTest.cs
+++ b/OpenSim/Data/Tests/BasicUserTest.cs
@@ -403,6 +403,7 @@ namespace OpenSim.Data.Tests
Assert.That(u1a, Constraints.PropertyCompareConstraint(u)
.IgnoreProperty(x=>x.HomeRegionX)
.IgnoreProperty(x=>x.HomeRegionY)
+ .IgnoreProperty(x=>x.RootInventoryFolderID)
);
}
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
index 063267b..5f53725 100644
--- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs
+++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
@@ -69,6 +69,15 @@ namespace OpenSim.Data.Tests
private bool ObjectCompare(object expected, object actual, Stack propertyNames)
{
+ //prevent loops...
+ if(propertyNames.Count > 50)
+ {
+ failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
+ failingActual = actual;
+ failingExpected = expected;
+ return false;
+ }
+
if (actual.GetType() != expected.GetType())
{
propertyNames.Push("GetType()");
@@ -122,6 +131,60 @@ namespace OpenSim.Data.Tests
return true;
}
+ IComparable comp = actual as IComparable;
+ if (comp != null)
+ {
+ if (comp.CompareTo(expected) != 0)
+ {
+ failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
+ failingActual = actual;
+ failingExpected = expected;
+ return false;
+ }
+ return true;
+ }
+
+ //Now try the much more annoying IComparable
+ Type icomparableInterface = actual.GetType().GetInterface("IComparable`1");
+ if (icomparableInterface != null)
+ {
+ int result = (int)icomparableInterface.GetMethod("CompareTo").Invoke(actual, new[] { expected });
+ if (result != 0)
+ {
+ failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
+ failingActual = actual;
+ failingExpected = expected;
+ return false;
+ }
+ return true;
+ }
+
+ IEnumerable arr = actual as IEnumerable;
+ if (arr != null)
+ {
+ List