From 91ad1f4ee71dc8e945e9be7b85f7d4e0ddcf4156 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Mon, 17 May 2010 12:37:49 +0300
Subject: Added generic base classes for testing database services
These are some generic classes that simplify writing tests
for any of the data connectors and databases. Among other
things, configuring the connection strings is done once,
in a separate resource file.
Tests based on the new BasicDataServiceTest class require
NUnit 2.5 or better.
---
OpenSim/Data/Tests/BasicDataServiceTest.cs | 171 +++++++++++++++++++++
OpenSim/Data/Tests/DefaultTestConns.cs | 63 ++++++++
.../Data/Tests/Resources/TestDataConnections.ini | 7 +
3 files changed, 241 insertions(+)
create mode 100644 OpenSim/Data/Tests/BasicDataServiceTest.cs
create mode 100644 OpenSim/Data/Tests/DefaultTestConns.cs
create mode 100644 OpenSim/Data/Tests/Resources/TestDataConnections.ini
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs
new file mode 100644
index 0000000..82f29d6
--- /dev/null
+++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs
@@ -0,0 +1,171 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using log4net.Config;
+using NUnit.Framework;
+using NUnit.Framework.Constraints;
+using OpenMetaverse;
+using OpenSim.Framework;
+using log4net;
+using System.Data;
+using System.Data.Common;
+using System.Reflection;
+
+namespace OpenSim.Data.Tests
+{
+ /// This is a base class for testing any Data service for any DBMS.
+ /// Requires NUnit 2.5 or better (to support the generics).
+ ///
+ ///
+ ///
+ public class BasicDataServiceTest
+ where TConn : DbConnection, new()
+ where TService : class, new()
+ {
+ protected string m_connStr;
+ private TService m_service;
+ private string m_file;
+
+ // TODO: Is this in the right place here?
+ protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ public BasicDataServiceTest()
+ : this("")
+ {
+ }
+
+ public BasicDataServiceTest(string conn)
+ {
+ m_connStr = !String.IsNullOrEmpty(conn) ? conn : DefaultTestConns.Get(typeof(TConn));
+
+ OpenSim.Tests.Common.TestLogging.LogToConsole(); // TODO: Is that right?
+ }
+
+ ///
+ /// To be overridden in derived classes. Do whatever init with the m_service, like setting the conn string to it.
+ /// You'd probably want to to cast the 'service' to a more specific type and store it in a member var.
+ /// This framework takes care of disposing it, if it's disposable.
+ ///
+ /// The service being tested
+ protected virtual void InitService(object service)
+ {
+ }
+
+ [TestFixtureSetUp]
+ public void Init()
+ {
+ // Sorry, some SQLite-specific stuff goes here (not a big deal, as its just some file ops)
+ if (typeof(TConn).Name.StartsWith("Sqlite"))
+ {
+ // SQLite doesn't work on power or z linux
+ if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd"))
+ Assert.Ignore();
+
+ // for SQLite, if no explicit conn string is specified, use a temp file
+ if (String.IsNullOrEmpty(m_connStr))
+ {
+ m_file = Path.GetTempFileName() + ".db";
+ m_connStr = "URI=file:" + m_file + ",version=3";
+ }
+ }
+
+ if (String.IsNullOrEmpty(m_connStr))
+ {
+ string msg = String.Format("Connection string for {0} is not defined, ignoring tests", typeof(TConn).Name);
+ m_log.Error(msg);
+ Assert.Ignore(msg);
+ }
+
+ // If we manage to connect to the database with the user
+ // and password above it is our test database, and run
+ // these tests. If anything goes wrong, ignore these
+ // tests.
+ try
+ {
+ m_service = new TService();
+ InitService(m_service);
+ }
+ catch (Exception e)
+ {
+ m_log.Error(e.ToString());
+ Assert.Ignore();
+ }
+ }
+
+ [TestFixtureTearDown]
+ public void Cleanup()
+ {
+ if (m_service != null)
+ {
+ if( m_service is IDisposable)
+ ((IDisposable)m_service).Dispose();
+ m_service = null;
+ }
+
+ if( !String.IsNullOrEmpty(m_file) && File.Exists(m_file) )
+ File.Delete(m_file);
+ }
+
+ protected virtual DbConnection Connect()
+ {
+ DbConnection cnn = new TConn();
+ cnn.ConnectionString = m_connStr;
+ cnn.Open();
+ return cnn;
+ }
+
+ protected virtual void ExecuteSql(string sql)
+ {
+ using (DbConnection dbcon = Connect())
+ {
+ using (DbCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = sql;
+ cmd.ExecuteNonQuery();
+ }
+ }
+ }
+
+ protected delegate bool ProcessRow(IDataReader reader);
+
+ protected virtual int ExecQuery(string sql, bool bSingleRow, ProcessRow action)
+ {
+ int nRecs = 0;
+ using (DbConnection dbcon = Connect())
+ {
+ using (DbCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = sql;
+ CommandBehavior cb = bSingleRow ? CommandBehavior.SingleRow : CommandBehavior.Default;
+ using (DbDataReader rdr = cmd.ExecuteReader(cb))
+ {
+ while (rdr.Read())
+ {
+ nRecs++;
+ if (!action(rdr))
+ break;
+ }
+ }
+ }
+ }
+ return nRecs;
+ }
+
+ /// Drop tables (listed as parameters). There is no "DROP IF EXISTS" syntax common for all
+ /// databases, so we just DROP and ignore an exception.
+ ///
+ ///
+ protected virtual void DropTables(params string[] tables)
+ {
+ foreach (string tbl in tables)
+ {
+ try
+ {
+ ExecuteSql("DROP TABLE " + tbl + ";");
+ }catch
+ {
+ }
+ }
+ }
+ }
+}
diff --git a/OpenSim/Data/Tests/DefaultTestConns.cs b/OpenSim/Data/Tests/DefaultTestConns.cs
new file mode 100644
index 0000000..7b52af5
--- /dev/null
+++ b/OpenSim/Data/Tests/DefaultTestConns.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+using System.IO;
+using Nini.Config;
+
+namespace OpenSim.Data.Tests
+{
+ /// This static class looks for TestDataConnections.ini file in the /bin directory to obtain
+ /// a connection string for testing one of the supported databases.
+ /// The connections must be in the section [TestConnections] with names matching the connection class
+ /// name for the specific database, e.g.:
+ ///
+ /// [TestConnections]
+ /// MySqlConnection="..."
+ /// SqlConnection="..."
+ /// SqliteConnection="..."
+ ///
+ /// Note that the conn string may also be set explicitly in the [TestCase()] attribute of test classes
+ /// based on BasicDataServiceTest.cs.
+ ///
+
+ static class DefaultTestConns
+ {
+ private static Dictionary conns = new Dictionary();
+
+ public static string Get(Type connType)
+ {
+ string sConn;
+
+ if (conns.TryGetValue(connType, out sConn))
+ return sConn;
+
+ Assembly asm = Assembly.GetExecutingAssembly();
+ string sType = connType.Name;
+
+ // Note: when running from NUnit, the DLL is located in some temp dir, so how do we get
+ // to the INI file? Ok, so put it into the resources!
+ // string iniName = Path.Combine(Path.GetDirectoryName(asm.Location), "TestDataConnections.ini");
+
+ string[] allres = asm.GetManifestResourceNames();
+ string sResFile = Array.Find(allres, s => s.Contains("TestDataConnections.ini"));
+
+ if (String.IsNullOrEmpty(sResFile))
+ throw new Exception(String.Format("Please add resource TestDataConnections.ini, with section [TestConnections] and settings like {0}=\"...\"",
+ sType));
+
+ using (Stream resource = asm.GetManifestResourceStream(sResFile))
+ {
+ IConfigSource source = new IniConfigSource(resource);
+ var cfg = source.Configs["TestConnections"];
+ sConn = cfg.Get(sType, "");
+ }
+
+ if (!String.IsNullOrEmpty(sConn))
+ conns[connType] = sConn;
+
+ return sConn;
+ }
+ }
+}
diff --git a/OpenSim/Data/Tests/Resources/TestDataConnections.ini b/OpenSim/Data/Tests/Resources/TestDataConnections.ini
new file mode 100644
index 0000000..d149744
--- /dev/null
+++ b/OpenSim/Data/Tests/Resources/TestDataConnections.ini
@@ -0,0 +1,7 @@
+; The default connections to the test databases. Used by tests based on BasicDataServiceTest.cs.
+; Read by code in DefaultTestConns.cs
+
+[TestConnections]
+MySqlConnection="Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;"
+;SqlConnection="..."
+;SqliteConnection="..."
\ No newline at end of file
--
cgit v1.1
From 7f70ae0ebd686507bc15ac6fc7eeb75ed0b9b64a Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Mon, 17 May 2010 15:54:43 +0300
Subject: All data tests made DBMS-independent
---
OpenSim/Data/MSSQL/MSSQLEstateData.cs | 2 +-
OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 116 ---
OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 99 --
OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 112 ---
OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs | 65 --
OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs | 66 --
OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs | 64 --
OpenSim/Data/Tests/BasicEstateTest.cs | 497 ----------
OpenSim/Data/Tests/BasicInventoryTest.cs | 339 -------
OpenSim/Data/Tests/BasicRegionTest.cs | 1061 ---------------------
OpenSim/Data/Tests/EstateTests.cs | 540 +++++++++++
OpenSim/Data/Tests/InventoryTests.cs | 347 +++++++
OpenSim/Data/Tests/RegionTests.cs | 1082 ++++++++++++++++++++++
13 files changed, 1970 insertions(+), 2420 deletions(-)
delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs
delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs
delete mode 100644 OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs
delete mode 100644 OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs
delete mode 100644 OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
delete mode 100644 OpenSim/Data/Tests/BasicEstateTest.cs
delete mode 100644 OpenSim/Data/Tests/BasicInventoryTest.cs
delete mode 100644 OpenSim/Data/Tests/BasicRegionTest.cs
create mode 100644 OpenSim/Data/Tests/EstateTests.cs
create mode 100644 OpenSim/Data/Tests/InventoryTests.cs
create mode 100644 OpenSim/Data/Tests/RegionTests.cs
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
index 66931e2..80bf106 100644
--- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
@@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Data.MSSQL
{
- public class MSSQLEstateData : IEstateDataStore
+ public class MSSQLEstateStore : IEstateDataStore
{
private const string _migrationStore = "EstateStore";
diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs
deleted file mode 100644
index 01afcae..0000000
--- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using NUnit.Framework;
-using OpenSim.Data.Tests;
-using log4net;
-using System.Reflection;
-using OpenSim.Tests.Common;
-using MySql.Data.MySqlClient;
-
-
-namespace OpenSim.Data.MySQL.Tests
-{
- [TestFixture, DatabaseTest]
- public class MySQLEstateTest : BasicEstateTest
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public string file;
- public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
-
- [TestFixtureSetUp]
- public void Init()
- {
- SuperInit();
- // If we manage to connect to the database with the user
- // and password above it is our test database, and run
- // these tests. If anything goes wrong, ignore these
- // tests.
- try
- {
- // clear db incase to ensure we are in a clean state
- ClearDB();
-
- regionDb = new MySQLDataStore();
- regionDb.Initialise(connect);
- db = new MySQLEstateStore();
- db.Initialise(connect);
- }
- catch (Exception e)
- {
- m_log.Error("Exception {0}", e);
- Assert.Ignore();
- }
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- if (regionDb != null)
- {
- regionDb.Dispose();
- }
- ClearDB();
- }
-
- private void ClearDB()
- {
- // if a new table is added, it has to be dropped here
- ExecuteSql("drop table if exists migrations");
- ExecuteSql("drop table if exists prims");
- ExecuteSql("drop table if exists primshapes");
- ExecuteSql("drop table if exists primitems");
- ExecuteSql("drop table if exists terrain");
- ExecuteSql("drop table if exists land");
- ExecuteSql("drop table if exists landaccesslist");
- ExecuteSql("drop table if exists regionban");
- ExecuteSql("drop table if exists regionsettings");
- ExecuteSql("drop table if exists estate_managers");
- ExecuteSql("drop table if exists estate_groups");
- ExecuteSql("drop table if exists estate_users");
- ExecuteSql("drop table if exists estateban");
- ExecuteSql("drop table if exists estate_settings");
- ExecuteSql("drop table if exists estate_map");
- }
-
- ///
- /// Execute a MySqlCommand
- ///
- /// sql string to execute
- private void ExecuteSql(string sql)
- {
- using (MySqlConnection dbcon = new MySqlConnection(connect))
- {
- dbcon.Open();
-
- MySqlCommand cmd = new MySqlCommand(sql, dbcon);
- cmd.ExecuteNonQuery();
- }
- }
- }
-}
diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
deleted file mode 100644
index 4575493..0000000
--- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using NUnit.Framework;
-using OpenSim.Data.Tests;
-using log4net;
-using System.Reflection;
-using OpenSim.Tests.Common;
-using MySql.Data.MySqlClient;
-
-
-namespace OpenSim.Data.MySQL.Tests
-{
- [TestFixture, DatabaseTest]
- public class MySQLInventoryTest : BasicInventoryTest
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public string file;
- public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
-
- [TestFixtureSetUp]
- public void Init()
- {
- SuperInit();
- // If we manage to connect to the database with the user
- // and password above it is our test database, and run
- // these tests. If anything goes wrong, ignore these
- // tests.
- try
- {
- DropTables();
- db = new MySQLInventoryData();
- db.Initialise(connect);
- }
- catch (Exception e)
- {
- m_log.Error("Exception {0}", e);
- Assert.Ignore();
- }
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- if (db != null)
- {
- db.Dispose();
- }
- DropTables();
- }
-
- private void DropTables()
- {
- ExecuteSql("drop table IF EXISTS inventoryitems");
- ExecuteSql("drop table IF EXISTS inventoryfolders");
- ExecuteSql("drop table IF EXISTS migrations");
- }
-
- ///
- /// Execute a MySqlCommand
- ///
- /// sql string to execute
- private void ExecuteSql(string sql)
- {
- using (MySqlConnection dbcon = new MySqlConnection(connect))
- {
- dbcon.Open();
-
- MySqlCommand cmd = new MySqlCommand(sql, dbcon);
- cmd.ExecuteNonQuery();
- }
- }
- }
-}
diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs
deleted file mode 100644
index e7e57e4..0000000
--- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using NUnit.Framework;
-using OpenSim.Data.Tests;
-using log4net;
-using System.Reflection;
-using OpenSim.Tests.Common;
-using MySql.Data.MySqlClient;
-
-namespace OpenSim.Data.MySQL.Tests
-{
- [TestFixture, DatabaseTest]
- public class MySQLRegionTest : BasicRegionTest
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public string file;
- public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
-
- [TestFixtureSetUp]
- public void Init()
- {
- SuperInit();
- // If we manage to connect to the database with the user
- // and password above it is our test database, and run
- // these tests. If anything goes wrong, ignore these
- // tests.
- try
- {
- // this is important in case a previous run ended badly
- ClearDB();
-
- db = new MySQLDataStore();
- db.Initialise(connect);
- }
- catch (Exception e)
- {
- m_log.Error("Exception {0}", e);
- Assert.Ignore();
- }
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- if (db != null)
- {
- db.Dispose();
- }
- ClearDB();
- }
-
- private void ClearDB()
- {
- ExecuteSql("drop table if exists migrations");
- ExecuteSql("drop table if exists prims");
- ExecuteSql("drop table if exists primshapes");
- ExecuteSql("drop table if exists primitems");
- ExecuteSql("drop table if exists terrain");
- ExecuteSql("drop table if exists land");
- ExecuteSql("drop table if exists landaccesslist");
- ExecuteSql("drop table if exists regionban");
- ExecuteSql("drop table if exists regionsettings");
- ExecuteSql("drop table if exists estate_managers");
- ExecuteSql("drop table if exists estate_groups");
- ExecuteSql("drop table if exists estate_users");
- ExecuteSql("drop table if exists estateban");
- ExecuteSql("drop table if exists estate_settings");
- ExecuteSql("drop table if exists estate_map");
- }
-
- ///
- /// Execute a MySqlCommand
- ///
- /// sql string to execute
- private void ExecuteSql(string sql)
- {
- using (MySqlConnection dbcon = new MySqlConnection(connect))
- {
- dbcon.Open();
-
- MySqlCommand cmd = new MySqlCommand(sql, dbcon);
- cmd.ExecuteNonQuery();
- }
- }
- }
-}
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs
deleted file mode 100644
index 30f6641..0000000
--- a/OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System.IO;
-using NUnit.Framework;
-using OpenSim.Data.Tests;
-using OpenSim.Tests.Common;
-
-namespace OpenSim.Data.SQLite.Tests
-{
- [TestFixture, DatabaseTest]
- public class SQLiteEstateTest : BasicEstateTest
- {
- public string file = "regiontest.db";
- public string connect;
-
- [TestFixtureSetUp]
- public void Init()
- {
- // SQLite doesn't work on power or z linux
- if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd"))
- {
- Assert.Ignore();
- }
-
- SuperInit();
- file = Path.GetTempFileName() + ".db";
- connect = "URI=file:" + file + ",version=3";
- db = new SQLiteEstateStore();
- db.Initialise(connect);
- regionDb = new SQLiteRegionData();
- regionDb.Initialise(connect);
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- regionDb.Dispose();
- }
- }
-}
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs
deleted file mode 100644
index 98458a3..0000000
--- a/OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System.IO;
-using NUnit.Framework;
-using OpenSim.Data.Tests;
-using OpenSim.Tests.Common;
-
-namespace OpenSim.Data.SQLite.Tests
-{
- [TestFixture, DatabaseTest]
- public class SQLiteInventoryTest : BasicInventoryTest
- {
- public string file;
- public string connect;
-
- [TestFixtureSetUp]
- public void Init()
- {
- // SQLite doesn't work on power or z linux
- if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd"))
- {
- Assert.Ignore();
- }
-
- SuperInit();
-
- file = Path.GetTempFileName() + ".db";
- connect = "URI=file:" + file + ",version=3";
-
- db = new SQLiteInventoryStore();
- db.Initialise(connect);
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- db.Dispose();
- File.Delete(file);
- }
- }
-}
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
deleted file mode 100644
index abb97cf..0000000
--- a/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System.IO;
-using NUnit.Framework;
-using OpenSim.Data.Tests;
-using OpenSim.Tests.Common;
-
-namespace OpenSim.Data.SQLite.Tests
-{
- [TestFixture, DatabaseTest]
- public class SQLiteRegionTest : BasicRegionTest
- {
- public string file = "regiontest.db";
- public string connect;
-
- [TestFixtureSetUp]
- public void Init()
- {
- // SQLite doesn't work on power or z linux
- if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd"))
- {
- Assert.Ignore();
- }
-
- SuperInit();
- file = Path.GetTempFileName() + ".db";
- connect = "URI=file:" + file + ",version=3";
- db = new SQLiteRegionData();
- db.Initialise(connect);
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- db.Dispose();
- File.Delete(file);
- }
- }
-}
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs
deleted file mode 100644
index d14d405..0000000
--- a/OpenSim/Data/Tests/BasicEstateTest.cs
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using log4net.Config;
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using System.Text;
-using log4net;
-using System.Reflection;
-
-namespace OpenSim.Data.Tests
-{
- public class BasicEstateTest
- {
- public IEstateDataStore db;
- public IRegionDataStore regionDb;
-
- public static UUID REGION_ID = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed7");
-
- public static UUID USER_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed1");
- public static UUID USER_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed2");
-
- public static UUID MANAGER_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed3");
- public static UUID MANAGER_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed4");
-
- public static UUID GROUP_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed5");
- public static UUID GROUP_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed6");
-
- public void SuperInit()
- {
- OpenSim.Tests.Common.TestLogging.LogToConsole();
- }
-
- #region 0Tests
-
- [Test]
- public void T010_EstateSettingsSimpleStorage_MinimumParameterSet()
- {
- EstateSettingsSimpleStorage(
- REGION_ID,
- DataTestUtil.STRING_MIN,
- DataTestUtil.UNSIGNED_INTEGER_MIN,
- DataTestUtil.FLOAT_MIN,
- DataTestUtil.INTEGER_MIN,
- DataTestUtil.INTEGER_MIN,
- DataTestUtil.INTEGER_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.DOUBLE_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.STRING_MIN,
- DataTestUtil.UUID_MIN
- );
- }
-
- [Test]
- public void T011_EstateSettingsSimpleStorage_MaximumParameterSet()
- {
- EstateSettingsSimpleStorage(
- REGION_ID,
- DataTestUtil.STRING_MAX(64),
- DataTestUtil.UNSIGNED_INTEGER_MAX,
- DataTestUtil.FLOAT_MAX,
- DataTestUtil.INTEGER_MAX,
- DataTestUtil.INTEGER_MAX,
- DataTestUtil.INTEGER_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.DOUBLE_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.BOOLEAN_MAX,
- DataTestUtil.STRING_MAX(255),
- DataTestUtil.UUID_MAX
- );
- }
-
- [Test]
- public void T012_EstateSettingsSimpleStorage_AccurateParameterSet()
- {
- EstateSettingsSimpleStorage(
- REGION_ID,
- DataTestUtil.STRING_MAX(1),
- DataTestUtil.UNSIGNED_INTEGER_MIN,
- DataTestUtil.FLOAT_ACCURATE,
- DataTestUtil.INTEGER_MIN,
- DataTestUtil.INTEGER_MIN,
- DataTestUtil.INTEGER_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.DOUBLE_ACCURATE,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.BOOLEAN_MIN,
- DataTestUtil.STRING_MAX(1),
- DataTestUtil.UUID_MIN
- );
- }
-
- [Test]
- public void T012_EstateSettingsRandomStorage()
- {
- // Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
- new PropertyScrambler()
- .DontScramble(x=>x.EstateID)
- .Scramble(originalSettings);
-
- // Saving settings.
- db.StoreEstateSettings(originalSettings);
-
- // Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
-
- // 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
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
-
- originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
-
- // Saving settings.
- db.StoreEstateSettings(originalSettings);
-
- // Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
-
- Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
- Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
- Assert.AreEqual(MANAGER_ID_2, loadedSettings.EstateManagers[1]);
- }
-
- [Test]
- public void T021_EstateSettingsUserList()
- {
- // Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
-
- originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
-
- // Saving settings.
- db.StoreEstateSettings(originalSettings);
-
- // Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
-
- Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
- Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
- Assert.AreEqual(USER_ID_2, loadedSettings.EstateAccess[1]);
- }
-
- [Test]
- public void T022_EstateSettingsGroupList()
- {
- // Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
-
- originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
-
- // Saving settings.
- db.StoreEstateSettings(originalSettings);
-
- // Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
-
- Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
- Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
- Assert.AreEqual(GROUP_ID_2, loadedSettings.EstateGroups[1]);
- }
-
- [Test]
- public void T022_EstateSettingsBanList()
- {
- // Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
-
- EstateBan estateBan1 = new EstateBan();
- estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
-
- EstateBan estateBan2 = new EstateBan();
- estateBan2.BannedUserID = DataTestUtil.UUID_MAX;
-
- originalSettings.EstateBans = new EstateBan[] { estateBan1, estateBan2 };
-
- // Saving settings.
- db.StoreEstateSettings(originalSettings);
-
- // Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
-
- Assert.AreEqual(2, loadedSettings.EstateBans.Length);
- Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
-
- Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].BannedUserID);
-
- }
-
- #endregion
-
- #region Parametrizable Test Implementations
-
- private void EstateSettingsSimpleStorage(
- UUID regionId,
- string estateName,
- uint parentEstateID,
- float billableFactor,
- int pricePerMeter,
- int redirectGridX,
- int redirectGridY,
- bool useGlobalTime,
- bool fixedSun,
- double sunPosition,
- bool allowVoice,
- bool allowDirectTeleport,
- bool resetHomeOnTeleport,
- bool denyAnonymous,
- bool denyIdentified,
- bool denyTransacted,
- bool denyMinors,
- bool abuseEmailToEstateOwner,
- bool blockDwell,
- bool estateSkipScripts,
- bool taxFree,
- bool publicAccess,
- string abuseEmail,
- UUID estateOwner
- )
- {
-
- // Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(regionId, true);
-
- SetEstateSettings(
- originalSettings,
- estateName,
- parentEstateID,
- billableFactor,
- pricePerMeter,
- redirectGridX,
- redirectGridY,
- useGlobalTime,
- fixedSun,
- sunPosition,
- allowVoice,
- allowDirectTeleport,
- resetHomeOnTeleport,
- denyAnonymous,
- denyIdentified,
- denyTransacted,
- denyMinors,
- abuseEmailToEstateOwner,
- blockDwell,
- estateSkipScripts,
- taxFree,
- publicAccess,
- abuseEmail,
- estateOwner
- );
-
- originalSettings.EstateName = estateName;
- originalSettings.ParentEstateID = parentEstateID;
- originalSettings.BillableFactor = billableFactor;
- originalSettings.PricePerMeter = pricePerMeter;
- originalSettings.RedirectGridX = redirectGridX;
- originalSettings.RedirectGridY = redirectGridY;
- originalSettings.UseGlobalTime = useGlobalTime;
- originalSettings.FixedSun = fixedSun;
- originalSettings.SunPosition = sunPosition;
- originalSettings.AllowVoice = allowVoice;
- originalSettings.AllowDirectTeleport = allowDirectTeleport;
- originalSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
- originalSettings.DenyAnonymous = denyAnonymous;
- originalSettings.DenyIdentified = denyIdentified;
- originalSettings.DenyTransacted = denyTransacted;
- originalSettings.DenyMinors = denyMinors;
- originalSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
- originalSettings.BlockDwell = blockDwell;
- originalSettings.EstateSkipScripts = estateSkipScripts;
- originalSettings.TaxFree = taxFree;
- originalSettings.PublicAccess = publicAccess;
- originalSettings.AbuseEmail = abuseEmail;
- originalSettings.EstateOwner = estateOwner;
-
- // Saving settings.
- db.StoreEstateSettings(originalSettings);
-
- // Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true);
-
- // Checking that loaded values are correct.
- ValidateEstateSettings(
- loadedSettings,
- estateName,
- parentEstateID,
- billableFactor,
- pricePerMeter,
- redirectGridX,
- redirectGridY,
- useGlobalTime,
- fixedSun,
- sunPosition,
- allowVoice,
- allowDirectTeleport,
- resetHomeOnTeleport,
- denyAnonymous,
- denyIdentified,
- denyTransacted,
- denyMinors,
- abuseEmailToEstateOwner,
- blockDwell,
- estateSkipScripts,
- taxFree,
- publicAccess,
- abuseEmail,
- estateOwner
- );
-
- }
-
- #endregion
-
- #region EstateSetting Initialization and Validation Methods
-
- private void SetEstateSettings(
- EstateSettings estateSettings,
- string estateName,
- uint parentEstateID,
- float billableFactor,
- int pricePerMeter,
- int redirectGridX,
- int redirectGridY,
- bool useGlobalTime,
- bool fixedSun,
- double sunPosition,
- bool allowVoice,
- bool allowDirectTeleport,
- bool resetHomeOnTeleport,
- bool denyAnonymous,
- bool denyIdentified,
- bool denyTransacted,
- bool denyMinors,
- bool abuseEmailToEstateOwner,
- bool blockDwell,
- bool estateSkipScripts,
- bool taxFree,
- bool publicAccess,
- string abuseEmail,
- UUID estateOwner
- )
- {
- estateSettings.EstateName = estateName;
- estateSettings.ParentEstateID = parentEstateID;
- estateSettings.BillableFactor = billableFactor;
- estateSettings.PricePerMeter = pricePerMeter;
- estateSettings.RedirectGridX = redirectGridX;
- estateSettings.RedirectGridY = redirectGridY;
- estateSettings.UseGlobalTime = useGlobalTime;
- estateSettings.FixedSun = fixedSun;
- estateSettings.SunPosition = sunPosition;
- estateSettings.AllowVoice = allowVoice;
- estateSettings.AllowDirectTeleport = allowDirectTeleport;
- estateSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
- estateSettings.DenyAnonymous = denyAnonymous;
- estateSettings.DenyIdentified = denyIdentified;
- estateSettings.DenyTransacted = denyTransacted;
- estateSettings.DenyMinors = denyMinors;
- estateSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
- estateSettings.BlockDwell = blockDwell;
- estateSettings.EstateSkipScripts = estateSkipScripts;
- estateSettings.TaxFree = taxFree;
- estateSettings.PublicAccess = publicAccess;
- estateSettings.AbuseEmail = abuseEmail;
- estateSettings.EstateOwner = estateOwner;
- }
-
- private void ValidateEstateSettings(
- EstateSettings estateSettings,
- string estateName,
- uint parentEstateID,
- float billableFactor,
- int pricePerMeter,
- int redirectGridX,
- int redirectGridY,
- bool useGlobalTime,
- bool fixedSun,
- double sunPosition,
- bool allowVoice,
- bool allowDirectTeleport,
- bool resetHomeOnTeleport,
- bool denyAnonymous,
- bool denyIdentified,
- bool denyTransacted,
- bool denyMinors,
- bool abuseEmailToEstateOwner,
- bool blockDwell,
- bool estateSkipScripts,
- bool taxFree,
- bool publicAccess,
- string abuseEmail,
- UUID estateOwner
- )
- {
- Assert.AreEqual(estateName, estateSettings.EstateName);
- Assert.AreEqual(parentEstateID, estateSettings.ParentEstateID);
-
- DataTestUtil.AssertFloatEqualsWithTolerance(billableFactor, estateSettings.BillableFactor);
-
- Assert.AreEqual(pricePerMeter, estateSettings.PricePerMeter);
- Assert.AreEqual(redirectGridX, estateSettings.RedirectGridX);
- Assert.AreEqual(redirectGridY, estateSettings.RedirectGridY);
- Assert.AreEqual(useGlobalTime, estateSettings.UseGlobalTime);
- Assert.AreEqual(fixedSun, estateSettings.FixedSun);
-
- DataTestUtil.AssertDoubleEqualsWithTolerance(sunPosition, estateSettings.SunPosition);
-
- Assert.AreEqual(allowVoice, estateSettings.AllowVoice);
- Assert.AreEqual(allowDirectTeleport, estateSettings.AllowDirectTeleport);
- Assert.AreEqual(resetHomeOnTeleport, estateSettings.ResetHomeOnTeleport);
- Assert.AreEqual(denyAnonymous, estateSettings.DenyAnonymous);
- Assert.AreEqual(denyIdentified, estateSettings.DenyIdentified);
- Assert.AreEqual(denyTransacted, estateSettings.DenyTransacted);
- Assert.AreEqual(denyMinors, estateSettings.DenyMinors);
- Assert.AreEqual(abuseEmailToEstateOwner, estateSettings.AbuseEmailToEstateOwner);
- Assert.AreEqual(blockDwell, estateSettings.BlockDwell);
- Assert.AreEqual(estateSkipScripts, estateSettings.EstateSkipScripts);
- Assert.AreEqual(taxFree, estateSettings.TaxFree);
- Assert.AreEqual(publicAccess, estateSettings.PublicAccess);
- Assert.AreEqual(abuseEmail, estateSettings.AbuseEmail);
- Assert.AreEqual(estateOwner, estateSettings.EstateOwner);
- }
-
- #endregion
-
- }
-}
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs
deleted file mode 100644
index 900186b..0000000
--- a/OpenSim/Data/Tests/BasicInventoryTest.cs
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using log4net.Config;
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-using OpenMetaverse;
-using OpenSim.Framework;
-using log4net;
-using System.Reflection;
-
-namespace OpenSim.Data.Tests
-{
- public class BasicInventoryTest
- {
- //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public IInventoryDataPlugin db;
- public UUID zero = UUID.Zero;
-
- public UUID folder1;
- public UUID folder2;
- public UUID folder3;
- public UUID owner1;
- public UUID owner2;
- public UUID owner3;
-
- public UUID item1;
- public UUID item2;
- public UUID item3;
- public UUID asset1;
- public UUID asset2;
- public UUID asset3;
-
- public string name1;
- public string name2;
- public string name3;
- public string niname1;
- public string iname1;
- public string iname2;
- public string iname3;
-
- public void SuperInit()
- {
- OpenSim.Tests.Common.TestLogging.LogToConsole();
-
- folder1 = UUID.Random();
- folder2 = UUID.Random();
- folder3 = UUID.Random();
- owner1 = UUID.Random();
- owner2 = UUID.Random();
- owner3 = UUID.Random();
- item1 = UUID.Random();
- item2 = UUID.Random();
- item3 = UUID.Random();
- asset1 = UUID.Random();
- asset2 = UUID.Random();
- asset3 = UUID.Random();
-
- name1 = "Root Folder for " + owner1.ToString();
- name2 = "First Level folder";
- name3 = "First Level folder 2";
- niname1 = "My Shirt";
- iname1 = "Shirt";
- iname2 = "Text Board";
- iname3 = "No Pants Barrel";
-
- }
-
- [Test]
- public void T001_LoadEmpty()
- {
- Assert.That(db.getInventoryFolder(zero), Is.Null);
- Assert.That(db.getInventoryFolder(folder1), Is.Null);
- Assert.That(db.getInventoryFolder(folder2), Is.Null);
- Assert.That(db.getInventoryFolder(folder3), Is.Null);
-
- Assert.That(db.getInventoryItem(zero), Is.Null);
- Assert.That(db.getInventoryItem(item1), Is.Null);
- Assert.That(db.getInventoryItem(item2), Is.Null);
- Assert.That(db.getInventoryItem(item3), Is.Null);
-
- Assert.That(db.getUserRootFolder(zero), Is.Null);
- Assert.That(db.getUserRootFolder(owner1), Is.Null);
- }
-
- // 01x - folder tests
- [Test]
- public void T010_FolderNonParent()
- {
- InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2);
- // the folder will go in
- db.addInventoryFolder(f1);
- InventoryFolderBase f1a = db.getUserRootFolder(owner1);
- Assert.That(f1a, Is.Null);
- }
-
- [Test]
- public void T011_FolderCreate()
- {
- InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1);
- // TODO: this is probably wrong behavior, but is what we have
- // db.updateInventoryFolder(f1);
- // InventoryFolderBase f1a = db.getUserRootFolder(owner1);
- // Assert.That(uuid1, Is.EqualTo(f1a.ID))
- // Assert.That(name1, Text.Matches(f1a.Name), "Assert.That(name1, Text.Matches(f1a.Name))");
- // Assert.That(db.getUserRootFolder(owner1), Is.Null);
-
- // succeed with true
- db.addInventoryFolder(f1);
- InventoryFolderBase f1a = db.getUserRootFolder(owner1);
- Assert.That(folder1, Is.EqualTo(f1a.ID), "Assert.That(folder1, Is.EqualTo(f1a.ID))");
- Assert.That(name1, Text.Matches(f1a.Name), "Assert.That(name1, Text.Matches(f1a.Name))");
- }
-
- // we now have the following tree
- // folder1
- // +--- folder2
- // +--- folder3
-
- [Test]
- public void T012_FolderList()
- {
- InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3);
- db.addInventoryFolder(f2);
-
- Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1), "Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1))");
- Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(2), "Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(2))");
- Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0))");
- Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(0))");
- Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0))");
-
- }
-
- [Test]
- public void T013_FolderHierarchy()
- {
- Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
- Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
- Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))");
- Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0))");
- Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0))");
- }
-
-
- [Test]
- public void T014_MoveFolder()
- {
- InventoryFolderBase f2 = db.getInventoryFolder(folder2);
- f2.ParentID = folder3;
- db.moveInventoryFolder(f2);
-
- Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1), "Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1))");
- Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(1), "Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(1))");
- Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0))");
- Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(1), "Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(1))");
- Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0))");
- }
-
- [Test]
- public void T015_FolderHierarchy()
- {
- Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
- Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
- Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))");
- Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(1), "Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(1))");
- Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0))");
- }
-
- // Item tests
- [Test]
- public void T100_NoItems()
- {
- Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
- Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))");
- Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0))");
- Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(0))");
- }
-
- // TODO: Feeding a bad inventory item down the data path will
- // crash the system. This is largely due to the builder
- // routines. That should be fixed and tested for.
- [Test]
- public void T101_CreatItems()
- {
- db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1));
- db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2));
- db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3));
- Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(3), "Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(3))");
- }
-
- [Test]
- public void T102_CompareItems()
- {
- InventoryItemBase i1 = db.getInventoryItem(item1);
- InventoryItemBase i2 = db.getInventoryItem(item2);
- InventoryItemBase i3 = db.getInventoryItem(item3);
- Assert.That(i1.Name, Is.EqualTo(iname1), "Assert.That(i1.Name, Is.EqualTo(iname1))");
- Assert.That(i2.Name, Is.EqualTo(iname2), "Assert.That(i2.Name, Is.EqualTo(iname2))");
- Assert.That(i3.Name, Is.EqualTo(iname3), "Assert.That(i3.Name, Is.EqualTo(iname3))");
- Assert.That(i1.Owner, Is.EqualTo(owner1), "Assert.That(i1.Owner, Is.EqualTo(owner1))");
- Assert.That(i2.Owner, Is.EqualTo(owner1), "Assert.That(i2.Owner, Is.EqualTo(owner1))");
- Assert.That(i3.Owner, Is.EqualTo(owner1), "Assert.That(i3.Owner, Is.EqualTo(owner1))");
- Assert.That(i1.AssetID, Is.EqualTo(asset1), "Assert.That(i1.AssetID, Is.EqualTo(asset1))");
- Assert.That(i2.AssetID, Is.EqualTo(asset2), "Assert.That(i2.AssetID, Is.EqualTo(asset2))");
- Assert.That(i3.AssetID, Is.EqualTo(asset3), "Assert.That(i3.AssetID, Is.EqualTo(asset3))");
- }
-
- [Test]
- 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
-
- InventoryItemBase i1 = db.getInventoryItem(item1);
- i1.Name = niname1;
- i1.Description = niname1;
- i1.Owner = owner2;
- db.updateInventoryItem(i1);
-
- i1 = db.getInventoryItem(item1);
- Assert.That(i1.Name, Is.EqualTo(niname1), "Assert.That(i1.Name, Is.EqualTo(niname1))");
- Assert.That(i1.Description, Is.EqualTo(niname1), "Assert.That(i1.Description, Is.EqualTo(niname1))");
- Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))");
- }
-
- [Test]
- public void T104_RandomUpdateItem()
- {
- PropertyScrambler folderScrambler =
- new PropertyScrambler()
- .DontScramble(x => x.Owner)
- .DontScramble(x => x.ParentID)
- .DontScramble(x => x.ID);
- UUID owner = UUID.Random();
- UUID folder = UUID.Random();
- UUID rootId = UUID.Random();
- UUID rootAsset = UUID.Random();
- InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1);
- folderScrambler.Scramble(f1);
-
- db.addInventoryFolder(f1);
- InventoryFolderBase f1a = db.getUserRootFolder(owner);
- Assert.That(f1a, Constraints.PropertyCompareConstraint(f1));
-
- folderScrambler.Scramble(f1a);
-
- db.updateInventoryFolder(f1a);
-
- InventoryFolderBase f1b = db.getUserRootFolder(owner);
- Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a));
-
- //Now we have a valid folder to insert into, we can insert the item.
- PropertyScrambler inventoryScrambler =
- new PropertyScrambler()
- .DontScramble(x => x.ID)
- .DontScramble(x => x.AssetID)
- .DontScramble(x => x.Owner)
- .DontScramble(x => x.Folder);
- InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset);
- inventoryScrambler.Scramble(root);
- db.addInventoryItem(root);
-
- InventoryItemBase expected = db.getInventoryItem(rootId);
- Assert.That(expected, Constraints.PropertyCompareConstraint(root)
- .IgnoreProperty(x => x.InvType)
- .IgnoreProperty(x => x.CreatorIdAsUuid)
- .IgnoreProperty(x => x.Description)
- .IgnoreProperty(x => x.CreatorId));
-
- inventoryScrambler.Scramble(expected);
- db.updateInventoryItem(expected);
-
- InventoryItemBase actual = db.getInventoryItem(rootId);
- Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
- .IgnoreProperty(x => x.InvType)
- .IgnoreProperty(x => x.CreatorIdAsUuid)
- .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();
- i.ID = id;
- i.Folder = parent;
- i.Owner = owner;
- i.CreatorId = owner.ToString();
- i.Name = name;
- i.Description = name;
- i.AssetID = asset;
- return i;
- }
-
- private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name)
- {
- InventoryFolderBase f = new InventoryFolderBase();
- f.ID = id;
- f.ParentID = parent;
- f.Owner = owner;
- f.Name = name;
- return f;
- }
- }
-}
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs
deleted file mode 100644
index dfbf522..0000000
--- a/OpenSim/Data/Tests/BasicRegionTest.cs
+++ /dev/null
@@ -1,1061 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Text;
-using log4net.Config;
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using log4net;
-using System.Reflection;
-
-namespace OpenSim.Data.Tests
-{
- public class BasicRegionTest
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public IRegionDataStore db;
- public UUID zero = UUID.Zero;
- public UUID region1;
- public UUID region2;
- public UUID region3;
- public UUID region4;
- public UUID prim1;
- public UUID prim2;
- public UUID prim3;
- public UUID prim4;
- public UUID prim5;
- public UUID prim6;
- public UUID item1;
- public UUID item2;
- public UUID item3;
-
- public static Random random;
-
- public string itemname1 = "item1";
-
- public uint localID;
-
- public double height1;
- public double height2;
-
- public void SuperInit()
- {
- OpenSim.Tests.Common.TestLogging.LogToConsole();
-
- region1 = UUID.Random();
- region3 = UUID.Random();
- region4 = UUID.Random();
- prim1 = UUID.Random();
- prim2 = UUID.Random();
- prim3 = UUID.Random();
- prim4 = UUID.Random();
- prim5 = UUID.Random();
- prim6 = UUID.Random();
- item1 = UUID.Random();
- item2 = UUID.Random();
- item3 = UUID.Random();
- random = new Random();
- localID = 1;
- height1 = 20;
- height2 = 100;
- }
-
- // Test Plan
- // Prims
- // - empty test - 001
- // - store / retrieve basic prims (most minimal we can make) - 010, 011
- // - store / retrieve parts in a scenegroup 012
- // - store a prim with complete information for consistency check 013
- // - update existing prims, make sure it sticks - 014
- // - tests empty inventory - 020
- // - add inventory items to prims make - 021
- // - retrieves the added item - 022
- // - update inventory items to prims - 023
- // - remove inventory items make sure it sticks - 024
- // - checks if all parameters are persistent - 025
- // - adds many items and see if it is handled correctly - 026
-
- [Test]
- public void T001_LoadEmpty()
- {
- List objs = db.LoadObjects(region1);
- List objs3 = db.LoadObjects(region3);
- List land = db.LoadLandObjects(region1);
-
- Assert.That(objs.Count, Is.EqualTo(0), "Assert.That(objs.Count, Is.EqualTo(0))");
- Assert.That(objs3.Count, Is.EqualTo(0), "Assert.That(objs3.Count, Is.EqualTo(0))");
- Assert.That(land.Count, Is.EqualTo(0), "Assert.That(land.Count, Is.EqualTo(0))");
- }
-
- // SOG round trips
- // * store objects, make sure they save
- // * update
-
- [Test]
- public void T010_StoreSimpleObject()
- {
- SceneObjectGroup sog = NewSOG("object1", prim1, region1);
- SceneObjectGroup sog2 = NewSOG("object2", prim2, region1);
-
- // in case the objects don't store
- try
- {
- db.StoreObject(sog, region1);
- }
- catch (Exception e)
- {
- m_log.Error(e.ToString());
- Assert.Fail();
- }
-
- try
- {
- db.StoreObject(sog2, region1);
- }
- catch (Exception e)
- {
- m_log.Error(e.ToString());
- Assert.Fail();
- }
-
- // This tests the ADO.NET driver
- List objs = db.LoadObjects(region1);
-
- Assert.That(objs.Count, Is.EqualTo(2), "Assert.That(objs.Count, Is.EqualTo(2))");
- }
-
- [Test]
- public void T011_ObjectNames()
- {
- List objs = db.LoadObjects(region1);
- foreach (SceneObjectGroup sog in objs)
- {
- SceneObjectPart p = sog.RootPart;
- Assert.That("", Is.Not.EqualTo(p.Name), "Assert.That(\"\", Is.Not.EqualTo(p.Name))");
- Assert.That(p.Name, Is.EqualTo(p.Description), "Assert.That(p.Name, Is.EqualTo(p.Description))");
- }
- }
-
- [Test]
- public void T012_SceneParts()
- {
- UUID tmp0 = UUID.Random();
- UUID tmp1 = UUID.Random();
- UUID tmp2 = UUID.Random();
- UUID tmp3 = UUID.Random();
- UUID newregion = UUID.Random();
- SceneObjectPart p1 = NewSOP("SoP 1",tmp1);
- SceneObjectPart p2 = NewSOP("SoP 2",tmp2);
- SceneObjectPart p3 = NewSOP("SoP 3",tmp3);
- SceneObjectGroup sog = NewSOG("Sop 0", tmp0, newregion);
- 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.HasChildPrim(tmp0), "Assert.That(newsog.HasChildPrim(tmp0))");
- Assert.That(newsog.HasChildPrim(tmp1), "Assert.That(newsog.HasChildPrim(tmp1))");
- Assert.That(newsog.HasChildPrim(tmp2), "Assert.That(newsog.HasChildPrim(tmp2))");
- Assert.That(newsog.HasChildPrim(tmp3), "Assert.That(newsog.HasChildPrim(tmp3))");
- }
-
- [Test]
- public void T013_DatabasePersistency()
- {
- // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data
- // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored
- // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently.
- UUID creator,uuid = new UUID();
- creator = UUID.Random();
- uint iserial = (uint)random.Next();
- TaskInventoryDictionary dic = new TaskInventoryDictionary();
- uint objf = (uint) random.Next();
- uuid = prim4;
- uint localid = localID+1;
- localID = localID + 1;
- string name = "Adam West";
- byte material = (byte) random.Next(127);
- ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
- int pin = random.Next();
- Byte[] partsys = new byte[8];
- Byte[] textani = new byte[8];
- random.NextBytes(textani);
- random.NextBytes(partsys);
- DateTime expires = new DateTime(2008, 12, 20);
- DateTime rezzed = new DateTime(2009, 07, 15);
- Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next());
- Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
- Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next());
- string description = name;
- Color color = Color.FromArgb(255, 165, 50, 100);
- string text = "All Your Base Are Belong to Us";
- string sitname = "SitName";
- string touchname = "TouchName";
- int linknum = random.Next();
- byte clickaction = (byte) random.Next(127);
- PrimitiveBaseShape pbshap = new PrimitiveBaseShape();
- pbshap = PrimitiveBaseShape.Default;
- pbshap.PathBegin = ushort.MaxValue;
- pbshap.PathEnd = ushort.MaxValue;
- pbshap.ProfileBegin = ushort.MaxValue;
- pbshap.ProfileEnd = ushort.MaxValue;
- pbshap.ProfileHollow = ushort.MaxValue;
- Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next());
- byte updatef = (byte) random.Next(127);
-
- RegionInfo regionInfo = new RegionInfo();
- regionInfo.RegionID = region3;
- regionInfo.RegionLocX = 0;
- regionInfo.RegionLocY = 0;
-
-// Scene scene = new Scene(regionInfo);
-
- SceneObjectPart sop = new SceneObjectPart();
- sop.RegionHandle = regionh;
- sop.UUID = uuid;
- sop.LocalId = localid;
- sop.Shape = pbshap;
- sop.GroupPosition = groupos;
- sop.RotationOffset = rotoff;
- sop.CreatorID = creator;
- sop.InventorySerial = iserial;
- sop.TaskInventory = dic;
- sop.ObjectFlags = objf;
- sop.Name = name;
- sop.Material = material;
- sop.ScriptAccessPin = pin;
- sop.TextureAnimation = textani;
- sop.ParticleSystem = partsys;
- sop.Expires = expires;
- sop.Rezzed = rezzed;
- sop.OffsetPosition = offset;
- sop.Velocity = velocity;
- sop.AngularVelocity = angvelo;
- sop.Acceleration = accel;
- sop.Description = description;
- sop.Color = color;
- sop.Text = text;
- sop.SitName = sitname;
- sop.TouchName = touchname;
- sop.LinkNum = linknum;
- sop.ClickAction = clickaction;
- sop.Scale = scale;
- sop.UpdateFlag = updatef;
-
- //Tests if local part accepted the parameters:
- Assert.That(regionh,Is.EqualTo(sop.RegionHandle), "Assert.That(regionh,Is.EqualTo(sop.RegionHandle))");
- Assert.That(localid,Is.EqualTo(sop.LocalId), "Assert.That(localid,Is.EqualTo(sop.LocalId))");
- Assert.That(groupos,Is.EqualTo(sop.GroupPosition), "Assert.That(groupos,Is.EqualTo(sop.GroupPosition))");
- Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))");
- Assert.That(rotoff,Is.EqualTo(sop.RotationOffset), "Assert.That(rotoff,Is.EqualTo(sop.RotationOffset))");
- Assert.That(uuid,Is.EqualTo(sop.UUID), "Assert.That(uuid,Is.EqualTo(sop.UUID))");
- Assert.That(creator,Is.EqualTo(sop.CreatorID), "Assert.That(creator,Is.EqualTo(sop.CreatorID))");
- // Modified in-class
- // Assert.That(iserial,Is.EqualTo(sop.InventorySerial), "Assert.That(iserial,Is.EqualTo(sop.InventorySerial))");
- Assert.That(dic,Is.EqualTo(sop.TaskInventory), "Assert.That(dic,Is.EqualTo(sop.TaskInventory))");
- Assert.That(objf,Is.EqualTo(sop.ObjectFlags), "Assert.That(objf,Is.EqualTo(sop.ObjectFlags))");
- Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))");
- Assert.That(material,Is.EqualTo(sop.Material), "Assert.That(material,Is.EqualTo(sop.Material))");
- Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))");
- Assert.That(textani,Is.EqualTo(sop.TextureAnimation), "Assert.That(textani,Is.EqualTo(sop.TextureAnimation))");
- Assert.That(partsys,Is.EqualTo(sop.ParticleSystem), "Assert.That(partsys,Is.EqualTo(sop.ParticleSystem))");
- Assert.That(expires,Is.EqualTo(sop.Expires), "Assert.That(expires,Is.EqualTo(sop.Expires))");
- Assert.That(rezzed,Is.EqualTo(sop.Rezzed), "Assert.That(rezzed,Is.EqualTo(sop.Rezzed))");
- Assert.That(offset,Is.EqualTo(sop.OffsetPosition), "Assert.That(offset,Is.EqualTo(sop.OffsetPosition))");
- Assert.That(velocity,Is.EqualTo(sop.Velocity), "Assert.That(velocity,Is.EqualTo(sop.Velocity))");
- Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity))");
- Assert.That(accel,Is.EqualTo(sop.Acceleration), "Assert.That(accel,Is.EqualTo(sop.Acceleration))");
- Assert.That(description,Is.EqualTo(sop.Description), "Assert.That(description,Is.EqualTo(sop.Description))");
- Assert.That(color,Is.EqualTo(sop.Color), "Assert.That(color,Is.EqualTo(sop.Color))");
- Assert.That(text,Is.EqualTo(sop.Text), "Assert.That(text,Is.EqualTo(sop.Text))");
- Assert.That(sitname,Is.EqualTo(sop.SitName), "Assert.That(sitname,Is.EqualTo(sop.SitName))");
- Assert.That(touchname,Is.EqualTo(sop.TouchName), "Assert.That(touchname,Is.EqualTo(sop.TouchName))");
- Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))");
- Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))");
- Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))");
- Assert.That(updatef,Is.EqualTo(sop.UpdateFlag), "Assert.That(updatef,Is.EqualTo(sop.UpdateFlag))");
-
- // This is necessary or object will not be inserted in DB
- sop.ObjectFlags = 0;
-
- SceneObjectGroup sog = new SceneObjectGroup(sop);
-
- // Inserts group in DB
- db.StoreObject(sog,region3);
- List sogs = db.LoadObjects(region3);
- Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
- // Makes sure there are no double insertions:
- db.StoreObject(sog,region3);
- sogs = db.LoadObjects(region3);
- Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
-
-
- // Tests if the parameters were inserted correctly
- SceneObjectPart p = sogs[0].RootPart;
- Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))");
- //Assert.That(localid,Is.EqualTo(p.LocalId), "Assert.That(localid,Is.EqualTo(p.LocalId))");
- Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))");
- Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
- Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))");
- Assert.That(uuid,Is.EqualTo(p.UUID), "Assert.That(uuid,Is.EqualTo(p.UUID))");
- Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))");
- //Assert.That(iserial,Is.EqualTo(p.InventorySerial), "Assert.That(iserial,Is.EqualTo(p.InventorySerial))");
- Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))");
- //Assert.That(objf,Is.EqualTo(p.ObjectFlags), "Assert.That(objf,Is.EqualTo(p.ObjectFlags))");
- Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
- Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))");
- Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))");
- Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))");
- Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))");
- //Assert.That(expires,Is.EqualTo(p.Expires), "Assert.That(expires,Is.EqualTo(p.Expires))");
- //Assert.That(rezzed,Is.EqualTo(p.Rezzed), "Assert.That(rezzed,Is.EqualTo(p.Rezzed))");
- Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))");
- Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))");
- Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))");
- Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))");
- Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))");
- Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))");
- Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))");
- Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))");
- Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))");
- //Assert.That(linknum,Is.EqualTo(p.LinkNum), "Assert.That(linknum,Is.EqualTo(p.LinkNum))");
- Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
- Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))");
-
- //Assert.That(updatef,Is.EqualTo(p.UpdateFlag), "Assert.That(updatef,Is.EqualTo(p.UpdateFlag))");
-
- Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin), "Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin))");
- Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd), "Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd))");
- Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin), "Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin))");
- Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))");
- Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))");
- }
-
- [Test]
- public void T014_UpdateObject()
- {
- string text1 = "object1 text";
- SceneObjectGroup sog = FindSOG("object1", region1);
- sog.RootPart.Text = text1;
- db.StoreObject(sog, region1);
-
- sog = FindSOG("object1", region1);
- Assert.That(text1, Is.EqualTo(sog.RootPart.Text), "Assert.That(text1, Is.EqualTo(sog.RootPart.Text))");
-
- // Creates random values
- UUID creator = new UUID();
- creator = UUID.Random();
- TaskInventoryDictionary dic = new TaskInventoryDictionary();
- localID = localID + 1;
- string name = "West Adam";
- byte material = (byte) random.Next(127);
- ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
- int pin = random.Next();
- Byte[] partsys = new byte[8];
- Byte[] textani = new byte[8];
- random.NextBytes(textani);
- random.NextBytes(partsys);
- DateTime expires = new DateTime(2010, 12, 20);
- DateTime rezzed = new DateTime(2005, 07, 15);
- Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next());
- Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
- Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next());
- string description = name;
- Color color = Color.FromArgb(255, 255, 255, 0);
- string text = "What You Say?{]\vz~";
- string sitname = RandomName();
- string touchname = RandomName();
- int linknum = random.Next();
- byte clickaction = (byte) random.Next(127);
- PrimitiveBaseShape pbshap = new PrimitiveBaseShape();
- pbshap = PrimitiveBaseShape.Default;
- Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next());
- byte updatef = (byte) random.Next(127);
-
- // Updates the region with new values
- SceneObjectGroup sog2 = FindSOG("Adam West", region3);
- Assert.That(sog2,Is.Not.Null);
- sog2.RootPart.RegionHandle = regionh;
- sog2.RootPart.Shape = pbshap;
- sog2.RootPart.GroupPosition = groupos;
- sog2.RootPart.RotationOffset = rotoff;
- sog2.RootPart.CreatorID = creator;
- sog2.RootPart.TaskInventory = dic;
- sog2.RootPart.Name = name;
- sog2.RootPart.Material = material;
- sog2.RootPart.ScriptAccessPin = pin;
- sog2.RootPart.TextureAnimation = textani;
- sog2.RootPart.ParticleSystem = partsys;
- sog2.RootPart.Expires = expires;
- sog2.RootPart.Rezzed = rezzed;
- sog2.RootPart.OffsetPosition = offset;
- sog2.RootPart.Velocity = velocity;
- sog2.RootPart.AngularVelocity = angvelo;
- sog2.RootPart.Acceleration = accel;
- sog2.RootPart.Description = description;
- sog2.RootPart.Color = color;
- sog2.RootPart.Text = text;
- sog2.RootPart.SitName = sitname;
- sog2.RootPart.TouchName = touchname;
- sog2.RootPart.LinkNum = linknum;
- sog2.RootPart.ClickAction = clickaction;
- sog2.RootPart.Scale = scale;
- sog2.RootPart.UpdateFlag = updatef;
-
- db.StoreObject(sog2, region3);
- List sogs = db.LoadObjects(region3);
- Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
-
- SceneObjectGroup retsog = FindSOG("West Adam", region3);
- Assert.That(retsog,Is.Not.Null);
- SceneObjectPart p = retsog.RootPart;
- Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))");
- Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))");
- Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
- Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))");
- Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))");
- Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))");
- Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
- Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))");
- Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))");
- Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))");
- Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))");
- Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))");
- Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))");
- Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))");
- Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))");
- Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))");
- Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))");
- Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))");
- Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))");
- Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))");
- Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
- Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))");
- }
-
- [Test]
- public void T015_LargeSceneObjects()
- {
- UUID id = UUID.Random();
- Dictionary mydic = new Dictionary();
- SceneObjectGroup sog = NewSOG("Test SOG", id, region4);
- mydic.Add(sog.RootPart.UUID,sog.RootPart);
- for (int i=0;i<30;i++)
- {
- UUID tmp = UUID.Random();
- SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp);
- Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next());
- Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
- Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next());
- Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next());
-
- sop.GroupPosition = groupos;
- sop.RotationOffset = rotoff;
- sop.OffsetPosition = offset;
- sop.Velocity = velocity;
- sop.AngularVelocity = angvelo;
- sop.Acceleration = accel;
-
- mydic.Add(tmp,sop);
- sog.AddPart(sop);
- db.StoreObject(sog, region4);
- }
-
- SceneObjectGroup retsog = FindSOG("Test SOG", region4);
- SceneObjectPart[] parts = retsog.GetParts();
- for (int i=0;i<30;i++)
- {
- SceneObjectPart cursop = mydic[parts[i].UUID];
- Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))");
- Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset), "Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset))");
- Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition), "Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition))");
- Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity), "Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity))");
- Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity), "Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity))");
- Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))");
- }
- }
-
- //[Test]
- public void T016_RandomSogWithSceneParts()
- {
- PropertyScrambler scrambler =
- new PropertyScrambler()
- .DontScramble(x => x.UUID);
- 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;
- p1.UUID = tmp1;
- p2.UUID = tmp2;
- p3.UUID = tmp3;
- scrambler.Scramble(p1);
- scrambler.Scramble(p2);
- scrambler.Scramble(p3);
-
- SceneObjectGroup sog = NewSOG("Sop 0", tmpSog, newregion);
- PropertyScrambler sogScrambler =
- new PropertyScrambler()
- .DontScramble(x => x.UUID);
- sogScrambler.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.RegionUUID)
- .IgnoreProperty(x=>x.Scene)
- .IgnoreProperty(x=>x.Children)
- .IgnoreProperty(x=>x.PassCollision)
- .IgnoreProperty(x=>x.RootPart));
- }
-
- [Test]
- public void T020_PrimInventoryEmpty()
- {
- SceneObjectGroup sog = FindSOG("object1", region1);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
- Assert.That(t, Is.Null);
- }
-
- [Test]
- public void T021_PrimInventoryStore()
- {
- SceneObjectGroup sog = FindSOG("object1", region1);
- InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
-
- Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
- Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
-
- // TODO: seriously??? this is the way we need to loop to get this?
-
- List list = new List();
- foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList())
- {
- list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid));
- }
-
- db.StorePrimInventory(prim1, list);
- }
-
- [Test]
- public void T022_PrimInventoryRetrieve()
- {
- SceneObjectGroup sog = FindSOG("object1", region1);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
-
- Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
- }
-
- [Test]
- public void T023_PrimInventoryUpdate()
- {
- SceneObjectGroup sog = FindSOG("object1", region1);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
-
- t.Name = "My New Name";
- sog.UpdateInventoryItem(t);
-
- Assert.That(t.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
-
- }
-
- [Test]
- public void T024_PrimInventoryRemove()
- {
- List list = new List();
- db.StorePrimInventory(prim1, list);
-
- SceneObjectGroup sog = FindSOG("object1", region1);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
- Assert.That(t, Is.Null);
- }
-
- [Test]
- public void T025_PrimInventoryPersistency()
- {
- InventoryItemBase i = new InventoryItemBase();
- UUID id = UUID.Random();
- i.ID = id;
- UUID folder = UUID.Random();
- i.Folder = folder;
- UUID owner = UUID.Random();
- i.Owner = owner;
- UUID creator = UUID.Random();
- i.CreatorId = creator.ToString();
- string name = RandomName();
- i.Name = name;
- i.Description = name;
- UUID assetid = UUID.Random();
- i.AssetID = assetid;
- int invtype = random.Next();
- i.InvType = invtype;
- uint nextperm = (uint) random.Next();
- i.NextPermissions = nextperm;
- uint curperm = (uint) random.Next();
- i.CurrentPermissions = curperm;
- uint baseperm = (uint) random.Next();
- i.BasePermissions = baseperm;
- uint eoperm = (uint) random.Next();
- i.EveryOnePermissions = eoperm;
- int assettype = random.Next();
- i.AssetType = assettype;
- UUID groupid = UUID.Random();
- i.GroupID = groupid;
- bool groupown = true;
- i.GroupOwned = groupown;
- int saleprice = random.Next();
- i.SalePrice = saleprice;
- byte saletype = (byte) random.Next(127);
- i.SaleType = saletype;
- uint flags = (uint) random.Next();
- i.Flags = flags;
- int creationd = random.Next();
- i.CreationDate = creationd;
-
- SceneObjectGroup sog = FindSOG("object1", region1);
- Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
-
- Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))");
- Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))");
- Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))");
- Assert.That(t.CreationDate,Is.EqualTo(creationd), "Assert.That(t.CreationDate,Is.EqualTo(creationd))");
- Assert.That(t.CreatorID,Is.EqualTo(creator), "Assert.That(t.CreatorID,Is.EqualTo(creator))");
- Assert.That(t.Description,Is.EqualTo(name), "Assert.That(t.Description,Is.EqualTo(name))");
- Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm), "Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm))");
- Assert.That(t.Flags,Is.EqualTo(flags), "Assert.That(t.Flags,Is.EqualTo(flags))");
- Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID), "Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID))");
- // Where is this group permissions??
- // Assert.That(t.GroupPermissions,Is.EqualTo(), "Assert.That(t.GroupPermissions,Is.EqualTo())");
- Assert.That(t.Type,Is.EqualTo(assettype), "Assert.That(t.Type,Is.EqualTo(assettype))");
- Assert.That(t.InvType, Is.EqualTo(invtype), "Assert.That(t.InvType, Is.EqualTo(invtype))");
- Assert.That(t.ItemID, Is.EqualTo(id), "Assert.That(t.ItemID, Is.EqualTo(id))");
- Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID), "Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID))");
- Assert.That(t.NextPermissions, Is.EqualTo(nextperm), "Assert.That(t.NextPermissions, Is.EqualTo(nextperm))");
- // Ownership changes when you drop an object into an object
- // owned by someone else
- Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID), "Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID))");
- Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8), "Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8))");
- Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))");
- Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))");
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentException))]
- public void T026_PrimInventoryMany()
- {
- UUID i1,i2,i3,i4;
- i1 = UUID.Random();
- i2 = UUID.Random();
- i3 = UUID.Random();
- i4 = i3;
- InventoryItemBase ib1 = NewItem(i1, zero, zero, RandomName(), zero);
- InventoryItemBase ib2 = NewItem(i2, zero, zero, RandomName(), zero);
- InventoryItemBase ib3 = NewItem(i3, zero, zero, RandomName(), zero);
- InventoryItemBase ib4 = NewItem(i4, zero, zero, RandomName(), zero);
-
- SceneObjectGroup sog = FindSOG("object1", region1);
-
- Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib1, zero), Is.True);
- Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib2, zero), Is.True);
- Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib3, zero), Is.True);
- Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib4, zero), Is.True);
-
- TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1);
- Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))");
- TaskInventoryItem t2 = sog.GetInventoryItem(sog.RootPart.LocalId, i2);
- Assert.That(t2.Name, Is.EqualTo(ib2.Name), "Assert.That(t2.Name, Is.EqualTo(ib2.Name))");
- TaskInventoryItem t3 = sog.GetInventoryItem(sog.RootPart.LocalId, i3);
- Assert.That(t3.Name, Is.EqualTo(ib3.Name), "Assert.That(t3.Name, Is.EqualTo(ib3.Name))");
- TaskInventoryItem t4 = sog.GetInventoryItem(sog.RootPart.LocalId, i4);
- Assert.That(t4, Is.Null);
- }
-
- [Test]
- public void T052_RemoveObject()
- {
- db.RemoveObject(prim1, region1);
- SceneObjectGroup sog = FindSOG("object1", region1);
- Assert.That(sog, Is.Null);
- }
-
-
- [Test]
- public void T100_DefaultRegionInfo()
- {
- RegionSettings r1 = db.LoadRegionSettings(region1);
- Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))");
-
- RegionSettings r2 = db.LoadRegionSettings(region2);
- Assert.That(r2.RegionUUID, Is.EqualTo(region2), "Assert.That(r2.RegionUUID, Is.EqualTo(region2))");
- }
-
- [Test]
- public void T101_UpdateRegionInfo()
- {
- int agentlimit = random.Next();
- double objectbonus = random.Next();
- int maturity = random.Next();
- UUID tertex1 = UUID.Random();
- UUID tertex2 = UUID.Random();
- UUID tertex3 = UUID.Random();
- UUID tertex4 = UUID.Random();
- double elev1nw = random.Next();
- double elev2nw = random.Next();
- double elev1ne = random.Next();
- double elev2ne = random.Next();
- double elev1se = random.Next();
- double elev2se = random.Next();
- double elev1sw = random.Next();
- double elev2sw = random.Next();
- double waterh = random.Next();
- double terrainraise = random.Next();
- double terrainlower = random.Next();
- Vector3 sunvector = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
- UUID terimgid = UUID.Random();
- double sunpos = random.Next();
- UUID cov = UUID.Random();
-
- RegionSettings r1 = db.LoadRegionSettings(region1);
- r1.BlockTerraform = true;
- r1.BlockFly = true;
- r1.AllowDamage = true;
- r1.RestrictPushing = true;
- r1.AllowLandResell = false;
- r1.AllowLandJoinDivide = false;
- r1.BlockShowInSearch = true;
- r1.AgentLimit = agentlimit;
- r1.ObjectBonus = objectbonus;
- r1.Maturity = maturity;
- r1.DisableScripts = true;
- r1.DisableCollisions = true;
- r1.DisablePhysics = true;
- r1.TerrainTexture1 = tertex1;
- r1.TerrainTexture2 = tertex2;
- r1.TerrainTexture3 = tertex3;
- r1.TerrainTexture4 = tertex4;
- r1.Elevation1NW = elev1nw;
- r1.Elevation2NW = elev2nw;
- r1.Elevation1NE = elev1ne;
- r1.Elevation2NE = elev2ne;
- r1.Elevation1SE = elev1se;
- r1.Elevation2SE = elev2se;
- r1.Elevation1SW = elev1sw;
- r1.Elevation2SW = elev2sw;
- r1.WaterHeight = waterh;
- r1.TerrainRaiseLimit = terrainraise;
- r1.TerrainLowerLimit = terrainlower;
- r1.UseEstateSun = false;
- r1.Sandbox = true;
- r1.SunVector = sunvector;
- r1.TerrainImageID = terimgid;
- r1.FixedSun = true;
- r1.SunPosition = sunpos;
- r1.Covenant = cov;
-
- db.StoreRegionSettings(r1);
-
- RegionSettings r1a = db.LoadRegionSettings(region1);
- Assert.That(r1a.RegionUUID, Is.EqualTo(region1), "Assert.That(r1a.RegionUUID, Is.EqualTo(region1))");
- Assert.That(r1a.BlockTerraform,Is.True);
- Assert.That(r1a.BlockFly,Is.True);
- Assert.That(r1a.AllowDamage,Is.True);
- Assert.That(r1a.RestrictPushing,Is.True);
- Assert.That(r1a.AllowLandResell,Is.False);
- Assert.That(r1a.AllowLandJoinDivide,Is.False);
- Assert.That(r1a.BlockShowInSearch,Is.True);
- Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit), "Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit))");
- Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus), "Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus))");
- Assert.That(r1a.Maturity,Is.EqualTo(maturity), "Assert.That(r1a.Maturity,Is.EqualTo(maturity))");
- Assert.That(r1a.DisableScripts,Is.True);
- Assert.That(r1a.DisableCollisions,Is.True);
- Assert.That(r1a.DisablePhysics,Is.True);
- Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1), "Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1))");
- Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2), "Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2))");
- Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3), "Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3))");
- Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4), "Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4))");
- Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw), "Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw))");
- Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw), "Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw))");
- Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne), "Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne))");
- Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne), "Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne))");
- Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se), "Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se))");
- Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se), "Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se))");
- Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw), "Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw))");
- Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw), "Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw))");
- Assert.That(r1a.WaterHeight,Is.EqualTo(waterh), "Assert.That(r1a.WaterHeight,Is.EqualTo(waterh))");
- Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise), "Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise))");
- Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower), "Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower))");
- Assert.That(r1a.UseEstateSun,Is.False);
- Assert.That(r1a.Sandbox,Is.True);
- Assert.That(r1a.SunVector,Is.EqualTo(sunvector), "Assert.That(r1a.SunVector,Is.EqualTo(sunvector))");
- //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))");
- Assert.That(r1a.FixedSun,Is.True);
- Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))");
- Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))");
-
- }
-
- [Test]
- public void T300_NoTerrain()
- {
- Assert.That(db.LoadTerrain(zero), Is.Null);
- Assert.That(db.LoadTerrain(region1), Is.Null);
- Assert.That(db.LoadTerrain(region2), Is.Null);
- Assert.That(db.LoadTerrain(UUID.Random()), Is.Null);
- }
-
- [Test]
- public void T301_CreateTerrain()
- {
- double[,] t1 = GenTerrain(height1);
- db.StoreTerrain(t1, region1);
-
- Assert.That(db.LoadTerrain(zero), Is.Null);
- Assert.That(db.LoadTerrain(region1), Is.Not.Null);
- Assert.That(db.LoadTerrain(region2), Is.Null);
- Assert.That(db.LoadTerrain(UUID.Random()), Is.Null);
- }
-
- [Test]
- public void T302_FetchTerrain()
- {
- double[,] baseterrain1 = GenTerrain(height1);
- double[,] baseterrain2 = GenTerrain(height2);
- double[,] t1 = db.LoadTerrain(region1);
- Assert.That(CompareTerrain(t1, baseterrain1), Is.True);
- Assert.That(CompareTerrain(t1, baseterrain2), Is.False);
- }
-
- [Test]
- public void T303_UpdateTerrain()
- {
- double[,] baseterrain1 = GenTerrain(height1);
- double[,] baseterrain2 = GenTerrain(height2);
- db.StoreTerrain(baseterrain2, region1);
-
- double[,] t1 = db.LoadTerrain(region1);
- Assert.That(CompareTerrain(t1, baseterrain1), Is.False);
- Assert.That(CompareTerrain(t1, baseterrain2), Is.True);
- }
-
- [Test]
- public void T400_EmptyLand()
- {
- Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))");
- Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))");
- Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))");
- Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0))");
- }
-
- // TODO: we should have real land tests, but Land is so
- // intermingled with scene that you can't test it without a
- // valid scene. That requires some disagregation.
-
-
- //************************************************************************************//
- // Extra private methods
-
- private double[,] GenTerrain(double value)
- {
- double[,] terret = new double[Constants.RegionSize, Constants.RegionSize];
- terret.Initialize();
- for (int x = 0; x < Constants.RegionSize; x++)
- for (int y = 0; y < Constants.RegionSize; y++)
- terret[x,y] = value;
-
- return terret;
- }
-
- private bool CompareTerrain(double[,] one, double[,] two)
- {
- for (int x = 0; x < Constants.RegionSize; x++)
- for (int y = 0; y < Constants.RegionSize; y++)
- if (one[x,y] != two[x,y])
- return false;
-
- return true;
- }
-
-
- private SceneObjectGroup FindSOG(string name, UUID r)
- {
- List objs = db.LoadObjects(r);
- foreach (SceneObjectGroup sog in objs)
- {
- SceneObjectPart p = sog.RootPart;
- if (p.Name == name) {
- RegionInfo regionInfo = new RegionInfo();
- regionInfo.RegionID = r;
- regionInfo.RegionLocX = 0;
- regionInfo.RegionLocY = 0;
-
- Scene scene = new Scene(regionInfo);
- sog.SetScene(scene);
-
- return sog;
- }
- }
-
- return null;
- }
-
- // This builds a minimalistic Prim, 1 SOG with 1 root SOP. A
- // common failure case is people adding new fields that aren't
- // initialized, but have non-null db constraints. We should
- // honestly be passing more and more null things in here.
- //
- // Please note that in Sqlite.BuildPrim there is a commented out inline version
- // of this so you can debug and step through the build process and check the fields
- //
- // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart
- // causes the application to crash at the database layer because of null values
- // in NOT NULL fields
- //
- private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId)
- {
- RegionInfo regionInfo = new RegionInfo();
- regionInfo.RegionID = regionId;
- regionInfo.RegionLocX = 0;
- regionInfo.RegionLocY = 0;
-
- Scene scene = new Scene(regionInfo);
-
- SceneObjectPart sop = new SceneObjectPart();
- sop.Name = name;
- sop.Description = name;
- sop.Text = RandomName();
- sop.SitName = RandomName();
- sop.TouchName = RandomName();
- sop.UUID = uuid;
- sop.Shape = PrimitiveBaseShape.Default;
-
- SceneObjectGroup sog = new SceneObjectGroup(sop);
- sog.SetScene(scene);
-
- return sog;
- }
-
- private SceneObjectPart NewSOP(string name, UUID uuid)
- {
- SceneObjectPart sop = new SceneObjectPart();
- sop.Name = name;
- sop.Description = name;
- sop.Text = RandomName();
- sop.SitName = RandomName();
- sop.TouchName = RandomName();
- sop.UUID = uuid;
- sop.Shape = PrimitiveBaseShape.Default;
- return sop;
- }
-
- // These are copied from the Inventory Item tests
-
- private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset)
- {
- InventoryItemBase i = new InventoryItemBase();
- i.ID = id;
- i.Folder = parent;
- i.Owner = owner;
- i.CreatorId = owner.ToString();
- i.Name = name;
- i.Description = name;
- i.AssetID = asset;
- return i;
- }
-
- private static string RandomName()
- {
- StringBuilder name = new StringBuilder();
- int size = random.Next(5,12);
- char ch ;
- for (int i=0; i : BasicDataServiceTest
+ where TConn : DbConnection, new()
+ where TEstateStore : class, IEstateDataStore, new()
+ {
+ public IEstateDataStore db;
+
+ public static UUID REGION_ID = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed7");
+
+ public static UUID USER_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed1");
+ public static UUID USER_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed2");
+
+ public static UUID MANAGER_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed3");
+ public static UUID MANAGER_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed4");
+
+ public static UUID GROUP_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed5");
+ public static UUID GROUP_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed6");
+
+ protected override void InitService(object service)
+ {
+ db = (IEstateDataStore)service;
+ db.Initialise(m_connStr);
+ ClearDB();
+ }
+
+ private void ClearDB()
+ {
+ // if a new table is added, it has to be dropped here
+ ExecuteSql("delete from migrations where name='EstateStore';");
+
+ DropTables(
+ "prims",
+ "primshapes",
+ "primitems",
+ "terrain",
+ "land",
+ "landaccesslist",
+ "regionban",
+ "regionsettings",
+ "estate_managers",
+ "estate_groups",
+ "estate_users",
+ "estateban",
+ "estate_settings",
+ "estate_map"
+ );
+ }
+
+ #region 0Tests
+
+ [Test]
+ public void T010_EstateSettingsSimpleStorage_MinimumParameterSet()
+ {
+ EstateSettingsSimpleStorage(
+ REGION_ID,
+ DataTestUtil.STRING_MIN,
+ DataTestUtil.UNSIGNED_INTEGER_MIN,
+ DataTestUtil.FLOAT_MIN,
+ DataTestUtil.INTEGER_MIN,
+ DataTestUtil.INTEGER_MIN,
+ DataTestUtil.INTEGER_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.DOUBLE_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.STRING_MIN,
+ DataTestUtil.UUID_MIN
+ );
+ }
+
+ [Test]
+ public void T011_EstateSettingsSimpleStorage_MaximumParameterSet()
+ {
+ EstateSettingsSimpleStorage(
+ REGION_ID,
+ DataTestUtil.STRING_MAX(64),
+ DataTestUtil.UNSIGNED_INTEGER_MAX,
+ DataTestUtil.FLOAT_MAX,
+ DataTestUtil.INTEGER_MAX,
+ DataTestUtil.INTEGER_MAX,
+ DataTestUtil.INTEGER_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.DOUBLE_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.BOOLEAN_MAX,
+ DataTestUtil.STRING_MAX(255),
+ DataTestUtil.UUID_MAX
+ );
+ }
+
+ [Test]
+ public void T012_EstateSettingsSimpleStorage_AccurateParameterSet()
+ {
+ EstateSettingsSimpleStorage(
+ REGION_ID,
+ DataTestUtil.STRING_MAX(1),
+ DataTestUtil.UNSIGNED_INTEGER_MIN,
+ DataTestUtil.FLOAT_ACCURATE,
+ DataTestUtil.INTEGER_MIN,
+ DataTestUtil.INTEGER_MIN,
+ DataTestUtil.INTEGER_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.DOUBLE_ACCURATE,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.BOOLEAN_MIN,
+ DataTestUtil.STRING_MAX(1),
+ DataTestUtil.UUID_MIN
+ );
+ }
+
+ [Test]
+ public void T012_EstateSettingsRandomStorage()
+ {
+ // Letting estate store generate rows to database for us
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
+ new PropertyScrambler()
+ .DontScramble(x=>x.EstateID)
+ .Scramble(originalSettings);
+
+ // Saving settings.
+ db.StoreEstateSettings(originalSettings);
+
+ // Loading settings to another instance variable.
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ // 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
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
+
+ // Saving settings.
+ db.StoreEstateSettings(originalSettings);
+
+ // Loading settings to another instance variable.
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
+ Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
+ Assert.AreEqual(MANAGER_ID_2, loadedSettings.EstateManagers[1]);
+ }
+
+ [Test]
+ public void T021_EstateSettingsUserList()
+ {
+ // Letting estate store generate rows to database for us
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
+
+ // Saving settings.
+ db.StoreEstateSettings(originalSettings);
+
+ // Loading settings to another instance variable.
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
+ Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
+ Assert.AreEqual(USER_ID_2, loadedSettings.EstateAccess[1]);
+ }
+
+ [Test]
+ public void T022_EstateSettingsGroupList()
+ {
+ // Letting estate store generate rows to database for us
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
+
+ // Saving settings.
+ db.StoreEstateSettings(originalSettings);
+
+ // Loading settings to another instance variable.
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
+ Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
+ Assert.AreEqual(GROUP_ID_2, loadedSettings.EstateGroups[1]);
+ }
+
+ [Test]
+ public void T022_EstateSettingsBanList()
+ {
+ // Letting estate store generate rows to database for us
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ EstateBan estateBan1 = new EstateBan();
+ estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
+
+ EstateBan estateBan2 = new EstateBan();
+ estateBan2.BannedUserID = DataTestUtil.UUID_MAX;
+
+ originalSettings.EstateBans = new EstateBan[] { estateBan1, estateBan2 };
+
+ // Saving settings.
+ db.StoreEstateSettings(originalSettings);
+
+ // Loading settings to another instance variable.
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
+
+ Assert.AreEqual(2, loadedSettings.EstateBans.Length);
+ Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
+
+ Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].BannedUserID);
+
+ }
+
+ #endregion
+
+ #region Parametrizable Test Implementations
+
+ private void EstateSettingsSimpleStorage(
+ UUID regionId,
+ string estateName,
+ uint parentEstateID,
+ float billableFactor,
+ int pricePerMeter,
+ int redirectGridX,
+ int redirectGridY,
+ bool useGlobalTime,
+ bool fixedSun,
+ double sunPosition,
+ bool allowVoice,
+ bool allowDirectTeleport,
+ bool resetHomeOnTeleport,
+ bool denyAnonymous,
+ bool denyIdentified,
+ bool denyTransacted,
+ bool denyMinors,
+ bool abuseEmailToEstateOwner,
+ bool blockDwell,
+ bool estateSkipScripts,
+ bool taxFree,
+ bool publicAccess,
+ string abuseEmail,
+ UUID estateOwner
+ )
+ {
+
+ // Letting estate store generate rows to database for us
+ EstateSettings originalSettings = db.LoadEstateSettings(regionId, true);
+
+ SetEstateSettings(
+ originalSettings,
+ estateName,
+ parentEstateID,
+ billableFactor,
+ pricePerMeter,
+ redirectGridX,
+ redirectGridY,
+ useGlobalTime,
+ fixedSun,
+ sunPosition,
+ allowVoice,
+ allowDirectTeleport,
+ resetHomeOnTeleport,
+ denyAnonymous,
+ denyIdentified,
+ denyTransacted,
+ denyMinors,
+ abuseEmailToEstateOwner,
+ blockDwell,
+ estateSkipScripts,
+ taxFree,
+ publicAccess,
+ abuseEmail,
+ estateOwner
+ );
+
+ originalSettings.EstateName = estateName;
+ originalSettings.ParentEstateID = parentEstateID;
+ originalSettings.BillableFactor = billableFactor;
+ originalSettings.PricePerMeter = pricePerMeter;
+ originalSettings.RedirectGridX = redirectGridX;
+ originalSettings.RedirectGridY = redirectGridY;
+ originalSettings.UseGlobalTime = useGlobalTime;
+ originalSettings.FixedSun = fixedSun;
+ originalSettings.SunPosition = sunPosition;
+ originalSettings.AllowVoice = allowVoice;
+ originalSettings.AllowDirectTeleport = allowDirectTeleport;
+ originalSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
+ originalSettings.DenyAnonymous = denyAnonymous;
+ originalSettings.DenyIdentified = denyIdentified;
+ originalSettings.DenyTransacted = denyTransacted;
+ originalSettings.DenyMinors = denyMinors;
+ originalSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
+ originalSettings.BlockDwell = blockDwell;
+ originalSettings.EstateSkipScripts = estateSkipScripts;
+ originalSettings.TaxFree = taxFree;
+ originalSettings.PublicAccess = publicAccess;
+ originalSettings.AbuseEmail = abuseEmail;
+ originalSettings.EstateOwner = estateOwner;
+
+ // Saving settings.
+ db.StoreEstateSettings(originalSettings);
+
+ // Loading settings to another instance variable.
+ EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true);
+
+ // Checking that loaded values are correct.
+ ValidateEstateSettings(
+ loadedSettings,
+ estateName,
+ parentEstateID,
+ billableFactor,
+ pricePerMeter,
+ redirectGridX,
+ redirectGridY,
+ useGlobalTime,
+ fixedSun,
+ sunPosition,
+ allowVoice,
+ allowDirectTeleport,
+ resetHomeOnTeleport,
+ denyAnonymous,
+ denyIdentified,
+ denyTransacted,
+ denyMinors,
+ abuseEmailToEstateOwner,
+ blockDwell,
+ estateSkipScripts,
+ taxFree,
+ publicAccess,
+ abuseEmail,
+ estateOwner
+ );
+
+ }
+
+ #endregion
+
+ #region EstateSetting Initialization and Validation Methods
+
+ private void SetEstateSettings(
+ EstateSettings estateSettings,
+ string estateName,
+ uint parentEstateID,
+ float billableFactor,
+ int pricePerMeter,
+ int redirectGridX,
+ int redirectGridY,
+ bool useGlobalTime,
+ bool fixedSun,
+ double sunPosition,
+ bool allowVoice,
+ bool allowDirectTeleport,
+ bool resetHomeOnTeleport,
+ bool denyAnonymous,
+ bool denyIdentified,
+ bool denyTransacted,
+ bool denyMinors,
+ bool abuseEmailToEstateOwner,
+ bool blockDwell,
+ bool estateSkipScripts,
+ bool taxFree,
+ bool publicAccess,
+ string abuseEmail,
+ UUID estateOwner
+ )
+ {
+ estateSettings.EstateName = estateName;
+ estateSettings.ParentEstateID = parentEstateID;
+ estateSettings.BillableFactor = billableFactor;
+ estateSettings.PricePerMeter = pricePerMeter;
+ estateSettings.RedirectGridX = redirectGridX;
+ estateSettings.RedirectGridY = redirectGridY;
+ estateSettings.UseGlobalTime = useGlobalTime;
+ estateSettings.FixedSun = fixedSun;
+ estateSettings.SunPosition = sunPosition;
+ estateSettings.AllowVoice = allowVoice;
+ estateSettings.AllowDirectTeleport = allowDirectTeleport;
+ estateSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
+ estateSettings.DenyAnonymous = denyAnonymous;
+ estateSettings.DenyIdentified = denyIdentified;
+ estateSettings.DenyTransacted = denyTransacted;
+ estateSettings.DenyMinors = denyMinors;
+ estateSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
+ estateSettings.BlockDwell = blockDwell;
+ estateSettings.EstateSkipScripts = estateSkipScripts;
+ estateSettings.TaxFree = taxFree;
+ estateSettings.PublicAccess = publicAccess;
+ estateSettings.AbuseEmail = abuseEmail;
+ estateSettings.EstateOwner = estateOwner;
+ }
+
+ private void ValidateEstateSettings(
+ EstateSettings estateSettings,
+ string estateName,
+ uint parentEstateID,
+ float billableFactor,
+ int pricePerMeter,
+ int redirectGridX,
+ int redirectGridY,
+ bool useGlobalTime,
+ bool fixedSun,
+ double sunPosition,
+ bool allowVoice,
+ bool allowDirectTeleport,
+ bool resetHomeOnTeleport,
+ bool denyAnonymous,
+ bool denyIdentified,
+ bool denyTransacted,
+ bool denyMinors,
+ bool abuseEmailToEstateOwner,
+ bool blockDwell,
+ bool estateSkipScripts,
+ bool taxFree,
+ bool publicAccess,
+ string abuseEmail,
+ UUID estateOwner
+ )
+ {
+ Assert.AreEqual(estateName, estateSettings.EstateName);
+ Assert.AreEqual(parentEstateID, estateSettings.ParentEstateID);
+
+ DataTestUtil.AssertFloatEqualsWithTolerance(billableFactor, estateSettings.BillableFactor);
+
+ Assert.AreEqual(pricePerMeter, estateSettings.PricePerMeter);
+ Assert.AreEqual(redirectGridX, estateSettings.RedirectGridX);
+ Assert.AreEqual(redirectGridY, estateSettings.RedirectGridY);
+ Assert.AreEqual(useGlobalTime, estateSettings.UseGlobalTime);
+ Assert.AreEqual(fixedSun, estateSettings.FixedSun);
+
+ DataTestUtil.AssertDoubleEqualsWithTolerance(sunPosition, estateSettings.SunPosition);
+
+ Assert.AreEqual(allowVoice, estateSettings.AllowVoice);
+ Assert.AreEqual(allowDirectTeleport, estateSettings.AllowDirectTeleport);
+ Assert.AreEqual(resetHomeOnTeleport, estateSettings.ResetHomeOnTeleport);
+ Assert.AreEqual(denyAnonymous, estateSettings.DenyAnonymous);
+ Assert.AreEqual(denyIdentified, estateSettings.DenyIdentified);
+ Assert.AreEqual(denyTransacted, estateSettings.DenyTransacted);
+ Assert.AreEqual(denyMinors, estateSettings.DenyMinors);
+ Assert.AreEqual(abuseEmailToEstateOwner, estateSettings.AbuseEmailToEstateOwner);
+ Assert.AreEqual(blockDwell, estateSettings.BlockDwell);
+ Assert.AreEqual(estateSkipScripts, estateSettings.EstateSkipScripts);
+ Assert.AreEqual(taxFree, estateSettings.TaxFree);
+ Assert.AreEqual(publicAccess, estateSettings.PublicAccess);
+ Assert.AreEqual(abuseEmail, estateSettings.AbuseEmail);
+ Assert.AreEqual(estateOwner, estateSettings.EstateOwner);
+ }
+
+ #endregion
+
+ }
+}
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
new file mode 100644
index 0000000..876dcf9
--- /dev/null
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -0,0 +1,347 @@
+/*
+ * 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 log4net.Config;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+using OpenMetaverse;
+using OpenSim.Framework;
+using log4net;
+using System.Reflection;
+using System.Data.Common;
+
+// DBMS-specific:
+using MySql.Data.MySqlClient;
+using OpenSim.Data.MySQL;
+
+using System.Data.SqlClient;
+using OpenSim.Data.MSSQL;
+
+using Mono.Data.Sqlite;
+using OpenSim.Data.SQLite;
+
+namespace OpenSim.Data.Tests
+{
+ [TestFixture(typeof(MySqlConnection), typeof(MySQLInventoryData), Description = "Inventory store tests (MySQL)")]
+ [TestFixture(typeof(SqlConnection), typeof(MSSQLInventoryData), Description = "Inventory store tests (MS SQL Server)")]
+ [TestFixture(typeof(SqliteConnection), typeof(SQLiteInventoryStore), Description = "Inventory store tests (SQLite)")]
+
+ public class InventoryTests : BasicDataServiceTest
+ where TConn : DbConnection, new()
+ where TInvStore : class, IInventoryDataPlugin, new()
+ {
+ public IInventoryDataPlugin db;
+
+ public UUID zero = UUID.Zero;
+
+ public UUID folder1 = UUID.Random();
+ public UUID folder2 = UUID.Random();
+ public UUID folder3 = UUID.Random();
+ public UUID owner1 = UUID.Random();
+ public UUID owner2 = UUID.Random();
+ public UUID owner3 = UUID.Random();
+
+ public UUID item1 = UUID.Random();
+ public UUID item2 = UUID.Random();
+ public UUID item3 = UUID.Random();
+ public UUID asset1 = UUID.Random();
+ public UUID asset2 = UUID.Random();
+ public UUID asset3 = UUID.Random();
+
+ public string name1;
+ public string name2 = "First Level folder";
+ public string name3 = "First Level folder 2";
+ public string niname1 = "My Shirt";
+ public string iname1 = "Shirt";
+ public string iname2 = "Text Board";
+ public string iname3 = "No Pants Barrel";
+
+ public InventoryTests(string conn) : base(conn)
+ {
+ name1 = "Root Folder for " + owner1.ToString();
+ }
+
+ protected override void InitService(object service)
+ {
+ db = (IInventoryDataPlugin)service;
+ db.Initialise(m_connStr);
+ ClearDB();
+ }
+
+ private void ClearDB()
+ {
+ DropTables("inventoryitems", "inventoryfolders");
+ ExecuteSql("delete from migrations where name='Inventory'");
+ }
+
+ [Test]
+ public void T001_LoadEmpty()
+ {
+ Assert.That(db.getInventoryFolder(zero), Is.Null);
+ Assert.That(db.getInventoryFolder(folder1), Is.Null);
+ Assert.That(db.getInventoryFolder(folder2), Is.Null);
+ Assert.That(db.getInventoryFolder(folder3), Is.Null);
+
+ Assert.That(db.getInventoryItem(zero), Is.Null);
+ Assert.That(db.getInventoryItem(item1), Is.Null);
+ Assert.That(db.getInventoryItem(item2), Is.Null);
+ Assert.That(db.getInventoryItem(item3), Is.Null);
+
+ Assert.That(db.getUserRootFolder(zero), Is.Null);
+ Assert.That(db.getUserRootFolder(owner1), Is.Null);
+ }
+
+ // 01x - folder tests
+ [Test]
+ public void T010_FolderNonParent()
+ {
+ InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2);
+ // the folder will go in
+ db.addInventoryFolder(f1);
+ InventoryFolderBase f1a = db.getUserRootFolder(owner1);
+ Assert.That(f1a, Is.Null);
+ }
+
+ [Test]
+ public void T011_FolderCreate()
+ {
+ InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1);
+ // TODO: this is probably wrong behavior, but is what we have
+ // db.updateInventoryFolder(f1);
+ // InventoryFolderBase f1a = db.getUserRootFolder(owner1);
+ // Assert.That(uuid1, Is.EqualTo(f1a.ID))
+ // Assert.That(name1, Text.Matches(f1a.Name), "Assert.That(name1, Text.Matches(f1a.Name))");
+ // Assert.That(db.getUserRootFolder(owner1), Is.Null);
+
+ // succeed with true
+ db.addInventoryFolder(f1);
+ InventoryFolderBase f1a = db.getUserRootFolder(owner1);
+ Assert.That(folder1, Is.EqualTo(f1a.ID), "Assert.That(folder1, Is.EqualTo(f1a.ID))");
+ Assert.That(name1, Text.Matches(f1a.Name), "Assert.That(name1, Text.Matches(f1a.Name))");
+ }
+
+ // we now have the following tree
+ // folder1
+ // +--- folder2
+ // +--- folder3
+
+ [Test]
+ public void T012_FolderList()
+ {
+ InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3);
+ db.addInventoryFolder(f2);
+
+ Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1), "Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1))");
+ Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(2), "Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(2))");
+ Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0))");
+ Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(0))");
+ Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0))");
+
+ }
+
+ [Test]
+ public void T013_FolderHierarchy()
+ {
+ Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
+ Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
+ Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))");
+ Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0))");
+ Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0))");
+ }
+
+
+ [Test]
+ public void T014_MoveFolder()
+ {
+ InventoryFolderBase f2 = db.getInventoryFolder(folder2);
+ f2.ParentID = folder3;
+ db.moveInventoryFolder(f2);
+
+ Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1), "Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1))");
+ Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(1), "Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(1))");
+ Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0))");
+ Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(1), "Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(1))");
+ Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0))");
+ }
+
+ [Test]
+ public void T015_FolderHierarchy()
+ {
+ Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
+ Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
+ Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))");
+ Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(1), "Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(1))");
+ Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0))");
+ }
+
+ // Item tests
+ [Test]
+ public void T100_NoItems()
+ {
+ Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
+ Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))");
+ Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0))");
+ Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(0))");
+ }
+
+ // TODO: Feeding a bad inventory item down the data path will
+ // crash the system. This is largely due to the builder
+ // routines. That should be fixed and tested for.
+ [Test]
+ public void T101_CreatItems()
+ {
+ db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1));
+ db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2));
+ db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3));
+ Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(3), "Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(3))");
+ }
+
+ [Test]
+ public void T102_CompareItems()
+ {
+ InventoryItemBase i1 = db.getInventoryItem(item1);
+ InventoryItemBase i2 = db.getInventoryItem(item2);
+ InventoryItemBase i3 = db.getInventoryItem(item3);
+ Assert.That(i1.Name, Is.EqualTo(iname1), "Assert.That(i1.Name, Is.EqualTo(iname1))");
+ Assert.That(i2.Name, Is.EqualTo(iname2), "Assert.That(i2.Name, Is.EqualTo(iname2))");
+ Assert.That(i3.Name, Is.EqualTo(iname3), "Assert.That(i3.Name, Is.EqualTo(iname3))");
+ Assert.That(i1.Owner, Is.EqualTo(owner1), "Assert.That(i1.Owner, Is.EqualTo(owner1))");
+ Assert.That(i2.Owner, Is.EqualTo(owner1), "Assert.That(i2.Owner, Is.EqualTo(owner1))");
+ Assert.That(i3.Owner, Is.EqualTo(owner1), "Assert.That(i3.Owner, Is.EqualTo(owner1))");
+ Assert.That(i1.AssetID, Is.EqualTo(asset1), "Assert.That(i1.AssetID, Is.EqualTo(asset1))");
+ Assert.That(i2.AssetID, Is.EqualTo(asset2), "Assert.That(i2.AssetID, Is.EqualTo(asset2))");
+ Assert.That(i3.AssetID, Is.EqualTo(asset3), "Assert.That(i3.AssetID, Is.EqualTo(asset3))");
+ }
+
+ [Test]
+ 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
+
+ InventoryItemBase i1 = db.getInventoryItem(item1);
+ i1.Name = niname1;
+ i1.Description = niname1;
+ i1.Owner = owner2;
+ db.updateInventoryItem(i1);
+
+ i1 = db.getInventoryItem(item1);
+ Assert.That(i1.Name, Is.EqualTo(niname1), "Assert.That(i1.Name, Is.EqualTo(niname1))");
+ Assert.That(i1.Description, Is.EqualTo(niname1), "Assert.That(i1.Description, Is.EqualTo(niname1))");
+ Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))");
+ }
+
+ [Test]
+ public void T104_RandomUpdateItem()
+ {
+ PropertyScrambler folderScrambler =
+ new PropertyScrambler()
+ .DontScramble(x => x.Owner)
+ .DontScramble(x => x.ParentID)
+ .DontScramble(x => x.ID);
+ UUID owner = UUID.Random();
+ UUID folder = UUID.Random();
+ UUID rootId = UUID.Random();
+ UUID rootAsset = UUID.Random();
+ InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1);
+ folderScrambler.Scramble(f1);
+
+ db.addInventoryFolder(f1);
+ InventoryFolderBase f1a = db.getUserRootFolder(owner);
+ Assert.That(f1a, Constraints.PropertyCompareConstraint(f1));
+
+ folderScrambler.Scramble(f1a);
+
+ db.updateInventoryFolder(f1a);
+
+ InventoryFolderBase f1b = db.getUserRootFolder(owner);
+ Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a));
+
+ //Now we have a valid folder to insert into, we can insert the item.
+ PropertyScrambler inventoryScrambler =
+ new PropertyScrambler()
+ .DontScramble(x => x.ID)
+ .DontScramble(x => x.AssetID)
+ .DontScramble(x => x.Owner)
+ .DontScramble(x => x.Folder);
+ InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset);
+ inventoryScrambler.Scramble(root);
+ db.addInventoryItem(root);
+
+ InventoryItemBase expected = db.getInventoryItem(rootId);
+ Assert.That(expected, Constraints.PropertyCompareConstraint(root)
+ .IgnoreProperty(x => x.InvType)
+ .IgnoreProperty(x => x.CreatorIdAsUuid)
+ .IgnoreProperty(x => x.Description)
+ .IgnoreProperty(x => x.CreatorId));
+
+ inventoryScrambler.Scramble(expected);
+ db.updateInventoryItem(expected);
+
+ InventoryItemBase actual = db.getInventoryItem(rootId);
+ Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
+ .IgnoreProperty(x => x.InvType)
+ .IgnoreProperty(x => x.CreatorIdAsUuid)
+ .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();
+ i.ID = id;
+ i.Folder = parent;
+ i.Owner = owner;
+ i.CreatorId = owner.ToString();
+ i.Name = name;
+ i.Description = name;
+ i.AssetID = asset;
+ return i;
+ }
+
+ private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name)
+ {
+ InventoryFolderBase f = new InventoryFolderBase();
+ f.ID = id;
+ f.ParentID = parent;
+ f.Owner = owner;
+ f.Name = name;
+ return f;
+ }
+ }
+}
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
new file mode 100644
index 0000000..2a97368
--- /dev/null
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -0,0 +1,1082 @@
+/*
+ * 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.Drawing;
+using System.Text;
+using log4net.Config;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using log4net;
+using System.Reflection;
+using System.Data.Common;
+
+// DBMS-specific:
+using MySql.Data.MySqlClient;
+using OpenSim.Data.MySQL;
+
+using System.Data.SqlClient;
+using OpenSim.Data.MSSQL;
+
+using Mono.Data.Sqlite;
+using OpenSim.Data.SQLite;
+
+namespace OpenSim.Data.Tests
+{
+ [TestFixture(typeof(MySqlConnection), typeof(MySqlRegionData), Description = "Region store tests (MySQL)")]
+ [TestFixture(typeof(SqlConnection), typeof(MSSQLRegionData), Description = "Region store tests (MS SQL Server)")]
+ [TestFixture(typeof(SqliteConnection), typeof(SQLiteRegionData), Description = "Region store tests (SQLite)")]
+
+ public class RegionTests : BasicDataServiceTest
+ where TConn : DbConnection, new()
+ where TRegStore : class, IRegionDataStore, new()
+ {
+ public IRegionDataStore db;
+ public UUID zero = UUID.Zero;
+ public UUID region1 = UUID.Random();
+ public UUID region2 = UUID.Random();
+ public UUID region3 = UUID.Random();
+ public UUID region4 = UUID.Random();
+ public UUID prim1 = UUID.Random();
+ public UUID prim2 = UUID.Random();
+ public UUID prim3 = UUID.Random();
+ public UUID prim4 = UUID.Random();
+ public UUID prim5 = UUID.Random();
+ public UUID prim6 = UUID.Random();
+ public UUID item1 = UUID.Random();
+ public UUID item2 = UUID.Random();
+ public UUID item3 = UUID.Random();
+
+ public static Random random = new Random();
+
+ public string itemname1 = "item1";
+
+ public uint localID = 1;
+
+ public double height1 = 20;
+ public double height2 = 100;
+
+
+ protected override void InitService(object service)
+ {
+ db = (IRegionDataStore)service;
+ db.Initialise(m_connStr);
+ ClearDB();
+ }
+
+
+ private void ClearDB()
+ {
+ // if a new table is added, it has to be dropped here
+ ExecuteSql("delete from migrations where name='RegionStore';");
+
+ DropTables(
+ "prims",
+ "primshapes",
+ "primitems",
+ "terrain",
+ "land",
+ "landaccesslist",
+ "regionban",
+ "regionsettings"
+ );
+ }
+
+
+ // Test Plan
+ // Prims
+ // - empty test - 001
+ // - store / retrieve basic prims (most minimal we can make) - 010, 011
+ // - store / retrieve parts in a scenegroup 012
+ // - store a prim with complete information for consistency check 013
+ // - update existing prims, make sure it sticks - 014
+ // - tests empty inventory - 020
+ // - add inventory items to prims make - 021
+ // - retrieves the added item - 022
+ // - update inventory items to prims - 023
+ // - remove inventory items make sure it sticks - 024
+ // - checks if all parameters are persistent - 025
+ // - adds many items and see if it is handled correctly - 026
+
+ [Test]
+ public void T001_LoadEmpty()
+ {
+ List objs = db.LoadObjects(region1);
+ List objs3 = db.LoadObjects(region3);
+ List land = db.LoadLandObjects(region1);
+
+ Assert.That(objs.Count, Is.EqualTo(0), "Assert.That(objs.Count, Is.EqualTo(0))");
+ Assert.That(objs3.Count, Is.EqualTo(0), "Assert.That(objs3.Count, Is.EqualTo(0))");
+ Assert.That(land.Count, Is.EqualTo(0), "Assert.That(land.Count, Is.EqualTo(0))");
+ }
+
+ // SOG round trips
+ // * store objects, make sure they save
+ // * update
+
+ [Test]
+ public void T010_StoreSimpleObject()
+ {
+ SceneObjectGroup sog = NewSOG("object1", prim1, region1);
+ SceneObjectGroup sog2 = NewSOG("object2", prim2, region1);
+
+ // in case the objects don't store
+ try
+ {
+ db.StoreObject(sog, region1);
+ }
+ catch (Exception e)
+ {
+ m_log.Error(e.ToString());
+ Assert.Fail();
+ }
+
+ try
+ {
+ db.StoreObject(sog2, region1);
+ }
+ catch (Exception e)
+ {
+ m_log.Error(e.ToString());
+ Assert.Fail();
+ }
+
+ // This tests the ADO.NET driver
+ List objs = db.LoadObjects(region1);
+
+ Assert.That(objs.Count, Is.EqualTo(2), "Assert.That(objs.Count, Is.EqualTo(2))");
+ }
+
+ [Test]
+ public void T011_ObjectNames()
+ {
+ List objs = db.LoadObjects(region1);
+ foreach (SceneObjectGroup sog in objs)
+ {
+ SceneObjectPart p = sog.RootPart;
+ Assert.That("", Is.Not.EqualTo(p.Name), "Assert.That(\"\", Is.Not.EqualTo(p.Name))");
+ Assert.That(p.Name, Is.EqualTo(p.Description), "Assert.That(p.Name, Is.EqualTo(p.Description))");
+ }
+ }
+
+ [Test]
+ public void T012_SceneParts()
+ {
+ UUID tmp0 = UUID.Random();
+ UUID tmp1 = UUID.Random();
+ UUID tmp2 = UUID.Random();
+ UUID tmp3 = UUID.Random();
+ UUID newregion = UUID.Random();
+ SceneObjectPart p1 = NewSOP("SoP 1",tmp1);
+ SceneObjectPart p2 = NewSOP("SoP 2",tmp2);
+ SceneObjectPart p3 = NewSOP("SoP 3",tmp3);
+ SceneObjectGroup sog = NewSOG("Sop 0", tmp0, newregion);
+ 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.HasChildPrim(tmp0), "Assert.That(newsog.HasChildPrim(tmp0))");
+ Assert.That(newsog.HasChildPrim(tmp1), "Assert.That(newsog.HasChildPrim(tmp1))");
+ Assert.That(newsog.HasChildPrim(tmp2), "Assert.That(newsog.HasChildPrim(tmp2))");
+ Assert.That(newsog.HasChildPrim(tmp3), "Assert.That(newsog.HasChildPrim(tmp3))");
+ }
+
+ [Test]
+ public void T013_DatabasePersistency()
+ {
+ // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data
+ // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored
+ // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently.
+ UUID creator,uuid = new UUID();
+ creator = UUID.Random();
+ uint iserial = (uint)random.Next();
+ TaskInventoryDictionary dic = new TaskInventoryDictionary();
+ uint objf = (uint) random.Next();
+ uuid = prim4;
+ uint localid = localID+1;
+ localID = localID + 1;
+ string name = "Adam West";
+ byte material = (byte) random.Next(127);
+ ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
+ int pin = random.Next();
+ Byte[] partsys = new byte[8];
+ Byte[] textani = new byte[8];
+ random.NextBytes(textani);
+ random.NextBytes(partsys);
+ DateTime expires = new DateTime(2008, 12, 20);
+ DateTime rezzed = new DateTime(2009, 07, 15);
+ Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next());
+ Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
+ Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next());
+ string description = name;
+ Color color = Color.FromArgb(255, 165, 50, 100);
+ string text = "All Your Base Are Belong to Us";
+ string sitname = "SitName";
+ string touchname = "TouchName";
+ int linknum = random.Next();
+ byte clickaction = (byte) random.Next(127);
+ PrimitiveBaseShape pbshap = new PrimitiveBaseShape();
+ pbshap = PrimitiveBaseShape.Default;
+ pbshap.PathBegin = ushort.MaxValue;
+ pbshap.PathEnd = ushort.MaxValue;
+ pbshap.ProfileBegin = ushort.MaxValue;
+ pbshap.ProfileEnd = ushort.MaxValue;
+ pbshap.ProfileHollow = ushort.MaxValue;
+ Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next());
+ byte updatef = (byte) random.Next(127);
+
+ RegionInfo regionInfo = new RegionInfo();
+ regionInfo.RegionID = region3;
+ regionInfo.RegionLocX = 0;
+ regionInfo.RegionLocY = 0;
+
+// Scene scene = new Scene(regionInfo);
+
+ SceneObjectPart sop = new SceneObjectPart();
+ sop.RegionHandle = regionh;
+ sop.UUID = uuid;
+ sop.LocalId = localid;
+ sop.Shape = pbshap;
+ sop.GroupPosition = groupos;
+ sop.RotationOffset = rotoff;
+ sop.CreatorID = creator;
+ sop.InventorySerial = iserial;
+ sop.TaskInventory = dic;
+ sop.ObjectFlags = objf;
+ sop.Name = name;
+ sop.Material = material;
+ sop.ScriptAccessPin = pin;
+ sop.TextureAnimation = textani;
+ sop.ParticleSystem = partsys;
+ sop.Expires = expires;
+ sop.Rezzed = rezzed;
+ sop.OffsetPosition = offset;
+ sop.Velocity = velocity;
+ sop.AngularVelocity = angvelo;
+ sop.Acceleration = accel;
+ sop.Description = description;
+ sop.Color = color;
+ sop.Text = text;
+ sop.SitName = sitname;
+ sop.TouchName = touchname;
+ sop.LinkNum = linknum;
+ sop.ClickAction = clickaction;
+ sop.Scale = scale;
+ sop.UpdateFlag = updatef;
+
+ //Tests if local part accepted the parameters:
+ Assert.That(regionh,Is.EqualTo(sop.RegionHandle), "Assert.That(regionh,Is.EqualTo(sop.RegionHandle))");
+ Assert.That(localid,Is.EqualTo(sop.LocalId), "Assert.That(localid,Is.EqualTo(sop.LocalId))");
+ Assert.That(groupos,Is.EqualTo(sop.GroupPosition), "Assert.That(groupos,Is.EqualTo(sop.GroupPosition))");
+ Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))");
+ Assert.That(rotoff,Is.EqualTo(sop.RotationOffset), "Assert.That(rotoff,Is.EqualTo(sop.RotationOffset))");
+ Assert.That(uuid,Is.EqualTo(sop.UUID), "Assert.That(uuid,Is.EqualTo(sop.UUID))");
+ Assert.That(creator,Is.EqualTo(sop.CreatorID), "Assert.That(creator,Is.EqualTo(sop.CreatorID))");
+ // Modified in-class
+ // Assert.That(iserial,Is.EqualTo(sop.InventorySerial), "Assert.That(iserial,Is.EqualTo(sop.InventorySerial))");
+ Assert.That(dic,Is.EqualTo(sop.TaskInventory), "Assert.That(dic,Is.EqualTo(sop.TaskInventory))");
+ Assert.That(objf,Is.EqualTo(sop.ObjectFlags), "Assert.That(objf,Is.EqualTo(sop.ObjectFlags))");
+ Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))");
+ Assert.That(material,Is.EqualTo(sop.Material), "Assert.That(material,Is.EqualTo(sop.Material))");
+ Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))");
+ Assert.That(textani,Is.EqualTo(sop.TextureAnimation), "Assert.That(textani,Is.EqualTo(sop.TextureAnimation))");
+ Assert.That(partsys,Is.EqualTo(sop.ParticleSystem), "Assert.That(partsys,Is.EqualTo(sop.ParticleSystem))");
+ Assert.That(expires,Is.EqualTo(sop.Expires), "Assert.That(expires,Is.EqualTo(sop.Expires))");
+ Assert.That(rezzed,Is.EqualTo(sop.Rezzed), "Assert.That(rezzed,Is.EqualTo(sop.Rezzed))");
+ Assert.That(offset,Is.EqualTo(sop.OffsetPosition), "Assert.That(offset,Is.EqualTo(sop.OffsetPosition))");
+ Assert.That(velocity,Is.EqualTo(sop.Velocity), "Assert.That(velocity,Is.EqualTo(sop.Velocity))");
+ Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity))");
+ Assert.That(accel,Is.EqualTo(sop.Acceleration), "Assert.That(accel,Is.EqualTo(sop.Acceleration))");
+ Assert.That(description,Is.EqualTo(sop.Description), "Assert.That(description,Is.EqualTo(sop.Description))");
+ Assert.That(color,Is.EqualTo(sop.Color), "Assert.That(color,Is.EqualTo(sop.Color))");
+ Assert.That(text,Is.EqualTo(sop.Text), "Assert.That(text,Is.EqualTo(sop.Text))");
+ Assert.That(sitname,Is.EqualTo(sop.SitName), "Assert.That(sitname,Is.EqualTo(sop.SitName))");
+ Assert.That(touchname,Is.EqualTo(sop.TouchName), "Assert.That(touchname,Is.EqualTo(sop.TouchName))");
+ Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))");
+ Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))");
+ Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))");
+ Assert.That(updatef,Is.EqualTo(sop.UpdateFlag), "Assert.That(updatef,Is.EqualTo(sop.UpdateFlag))");
+
+ // This is necessary or object will not be inserted in DB
+ sop.ObjectFlags = 0;
+
+ SceneObjectGroup sog = new SceneObjectGroup(sop);
+
+ // Inserts group in DB
+ db.StoreObject(sog,region3);
+ List sogs = db.LoadObjects(region3);
+ Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
+ // Makes sure there are no double insertions:
+ db.StoreObject(sog,region3);
+ sogs = db.LoadObjects(region3);
+ Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
+
+
+ // Tests if the parameters were inserted correctly
+ SceneObjectPart p = sogs[0].RootPart;
+ Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))");
+ //Assert.That(localid,Is.EqualTo(p.LocalId), "Assert.That(localid,Is.EqualTo(p.LocalId))");
+ Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))");
+ Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
+ Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))");
+ Assert.That(uuid,Is.EqualTo(p.UUID), "Assert.That(uuid,Is.EqualTo(p.UUID))");
+ Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))");
+ //Assert.That(iserial,Is.EqualTo(p.InventorySerial), "Assert.That(iserial,Is.EqualTo(p.InventorySerial))");
+ Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))");
+ //Assert.That(objf,Is.EqualTo(p.ObjectFlags), "Assert.That(objf,Is.EqualTo(p.ObjectFlags))");
+ Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
+ Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))");
+ Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))");
+ Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))");
+ Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))");
+ //Assert.That(expires,Is.EqualTo(p.Expires), "Assert.That(expires,Is.EqualTo(p.Expires))");
+ //Assert.That(rezzed,Is.EqualTo(p.Rezzed), "Assert.That(rezzed,Is.EqualTo(p.Rezzed))");
+ Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))");
+ Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))");
+ Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))");
+ Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))");
+ Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))");
+ Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))");
+ Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))");
+ Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))");
+ Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))");
+ //Assert.That(linknum,Is.EqualTo(p.LinkNum), "Assert.That(linknum,Is.EqualTo(p.LinkNum))");
+ Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
+ Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))");
+
+ //Assert.That(updatef,Is.EqualTo(p.UpdateFlag), "Assert.That(updatef,Is.EqualTo(p.UpdateFlag))");
+
+ Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin), "Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin))");
+ Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd), "Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd))");
+ Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin), "Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin))");
+ Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))");
+ Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))");
+ }
+
+ [Test]
+ public void T014_UpdateObject()
+ {
+ string text1 = "object1 text";
+ SceneObjectGroup sog = FindSOG("object1", region1);
+ sog.RootPart.Text = text1;
+ db.StoreObject(sog, region1);
+
+ sog = FindSOG("object1", region1);
+ Assert.That(text1, Is.EqualTo(sog.RootPart.Text), "Assert.That(text1, Is.EqualTo(sog.RootPart.Text))");
+
+ // Creates random values
+ UUID creator = new UUID();
+ creator = UUID.Random();
+ TaskInventoryDictionary dic = new TaskInventoryDictionary();
+ localID = localID + 1;
+ string name = "West Adam";
+ byte material = (byte) random.Next(127);
+ ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
+ int pin = random.Next();
+ Byte[] partsys = new byte[8];
+ Byte[] textani = new byte[8];
+ random.NextBytes(textani);
+ random.NextBytes(partsys);
+ DateTime expires = new DateTime(2010, 12, 20);
+ DateTime rezzed = new DateTime(2005, 07, 15);
+ Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next());
+ Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
+ Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next());
+ string description = name;
+ Color color = Color.FromArgb(255, 255, 255, 0);
+ string text = "What You Say?{]\vz~";
+ string sitname = RandomName();
+ string touchname = RandomName();
+ int linknum = random.Next();
+ byte clickaction = (byte) random.Next(127);
+ PrimitiveBaseShape pbshap = new PrimitiveBaseShape();
+ pbshap = PrimitiveBaseShape.Default;
+ Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next());
+ byte updatef = (byte) random.Next(127);
+
+ // Updates the region with new values
+ SceneObjectGroup sog2 = FindSOG("Adam West", region3);
+ Assert.That(sog2,Is.Not.Null);
+ sog2.RootPart.RegionHandle = regionh;
+ sog2.RootPart.Shape = pbshap;
+ sog2.RootPart.GroupPosition = groupos;
+ sog2.RootPart.RotationOffset = rotoff;
+ sog2.RootPart.CreatorID = creator;
+ sog2.RootPart.TaskInventory = dic;
+ sog2.RootPart.Name = name;
+ sog2.RootPart.Material = material;
+ sog2.RootPart.ScriptAccessPin = pin;
+ sog2.RootPart.TextureAnimation = textani;
+ sog2.RootPart.ParticleSystem = partsys;
+ sog2.RootPart.Expires = expires;
+ sog2.RootPart.Rezzed = rezzed;
+ sog2.RootPart.OffsetPosition = offset;
+ sog2.RootPart.Velocity = velocity;
+ sog2.RootPart.AngularVelocity = angvelo;
+ sog2.RootPart.Acceleration = accel;
+ sog2.RootPart.Description = description;
+ sog2.RootPart.Color = color;
+ sog2.RootPart.Text = text;
+ sog2.RootPart.SitName = sitname;
+ sog2.RootPart.TouchName = touchname;
+ sog2.RootPart.LinkNum = linknum;
+ sog2.RootPart.ClickAction = clickaction;
+ sog2.RootPart.Scale = scale;
+ sog2.RootPart.UpdateFlag = updatef;
+
+ db.StoreObject(sog2, region3);
+ List sogs = db.LoadObjects(region3);
+ Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
+
+ SceneObjectGroup retsog = FindSOG("West Adam", region3);
+ Assert.That(retsog,Is.Not.Null);
+ SceneObjectPart p = retsog.RootPart;
+ Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))");
+ Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))");
+ Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
+ Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))");
+ Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))");
+ Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))");
+ Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
+ Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))");
+ Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))");
+ Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))");
+ Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))");
+ Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))");
+ Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))");
+ Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))");
+ Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))");
+ Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))");
+ Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))");
+ Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))");
+ Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))");
+ Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))");
+ Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
+ Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))");
+ }
+
+ [Test]
+ public void T015_LargeSceneObjects()
+ {
+ UUID id = UUID.Random();
+ Dictionary mydic = new Dictionary();
+ SceneObjectGroup sog = NewSOG("Test SOG", id, region4);
+ mydic.Add(sog.RootPart.UUID,sog.RootPart);
+ for (int i=0;i<30;i++)
+ {
+ UUID tmp = UUID.Random();
+ SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp);
+ Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next());
+ Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
+ Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next());
+ Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next());
+
+ sop.GroupPosition = groupos;
+ sop.RotationOffset = rotoff;
+ sop.OffsetPosition = offset;
+ sop.Velocity = velocity;
+ sop.AngularVelocity = angvelo;
+ sop.Acceleration = accel;
+
+ mydic.Add(tmp,sop);
+ sog.AddPart(sop);
+ db.StoreObject(sog, region4);
+ }
+
+ SceneObjectGroup retsog = FindSOG("Test SOG", region4);
+ SceneObjectPart[] parts = retsog.GetParts();
+ for (int i=0;i<30;i++)
+ {
+ SceneObjectPart cursop = mydic[parts[i].UUID];
+ Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))");
+ Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset), "Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset))");
+ Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition), "Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition))");
+ Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity), "Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity))");
+ Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity), "Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity))");
+ Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))");
+ }
+ }
+
+ //[Test]
+ public void T016_RandomSogWithSceneParts()
+ {
+ PropertyScrambler scrambler =
+ new PropertyScrambler()
+ .DontScramble(x => x.UUID);
+ 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;
+ p1.UUID = tmp1;
+ p2.UUID = tmp2;
+ p3.UUID = tmp3;
+ scrambler.Scramble(p1);
+ scrambler.Scramble(p2);
+ scrambler.Scramble(p3);
+
+ SceneObjectGroup sog = NewSOG("Sop 0", tmpSog, newregion);
+ PropertyScrambler sogScrambler =
+ new PropertyScrambler()
+ .DontScramble(x => x.UUID);
+ sogScrambler.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.RegionUUID)
+ .IgnoreProperty(x=>x.Scene)
+ .IgnoreProperty(x=>x.Children)
+ .IgnoreProperty(x=>x.PassCollision)
+ .IgnoreProperty(x=>x.RootPart));
+ }
+
+ [Test]
+ public void T020_PrimInventoryEmpty()
+ {
+ SceneObjectGroup sog = FindSOG("object1", region1);
+ TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
+ Assert.That(t, Is.Null);
+ }
+
+ [Test]
+ public void T021_PrimInventoryStore()
+ {
+ SceneObjectGroup sog = FindSOG("object1", region1);
+ InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
+
+ Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
+ TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
+ Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
+
+ // TODO: seriously??? this is the way we need to loop to get this?
+
+ List list = new List();
+ foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList())
+ {
+ list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid));
+ }
+
+ db.StorePrimInventory(prim1, list);
+ }
+
+ [Test]
+ public void T022_PrimInventoryRetrieve()
+ {
+ SceneObjectGroup sog = FindSOG("object1", region1);
+ TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
+
+ Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
+ }
+
+ [Test]
+ public void T023_PrimInventoryUpdate()
+ {
+ SceneObjectGroup sog = FindSOG("object1", region1);
+ TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
+
+ t.Name = "My New Name";
+ sog.UpdateInventoryItem(t);
+
+ Assert.That(t.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
+
+ }
+
+ [Test]
+ public void T024_PrimInventoryRemove()
+ {
+ List list = new List();
+ db.StorePrimInventory(prim1, list);
+
+ SceneObjectGroup sog = FindSOG("object1", region1);
+ TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
+ Assert.That(t, Is.Null);
+ }
+
+ [Test]
+ public void T025_PrimInventoryPersistency()
+ {
+ InventoryItemBase i = new InventoryItemBase();
+ UUID id = UUID.Random();
+ i.ID = id;
+ UUID folder = UUID.Random();
+ i.Folder = folder;
+ UUID owner = UUID.Random();
+ i.Owner = owner;
+ UUID creator = UUID.Random();
+ i.CreatorId = creator.ToString();
+ string name = RandomName();
+ i.Name = name;
+ i.Description = name;
+ UUID assetid = UUID.Random();
+ i.AssetID = assetid;
+ int invtype = random.Next();
+ i.InvType = invtype;
+ uint nextperm = (uint) random.Next();
+ i.NextPermissions = nextperm;
+ uint curperm = (uint) random.Next();
+ i.CurrentPermissions = curperm;
+ uint baseperm = (uint) random.Next();
+ i.BasePermissions = baseperm;
+ uint eoperm = (uint) random.Next();
+ i.EveryOnePermissions = eoperm;
+ int assettype = random.Next();
+ i.AssetType = assettype;
+ UUID groupid = UUID.Random();
+ i.GroupID = groupid;
+ bool groupown = true;
+ i.GroupOwned = groupown;
+ int saleprice = random.Next();
+ i.SalePrice = saleprice;
+ byte saletype = (byte) random.Next(127);
+ i.SaleType = saletype;
+ uint flags = (uint) random.Next();
+ i.Flags = flags;
+ int creationd = random.Next();
+ i.CreationDate = creationd;
+
+ SceneObjectGroup sog = FindSOG("object1", region1);
+ Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
+ TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
+
+ Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))");
+ Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))");
+ Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))");
+ Assert.That(t.CreationDate,Is.EqualTo(creationd), "Assert.That(t.CreationDate,Is.EqualTo(creationd))");
+ Assert.That(t.CreatorID,Is.EqualTo(creator), "Assert.That(t.CreatorID,Is.EqualTo(creator))");
+ Assert.That(t.Description,Is.EqualTo(name), "Assert.That(t.Description,Is.EqualTo(name))");
+ Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm), "Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm))");
+ Assert.That(t.Flags,Is.EqualTo(flags), "Assert.That(t.Flags,Is.EqualTo(flags))");
+ Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID), "Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID))");
+ // Where is this group permissions??
+ // Assert.That(t.GroupPermissions,Is.EqualTo(), "Assert.That(t.GroupPermissions,Is.EqualTo())");
+ Assert.That(t.Type,Is.EqualTo(assettype), "Assert.That(t.Type,Is.EqualTo(assettype))");
+ Assert.That(t.InvType, Is.EqualTo(invtype), "Assert.That(t.InvType, Is.EqualTo(invtype))");
+ Assert.That(t.ItemID, Is.EqualTo(id), "Assert.That(t.ItemID, Is.EqualTo(id))");
+ Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID), "Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID))");
+ Assert.That(t.NextPermissions, Is.EqualTo(nextperm), "Assert.That(t.NextPermissions, Is.EqualTo(nextperm))");
+ // Ownership changes when you drop an object into an object
+ // owned by someone else
+ Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID), "Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID))");
+ Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8), "Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8))");
+ Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))");
+ Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))");
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void T026_PrimInventoryMany()
+ {
+ UUID i1,i2,i3,i4;
+ i1 = UUID.Random();
+ i2 = UUID.Random();
+ i3 = UUID.Random();
+ i4 = i3;
+ InventoryItemBase ib1 = NewItem(i1, zero, zero, RandomName(), zero);
+ InventoryItemBase ib2 = NewItem(i2, zero, zero, RandomName(), zero);
+ InventoryItemBase ib3 = NewItem(i3, zero, zero, RandomName(), zero);
+ InventoryItemBase ib4 = NewItem(i4, zero, zero, RandomName(), zero);
+
+ SceneObjectGroup sog = FindSOG("object1", region1);
+
+ Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib1, zero), Is.True);
+ Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib2, zero), Is.True);
+ Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib3, zero), Is.True);
+ Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib4, zero), Is.True);
+
+ TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1);
+ Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))");
+ TaskInventoryItem t2 = sog.GetInventoryItem(sog.RootPart.LocalId, i2);
+ Assert.That(t2.Name, Is.EqualTo(ib2.Name), "Assert.That(t2.Name, Is.EqualTo(ib2.Name))");
+ TaskInventoryItem t3 = sog.GetInventoryItem(sog.RootPart.LocalId, i3);
+ Assert.That(t3.Name, Is.EqualTo(ib3.Name), "Assert.That(t3.Name, Is.EqualTo(ib3.Name))");
+ TaskInventoryItem t4 = sog.GetInventoryItem(sog.RootPart.LocalId, i4);
+ Assert.That(t4, Is.Null);
+ }
+
+ [Test]
+ public void T052_RemoveObject()
+ {
+ db.RemoveObject(prim1, region1);
+ SceneObjectGroup sog = FindSOG("object1", region1);
+ Assert.That(sog, Is.Null);
+ }
+
+
+ [Test]
+ public void T100_DefaultRegionInfo()
+ {
+ RegionSettings r1 = db.LoadRegionSettings(region1);
+ Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))");
+
+ RegionSettings r2 = db.LoadRegionSettings(region2);
+ Assert.That(r2.RegionUUID, Is.EqualTo(region2), "Assert.That(r2.RegionUUID, Is.EqualTo(region2))");
+ }
+
+ [Test]
+ public void T101_UpdateRegionInfo()
+ {
+ int agentlimit = random.Next();
+ double objectbonus = random.Next();
+ int maturity = random.Next();
+ UUID tertex1 = UUID.Random();
+ UUID tertex2 = UUID.Random();
+ UUID tertex3 = UUID.Random();
+ UUID tertex4 = UUID.Random();
+ double elev1nw = random.Next();
+ double elev2nw = random.Next();
+ double elev1ne = random.Next();
+ double elev2ne = random.Next();
+ double elev1se = random.Next();
+ double elev2se = random.Next();
+ double elev1sw = random.Next();
+ double elev2sw = random.Next();
+ double waterh = random.Next();
+ double terrainraise = random.Next();
+ double terrainlower = random.Next();
+ Vector3 sunvector = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
+ UUID terimgid = UUID.Random();
+ double sunpos = random.Next();
+ UUID cov = UUID.Random();
+
+ RegionSettings r1 = db.LoadRegionSettings(region1);
+ r1.BlockTerraform = true;
+ r1.BlockFly = true;
+ r1.AllowDamage = true;
+ r1.RestrictPushing = true;
+ r1.AllowLandResell = false;
+ r1.AllowLandJoinDivide = false;
+ r1.BlockShowInSearch = true;
+ r1.AgentLimit = agentlimit;
+ r1.ObjectBonus = objectbonus;
+ r1.Maturity = maturity;
+ r1.DisableScripts = true;
+ r1.DisableCollisions = true;
+ r1.DisablePhysics = true;
+ r1.TerrainTexture1 = tertex1;
+ r1.TerrainTexture2 = tertex2;
+ r1.TerrainTexture3 = tertex3;
+ r1.TerrainTexture4 = tertex4;
+ r1.Elevation1NW = elev1nw;
+ r1.Elevation2NW = elev2nw;
+ r1.Elevation1NE = elev1ne;
+ r1.Elevation2NE = elev2ne;
+ r1.Elevation1SE = elev1se;
+ r1.Elevation2SE = elev2se;
+ r1.Elevation1SW = elev1sw;
+ r1.Elevation2SW = elev2sw;
+ r1.WaterHeight = waterh;
+ r1.TerrainRaiseLimit = terrainraise;
+ r1.TerrainLowerLimit = terrainlower;
+ r1.UseEstateSun = false;
+ r1.Sandbox = true;
+ r1.SunVector = sunvector;
+ r1.TerrainImageID = terimgid;
+ r1.FixedSun = true;
+ r1.SunPosition = sunpos;
+ r1.Covenant = cov;
+
+ db.StoreRegionSettings(r1);
+
+ RegionSettings r1a = db.LoadRegionSettings(region1);
+ Assert.That(r1a.RegionUUID, Is.EqualTo(region1), "Assert.That(r1a.RegionUUID, Is.EqualTo(region1))");
+ Assert.That(r1a.BlockTerraform,Is.True);
+ Assert.That(r1a.BlockFly,Is.True);
+ Assert.That(r1a.AllowDamage,Is.True);
+ Assert.That(r1a.RestrictPushing,Is.True);
+ Assert.That(r1a.AllowLandResell,Is.False);
+ Assert.That(r1a.AllowLandJoinDivide,Is.False);
+ Assert.That(r1a.BlockShowInSearch,Is.True);
+ Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit), "Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit))");
+ Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus), "Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus))");
+ Assert.That(r1a.Maturity,Is.EqualTo(maturity), "Assert.That(r1a.Maturity,Is.EqualTo(maturity))");
+ Assert.That(r1a.DisableScripts,Is.True);
+ Assert.That(r1a.DisableCollisions,Is.True);
+ Assert.That(r1a.DisablePhysics,Is.True);
+ Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1), "Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1))");
+ Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2), "Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2))");
+ Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3), "Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3))");
+ Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4), "Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4))");
+ Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw), "Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw))");
+ Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw), "Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw))");
+ Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne), "Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne))");
+ Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne), "Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne))");
+ Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se), "Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se))");
+ Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se), "Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se))");
+ Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw), "Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw))");
+ Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw), "Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw))");
+ Assert.That(r1a.WaterHeight,Is.EqualTo(waterh), "Assert.That(r1a.WaterHeight,Is.EqualTo(waterh))");
+ Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise), "Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise))");
+ Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower), "Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower))");
+ Assert.That(r1a.UseEstateSun,Is.False);
+ Assert.That(r1a.Sandbox,Is.True);
+ Assert.That(r1a.SunVector,Is.EqualTo(sunvector), "Assert.That(r1a.SunVector,Is.EqualTo(sunvector))");
+ //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))");
+ Assert.That(r1a.FixedSun,Is.True);
+ Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))");
+ Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))");
+
+ }
+
+ [Test]
+ public void T300_NoTerrain()
+ {
+ Assert.That(db.LoadTerrain(zero), Is.Null);
+ Assert.That(db.LoadTerrain(region1), Is.Null);
+ Assert.That(db.LoadTerrain(region2), Is.Null);
+ Assert.That(db.LoadTerrain(UUID.Random()), Is.Null);
+ }
+
+ [Test]
+ public void T301_CreateTerrain()
+ {
+ double[,] t1 = GenTerrain(height1);
+ db.StoreTerrain(t1, region1);
+
+ Assert.That(db.LoadTerrain(zero), Is.Null);
+ Assert.That(db.LoadTerrain(region1), Is.Not.Null);
+ Assert.That(db.LoadTerrain(region2), Is.Null);
+ Assert.That(db.LoadTerrain(UUID.Random()), Is.Null);
+ }
+
+ [Test]
+ public void T302_FetchTerrain()
+ {
+ double[,] baseterrain1 = GenTerrain(height1);
+ double[,] baseterrain2 = GenTerrain(height2);
+ double[,] t1 = db.LoadTerrain(region1);
+ Assert.That(CompareTerrain(t1, baseterrain1), Is.True);
+ Assert.That(CompareTerrain(t1, baseterrain2), Is.False);
+ }
+
+ [Test]
+ public void T303_UpdateTerrain()
+ {
+ double[,] baseterrain1 = GenTerrain(height1);
+ double[,] baseterrain2 = GenTerrain(height2);
+ db.StoreTerrain(baseterrain2, region1);
+
+ double[,] t1 = db.LoadTerrain(region1);
+ Assert.That(CompareTerrain(t1, baseterrain1), Is.False);
+ Assert.That(CompareTerrain(t1, baseterrain2), Is.True);
+ }
+
+ [Test]
+ public void T400_EmptyLand()
+ {
+ Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))");
+ Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))");
+ Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))");
+ Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0))");
+ }
+
+ // TODO: we should have real land tests, but Land is so
+ // intermingled with scene that you can't test it without a
+ // valid scene. That requires some disagregation.
+
+
+ //************************************************************************************//
+ // Extra private methods
+
+ private double[,] GenTerrain(double value)
+ {
+ double[,] terret = new double[Constants.RegionSize, Constants.RegionSize];
+ terret.Initialize();
+ for (int x = 0; x < Constants.RegionSize; x++)
+ for (int y = 0; y < Constants.RegionSize; y++)
+ terret[x,y] = value;
+
+ return terret;
+ }
+
+ private bool CompareTerrain(double[,] one, double[,] two)
+ {
+ for (int x = 0; x < Constants.RegionSize; x++)
+ for (int y = 0; y < Constants.RegionSize; y++)
+ if (one[x,y] != two[x,y])
+ return false;
+
+ return true;
+ }
+
+
+ private SceneObjectGroup FindSOG(string name, UUID r)
+ {
+ List objs = db.LoadObjects(r);
+ foreach (SceneObjectGroup sog in objs)
+ {
+ SceneObjectPart p = sog.RootPart;
+ if (p.Name == name) {
+ RegionInfo regionInfo = new RegionInfo();
+ regionInfo.RegionID = r;
+ regionInfo.RegionLocX = 0;
+ regionInfo.RegionLocY = 0;
+
+ Scene scene = new Scene(regionInfo);
+ sog.SetScene(scene);
+
+ return sog;
+ }
+ }
+
+ return null;
+ }
+
+ // This builds a minimalistic Prim, 1 SOG with 1 root SOP. A
+ // common failure case is people adding new fields that aren't
+ // initialized, but have non-null db constraints. We should
+ // honestly be passing more and more null things in here.
+ //
+ // Please note that in Sqlite.BuildPrim there is a commented out inline version
+ // of this so you can debug and step through the build process and check the fields
+ //
+ // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart
+ // causes the application to crash at the database layer because of null values
+ // in NOT NULL fields
+ //
+ private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId)
+ {
+ RegionInfo regionInfo = new RegionInfo();
+ regionInfo.RegionID = regionId;
+ regionInfo.RegionLocX = 0;
+ regionInfo.RegionLocY = 0;
+
+ Scene scene = new Scene(regionInfo);
+
+ SceneObjectPart sop = new SceneObjectPart();
+ sop.Name = name;
+ sop.Description = name;
+ sop.Text = RandomName();
+ sop.SitName = RandomName();
+ sop.TouchName = RandomName();
+ sop.UUID = uuid;
+ sop.Shape = PrimitiveBaseShape.Default;
+
+ SceneObjectGroup sog = new SceneObjectGroup(sop);
+ sog.SetScene(scene);
+
+ return sog;
+ }
+
+ private SceneObjectPart NewSOP(string name, UUID uuid)
+ {
+ SceneObjectPart sop = new SceneObjectPart();
+ sop.Name = name;
+ sop.Description = name;
+ sop.Text = RandomName();
+ sop.SitName = RandomName();
+ sop.TouchName = RandomName();
+ sop.UUID = uuid;
+ sop.Shape = PrimitiveBaseShape.Default;
+ return sop;
+ }
+
+ // These are copied from the Inventory Item tests
+
+ private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset)
+ {
+ InventoryItemBase i = new InventoryItemBase();
+ i.ID = id;
+ i.Folder = parent;
+ i.Owner = owner;
+ i.CreatorId = owner.ToString();
+ i.Name = name;
+ i.Description = name;
+ i.AssetID = asset;
+ return i;
+ }
+
+ private static string RandomName()
+ {
+ StringBuilder name = new StringBuilder();
+ int size = random.Next(5,12);
+ char ch ;
+ for (int i=0; ithe asset
private void UpdateAsset(AssetBase asset)
{
- string sql = @"UPDATE assets set id = @id, name = @name, description = @description, assetType = @assetType,
+ string sql = @"UPDATE assets set name = @name, description = @description, assetType = @assetType,
local = @local, temporary = @temporary, data = @data
WHERE id = @keyId;";
@@ -231,14 +231,13 @@ namespace OpenSim.Data.MSSQL
using (SqlConnection conn = new SqlConnection(m_connectionString))
using (SqlCommand command = new SqlCommand(sql, conn))
{
- command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
+ command.Parameters.Add(m_database.CreateParameter("keyId", asset.FullID));
command.Parameters.Add(m_database.CreateParameter("name", assetName));
command.Parameters.Add(m_database.CreateParameter("description", assetDescription));
command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
- command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID));
conn.Open();
try
{
@@ -295,15 +294,21 @@ namespace OpenSim.Data.MSSQL
public override List FetchAssetMetadataSet(int start, int count)
{
List retList = new List(count);
- string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER()
- OVER (ORDER BY (some column to order by))
- WHERE Row >= @Start AND Row < @Start + @Count";
+ string sql = @"WITH OrderedAssets AS
+ (
+ SELECT id, name, description, assetType, temporary,
+ Row = ROW_NUMBER() OVER (ORDER BY id)
+ FROM assets
+ )
+ SELECT *
+ FROM OrderedAssets
+ WHERE RowNumber BETWEEN @start AND @stop;";
using (SqlConnection conn = new SqlConnection(m_connectionString))
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.Add(m_database.CreateParameter("start", start));
- cmd.Parameters.Add(m_database.CreateParameter("count", count));
+ cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1));
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
--
cgit v1.1
From 49f4cc424624c314066d154de54441344b99916c Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Wed, 19 May 2010 21:38:29 +0300
Subject: MSSQLAssetData updated to support [CreatorID], [asset_flags]
---
OpenSim/Data/MSSQL/MSSQLAssetData.cs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index 5d1e170..ec9d4f6 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -121,15 +121,16 @@ namespace OpenSim.Data.MSSQL
if (reader.Read())
{
AssetBase asset = new AssetBase(
- new UUID((Guid)reader["id"]),
+ DBGuid.FromDB(reader["id"]),
(string)reader["name"],
Convert.ToSByte(reader["assetType"]),
- String.Empty
+ reader["creatorid"].ToString()
);
// Region Main
asset.Description = (string)reader["description"];
asset.Local = Convert.ToBoolean(reader["local"]);
asset.Temporary = Convert.ToBoolean(reader["temporary"]);
+ asset.Flags = (AssetFlags)(Convert.ToInt32(reader["asset_flags"]));
asset.Data = (byte[])reader["data"];
return asset;
}
@@ -160,10 +161,10 @@ namespace OpenSim.Data.MSSQL
string sql = @"INSERT INTO assets
([id], [name], [description], [assetType], [local],
- [temporary], [create_time], [access_time], [data])
+ [temporary], [create_time], [access_time], [creatorid], [asset_flags], [data])
VALUES
(@id, @name, @description, @assetType, @local,
- @temporary, @create_time, @access_time, @data)";
+ @temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)";
string assetName = asset.Name;
if (asset.Name.Length > 64)
@@ -191,6 +192,8 @@ namespace OpenSim.Data.MSSQL
command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
command.Parameters.Add(m_database.CreateParameter("access_time", now));
command.Parameters.Add(m_database.CreateParameter("create_time", now));
+ command.Parameters.Add(m_database.CreateParameter("asset_flags", (int)asset.Flags));
+ command.Parameters.Add(m_database.CreateParameter("creatorid", asset.Metadata.CreatorID));
command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
conn.Open();
try
@@ -212,6 +215,7 @@ namespace OpenSim.Data.MSSQL
{
string sql = @"UPDATE assets set name = @name, description = @description, assetType = @assetType,
local = @local, temporary = @temporary, data = @data
+ , creatorid = @creatorid
WHERE id = @keyId;";
string assetName = asset.Name;
@@ -238,6 +242,7 @@ namespace OpenSim.Data.MSSQL
command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
+ command.Parameters.Add(m_database.CreateParameter("creatorid", asset.Metadata.CreatorID));
conn.Open();
try
{
@@ -296,7 +301,7 @@ namespace OpenSim.Data.MSSQL
List retList = new List(count);
string sql = @"WITH OrderedAssets AS
(
- SELECT id, name, description, assetType, temporary,
+ SELECT id, name, description, assetType, temporary, creatorid,
Row = ROW_NUMBER() OVER (ORDER BY id)
FROM assets
)
@@ -320,6 +325,7 @@ namespace OpenSim.Data.MSSQL
metadata.Description = (string)reader["description"];
metadata.Type = Convert.ToSByte(reader["assetType"]);
metadata.Temporary = Convert.ToBoolean(reader["temporary"]);
+ metadata.CreatorID = (string)reader["creatorid"];
}
}
}
--
cgit v1.1
From 187a98615bd73a0a21b66e7137658939fe4664e2 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Wed, 19 May 2010 10:28:10 +0300
Subject: MSSQL: added asset_flags, CreatorID to migrations
---
OpenSim/Data/MSSQL/Resources/AssetStore.migrations | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/Resources/AssetStore.migrations b/OpenSim/Data/MSSQL/Resources/AssetStore.migrations
index beb82b9..8664ce9 100644
--- a/OpenSim/Data/MSSQL/Resources/AssetStore.migrations
+++ b/OpenSim/Data/MSSQL/Resources/AssetStore.migrations
@@ -97,4 +97,10 @@ COMMIT
DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621';
+:VERSION 6
+ALTER TABLE assets ADD asset_flags INTEGER NOT NULL DEFAULT 0;
+
+:VERSION 7
+
+alter table assets add creatorid varchar(36) not null default '';
--
cgit v1.1
From 6322a085b3141bbf91ad11f86e9e8c8d5c5b3be5 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Tue, 18 May 2010 14:30:17 +0300
Subject: Minor corrections in BasicDataServiceTest.cs
(added more functions for cleaning up DB from the
derived tests)
---
OpenSim/Data/Tests/BasicDataServiceTest.cs | 41 ++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs
index 82f29d6..e91a45d 100644
--- a/OpenSim/Data/Tests/BasicDataServiceTest.cs
+++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs
@@ -167,5 +167,46 @@ namespace OpenSim.Data.Tests
}
}
}
+
+ /// Clear tables listed as parameters (without dropping them).
+ ///
+ ///
+ protected virtual void ResetMigrations(params string[] stores)
+ {
+ string lst = "";
+ foreach (string store in stores)
+ {
+ string s = "'" + store + "'";
+ if (lst == "")
+ lst = s;
+ else
+ lst += ", " + s;
+ }
+
+ try
+ {
+ ExecuteSql("DELETE FROM `migrations` where name in (" + lst + ");");
+ }
+ catch
+ {
+ }
+ }
+
+ /// Clear tables listed as parameters (without dropping them).
+ ///
+ ///
+ protected virtual void ClearTables(params string[] tables)
+ {
+ foreach (string tbl in tables)
+ {
+ try
+ {
+ ExecuteSql("DELETE FROM " + tbl + ";");
+ }
+ catch
+ {
+ }
+ }
+ }
}
}
--
cgit v1.1
From 94f4c20866a5ddee99c555bec347fbc68b3a99fd Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Tue, 18 May 2010 14:33:57 +0300
Subject: Corrections in RegionTests.cs. It now fully works!
The problem was that some tests relied on prior tests
to leave the DB in a particular state, but the test class
cleared the DB every time. The affected tests have been
merged into one to remove the dependencies.
tested on all 3 Dbs, all tests green.
---
OpenSim/Data/Tests/RegionTests.cs | 123 +++++++++++++++++++++++---------------
1 file changed, 75 insertions(+), 48 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index 2a97368..2451ef0 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -60,6 +60,8 @@ namespace OpenSim.Data.Tests
where TConn : DbConnection, new()
where TRegStore : class, IRegionDataStore, new()
{
+ bool m_rebuildDB;
+
public IRegionDataStore db;
public UUID zero = UUID.Zero;
public UUID region1 = UUID.Random();
@@ -85,6 +87,16 @@ namespace OpenSim.Data.Tests
public double height1 = 20;
public double height2 = 100;
+ public RegionTests(string conn, bool rebuild)
+ : base(conn)
+ {
+ m_rebuildDB = rebuild;
+ }
+
+ public RegionTests() : this("", false) { }
+ public RegionTests(string conn) : this(conn, false) {}
+ public RegionTests(bool rebuild): this("", rebuild) {}
+
protected override void InitService(object service)
{
@@ -93,22 +105,17 @@ namespace OpenSim.Data.Tests
ClearDB();
}
-
private void ClearDB()
{
- // if a new table is added, it has to be dropped here
- ExecuteSql("delete from migrations where name='RegionStore';");
-
- DropTables(
- "prims",
- "primshapes",
- "primitems",
- "terrain",
- "land",
- "landaccesslist",
- "regionban",
- "regionsettings"
- );
+ string[] reg_tables = new string[] {
+ "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings"
+ };
+ if (m_rebuildDB)
+ {
+ DropTables(reg_tables);
+ ResetMigrations("RegionStore");
+ }else
+ ClearTables(reg_tables);
}
@@ -601,68 +608,88 @@ namespace OpenSim.Data.Tests
.IgnoreProperty(x=>x.PassCollision)
.IgnoreProperty(x=>x.RootPart));
}
+
+
+ private SceneObjectGroup GetMySOG(string name)
+ {
+ SceneObjectGroup sog = FindSOG(name, region1);
+ if (sog == null)
+ {
+ sog = NewSOG(name, prim1, region1);
+ db.StoreObject(sog, region1);
+ }
+ return sog;
+ }
+
+ // NOTE: it is a bad practice to rely on some of the previous tests having been run before.
+ // If the tests are run manually, one at a time, each starts with full class init (DB cleared).
+ // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order.
+ // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*!
+
[Test]
public void T020_PrimInventoryEmpty()
{
- SceneObjectGroup sog = FindSOG("object1", region1);
+ SceneObjectGroup sog = GetMySOG("object1");
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
Assert.That(t, Is.Null);
}
- [Test]
- public void T021_PrimInventoryStore()
- {
- SceneObjectGroup sog = FindSOG("object1", region1);
- InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
-
- Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
- Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
-
- // TODO: seriously??? this is the way we need to loop to get this?
+ // TODO: Is there any point to call StorePrimInventory on a list, rather than on the prim itself?
+ private void StoreInventory(SceneObjectGroup sog)
+ {
List list = new List();
+ // TODO: seriously??? this is the way we need to loop to get this?
foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList())
{
list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid));
}
-
- db.StorePrimInventory(prim1, list);
+
+ db.StorePrimInventory(sog.RootPart.UUID, list);
}
- [Test]
- public void T022_PrimInventoryRetrieve()
- {
- SceneObjectGroup sog = FindSOG("object1", region1);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
- Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
- }
-
[Test]
- public void T023_PrimInventoryUpdate()
+ public void T021_PrimInventoryBasic()
{
- SceneObjectGroup sog = FindSOG("object1", region1);
+ SceneObjectGroup sog = GetMySOG("object1");
+ InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
+
+ Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
+ Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
- t.Name = "My New Name";
- sog.UpdateInventoryItem(t);
+ StoreInventory(sog);
- Assert.That(t.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
+ SceneObjectGroup sog1 = FindSOG("object1", region1);
+ Assert.That(sog1, Is.Not.Null);
- }
+ TaskInventoryItem t1 = sog1.GetInventoryItem(sog1.RootPart.LocalId, item1);
+ Assert.That(t1, Is.Not.Null);
+ Assert.That(t1.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
+
+ // Updating inventory
+ t1.Name = "My New Name";
+ sog1.UpdateInventoryItem(t1);
+
+ StoreInventory(sog1);
+
+ SceneObjectGroup sog2 = FindSOG("object1", region1);
+ TaskInventoryItem t2 = sog2.GetInventoryItem(sog2.RootPart.LocalId, item1);
+ Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
+
+ // Removing inventory
- [Test]
- public void T024_PrimInventoryRemove()
- {
List list = new List();
db.StorePrimInventory(prim1, list);
- SceneObjectGroup sog = FindSOG("object1", region1);
- TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
+ sog = FindSOG("object1", region1);
+ t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
Assert.That(t, Is.Null);
+
}
+
[Test]
public void T025_PrimInventoryPersistency()
@@ -706,7 +733,7 @@ namespace OpenSim.Data.Tests
int creationd = random.Next();
i.CreationDate = creationd;
- SceneObjectGroup sog = FindSOG("object1", region1);
+ SceneObjectGroup sog = GetMySOG("object1");
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
--
cgit v1.1
From f527584ed336d246a77856b06d4ed9536e2b55bb Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Tue, 18 May 2010 01:45:21 +0300
Subject: EstateData tests passing on all DBs
---
OpenSim/Data/Tests/EstateTests.cs | 30 ++----------------------------
1 file changed, 2 insertions(+), 28 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs
index 7f13925..39ecb89 100644
--- a/OpenSim/Data/Tests/EstateTests.cs
+++ b/OpenSim/Data/Tests/EstateTests.cs
@@ -335,8 +335,7 @@ namespace OpenSim.Data.Tests
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(regionId, true);
- SetEstateSettings(
- originalSettings,
+ SetEstateSettings(originalSettings,
estateName,
parentEstateID,
billableFactor,
@@ -362,30 +361,6 @@ namespace OpenSim.Data.Tests
estateOwner
);
- originalSettings.EstateName = estateName;
- originalSettings.ParentEstateID = parentEstateID;
- originalSettings.BillableFactor = billableFactor;
- originalSettings.PricePerMeter = pricePerMeter;
- originalSettings.RedirectGridX = redirectGridX;
- originalSettings.RedirectGridY = redirectGridY;
- originalSettings.UseGlobalTime = useGlobalTime;
- originalSettings.FixedSun = fixedSun;
- originalSettings.SunPosition = sunPosition;
- originalSettings.AllowVoice = allowVoice;
- originalSettings.AllowDirectTeleport = allowDirectTeleport;
- originalSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
- originalSettings.DenyAnonymous = denyAnonymous;
- originalSettings.DenyIdentified = denyIdentified;
- originalSettings.DenyTransacted = denyTransacted;
- originalSettings.DenyMinors = denyMinors;
- originalSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
- originalSettings.BlockDwell = blockDwell;
- originalSettings.EstateSkipScripts = estateSkipScripts;
- originalSettings.TaxFree = taxFree;
- originalSettings.PublicAccess = publicAccess;
- originalSettings.AbuseEmail = abuseEmail;
- originalSettings.EstateOwner = estateOwner;
-
// Saving settings.
db.StoreEstateSettings(originalSettings);
@@ -393,8 +368,7 @@ namespace OpenSim.Data.Tests
EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true);
// Checking that loaded values are correct.
- ValidateEstateSettings(
- loadedSettings,
+ ValidateEstateSettings(loadedSettings,
estateName,
parentEstateID,
billableFactor,
--
cgit v1.1
From 749cf0f6eb52ee147b05e120c6763cb8846ce32f Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Mon, 17 May 2010 18:40:25 +0300
Subject: Bugfix in tests (must clear db before migrations, not after)
---
OpenSim/Data/Tests/EstateTests.cs | 2 +-
OpenSim/Data/Tests/InventoryTests.cs | 2 +-
OpenSim/Data/Tests/RegionTests.cs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs
index 39ecb89..4893cc7 100644
--- a/OpenSim/Data/Tests/EstateTests.cs
+++ b/OpenSim/Data/Tests/EstateTests.cs
@@ -74,9 +74,9 @@ namespace OpenSim.Data.Tests
protected override void InitService(object service)
{
+ ClearDB();
db = (IEstateDataStore)service;
db.Initialise(m_connStr);
- ClearDB();
}
private void ClearDB()
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
index 876dcf9..d5f3be4 100644
--- a/OpenSim/Data/Tests/InventoryTests.cs
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -88,9 +88,9 @@ namespace OpenSim.Data.Tests
protected override void InitService(object service)
{
+ ClearDB();
db = (IInventoryDataPlugin)service;
db.Initialise(m_connStr);
- ClearDB();
}
private void ClearDB()
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index 2451ef0..f38dc4a 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -100,9 +100,9 @@ namespace OpenSim.Data.Tests
protected override void InitService(object service)
{
+ ClearDB();
db = (IRegionDataStore)service;
db.Initialise(m_connStr);
- ClearDB();
}
private void ClearDB()
--
cgit v1.1
From b1e6e995065371a88c40284d9d504135c83b6f11 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Thu, 6 May 2010 21:10:01 +0200
Subject: BasicAssetTest.cs replaced by AssetTests.cs
AssetTests: The name has changed to reflect the fact it is no longer a base class,
but the complete asset test for all supported databases.
The test can also check storing of CreatorID, but the feature is
disabled at this commit!
---
OpenSim/Data/Tests/AssetTests.cs | 161 +++++++++++++++++++++++++++++++++++++++
1 file changed, 161 insertions(+)
create mode 100644 OpenSim/Data/Tests/AssetTests.cs
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
new file mode 100644
index 0000000..acd5449
--- /dev/null
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -0,0 +1,161 @@
+/*
+ * 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 log4net.Config;
+using NUnit.Framework;
+using NUnit.Framework.Constraints;
+using OpenMetaverse;
+using OpenSim.Framework;
+using System.Data.Common;
+using log4net;
+
+// DBMS-specific:
+using MySql.Data.MySqlClient;
+using OpenSim.Data.MySQL;
+
+using System.Data.SqlClient;
+using OpenSim.Data.MSSQL;
+
+using Mono.Data.Sqlite;
+using OpenSim.Data.SQLite;
+
+namespace OpenSim.Data.Tests
+{
+ [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)")]
+
+ public class AssetTests : BasicDataServiceTest
+ where TConn : DbConnection, new()
+ where TAssetData : AssetDataBase, new()
+ {
+ TAssetData m_db;
+
+ const bool COMPARE_CREATOR = false;
+
+ public UUID uuid1 = UUID.Random();
+ public UUID uuid2 = UUID.Random();
+ public UUID uuid3 = UUID.Random();
+
+ public UUID critter1 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero;
+ public UUID critter2 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero;
+ public UUID critter3 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero;
+
+ public byte[] data1 = new byte[100];
+
+ PropertyScrambler scrambler = new PropertyScrambler()
+ .DontScramble(x => x.ID)
+ .DontScramble(x => x.Type)
+ .DontScramble(x => x.FullID)
+ .DontScramble(x => x.Metadata.ID)
+ .DontScramble(x => x.Metadata.CreatorID)
+ .DontScramble(x => x.Metadata.ContentType)
+ .DontScramble(x => x.Metadata.FullID)
+ .DontScramble(x => x.Data);
+
+ protected override void InitService(object service)
+ {
+ m_db = (TAssetData)service;
+ m_db.Initialise(m_connStr);
+ }
+
+ [Test]
+ public void T001_LoadEmpty()
+ {
+ Assert.That(m_db.ExistsAsset(uuid1), Is.False);
+ Assert.That(m_db.ExistsAsset(uuid2), Is.False);
+ Assert.That(m_db.ExistsAsset(uuid3), Is.False);
+ }
+
+ [Test]
+ public void T010_StoreReadVerifyAssets()
+ {
+ AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1.ToString());
+ AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2.ToString());
+ AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3.ToString());
+ a1.Data = data1;
+ a2.Data = data1;
+ a3.Data = data1;
+
+ scrambler.Scramble(a1);
+ scrambler.Scramble(a2);
+ scrambler.Scramble(a3);
+
+ m_db.StoreAsset(a1);
+ m_db.StoreAsset(a2);
+ m_db.StoreAsset(a3);
+
+ AssetBase a1a = m_db.GetAsset(uuid1);
+ Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
+
+ AssetBase a2a = m_db.GetAsset(uuid2);
+ Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
+
+ AssetBase a3a = m_db.GetAsset(uuid3);
+ Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
+
+ scrambler.Scramble(a1a);
+ scrambler.Scramble(a2a);
+ scrambler.Scramble(a3a);
+
+ m_db.StoreAsset(a1a);
+ m_db.StoreAsset(a2a);
+ m_db.StoreAsset(a3a);
+
+ AssetBase a1b = m_db.GetAsset(uuid1);
+ Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
+
+ AssetBase a2b = m_db.GetAsset(uuid2);
+ Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
+
+ AssetBase a3b = m_db.GetAsset(uuid3);
+ Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
+
+ Assert.That(m_db.ExistsAsset(uuid1), Is.True);
+ Assert.That(m_db.ExistsAsset(uuid2), Is.True);
+ Assert.That(m_db.ExistsAsset(uuid3), Is.True);
+
+ List metadatas = m_db.FetchAssetMetadataSet(0, 1000);
+
+ Assert.That(metadatas.Count >= 3, "FetchAssetMetadataSet() should have returned at least 3 assets!");
+
+ // It is possible that the Asset table is filled with data, in which case we don't try to find "our"
+ // assets there:
+ if (metadatas.Count < 1000)
+ {
+ AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1);
+ Assert.That(metadata.Name, Is.EqualTo(a1b.Name));
+ Assert.That(metadata.Description, Is.EqualTo(a1b.Description));
+ Assert.That(metadata.Type, Is.EqualTo(a1b.Type));
+ Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary));
+ Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
+ }
+ }
+ }
+}
--
cgit v1.1
From 40031e6d379916c507591f4c5032b22afe851020 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Fri, 21 May 2010 14:00:41 +0300
Subject: Removed MySql and SQLite-specific asset test files
---
OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 92 ----------------------------
OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs | 64 -------------------
2 files changed, 156 deletions(-)
delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs
delete mode 100644 OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs
deleted file mode 100644
index a46fdf8..0000000
--- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using NUnit.Framework;
-using OpenSim.Data.Tests;
-using log4net;
-using System.Reflection;
-using OpenSim.Tests.Common;
-using MySql.Data.MySqlClient;
-
-namespace OpenSim.Data.MySQL.Tests
-{
- [TestFixture, DatabaseTest]
- public class MySQLAssetTest : BasicAssetTest
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public string file;
- private string m_connectionString;
- public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
-
- [TestFixtureSetUp]
- public void Init()
- {
- SuperInit();
- // If we manage to connect to the database with the user
- // and password above it is our test database, and run
- // these tests. If anything goes wrong, ignore these
- // tests.
- try
- {
- db = new MySQLAssetData();
- db.Initialise(connect);
- }
- catch (Exception e)
- {
- m_log.Error(e.ToString());
- Assert.Ignore();
- }
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- if (db != null)
- {
- db.Dispose();
- }
- ExecuteSql("drop table migrations");
- ExecuteSql("drop table assets");
- }
-
- ///
- /// Execute a MySqlCommand
- ///
- /// sql string to execute
- private void ExecuteSql(string sql)
- {
- using (MySqlConnection dbcon = new MySqlConnection(connect))
- {
- dbcon.Open();
-
- MySqlCommand cmd = new MySqlCommand(sql, dbcon);
- cmd.ExecuteNonQuery();
- }
- }
- }
-}
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs
deleted file mode 100644
index 0c2f5df..0000000
--- a/OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System.IO;
-using NUnit.Framework;
-using OpenSim.Data.Tests;
-using OpenSim.Tests.Common;
-
-namespace OpenSim.Data.SQLite.Tests
-{
- [TestFixture, DatabaseTest]
- public class SQLiteAssetTest : BasicAssetTest
- {
- public string file;
- public string connect;
-
- [TestFixtureSetUp]
- public void Init()
- {
- // SQLite doesn't work on power or z linux
- if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd"))
- {
- Assert.Ignore();
- }
-
- SuperInit();
- file = Path.GetTempFileName() + ".db";
- connect = "URI=file:" + file + ",version=3";
- db = new SQLiteAssetData();
- db.Initialise(connect);
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- db.Dispose();
- File.Delete(file);
- }
- }
-}
--
cgit v1.1
From 330ad501a5b1933ad041cd13676548701170c56d Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Fri, 21 May 2010 15:47:37 +0300
Subject: Added MS SQL test conn to INI - only as an example, modify before
use!!!
NOTE that this INI file is currently loaded as a embedded RESOURCE, which is weird and has a
disadvantage of having to rebuild the Tests whenever the conn strings are changed.
The only reason is that I couldn't figure out a reliable way to put this INI into the correct
dir at runtime. If somebody can do it, that would be cool.
---
.../Data/Tests/Resources/TestDataConnections.ini | 25 ++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/Resources/TestDataConnections.ini b/OpenSim/Data/Tests/Resources/TestDataConnections.ini
index d149744..5e68ab0 100644
--- a/OpenSim/Data/Tests/Resources/TestDataConnections.ini
+++ b/OpenSim/Data/Tests/Resources/TestDataConnections.ini
@@ -1,7 +1,24 @@
-; The default connections to the test databases. Used by tests based on BasicDataServiceTest.cs.
-; Read by code in DefaultTestConns.cs
+; The default connections to the test databases. Used by all data tests based on BasicDataServiceTest.cs.
+; This is read by code in DefaultTestConns.cs.
+
+; NOTE that this INI file is currently loaded as a embedded RESOURCE, which is weird and has a
+; disadvantage of having to rebuild the Tests whenever the conn strings are changed.
+; The only reason is that I couldn't figure out a reliable way to put this INI into the correct
+; dir at runtime. If somebody can do it, that would be cool.
+
+; I'm using a local MSDE server for testing. Obviously, you'll have to modify
+; the conn string to whatever MS SQL server is available to you.
+
+; If any of the conn strings is commented out, emty or not valid on your system,
+; the relevant tests will be ignored, rather than fail.
+
+; As to SQLite, if the conn string here is empty, it will work anyway using a temporary
+; file for the DB. If you want the resulting DB to persist (e.g. for performance testing,
+; when filling up the tables can take a long time), explicitly specify a conn string like this:
+
+; SqliteConnection="URI=file:,version=3"
[TestConnections]
MySqlConnection="Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;"
-;SqlConnection="..."
-;SqliteConnection="..."
\ No newline at end of file
+SqlConnection="Server=.\SQL2008;Database=opensim-nunit;Trusted_Connection=True;"
+SqliteConnection=""
\ No newline at end of file
--
cgit v1.1
From 2537acc04db736cdc885e23bbfaade690d56fa5f Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Fri, 21 May 2010 15:59:26 +0300
Subject: Unitests: Asset, Estate, Region (the "legacy" one), Inventory
The tests have been modified to work under NUnit 2.4.6
(the one currently used in the project).
They will also work with NUnit 2.5+ as is, but will look better
if you #define NUNIT25 for them.
---
OpenSim/Data/Tests/AssetTests.cs | 62 +++++++++++--
OpenSim/Data/Tests/BasicAssetTest.cs | 166 -----------------------------------
OpenSim/Data/Tests/EstateTests.cs | 26 ++++++
OpenSim/Data/Tests/InventoryTests.cs | 29 +++++-
OpenSim/Data/Tests/RegionTests.cs | 27 +++++-
5 files changed, 137 insertions(+), 173 deletions(-)
delete mode 100644 OpenSim/Data/Tests/BasicAssetTest.cs
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
index acd5449..d228c1f 100644
--- a/OpenSim/Data/Tests/AssetTests.cs
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -35,6 +35,10 @@ 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;
@@ -47,25 +51,46 @@ 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 = "Region store tests (SQLite)")]
+ public class SQLiteAssetTests : AssetTests
+ {
+ }
+
+ [TestFixture(Description = "Region store tests (MySQL)")]
+ public class MySqlAssetTests : AssetTests
+ {
+ }
+
+ [TestFixture(Description = "Region store tests (MS SQL Server)")]
+ public class MSSQLAssetTests : AssetTests
+ {
+ }
+
+#endif
+
+
public class AssetTests : BasicDataServiceTest
where TConn : DbConnection, new()
where TAssetData : AssetDataBase, new()
{
TAssetData m_db;
- const bool COMPARE_CREATOR = false;
-
public UUID uuid1 = UUID.Random();
public UUID uuid2 = UUID.Random();
public UUID uuid3 = UUID.Random();
- public UUID critter1 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero;
- public UUID critter2 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero;
- public UUID critter3 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero;
+ public string critter1 = UUID.Random().ToString();
+ public string critter2 = UUID.Random().ToString();
+ public string critter3 = UUID.Random().ToString();
public byte[] data1 = new byte[100];
@@ -157,5 +182,32 @@ namespace OpenSim.Data.Tests
Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
}
}
+
+ [Test]
+ public void T020_CheckForWeirdCreatorID()
+ {
+ // It is expected that eventually the CreatorID might be an arbitrary string (an URI)
+ // rather than a valid UUID (?). This test is to make sure that the database layer does not
+ // attempt to convert CreatorID to GUID, but just passes it both ways as a string.
+ AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1);
+ AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!");
+ AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, "");
+ a1.Data = data1;
+ a2.Data = data1;
+ a3.Data = data1;
+
+ m_db.StoreAsset(a1);
+ m_db.StoreAsset(a2);
+ m_db.StoreAsset(a3);
+
+ AssetBase a1a = m_db.GetAsset(uuid1);
+ Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
+
+ AssetBase a2a = m_db.GetAsset(uuid2);
+ Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
+
+ AssetBase a3a = m_db.GetAsset(uuid3);
+ Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
+ }
}
}
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs
deleted file mode 100644
index 71d6314..0000000
--- a/OpenSim/Data/Tests/BasicAssetTest.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using log4net.Config;
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-using OpenMetaverse;
-using OpenSim.Framework;
-using log4net;
-
-namespace OpenSim.Data.Tests
-{
- public class BasicAssetTest
- {
- public IAssetDataPlugin db;
- public UUID uuid1;
- public UUID uuid2;
- public UUID uuid3;
- public string critter1 = UUID.Random().ToString();
- public string critter2 = UUID.Random().ToString();
- public string critter3 = UUID.Random().ToString();
- public byte[] asset1;
- PropertyScrambler scrambler;
-
- public void SuperInit()
- {
- OpenSim.Tests.Common.TestLogging.LogToConsole();
-
- uuid1 = UUID.Random();
- uuid2 = UUID.Random();
- uuid3 = UUID.Random();
- asset1 = new byte[100];
- asset1.Initialize();
-
-
- scrambler = new PropertyScrambler()
- .DontScramble(x => x.ID)
- .DontScramble(x => x.FullID)
- .DontScramble(x => x.Metadata.ID)
- .DontScramble(x => x.Metadata.Type)
- .DontScramble(x => x.Metadata.CreatorID)
- .DontScramble(x => x.Metadata.ContentType)
- .DontScramble(x => x.Metadata.FullID);
- }
-
- [Test]
- public void T001_LoadEmpty()
- {
- Assert.That(db.ExistsAsset(uuid1), Is.False);
- Assert.That(db.ExistsAsset(uuid2), Is.False);
- Assert.That(db.ExistsAsset(uuid3), Is.False);
- }
-
- [Test]
- public void T010_StoreSimpleAsset()
- {
- AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1);
- AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2);
- AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3);
- a1.Data = asset1;
- a2.Data = asset1;
- a3.Data = asset1;
-
- scrambler.Scramble(a1);
- scrambler.Scramble(a2);
- scrambler.Scramble(a3);
-
- db.StoreAsset(a1);
- db.StoreAsset(a2);
- db.StoreAsset(a3);
-
- AssetBase a1a = db.GetAsset(uuid1);
- Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
-
- AssetBase a2a = db.GetAsset(uuid2);
- Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
-
- AssetBase a3a = db.GetAsset(uuid3);
- Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
-
- scrambler.Scramble(a1a);
- scrambler.Scramble(a2a);
- scrambler.Scramble(a3a);
-
- db.StoreAsset(a1a);
- db.StoreAsset(a2a);
- db.StoreAsset(a3a);
-
- AssetBase a1b = db.GetAsset(uuid1);
- Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
-
- AssetBase a2b = db.GetAsset(uuid2);
- Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
-
- AssetBase a3b = db.GetAsset(uuid3);
- Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
-
- Assert.That(db.ExistsAsset(uuid1), Is.True);
- Assert.That(db.ExistsAsset(uuid2), Is.True);
- Assert.That(db.ExistsAsset(uuid3), Is.True);
-
- List metadatas = db.FetchAssetMetadataSet(0, 1000);
-
- AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1);
- Assert.That(metadata.Name, Is.EqualTo(a1b.Name));
- Assert.That(metadata.Description, Is.EqualTo(a1b.Description));
- Assert.That(metadata.Type, Is.EqualTo(a1b.Type));
- Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary));
- Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
- }
-
-
- [Test]
- public void T020_CheckForWeirdCreatorID()
- {
- // It is expected that eventually the CreatorID might be an arbitrary string (an URI)
- // rather than a valid UUID (?). This test is to make sure that the database layer does not
- // attempt to convert CreatorID to GUID, but just passes it both ways as a string.
- AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1);
- AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!");
- AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, "");
- a1.Data = asset1;
- a2.Data = asset1;
- a3.Data = asset1;
-
- db.StoreAsset(a1);
- db.StoreAsset(a2);
- db.StoreAsset(a3);
-
- AssetBase a1a = db.GetAsset(uuid1);
- Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
-
- AssetBase a2a = db.GetAsset(uuid2);
- Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
-
- AssetBase a3a = db.GetAsset(uuid3);
- Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
- }
- }
-}
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs
index 4893cc7..2da010d 100644
--- a/OpenSim/Data/Tests/EstateTests.cs
+++ b/OpenSim/Data/Tests/EstateTests.cs
@@ -37,6 +37,10 @@ using log4net;
using System.Reflection;
using System.Data.Common;
+#if !NUNIT25
+using NUnit.Framework.SyntaxHelpers;
+#endif
+
// DBMS-specific:
using MySql.Data.MySqlClient;
@@ -51,10 +55,32 @@ 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
+ {
+ }
+
+ [TestFixture(Description = "Estate store tests (MySQL)")]
+ public class MySqlEstateTests : EstateTests
+ {
+ }
+
+ [TestFixture(Description = "Estate store tests (MS SQL Server)")]
+ public class MSSQLEstateTests : EstateTests
+ {
+ }
+
+#endif
+
public class EstateTests : BasicDataServiceTest
where TConn : DbConnection, new()
where TEstateStore : class, IEstateDataStore, new()
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
index d5f3be4..93e1eba 100644
--- a/OpenSim/Data/Tests/InventoryTests.cs
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -25,6 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+// #define NUNIT25
+
using System;
using log4net.Config;
using NUnit.Framework;
@@ -35,6 +37,10 @@ using log4net;
using System.Reflection;
using System.Data.Common;
+#if !NUNIT25
+using NUnit.Framework.SyntaxHelpers;
+#endif
+
// DBMS-specific:
using MySql.Data.MySqlClient;
using OpenSim.Data.MySQL;
@@ -47,9 +53,29 @@ 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)")]
- [TestFixture(typeof(SqliteConnection), typeof(SQLiteInventoryStore), Description = "Inventory store tests (SQLite)")]
+
+#else
+
+ [TestFixture(Description = "Inventory store tests (SQLite)")]
+ public class SQLiteInventoryTests : InventoryTests
+ {
+ }
+
+ [TestFixture(Description = "Inventory store tests (MySQL)")]
+ public class MySqlInventoryTests : InventoryTests
+ {
+ }
+
+ [TestFixture(Description = "Inventory store tests (MS SQL Server)")]
+ public class MSSQLInventoryTests : InventoryTests
+ {
+ }
+#endif
public class InventoryTests : BasicDataServiceTest
where TConn : DbConnection, new()
@@ -85,6 +111,7 @@ namespace OpenSim.Data.Tests
{
name1 = "Root Folder for " + owner1.ToString();
}
+ public InventoryTests() : this("") { }
protected override void InitService(object service)
{
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index f38dc4a..5ac2dd0 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -40,6 +40,10 @@ using log4net;
using System.Reflection;
using System.Data.Common;
+#if !NUNIT25
+using NUnit.Framework.SyntaxHelpers;
+#endif
+
// DBMS-specific:
using MySql.Data.MySqlClient;
using OpenSim.Data.MySQL;
@@ -52,9 +56,30 @@ 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)")]
- [TestFixture(typeof(SqliteConnection), typeof(SQLiteRegionData), Description = "Region store tests (SQLite)")]
+
+#else
+
+ [TestFixture(Description = "Region store tests (SQLite)")]
+ public class SQLiteRegionTests : RegionTests
+ {
+ }
+
+ [TestFixture(Description = "Region store tests (MySQL)")]
+ public class MySqlRegionTests : RegionTests
+ {
+ }
+
+ [TestFixture(Description = "Region store tests (MS SQL Server)")]
+ public class MSSQLRegionTests : RegionTests
+ {
+ }
+
+#endif
public class RegionTests : BasicDataServiceTest
where TConn : DbConnection, new()
--
cgit v1.1
From ebc2b6d4f6ebb0392ec0081bea913d24e9753786 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Mon, 17 May 2010 17:37:16 +0200
Subject: Split migrations for RegionStore and EstateStore (see WARNING!)
ok, so the estate stores now want their own migration files, but as it
happened the SQL definition were inside the Region migrations.
It seems better/cleaner to keep each 'store' separately updatable.
WARNING: any editing in the middle of the migration scripts (as opposite
to just appending to them) has the potential of messing up updates of
existing databases. As far as I can see, this one is (probably) safe,
the worst that could happen is the EstateStore migration silently fail
if the estate the tables are already there.
---
.../Data/MySQL/Resources/EstateStore.migrations | 69 +++++++++++++++++
.../Data/MySQL/Resources/RegionStore.migrations | 78 -------------------
.../Data/SQLite/Resources/EstateStore.migrations | 88 ++++++++++++++++++++++
.../Data/SQLite/Resources/RegionStore.migrations | 25 ------
4 files changed, 157 insertions(+), 103 deletions(-)
create mode 100644 OpenSim/Data/MySQL/Resources/EstateStore.migrations
create mode 100644 OpenSim/Data/SQLite/Resources/EstateStore.migrations
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations
new file mode 100644
index 0000000..2e0d658
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations
@@ -0,0 +1,69 @@
+:VERSION 13
+
+# The estate migrations used to be in Region store
+
+CREATE TABLE IF NOT EXISTS `estate_managers` (
+ `EstateID` int(10) unsigned NOT NULL,
+ `uuid` char(36) NOT NULL,
+ KEY `EstateID` (`EstateID`)
+) ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS `estate_groups` (
+ `EstateID` int(10) unsigned NOT NULL,
+ `uuid` char(36) NOT NULL,
+ KEY `EstateID` (`EstateID`)
+) ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS `estate_users` (
+ `EstateID` int(10) unsigned NOT NULL,
+ `uuid` char(36) NOT NULL,
+ KEY `EstateID` (`EstateID`)
+) ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS `estateban` (
+ `EstateID` int(10) unsigned NOT NULL,
+ `bannedUUID` varchar(36) NOT NULL,
+ `bannedIp` varchar(16) NOT NULL,
+ `bannedIpHostMask` varchar(16) NOT NULL,
+ `bannedNameMask` varchar(64) default NULL,
+ KEY `estateban_EstateID` (`EstateID`)
+) ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS `estate_settings` (
+ `EstateID` int(10) unsigned NOT NULL auto_increment,
+ `EstateName` varchar(64) default NULL,
+ `AbuseEmailToEstateOwner` tinyint(4) NOT NULL,
+ `DenyAnonymous` tinyint(4) NOT NULL,
+ `ResetHomeOnTeleport` tinyint(4) NOT NULL,
+ `FixedSun` tinyint(4) NOT NULL,
+ `DenyTransacted` tinyint(4) NOT NULL,
+ `BlockDwell` tinyint(4) NOT NULL,
+ `DenyIdentified` tinyint(4) NOT NULL,
+ `AllowVoice` tinyint(4) NOT NULL,
+ `UseGlobalTime` tinyint(4) NOT NULL,
+ `PricePerMeter` int(11) NOT NULL,
+ `TaxFree` tinyint(4) NOT NULL,
+ `AllowDirectTeleport` tinyint(4) NOT NULL,
+ `RedirectGridX` int(11) NOT NULL,
+ `RedirectGridY` int(11) NOT NULL,
+ `ParentEstateID` int(10) unsigned NOT NULL,
+ `SunPosition` double NOT NULL,
+ `EstateSkipScripts` tinyint(4) NOT NULL,
+ `BillableFactor` float NOT NULL,
+ `PublicAccess` tinyint(4) NOT NULL,
+ `AbuseEmail` varchar(255) not null,
+ `EstateOwner` varchar(36) not null,
+ `DenyMinors` tinyint not null,
+
+ PRIMARY KEY (`EstateID`)
+) ENGINE=InnoDB AUTO_INCREMENT=100;
+
+CREATE TABLE IF NOT EXISTS `estate_map` (
+ `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000',
+ `EstateID` int(11) NOT NULL,
+ PRIMARY KEY (`RegionID`),
+ KEY `EstateID` (`EstateID`)
+) ENGINE=InnoDB;
+
+
+
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index baeeedd..383c328 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -386,84 +386,6 @@ CREATE TABLE `regionsettings` (
PRIMARY KEY (`regionUUID`)
) ENGINE=InnoDB;
-CREATE TABLE `estate_managers` (
- `EstateID` int(10) unsigned NOT NULL,
- `uuid` char(36) NOT NULL,
- KEY `EstateID` (`EstateID`)
-) ENGINE=InnoDB;
-
-CREATE TABLE `estate_groups` (
- `EstateID` int(10) unsigned NOT NULL,
- `uuid` char(36) NOT NULL,
- KEY `EstateID` (`EstateID`)
-) ENGINE=InnoDB;
-
-CREATE TABLE `estate_users` (
- `EstateID` int(10) unsigned NOT NULL,
- `uuid` char(36) NOT NULL,
- KEY `EstateID` (`EstateID`)
-) ENGINE=InnoDB;
-
-CREATE TABLE `estateban` (
- `EstateID` int(10) unsigned NOT NULL,
- `bannedUUID` varchar(36) NOT NULL,
- `bannedIp` varchar(16) NOT NULL,
- `bannedIpHostMask` varchar(16) NOT NULL,
- `bannedNameMask` varchar(64) default NULL,
- KEY `estateban_EstateID` (`EstateID`)
-) ENGINE=InnoDB;
-
-CREATE TABLE `estate_settings` (
- `EstateID` int(10) unsigned NOT NULL auto_increment,
- `EstateName` varchar(64) default NULL,
- `AbuseEmailToEstateOwner` tinyint(4) NOT NULL,
- `DenyAnonymous` tinyint(4) NOT NULL,
- `ResetHomeOnTeleport` tinyint(4) NOT NULL,
- `FixedSun` tinyint(4) NOT NULL,
- `DenyTransacted` tinyint(4) NOT NULL,
- `BlockDwell` tinyint(4) NOT NULL,
- `DenyIdentified` tinyint(4) NOT NULL,
- `AllowVoice` tinyint(4) NOT NULL,
- `UseGlobalTime` tinyint(4) NOT NULL,
- `PricePerMeter` int(11) NOT NULL,
- `TaxFree` tinyint(4) NOT NULL,
- `AllowDirectTeleport` tinyint(4) NOT NULL,
- `RedirectGridX` int(11) NOT NULL,
- `RedirectGridY` int(11) NOT NULL,
- `ParentEstateID` int(10) unsigned NOT NULL,
- `SunPosition` double NOT NULL,
- `EstateSkipScripts` tinyint(4) NOT NULL,
- `BillableFactor` float NOT NULL,
- `PublicAccess` tinyint(4) NOT NULL,
- PRIMARY KEY (`EstateID`)
-) ENGINE=InnoDB AUTO_INCREMENT=100;
-
-CREATE TABLE `estate_map` (
- `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000',
- `EstateID` int(11) NOT NULL,
- PRIMARY KEY (`RegionID`),
- KEY `EstateID` (`EstateID`)
-) ENGINE=InnoDB;
-
-commit;
-
-:VERSION 14 #---------------------
-
-begin;
-
-alter table estate_settings add column AbuseEmail varchar(255) not null;
-
-alter table estate_settings add column EstateOwner varchar(36) not null;
-
-commit;
-
-
-:VERSION 15 #---------------------
-
-begin;
-
-alter table estate_settings add column DenyMinors tinyint not null;
-
commit;
:VERSION 16 #---------------------
diff --git a/OpenSim/Data/SQLite/Resources/EstateStore.migrations b/OpenSim/Data/SQLite/Resources/EstateStore.migrations
new file mode 100644
index 0000000..62f6464
--- /dev/null
+++ b/OpenSim/Data/SQLite/Resources/EstateStore.migrations
@@ -0,0 +1,88 @@
+:VERSION 6
+
+BEGIN TRANSACTION;
+
+CREATE TABLE estate_groups (
+ EstateID int(10) NOT NULL,
+ uuid char(36) NOT NULL
+);
+
+CREATE TABLE estate_managers (
+ EstateID int(10) NOT NULL,
+ uuid char(36) NOT NULL
+);
+
+CREATE TABLE estate_map (
+ RegionID char(36) NOT NULL default '00000000-0000-0000-0000-000000000000',
+ EstateID int(11) NOT NULL
+);
+
+CREATE TABLE estate_settings (
+ EstateID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ EstateName varchar(64) default NULL,
+ AbuseEmailToEstateOwner tinyint(4) NOT NULL,
+ DenyAnonymous tinyint(4) NOT NULL,
+ ResetHomeOnTeleport tinyint(4) NOT NULL,
+ FixedSun tinyint(4) NOT NULL,
+ DenyTransacted tinyint(4) NOT NULL,
+ BlockDwell tinyint(4) NOT NULL,
+ DenyIdentified tinyint(4) NOT NULL,
+ AllowVoice tinyint(4) NOT NULL,
+ UseGlobalTime tinyint(4) NOT NULL,
+ PricePerMeter int(11) NOT NULL,
+ TaxFree tinyint(4) NOT NULL,
+ AllowDirectTeleport tinyint(4) NOT NULL,
+ RedirectGridX int(11) NOT NULL,
+ RedirectGridY int(11) NOT NULL,
+ ParentEstateID int(10) NOT NULL,
+ SunPosition double NOT NULL,
+ EstateSkipScripts tinyint(4) NOT NULL,
+ BillableFactor float NOT NULL,
+ PublicAccess tinyint(4) NOT NULL
+);
+
+insert into estate_settings (
+ EstateID,EstateName,AbuseEmailToEstateOwner,DenyAnonymous,ResetHomeOnTeleport,FixedSun,DenyTransacted,BlockDwell,DenyIdentified,AllowVoice,UseGlobalTime,PricePerMeter,TaxFree,AllowDirectTeleport,RedirectGridX,RedirectGridY,ParentEstateID,SunPosition,PublicAccess,EstateSkipScripts,BillableFactor)
+ values ( 99, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
+delete from estate_settings;
+
+CREATE TABLE estate_users (
+ EstateID int(10) NOT NULL,
+ uuid char(36) NOT NULL
+);
+
+CREATE TABLE estateban (
+ EstateID int(10) NOT NULL,
+ bannedUUID varchar(36) NOT NULL,
+ bannedIp varchar(16) NOT NULL,
+ bannedIpHostMask varchar(16) NOT NULL,
+ bannedNameMask varchar(64) default NULL
+);
+
+CREATE INDEX estate_ban_estate_id on estateban(EstateID);
+CREATE INDEX estate_groups_estate_id on estate_groups(EstateID);
+CREATE INDEX estate_managers_estate_id on estate_managers(EstateID);
+CREATE INDEX estate_map_estate_id on estate_map(EstateID);
+CREATE UNIQUE INDEX estate_map_region_id on estate_map(RegionID);
+CREATE INDEX estate_users_estate_id on estate_users(EstateID);
+
+COMMIT;
+
+
+:VERSION 7
+
+begin;
+
+alter table estate_settings add column AbuseEmail varchar(255) not null default '';
+
+alter table estate_settings add column EstateOwner varchar(36) not null default '';
+
+commit;
+
+:VERSION 8
+
+begin;
+
+alter table estate_settings add column DenyMinors tinyint not null default 0;
+
+commit;
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
index 7b27378..c47a85d 100644
--- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations
+++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
@@ -311,33 +311,8 @@ CREATE TABLE regionsettings (
PRIMARY KEY (regionUUID)
);
-CREATE INDEX estate_ban_estate_id on estateban(EstateID);
-CREATE INDEX estate_groups_estate_id on estate_groups(EstateID);
-CREATE INDEX estate_managers_estate_id on estate_managers(EstateID);
-CREATE INDEX estate_map_estate_id on estate_map(EstateID);
-CREATE UNIQUE INDEX estate_map_region_id on estate_map(RegionID);
-CREATE INDEX estate_users_estate_id on estate_users(EstateID);
-
COMMIT;
-:VERSION 7
-
-begin;
-
-alter table estate_settings add column AbuseEmail varchar(255) not null default '';
-
-alter table estate_settings add column EstateOwner varchar(36) not null default '';
-
-commit;
-
-:VERSION 8
-
-begin;
-
-alter table estate_settings add column DenyMinors tinyint not null default 0;
-
-commit;
-
:VERSION 9
BEGIN;
--
cgit v1.1
From 9976cb93ce351f45dea77e3389e0159b866757ae Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Sun, 23 May 2010 11:26:53 +0300
Subject: Further corrections to MS SQL stores (now passes all tests)
Besides, AssetData is slightly optimized to StoreAsset in one request
("IF EXISTS() UPDATE ... ELSE INSERT ...")
The main change in the MS SQL Inventory implem. is that it now return
empty list (or whatever) when called with UUID.Zero, which is consistent
with how the code for other DBs work.
I did no changes at all in XInventory, as there is no test set for them.
---
OpenSim/Data/MSSQL/MSSQLAssetData.cs | 87 +++++++-------------------------
OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 51 ++++++++++++-------
2 files changed, 49 insertions(+), 89 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index ec9d4f6..c7488d8 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -145,26 +145,19 @@ namespace OpenSim.Data.MSSQL
/// the asset
override public void StoreAsset(AssetBase asset)
{
- if (ExistsAsset(asset.FullID))
- UpdateAsset(asset);
- else
- InsertAsset(asset);
- }
-
-
- private void InsertAsset(AssetBase asset)
- {
- if (ExistsAsset(asset.FullID))
- {
- return;
- }
-
- string sql = @"INSERT INTO assets
- ([id], [name], [description], [assetType], [local],
- [temporary], [create_time], [access_time], [creatorid], [asset_flags], [data])
- VALUES
- (@id, @name, @description, @assetType, @local,
- @temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)";
+
+ string sql =
+ @"IF EXISTS(SELECT * FROM assets WHERE id=@id)
+ UPDATE assets set name = @name, description = @description, assetType = @assetType,
+ local = @local, temporary = @temporary, creatorid = @creatorid, data = @data
+ WHERE id=@id
+ ELSE
+ INSERT INTO assets
+ ([id], [name], [description], [assetType], [local],
+ [temporary], [create_time], [access_time], [creatorid], [asset_flags], [data])
+ VALUES
+ (@id, @name, @description, @assetType, @local,
+ @temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)";
string assetName = asset.Name;
if (asset.Name.Length > 64)
@@ -202,58 +195,11 @@ namespace OpenSim.Data.MSSQL
}
catch(Exception e)
{
- m_log.Error("[ASSET DB]: Error inserting item :" + e.Message);
+ m_log.Error("[ASSET DB]: Error storing item :" + e.Message);
}
}
}
- ///
- /// Update asset in m_database
- ///
- /// the asset
- private void UpdateAsset(AssetBase asset)
- {
- string sql = @"UPDATE assets set name = @name, description = @description, assetType = @assetType,
- local = @local, temporary = @temporary, data = @data
- , creatorid = @creatorid
- WHERE id = @keyId;";
-
- string assetName = asset.Name;
- if (asset.Name.Length > 64)
- {
- assetName = asset.Name.Substring(0, 64);
- m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on update");
- }
-
- string assetDescription = asset.Description;
- if (asset.Description.Length > 64)
- {
- assetDescription = asset.Description.Substring(0, 64);
- m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on update");
- }
-
- using (SqlConnection conn = new SqlConnection(m_connectionString))
- using (SqlCommand command = new SqlCommand(sql, conn))
- {
- command.Parameters.Add(m_database.CreateParameter("keyId", asset.FullID));
- command.Parameters.Add(m_database.CreateParameter("name", assetName));
- command.Parameters.Add(m_database.CreateParameter("description", assetDescription));
- command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
- command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
- command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
- command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
- command.Parameters.Add(m_database.CreateParameter("creatorid", asset.Metadata.CreatorID));
- conn.Open();
- try
- {
- command.ExecuteNonQuery();
- }
- catch (Exception e)
- {
- m_log.Error(e.ToString());
- }
- }
- }
// Commented out since currently unused - this probably should be called in GetAsset()
// private void UpdateAccessTime(AssetBase asset)
@@ -302,7 +248,7 @@ namespace OpenSim.Data.MSSQL
string sql = @"WITH OrderedAssets AS
(
SELECT id, name, description, assetType, temporary, creatorid,
- Row = ROW_NUMBER() OVER (ORDER BY id)
+ RowNumber = ROW_NUMBER() OVER (ORDER BY id)
FROM assets
)
SELECT *
@@ -320,12 +266,13 @@ namespace OpenSim.Data.MSSQL
while (reader.Read())
{
AssetMetadata metadata = new AssetMetadata();
- metadata.FullID = new UUID((Guid)reader["id"]);
+ metadata.FullID = DBGuid.FromDB(reader["id"]);
metadata.Name = (string)reader["name"];
metadata.Description = (string)reader["description"];
metadata.Type = Convert.ToSByte(reader["assetType"]);
metadata.Temporary = Convert.ToBoolean(reader["temporary"]);
metadata.CreatorID = (string)reader["creatorid"];
+ retList.Add(metadata);
}
}
}
diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
index 4815700..4d06377 100644
--- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
@@ -111,6 +111,9 @@ namespace OpenSim.Data.MSSQL
/// A list of folder objects
public List getUserRootFolders(UUID user)
{
+ if (user == UUID.Zero)
+ return new List();
+
return getInventoryFolders(UUID.Zero, user);
}
@@ -184,7 +187,19 @@ namespace OpenSim.Data.MSSQL
//Note maybe change this to use a Dataset that loading in all folders of a user and then go throw it that way.
//Note this is changed so it opens only one connection to the database and not everytime it wants to get data.
+ /* NOTE: the implementation below is very inefficient (makes a separate request to get subfolders for
+ * every found folder, recursively). Inventory code for other DBs has been already rewritten to get ALL
+ * inventory for a specific user at once.
+ *
+ * Meanwhile, one little thing is corrected: getFolderHierarchy(UUID.Zero) doesn't make sense and should never
+ * be used, so check for that and return an empty list.
+ */
+
List folders = new List();
+
+ if (parentID == UUID.Zero)
+ return folders;
+
string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID";
using (SqlConnection conn = new SqlConnection(m_connectionString))
using (SqlCommand cmd = new SqlCommand(sql, conn))
@@ -249,13 +264,12 @@ namespace OpenSim.Data.MSSQL
/// Folder to update
public void updateInventoryFolder(InventoryFolderBase folder)
{
- string sql = @"UPDATE inventoryfolders SET folderID = @folderID,
- agentID = @agentID,
+ string sql = @"UPDATE inventoryfolders SET agentID = @agentID,
parentFolderID = @parentFolderID,
folderName = @folderName,
type = @type,
version = @version
- WHERE folderID = @keyFolderID";
+ WHERE folderID = @folderID";
string folderName = folder.Name;
if (folderName.Length > 64)
@@ -272,7 +286,6 @@ namespace OpenSim.Data.MSSQL
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
- cmd.Parameters.Add(database.CreateParameter("@keyFolderID", folder.ID));
conn.Open();
try
{
@@ -296,7 +309,7 @@ namespace OpenSim.Data.MSSQL
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
- cmd.Parameters.Add(database.CreateParameter("@folderID", folder.ID));
+ cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
conn.Open();
try
{
@@ -489,8 +502,7 @@ namespace OpenSim.Data.MSSQL
/// Inventory item to update
public void updateInventoryItem(InventoryItemBase item)
{
- string sql = @"UPDATE inventoryitems SET inventoryID = @inventoryID,
- assetID = @assetID,
+ string sql = @"UPDATE inventoryitems SET assetID = @assetID,
assetType = @assetType,
parentFolderID = @parentFolderID,
avatarID = @avatarID,
@@ -502,13 +514,14 @@ namespace OpenSim.Data.MSSQL
creatorID = @creatorID,
inventoryBasePermissions = @inventoryBasePermissions,
inventoryEveryOnePermissions = @inventoryEveryOnePermissions,
+ inventoryGroupPermissions = @inventoryGroupPermissions,
salePrice = @salePrice,
saleType = @saleType,
creationDate = @creationDate,
groupID = @groupID,
groupOwned = @groupOwned,
flags = @flags
- WHERE inventoryID = @keyInventoryID";
+ WHERE inventoryID = @inventoryID";
string itemName = item.Name;
if (item.Name.Length > 64)
@@ -537,16 +550,16 @@ namespace OpenSim.Data.MSSQL
command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions));
command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions));
command.Parameters.Add(database.CreateParameter("invType", item.InvType));
- command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorIdAsUuid));
+ command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId));
command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions));
command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions));
+ command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions));
command.Parameters.Add(database.CreateParameter("salePrice", item.SalePrice));
command.Parameters.Add(database.CreateParameter("saleType", item.SaleType));
command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate));
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
- command.Parameters.Add(database.CreateParameter("keyInventoryID", item.ID));
conn.Open();
try
{
@@ -732,9 +745,9 @@ namespace OpenSim.Data.MSSQL
try
{
InventoryFolderBase folder = new InventoryFolderBase();
- folder.Owner = new UUID((Guid)reader["agentID"]);
- folder.ParentID = new UUID((Guid)reader["parentFolderID"]);
- folder.ID = new UUID((Guid)reader["folderID"]);
+ folder.Owner = DBGuid.FromDB(reader["agentID"]);
+ folder.ParentID = DBGuid.FromDB(reader["parentFolderID"]);
+ folder.ID = DBGuid.FromDB(reader["folderID"]);
folder.Name = (string)reader["folderName"];
folder.Type = (short)reader["type"];
folder.Version = Convert.ToUInt16(reader["version"]);
@@ -760,24 +773,24 @@ namespace OpenSim.Data.MSSQL
{
InventoryItemBase item = new InventoryItemBase();
- item.ID = new UUID((Guid)reader["inventoryID"]);
- item.AssetID = new UUID((Guid)reader["assetID"]);
+ item.ID = DBGuid.FromDB(reader["inventoryID"]);
+ item.AssetID = DBGuid.FromDB(reader["assetID"]);
item.AssetType = Convert.ToInt32(reader["assetType"].ToString());
- item.Folder = new UUID((Guid)reader["parentFolderID"]);
- item.Owner = new UUID((Guid)reader["avatarID"]);
+ item.Folder = DBGuid.FromDB(reader["parentFolderID"]);
+ item.Owner = DBGuid.FromDB(reader["avatarID"]);
item.Name = reader["inventoryName"].ToString();
item.Description = reader["inventoryDescription"].ToString();
item.NextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]);
item.CurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]);
item.InvType = Convert.ToInt32(reader["invType"].ToString());
- item.CreatorId = ((Guid)reader["creatorID"]).ToString();
+ item.CreatorId = reader["creatorID"].ToString();
item.BasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]);
item.EveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]);
item.GroupPermissions = Convert.ToUInt32(reader["inventoryGroupPermissions"]);
item.SalePrice = Convert.ToInt32(reader["salePrice"]);
item.SaleType = Convert.ToByte(reader["saleType"]);
item.CreationDate = Convert.ToInt32(reader["creationDate"]);
- item.GroupID = new UUID((Guid)reader["groupID"]);
+ item.GroupID = DBGuid.FromDB(reader["groupID"]);
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
item.Flags = Convert.ToUInt32(reader["flags"]);
--
cgit v1.1
From 89b7c64b6f491c4f703bb8fe28987ee5e3d5c50f Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Sun, 23 May 2010 11:31:19 +0300
Subject: Various minor changes in the data tests
---
OpenSim/Data/Tests/AssetTests.cs | 8 ++++++++
OpenSim/Data/Tests/BasicDataServiceTest.cs | 3 ++-
OpenSim/Data/Tests/EstateTests.cs | 11 +----------
OpenSim/Data/Tests/InventoryTests.cs | 8 +++++---
OpenSim/Data/Tests/RegionTests.cs | 4 ++--
5 files changed, 18 insertions(+), 16 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
index d228c1f..d771053 100644
--- a/OpenSim/Data/Tests/AssetTests.cs
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -106,10 +106,18 @@ namespace OpenSim.Data.Tests
protected override void InitService(object service)
{
+ ClearDB();
m_db = (TAssetData)service;
m_db.Initialise(m_connStr);
}
+ private void ClearDB()
+ {
+ DropTables("assets");
+ ResetMigrations("AssetStore");
+ }
+
+
[Test]
public void T001_LoadEmpty()
{
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs
index e91a45d..4c7cf28 100644
--- a/OpenSim/Data/Tests/BasicDataServiceTest.cs
+++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs
@@ -183,9 +183,10 @@ namespace OpenSim.Data.Tests
lst += ", " + s;
}
+ string sCond = stores.Length > 1 ? ("in (" + lst + ")") : ("=" + lst);
try
{
- ExecuteSql("DELETE FROM `migrations` where name in (" + lst + ");");
+ ExecuteSql("DELETE FROM migrations where name " + sCond);
}
catch
{
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs
index 2da010d..d6eed3d 100644
--- a/OpenSim/Data/Tests/EstateTests.cs
+++ b/OpenSim/Data/Tests/EstateTests.cs
@@ -108,17 +108,7 @@ namespace OpenSim.Data.Tests
private void ClearDB()
{
// if a new table is added, it has to be dropped here
- ExecuteSql("delete from migrations where name='EstateStore';");
-
DropTables(
- "prims",
- "primshapes",
- "primitems",
- "terrain",
- "land",
- "landaccesslist",
- "regionban",
- "regionsettings",
"estate_managers",
"estate_groups",
"estate_users",
@@ -126,6 +116,7 @@ namespace OpenSim.Data.Tests
"estate_settings",
"estate_map"
);
+ ResetMigrations("EstateStore");
}
#region 0Tests
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
index 93e1eba..c22e26c 100644
--- a/OpenSim/Data/Tests/InventoryTests.cs
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -123,7 +123,7 @@ namespace OpenSim.Data.Tests
private void ClearDB()
{
DropTables("inventoryitems", "inventoryfolders");
- ExecuteSql("delete from migrations where name='Inventory'");
+ ResetMigrations("InventoryStore");
}
[Test]
@@ -194,8 +194,10 @@ namespace OpenSim.Data.Tests
[Test]
public void T013_FolderHierarchy()
{
- Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
- Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
+ int n = db.getFolderHierarchy(zero).Count; // (for dbg - easier to see what's returned)
+ Assert.That(n, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
+ n = db.getFolderHierarchy(folder1).Count;
+ Assert.That(n, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))");
Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0))");
Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0))");
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index 5ac2dd0..1f654d3 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -118,8 +118,8 @@ namespace OpenSim.Data.Tests
m_rebuildDB = rebuild;
}
- public RegionTests() : this("", false) { }
- public RegionTests(string conn) : this(conn, false) {}
+ public RegionTests() : this("", true) { }
+ public RegionTests(string conn) : this(conn, true) {}
public RegionTests(bool rebuild): this("", rebuild) {}
--
cgit v1.1
From 52a3dbd076394a67d165a5b1f852a5bc9ac918d4 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Sun, 23 May 2010 11:34:56 +0300
Subject: MSSQL Migration: CreatorID in InventoryItems changed to VARCHAR(36)
Again, the same thing about potentially having non-GUID CreatorID.
---
.../Data/MSSQL/Resources/InventoryStore.migrations | 70 ++++++++++++++++++++++
1 file changed, 70 insertions(+)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations b/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations
index cd5dfdc..e2a8d57 100644
--- a/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations
+++ b/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations
@@ -171,4 +171,74 @@ CREATE NONCLUSTERED INDEX folder ON dbo.inventoryitems
COMMIT
+:VERSION 5
+
+# It would be totally crazy to have to recreate the whole table just to change one column type,
+# just because MS SQL treats each DEFAULT as a constraint object that must be dropped
+# before anything can be done to the column. Since all defaults here are unnamed, there is
+# no easy way to drop them! The hairy piece of code below removes all DEFAULT constraints
+# from InventoryItems.
+
+# SO: anything that's NULLable is by default NULL, so please don't declare DEFAULT(NULL),
+# they do nothing but prevent changes to the columns. If you really
+# need to have DEFAULTs or other constraints, give them names so they can be dropped when needed!
+
+BEGIN TRANSACTION
+DECLARE @nm varchar(80);
+DECLARE x CURSOR LOCAL FORWARD_ONLY READ_ONLY
+ FOR SELECT name FROM sys.default_constraints where parent_object_id = OBJECT_ID('inventoryitems');
+OPEN x;
+FETCH NEXT FROM x INTO @nm;
+WHILE @@FETCH_STATUS = 0
+BEGIN
+ EXEC('alter table inventoryitems drop ' + @nm);
+ FETCH NEXT FROM x INTO @nm;
+END
+CLOSE x
+DEALLOCATE x
+COMMIT
+
+# all DEFAULTs dropped!
+
+:GO
+
+BEGIN TRANSACTION
+
+# Restoring defaults:
+# NOTE: [inventoryID] does NOT need one: it's NOT NULL PK and a unique Guid must be provided every time anyway!
+
+alter table inventoryitems
+ add constraint def_baseperm default 0 for inventoryBasePermissions
+alter table inventoryitems
+ add constraint def_allperm default 0 for inventoryEveryOnePermissions
+alter table inventoryitems
+ add constraint def_grpperm default 0 for inventoryGroupPermissions
+
+COMMIT
+
+:VERSION 7
+
+BEGIN TRANSACTION
+
+# CreatorID goes back to VARCHAR(36) (???)
+
+exec sp_rename 'inventoryitems.CreatorID', 'cr_old', 'COLUMN'
+
+:GO
+
+alter table inventoryitems
+ add creatorID varchar(36) NULL
+
+:GO
+
+update inventoryitems set creatorID = CONVERT(VARCHAR(36), cr_old)
+
+alter table inventoryitems
+ drop column cr_old
+
+COMMIT
+
+
+
+
--
cgit v1.1
From 05d9ca1b26baaae3e9ab106665163f5beeecd11d Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Sun, 23 May 2010 11:36:40 +0300
Subject: MySQL Migrations: Minor correcton to Region/Estate split
(some Estate SQL left behind in the Region migration)
---
OpenSim/Data/MySQL/Resources/EstateStore.migrations | 12 ++++++++++++
OpenSim/Data/MySQL/Resources/RegionStore.migrations | 6 ------
2 files changed, 12 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations
index 2e0d658..df82a2e 100644
--- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations
@@ -1,6 +1,10 @@
:VERSION 13
# The estate migrations used to be in Region store
+# here they will do nothing (bad) if the tables are already there,
+# just update the store version.
+
+BEGIN;
CREATE TABLE IF NOT EXISTS `estate_managers` (
`EstateID` int(10) unsigned NOT NULL,
@@ -65,5 +69,13 @@ CREATE TABLE IF NOT EXISTS `estate_map` (
KEY `EstateID` (`EstateID`)
) ENGINE=InnoDB;
+COMMIT;
+
+:VERSION 32 #--------------------- (moved from RegionStore migr, just in case)
+
+BEGIN;
+ALTER TABLE estate_settings AUTO_INCREMENT = 100;
+COMMIT;
+
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index 383c328..d8a279d 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -717,12 +717,6 @@ ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT
COMMIT;
-:VERSION 32 #---------------------
-
-BEGIN;
-ALTER TABLE estate_settings AUTO_INCREMENT = 100;
-COMMIT;
-
:VERSION 33 #---------------------
BEGIN;
--
cgit v1.1
From b9b6d9c4ea1dc3aacda1799d5603a06a5b704db7 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Sun, 23 May 2010 11:41:44 +0300
Subject: Removed (unused?) empty SQL files from MSSQL resource dir
There was a whole bunch of these SQL files, all empty and apparently
unused. Removing them is just a clean-up, if anybody has a reason for these
files to be there, feel free to revert.
---
OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql | 0
OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql | 0
OpenSim/Data/MSSQL/Resources/CreateFoldersTable.sql | 0
OpenSim/Data/MSSQL/Resources/CreateItemsTable.sql | 0
OpenSim/Data/MSSQL/Resources/CreateUserFriendsTable.sql | 0
OpenSim/Data/MSSQL/Resources/Mssql-agents.sql | 0
OpenSim/Data/MSSQL/Resources/Mssql-logs.sql | 0
OpenSim/Data/MSSQL/Resources/Mssql-regions.sql | 0
OpenSim/Data/MSSQL/Resources/Mssql-users.sql | 0
9 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql
delete mode 100644 OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql
delete mode 100644 OpenSim/Data/MSSQL/Resources/CreateFoldersTable.sql
delete mode 100644 OpenSim/Data/MSSQL/Resources/CreateItemsTable.sql
delete mode 100644 OpenSim/Data/MSSQL/Resources/CreateUserFriendsTable.sql
delete mode 100644 OpenSim/Data/MSSQL/Resources/Mssql-agents.sql
delete mode 100644 OpenSim/Data/MSSQL/Resources/Mssql-logs.sql
delete mode 100644 OpenSim/Data/MSSQL/Resources/Mssql-regions.sql
delete mode 100644 OpenSim/Data/MSSQL/Resources/Mssql-users.sql
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql b/OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql b/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/OpenSim/Data/MSSQL/Resources/CreateFoldersTable.sql b/OpenSim/Data/MSSQL/Resources/CreateFoldersTable.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/OpenSim/Data/MSSQL/Resources/CreateItemsTable.sql b/OpenSim/Data/MSSQL/Resources/CreateItemsTable.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/OpenSim/Data/MSSQL/Resources/CreateUserFriendsTable.sql b/OpenSim/Data/MSSQL/Resources/CreateUserFriendsTable.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/OpenSim/Data/MSSQL/Resources/Mssql-agents.sql b/OpenSim/Data/MSSQL/Resources/Mssql-agents.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/OpenSim/Data/MSSQL/Resources/Mssql-logs.sql b/OpenSim/Data/MSSQL/Resources/Mssql-logs.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/OpenSim/Data/MSSQL/Resources/Mssql-regions.sql b/OpenSim/Data/MSSQL/Resources/Mssql-regions.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/OpenSim/Data/MSSQL/Resources/Mssql-users.sql b/OpenSim/Data/MSSQL/Resources/Mssql-users.sql
deleted file mode 100644
index e69de29..0000000
--
cgit v1.1
From 57f4729eeaa377f74681bd3d0bbb999680c72441 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Sun, 23 May 2010 12:46:33 +0300
Subject: Ensured that tests are skipped for wrong conn string, also m_log chng
The base test class now tries to connect to DB, ignores all tests in the
class if unable to.
Also m_log changed to instance field (which in this case shouldn't cause
any problems), to avoid having to define it separately in each derived
class. Here I touched things that I don't understand well (using log4net),
so please review this commit.
---
OpenSim/Data/Tests/BasicDataServiceTest.cs | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs
index 4c7cf28..c261126 100644
--- a/OpenSim/Data/Tests/BasicDataServiceTest.cs
+++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs
@@ -27,7 +27,10 @@ namespace OpenSim.Data.Tests
private string m_file;
// TODO: Is this in the right place here?
- protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ // Later: apparently it's not, but does it matter here?
+// protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ protected ILog m_log; // doesn't matter here that it's not static, init to correct type in instance .ctor
public BasicDataServiceTest()
: this("")
@@ -38,6 +41,7 @@ namespace OpenSim.Data.Tests
{
m_connStr = !String.IsNullOrEmpty(conn) ? conn : DefaultTestConns.Get(typeof(TConn));
+ m_log = LogManager.GetLogger(this.GetType());
OpenSim.Tests.Common.TestLogging.LogToConsole(); // TODO: Is that right?
}
@@ -72,10 +76,27 @@ namespace OpenSim.Data.Tests
if (String.IsNullOrEmpty(m_connStr))
{
string msg = String.Format("Connection string for {0} is not defined, ignoring tests", typeof(TConn).Name);
- m_log.Error(msg);
+ m_log.Warn(msg);
Assert.Ignore(msg);
}
+ // Try the connection, ignore tests if Open() fails
+ using (TConn conn = new TConn())
+ {
+ conn.ConnectionString = m_connStr;
+ try
+ {
+ conn.Open();
+ conn.Close();
+ }
+ catch
+ {
+ string msg = String.Format("{0} is unable to connect to the database, ignoring tests", typeof(TConn).Name);
+ m_log.Warn(msg);
+ Assert.Ignore(msg);
+ }
+ }
+
// If we manage to connect to the database with the user
// and password above it is our test database, and run
// these tests. If anything goes wrong, ignore these
--
cgit v1.1
From 5d65ef2db3da400a005f2279211de9e9c62641b3 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Wed, 26 May 2010 10:22:59 +0300
Subject: Minor correction to AssetTests.cs
(forgot to change test descriptions, has no effect on running the tests)
---
OpenSim/Data/Tests/AssetTests.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
index d771053..800b9bf 100644
--- a/OpenSim/Data/Tests/AssetTests.cs
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -60,17 +60,17 @@ namespace OpenSim.Data.Tests
#else
- [TestFixture(Description = "Region store tests (SQLite)")]
+ [TestFixture(Description = "Asset store tests (SQLite)")]
public class SQLiteAssetTests : AssetTests
{
}
- [TestFixture(Description = "Region store tests (MySQL)")]
+ [TestFixture(Description = "Asset store tests (MySQL)")]
public class MySqlAssetTests : AssetTests
{
}
- [TestFixture(Description = "Region store tests (MS SQL Server)")]
+ [TestFixture(Description = "Asset store tests (MS SQL Server)")]
public class MSSQLAssetTests : AssetTests
{
}
--
cgit v1.1