Thank you kindly, TLaukkan (Tommil) for a patch that:

* Created value object for EstateRegionLink for storing the estate region relationship.
* Refactored slightly NHibernateManager and NHibernateXXXXData implementations for accesing nhibernate generated ID on insert.
** Changed NHibernateManager.Save method name to Insert as it does Insert.
** Changed NHibernateManager.Save return value object as ID can be both UUID and uint currently.
** Changed NHibernateManager.Load method Id parameter to object as it can be both UUID and uint.
* Created NHibernateEstateData implementation. This is the actual estate storage.
* Created NHibernate mapping files for both EstateSettings and EstateRegionLink
* Created MigrationSyntaxDifferences.txt files to write notes about differences in migration scripts between different databases.
* Created estate storage migration scripts for all four databases.
* Created estate unit test classes for all four databases.
* Updated one missing field to BasicEstateTest.cs
* Tested NHibernate unit tests with NUnit GUI. Asset databases fail but that is not related to this patch.
* Tested build with both Visual Studio and nant.
* Executed build tests with nant succesfully.
0.6.3-post-fixes
Charles Krinke 2009-02-14 19:47:02 +00:00
parent 67b0ba71da
commit a583d8ad70
20 changed files with 803 additions and 57 deletions

View File

@ -0,0 +1,49 @@
?using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
namespace OpenSim.Data.NHibernate
{
public class EstateRegionLink
{
private UUID estateRegionLinkID;
public UUID EstateRegionLinkID
{
get
{
return estateRegionLinkID;
}
set
{
estateRegionLinkID = value;
}
}
private uint estateID;
public uint EstateID
{
get
{
return estateID;
}
set
{
estateID = value;
}
}
private UUID regionID;
public UUID RegionID
{
get
{
return regionID;
}
set
{
regionID = value;
}
}
}
}

View File

@ -45,7 +45,8 @@ namespace OpenSim.Data.NHibernate
public override void Initialise()
{
Initialise("SQLiteDialect;SqliteClientDriver;URI=file:Asset.db,version=3");
m_log.Info("[NHibernateGridData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException(Name);
}
public override void Initialise(string connect)
@ -66,7 +67,7 @@ namespace OpenSim.Data.NHibernate
AssetBase temp = (AssetBase)manager.Load(typeof(AssetBase), asset.Metadata.FullID);
if (temp == null)
{
manager.Save(asset);
manager.Insert(asset);
}
}

View File

@ -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 OpenSim 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.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using NHibernate;
using NHibernate.Criterion;
using System.Collections;
using System;
namespace OpenSim.Data.NHibernate
{
/// <summary>
/// A User storage interface for the DB4o database system
/// </summary>
public class NHibernateEstateData : IEstateDataStore
{
#region Fields
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public NHibernateManager manager;
public string Name
{
get { return "NHibernateEstateData"; }
}
public string Version
{
get { return "0.1"; }
}
#endregion
#region Startup and shutdown.
public void Initialise()
{
m_log.Info("[NHIBERNATE]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException(Name);
}
public void Initialise(string connect)
{
m_log.InfoFormat("[NHIBERNATE] Initializing " + Name + ".");
manager = new NHibernateManager(connect, "EstateStore");
}
public void Dispose() { }
#endregion
#region IEstateDataStore Members
public EstateSettings LoadEstateSettings(UUID regionID)
{
EstateRegionLink link = LoadEstateRegionLink(regionID);
// Ensure that estate settings exist for the link
if (link != null)
{
if (manager.Load(typeof(EstateSettings), link.EstateID) == null)
{
// Delete broken link
manager.Delete(link);
link = null;
}
}
// If estate link does not exist create estate settings and link it to region.
if (link == null)
{
EstateSettings estateSettings = new EstateSettings();
//estateSettings.EstateOwner = UUID.Random();
//estateSettings.BlockDwell = false;
object identifier = manager.Insert(estateSettings);
if (identifier == null)
{
// Saving failed. Error is logged in the manager.
return null;
}
uint estateID = (uint)identifier;
link = new EstateRegionLink();
link.EstateRegionLinkID = UUID.Random();
link.RegionID = regionID;
link.EstateID = estateID;
manager.Insert(link);
}
// Load estate settings according to the existing or created link.
return (EstateSettings)manager.Load(typeof(EstateSettings), link.EstateID);
}
public void StoreEstateSettings(EstateSettings estateSettings)
{
// Estates are always updated when stored.
// Insert is always done via. load method as with the current API
// this is explicitly the only way to create region link.
manager.Update(estateSettings);
}
#endregion
#region Private Utility Methods
private EstateRegionLink LoadEstateRegionLink(UUID regionID)
{
ICriteria criteria = manager.GetSession().CreateCriteria(typeof(EstateRegionLink));
criteria.Add(Expression.Eq("RegionID", regionID));
IList links = criteria.List();
// Fail fast if more than one estate links exist
if (links.Count > 1)
{
m_log.Error("[NHIBERNATE]: Region had more than one estate linked: " + regionID);
throw new Exception("[NHIBERNATE]: Region had more than one estate linked: " + regionID);
}
if (links.Count == 1)
{
return (EstateRegionLink)links[0];
}
else
{
return null;
}
}
#endregion
}
}

View File

@ -113,7 +113,7 @@ namespace OpenSim.Data.NHibernate
{
if (manager.Load(typeof(RegionProfileData), profile.Uuid) == null)
{
manager.Save(profile);
manager.Insert(profile);
return DataResponse.RESPONSE_OK;
}
else

View File

@ -42,6 +42,34 @@ namespace OpenSim.Data.NHibernate
public NHibernateManager manager;
/// <summary>
/// The plugin being loaded
/// </summary>
/// <returns>A string containing the plugin name</returns>
public string Name
{
get { return "NHibernate Inventory Data Interface"; }
}
/// <summary>
/// The plugins version
/// </summary>
/// <returns>A string containing the plugin version</returns>
public string Version
{
get
{
Module module = GetType().Module;
// string dllName = module.Assembly.ManifestModule.Name;
Version dllVersion = module.Assembly.GetName().Version;
return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision);
}
}
public void Initialise()
{
m_log.Info("[NHibernateInventoryData]: " + Name + " cannot be default-initialized!");
@ -57,6 +85,13 @@ namespace OpenSim.Data.NHibernate
manager = new NHibernateManager(connect, "InventoryStore");
}
/// <summary>
/// Closes the interface
/// </summary>
public void Dispose()
{
}
/*****************************************************************
*
* Basic CRUD operations on Data
@ -92,7 +127,7 @@ namespace OpenSim.Data.NHibernate
{
if (!ExistsItem(item.ID))
{
manager.Save(item);
manager.Insert(item);
}
else
{
@ -161,7 +196,7 @@ namespace OpenSim.Data.NHibernate
{
if (!ExistsFolder(folder.ID))
{
manager.Save(folder);
manager.Insert(folder);
}
else
{
@ -220,41 +255,6 @@ namespace OpenSim.Data.NHibernate
// TODO: DataSet commit
}
/// <summary>
/// Closes the interface
/// </summary>
public void Dispose()
{
}
/// <summary>
/// The plugin being loaded
/// </summary>
/// <returns>A string containing the plugin name</returns>
public string Name
{
get { return "NHibernate Inventory Data Interface"; }
}
/// <summary>
/// The plugins version
/// </summary>
/// <returns>A string containing the plugin version</returns>
public string Version
{
get
{
Module module = GetType().Module;
// string dllName = module.Assembly.ManifestModule.Name;
Version dllVersion = module.Assembly.GetName().Version;
return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision);
}
}
// Move seems to be just update
public void moveInventoryFolder(InventoryFolderBase folder)

View File

@ -131,25 +131,25 @@ namespace OpenSim.Data.NHibernate
RunMigration(dialect, assembly, store);
}
public object Load(Type type, UUID uuid)
public object Load(Type type, Object id)
{
using (IStatelessSession session = sessionFactory.OpenStatelessSession())
{
object obj = null;
try
{
obj = session.Get(type.FullName, uuid);
obj = session.Get(type.FullName, id);
}
catch (Exception e)
{
m_log.ErrorFormat("[NHIBERNATE] {0} of id {1} loading threw exception: "+ e.ToString(), type.Name, uuid);
m_log.ErrorFormat("[NHIBERNATE] {0} of id {1} loading threw exception: " + e.ToString(), type.Name, id);
}
return obj;
}
}
public bool Save(object obj)
public object Insert(object obj)
{
try
{
@ -157,16 +157,16 @@ namespace OpenSim.Data.NHibernate
{
using (ITransaction transaction=session.BeginTransaction())
{
session.Insert(obj);
Object identifier=session.Insert(obj);
transaction.Commit();
return true;
return identifier;
}
}
}
catch (Exception e)
{
m_log.Error("[NHIBERNATE] issue inserting object ", e);
return false;
return null;
}
}

View File

@ -70,7 +70,7 @@ namespace OpenSim.Data.NHibernate
}
else
{
manager.Save(rs);
manager.Insert(rs);
}
}
@ -82,7 +82,7 @@ namespace OpenSim.Data.NHibernate
{
regionSettings = new RegionSettings();
regionSettings.RegionUUID = regionUUID;
manager.Save(regionSettings);
manager.Insert(regionSettings);
}
regionSettings.OnSave += StoreRegionSettings;
@ -105,7 +105,7 @@ namespace OpenSim.Data.NHibernate
else
{
m_log.InfoFormat("[NHIBERNATE] saving object {0}", p.UUID);
manager.Save(p);
manager.Insert(p);
}
}
@ -129,7 +129,7 @@ namespace OpenSim.Data.NHibernate
else
{
m_log.InfoFormat("[NHIBERNATE] saving terrain {0}", t.RegionID);
manager.Save(t);
manager.Insert(t);
}
}
@ -394,7 +394,7 @@ namespace OpenSim.Data.NHibernate
foreach (TaskInventoryItem i in items)
{
manager.Save(i);
manager.Insert(i);
}
}

View File

@ -102,7 +102,7 @@ namespace OpenSim.Data.NHibernate
if (!ExistsUser(profile.ID))
{
m_log.InfoFormat("[NHIBERNATE] AddNewUserProfile {0}", profile.ID);
manager.Save(profile);
manager.Insert(profile);
// Agent should not be saved according to BasicUserTest.T015_UserPersistency()
// SetAgentData(profile.ID, profile.CurrentAgent);
@ -169,7 +169,7 @@ namespace OpenSim.Data.NHibernate
manager.Delete(old);
}
manager.Save(agent);
manager.Insert(agent);
}
@ -245,11 +245,11 @@ namespace OpenSim.Data.NHibernate
{
if (!FriendRelationExists(ownerId,friendId))
{
manager.Save(new UserFriend(UUID.Random(), ownerId, friendId, perms));
manager.Insert(new UserFriend(UUID.Random(), ownerId, friendId, perms));
}
if (!FriendRelationExists(friendId, ownerId))
{
manager.Save(new UserFriend(UUID.Random(), friendId, ownerId, perms));
manager.Insert(new UserFriend(UUID.Random(), friendId, ownerId, perms));
}
return;
}
@ -426,7 +426,7 @@ namespace OpenSim.Data.NHibernate
}
else
{
manager.Save(appearance);
manager.Insert(appearance);
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="OpenSim.Data.NHibernate.EstateRegionLink, OpenSim.Data.NHibernate" table="EstateRegionLink" lazy="false">
<id name="EstateRegionLinkID" column="EstateRegionLinkID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
<generator class="assigned" />
</id>
<property name="EstateID" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="RegionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
</class>
</hibernate-mapping>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="OpenSim.Framework.EstateSettings, OpenSim.Framework" table="EstateSettings" lazy="false">
<id name="EstateID" column="EstateID" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate">
<generator class="increment" />
</id>
<property name="ParentEstateID" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="EstateOwner" column="EstateOwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="EstateName" column="Name" type="String" length="64" />
<property name="RedirectGridX" type="System.Int32" />
<property name="RedirectGridY" type="System.Int32" />
<property name="BillableFactor" type="System.Single" />
<property name="PricePerMeter" type="System.Int32" />
<property name="SunPosition" type="System.Double" />
<property name="UseGlobalTime" type="System.Boolean" />
<property name="FixedSun" type="System.Boolean" />
<property name="AllowVoice" type="System.Boolean" />
<property name="AllowDirectTeleport" type="System.Boolean" />
<property name="ResetHomeOnTeleport" type="System.Boolean" />
<property name="PublicAccess" type="System.Boolean" />
<property name="DenyAnonymous" type="System.Boolean" />
<property name="DenyIdentified" type="System.Boolean" />
<property name="DenyTransacted" type="System.Boolean" />
<property name="DenyMinors" type="System.Boolean" />
<property name="BlockDwell" type="System.Boolean" />
<property name="EstateSkipScripts" type="System.Boolean" />
<property name="TaxFree" type="System.Boolean" />
<property name="AbuseEmailToEstateOwner" type="System.Boolean" />
<property name="AbuseEmail" type="String" length="255" />
</class>
</hibernate-mapping>

View File

@ -0,0 +1,14 @@
?This file describes the differences in schema creation and migration scripts.
MySQL is used as reference script against which differences are listed.
Generally MySQL create table options should be removed for other databases.
_PostgreSQL_
* DOUBLE->DOUBLE PRECISION
* BIT->BOOLEAN
_MsSql_
* VARCHAR->NVARCHAR
* Remove DEFAULT-keywords
* DOUBLE->REAL

View File

@ -0,0 +1,40 @@
CREATE TABLE EstateSettings (
EstateID INT NOT NULL,
ParentEstateID INT NULL,
EstateOwnerID NVARCHAR(36) NULL,
Name NVARCHAR(64) NULL,
RedirectGridX INT NULL,
RedirectGridY INT NULL,
BillableFactor REAL NULL,
PricePerMeter INT NULL,
SunPosition REAL NULL,
UseGlobalTime BIT NULL,
FixedSun BIT NULL,
AllowVoice BIT NULL,
AllowDirectTeleport BIT NULL,
ResetHomeOnTeleport BIT NULL,
PublicAccess BIT NULL,
DenyAnonymous BIT NULL,
DenyIdentified BIT NULL,
DenyTransacted BIT NULL,
DenyMinors BIT NULL,
BlockDwell BIT NULL,
EstateSkipScripts BIT NULL,
TaxFree BIT NULL,
AbuseEmailToEstateOwner BIT NULL,
AbuseEmail NVARCHAR(255) NULL,
PRIMARY KEY (EstateID)
);
CREATE TABLE EstateRegionLink (
EstateRegionLinkID NVARCHAR(36) NOT NULL,
EstateID INT NULL,
RegionID NVARCHAR(36) NULL,
PRIMARY KEY (EstateRegionLinkID)
);
CREATE INDEX EstateRegionLinkEstateIDIndex ON EstateRegionLink (EstateID);
CREATE INDEX EstateRegionLinkERegionIDIndex ON EstateRegionLink (RegionID);

View File

@ -0,0 +1,40 @@
CREATE TABLE EstateSettings (
EstateID INT NOT NULL,
ParentEstateID INT DEFAULT NULL,
EstateOwnerID VARCHAR(36) DEFAULT NULL,
Name VARCHAR(64) DEFAULT NULL,
RedirectGridX INT DEFAULT NULL,
RedirectGridY INT DEFAULT NULL,
BillableFactor DOUBLE DEFAULT NULL,
PricePerMeter INT DEFAULT NULL,
SunPosition DOUBLE DEFAULT NULL,
UseGlobalTime BIT DEFAULT NULL,
FixedSun BIT DEFAULT NULL,
AllowVoice BIT DEFAULT NULL,
AllowDirectTeleport BIT DEFAULT NULL,
ResetHomeOnTeleport BIT DEFAULT NULL,
PublicAccess BIT DEFAULT NULL,
DenyAnonymous BIT DEFAULT NULL,
DenyIdentified BIT DEFAULT NULL,
DenyTransacted BIT DEFAULT NULL,
DenyMinors BIT DEFAULT NULL,
BlockDwell BIT DEFAULT NULL,
EstateSkipScripts BIT DEFAULT NULL,
TaxFree BIT DEFAULT NULL,
AbuseEmailToEstateOwner BIT DEFAULT NULL,
AbuseEmail VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (EstateID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1';
CREATE TABLE EstateRegionLink (
EstateRegionLinkID VARCHAR(36) NOT NULL,
EstateID INT DEFAULT NULL,
RegionID VARCHAR(36) DEFAULT NULL,
PRIMARY KEY (EstateRegionLinkID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1';
CREATE INDEX EstateRegionLinkEstateIDIndex ON EstateRegionLink (EstateID);
CREATE INDEX EstateRegionLinkERegionIDIndex ON EstateRegionLink (RegionID);

View File

@ -0,0 +1,40 @@
CREATE TABLE EstateSettings (
EstateID INT NOT NULL,
ParentEstateID INT DEFAULT NULL,
EstateOwnerID VARCHAR(36) DEFAULT NULL,
Name VARCHAR(64) DEFAULT NULL,
RedirectGridX INT DEFAULT NULL,
RedirectGridY INT DEFAULT NULL,
BillableFactor DOUBLE PRECISION DEFAULT NULL,
PricePerMeter INT DEFAULT NULL,
SunPosition DOUBLE PRECISION DEFAULT NULL,
UseGlobalTime BOOLEAN DEFAULT NULL,
FixedSun BOOLEAN DEFAULT NULL,
AllowVoice BOOLEAN DEFAULT NULL,
AllowDirectTeleport BOOLEAN DEFAULT NULL,
ResetHomeOnTeleport BOOLEAN DEFAULT NULL,
PublicAccess BOOLEAN DEFAULT NULL,
DenyAnonymous BOOLEAN DEFAULT NULL,
DenyIdentified BOOLEAN DEFAULT NULL,
DenyTransacted BOOLEAN DEFAULT NULL,
DenyMinors BOOLEAN DEFAULT NULL,
BlockDwell BOOLEAN DEFAULT NULL,
EstateSkipScripts BOOLEAN DEFAULT NULL,
TaxFree BOOLEAN DEFAULT NULL,
AbuseEmailToEstateOwner BOOLEAN DEFAULT NULL,
AbuseEmail VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (EstateID)
);
CREATE TABLE EstateRegionLink (
EstateRegionLinkID VARCHAR(36) NOT NULL,
EstateID INT DEFAULT NULL,
RegionID VARCHAR(36) DEFAULT NULL,
PRIMARY KEY (EstateRegionLinkID)
);
CREATE INDEX EstateRegionLinkEstateIDIndex ON EstateRegionLink (EstateID);
CREATE INDEX EstateRegionLinkERegionIDIndex ON EstateRegionLink (RegionID);

View File

@ -0,0 +1,40 @@
CREATE TABLE EstateSettings (
EstateID INT NOT NULL,
ParentEstateID INT DEFAULT NULL,
EstateOwnerID VARCHAR(36) DEFAULT NULL,
Name VARCHAR(64) DEFAULT NULL,
RedirectGridX INT DEFAULT NULL,
RedirectGridY INT DEFAULT NULL,
BillableFactor DOUBLE DEFAULT NULL,
PricePerMeter INT DEFAULT NULL,
SunPosition DOUBLE DEFAULT NULL,
UseGlobalTime BIT DEFAULT NULL,
FixedSun BIT DEFAULT NULL,
AllowVoice BIT DEFAULT NULL,
AllowDirectTeleport BIT DEFAULT NULL,
ResetHomeOnTeleport BIT DEFAULT NULL,
PublicAccess BIT DEFAULT NULL,
DenyAnonymous BIT DEFAULT NULL,
DenyIdentified BIT DEFAULT NULL,
DenyTransacted BIT DEFAULT NULL,
DenyMinors BIT DEFAULT NULL,
BlockDwell BIT DEFAULT NULL,
EstateSkipScripts BIT DEFAULT NULL,
TaxFree BIT DEFAULT NULL,
AbuseEmailToEstateOwner BIT DEFAULT NULL,
AbuseEmail VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (EstateID)
);
CREATE TABLE EstateRegionLink (
EstateRegionLinkID VARCHAR(36) NOT NULL,
EstateID INT DEFAULT NULL,
RegionID VARCHAR(36) DEFAULT NULL,
PRIMARY KEY (EstateRegionLinkID)
);
CREATE INDEX EstateRegionLinkEstateIDIndex ON EstateRegionLink (EstateID);
CREATE INDEX EstateRegionLinkERegionIDIndex ON EstateRegionLink (RegionID);

View File

@ -0,0 +1,77 @@
/*
* 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 OpenSim 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;
namespace OpenSim.Data.NHibernate.Tests
{
[TestFixture]
public class NHibernateMsSqlEstateTest : BasicEstateTest
{
public string file;
public NHibernateManager database;
[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
{
string connect = "MsSql2005Dialect;SqlClientDriver;Data Source=127.0.0.1;Network Library=DBMSSOCN;Initial Catalog=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit";
db = new NHibernateEstateData();
db.Initialise(connect);
database = ((NHibernateEstateData)db).manager;
}
catch (Exception e)
{
Console.WriteLine("Exception {0}", e);
Assert.Ignore();
}
}
[TestFixtureTearDown]
public void Cleanup()
{
if (db != null)
{
((NHibernateEstateData)db).Dispose();
}
if (database != null)
{
database.DropSchema();
}
}
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim 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;
namespace OpenSim.Data.NHibernate.Tests
{
[TestFixture]
public class NHibernateMySQLEstateTest : BasicEstateTest
{
public string file;
public NHibernateManager database;
public string connect = "MySQL5Dialect;MySqlDataDriver;Server=localhost;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit";
[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 NHibernateEstateData();
db.Initialise(connect);
database = ((NHibernateEstateData)db).manager;
}
catch (Exception e)
{
Console.WriteLine("Exception {0}", e);
Assert.Ignore();
}
}
[TestFixtureTearDown]
public void Cleanup()
{
if (db != null)
{
((NHibernateEstateData)db).Dispose();
}
if (database != null)
{
database.DropSchema();
}
}
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim 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;
namespace OpenSim.Data.NHibernate.Tests
{
[TestFixture]
public class NHibernatePostgreSQLEstateTest : BasicEstateTest
{
public string file;
public NHibernateManager database;
public string connect = "PostgreSQLDialect;NpgsqlDriver;Server=localhost;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;";
[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 NHibernateEstateData();
db.Initialise(connect);
database = ((NHibernateEstateData)db).manager;
}
catch (Exception e)
{
Console.WriteLine("Exception {0}", e);
Assert.Ignore();
}
}
[TestFixtureTearDown]
public void Cleanup()
{
if (db != null)
{
((NHibernateEstateData)db).Dispose();
}
if (database != null)
{
database.DropSchema();
}
}
}
}

View File

@ -0,0 +1,78 @@
/*
* 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 OpenSim 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.IO;
using NUnit.Framework;
using OpenSim.Data.Tests;
namespace OpenSim.Data.NHibernate.Tests
{
[TestFixture]
public class NHibernateSQLiteEstateTest : BasicEstateTest
{
public string file;
public NHibernateManager database;
[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
{
string connect = "SQLiteDialect;SQLite20Driver;Data Source=" + Path.GetTempFileName() + ".db;Version=3";
db = new NHibernateEstateData();
db.Initialise(connect);
database = ((NHibernateEstateData)db).manager;
}
catch (Exception e)
{
Console.WriteLine("Exception {0}", e);
Assert.Ignore();
}
}
[TestFixtureTearDown]
public void Cleanup()
{
if (db != null)
{
((NHibernateEstateData)db).Dispose();
}
if (database != null)
{
database.DropSchema();
}
}
}
}

View File

@ -73,6 +73,7 @@ namespace OpenSim.Data.Tests
double sunPosition = 7;
bool allowVoice = true;
bool allowDirectTeleport = true;
bool resetHomeOnTeleport = true;
bool denyAnonymous = true;
bool denyIdentified = true;
bool denyTransacted = true;
@ -103,6 +104,7 @@ namespace OpenSim.Data.Tests
es.SunPosition = sunPosition;
es.AllowVoice = allowVoice;
es.AllowDirectTeleport = allowDirectTeleport;
es.ResetHomeOnTeleport = resetHomeOnTeleport;
es.DenyAnonymous = denyAnonymous;
es.DenyIdentified = denyIdentified;
es.DenyTransacted = denyTransacted;
@ -133,6 +135,7 @@ namespace OpenSim.Data.Tests
Assert.That(sunPosition, Is.EqualTo(nes.SunPosition));
Assert.That(allowVoice, Is.EqualTo(nes.AllowVoice));
Assert.That(allowDirectTeleport, Is.EqualTo(nes.AllowDirectTeleport));
Assert.That(resetHomeOnTeleport, Is.EqualTo(nes.ResetHomeOnTeleport));
Assert.That(denyAnonymous, Is.EqualTo(nes.DenyAnonymous));
Assert.That(denyIdentified, Is.EqualTo(nes.DenyIdentified));
Assert.That(denyTransacted, Is.EqualTo(nes.DenyTransacted));