From 71e05a5707f1eaed098592dc1c3feb3389731634 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 28 Nov 2008 19:39:46 +0000
Subject: * test: Add a wodge of code in order to be able to slightly extend a
test to deliver a taken object to a user inventory folder without throwing an
exception * test doesn't actually double check for the presence of the item
yet
---
OpenSim/Region/Environment/Scenes/Scene.cs | 4 +-
.../Environment/Scenes/Tests/EntityListTests.cs | 15 +----
.../Environment/Scenes/Tests/SceneObjectTests.cs | 20 +++----
.../Environment/Scenes/Tests/ScenePresenceTests.cs | 15 +----
.../Environment/Scenes/Tests/SceneTestUtils.cs | 18 ++++--
.../Scenes/Tests/TestAssetDataPlugin.cs | 53 +++++++++++++++++
.../Scenes/Tests/TestInventoryDataPlugin.cs | 68 ++++++++++++++++++++--
.../Environment/Scenes/Tests/TestUserDataPlugin.cs | 3 +-
8 files changed, 144 insertions(+), 52 deletions(-)
create mode 100644 OpenSim/Region/Environment/Scenes/Tests/TestAssetDataPlugin.cs
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index d3cbe91..e544703 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1074,7 +1074,6 @@ namespace OpenSim.Region.Environment.Scenes
///
/// Loads the World heightmap
///
- ///
public override void LoadWorldMap()
{
try
@@ -1095,7 +1094,7 @@ namespace OpenSim.Region.Environment.Scenes
}
catch (Exception e)
{
- m_log.Warn("[terrain]: Scene.cs: LoadWorldMap() - Failed with exception " + e.ToString());
+ m_log.Warn("[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception " + e.ToString());
}
}
@@ -2269,6 +2268,7 @@ namespace OpenSim.Region.Environment.Scenes
CreateAndAddScenePresence(client, child);
}
+
m_LastLogin = System.Environment.TickCount;
EventManager.TriggerOnNewClient(client);
}
diff --git a/OpenSim/Region/Environment/Scenes/Tests/EntityListTests.cs b/OpenSim/Region/Environment/Scenes/Tests/EntityListTests.cs
index 7628a88..c8f86f3 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/EntityListTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/EntityListTests.cs
@@ -44,20 +44,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests
///
[TestFixture]
public class EntityListTests
- {
- [SetUp]
- public void Init()
- {
- try
- {
- log4net.Config.XmlConfigurator.Configure();
- }
- catch
- {
- // I don't care, just leave log4net off
- }
- }
-
+ {
static public Random random;
SceneObjectGroup found;
Scene scene = SceneTestUtils.SetupScene();
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
index a6e4d4e..500512e 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
@@ -45,15 +45,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests
{
[SetUp]
public void Init()
- {
- try
- {
- log4net.Config.XmlConfigurator.Configure();
- }
- catch
- {
- // I don't care, just leave log4net off
- }
+ {
}
///
@@ -118,6 +110,8 @@ namespace OpenSim.Region.Environment.Scenes.Tests
[Test]
public void TestDeleteSceneObjectAsyncToUserInventory()
{
+ log4net.Config.XmlConfigurator.Configure();
+
UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
TestScene scene = SceneTestUtils.SetupScene();
@@ -132,12 +126,16 @@ namespace OpenSim.Region.Environment.Scenes.Tests
Is.EqualTo(agentId));
IClientAPI client = SceneTestUtils.AddRootAgent(scene, agentId);
- SceneTestUtils.DeleteSceneObjectAsync(scene, part, DeRezAction.TakeCopy, client);
-
+
CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId);
Assert.That(userInfo, Is.Not.Null);
+ Assert.That(userInfo.RootFolder, Is.Not.Null);
+
+ SceneTestUtils.DeleteSceneObjectAsync(scene, part, DeRezAction.TakeCopy, userInfo.RootFolder.ID, client);
// TODO: test that the object actually made it successfully into inventory
+
+ log4net.LogManager.Shutdown();
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
index 587d288..a16c26a 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
@@ -38,20 +38,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests
///
[TestFixture]
public class ScenePresenceTests
- {
- [SetUp]
- public void Init()
- {
- try
- {
- log4net.Config.XmlConfigurator.Configure();
- }
- catch
- {
- // I don't care, just leave log4net off
- }
- }
-
+ {
///
/// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
///
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs
index 51be872..468a4ad 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs
@@ -29,6 +29,7 @@ using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
+using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers;
using OpenSim.Region.Physics.Manager;
using OpenSim.Region.Environment.Scenes;
@@ -52,15 +53,20 @@ namespace OpenSim.Region.Environment.Scenes.Tests
AgentCircuitManager acm = new AgentCircuitManager();
CommunicationsManager cm = new TestCommunicationsManager();
- SceneCommunicationService scs = new SceneCommunicationService(cm);
+ SceneCommunicationService scs = new SceneCommunicationService(cm);
+
+ SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin());
+ AssetCache ac = new AssetCache(assetService);
+
StorageManager sm = new OpenSim.Region.Environment.StorageManager("OpenSim.Data.Null.dll", "", "");
BaseHttpServer httpServer = new BaseHttpServer(666);
IConfigSource configSource = new IniConfigSource();
TestScene testScene = new TestScene(
- regInfo, acm, cm, scs, null, sm, httpServer, null, false, false, false, configSource, null);
+ regInfo, acm, cm, scs, ac, sm, httpServer, null, false, false, false, configSource, null);
testScene.LandChannel = new TestLandChannel();
+ testScene.LoadWorldMap();
PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
@@ -93,7 +99,8 @@ namespace OpenSim.Region.Environment.Scenes.Tests
scene.NewUserConnection(agent);
IClientAPI client = new TestClient(agent);
- scene.AddNewClient(client, false);
+ scene.AddNewClient(client, true);
+ scene.AgentCrossing(agent.AgentID, new Vector3(90, 90, 90), false);
return client;
}
@@ -123,15 +130,16 @@ namespace OpenSim.Region.Environment.Scenes.Tests
///
///
///
+ ///
///
public static void DeleteSceneObjectAsync(
- TestScene scene, SceneObjectPart part, DeRezAction action, IClientAPI client)
+ TestScene scene, SceneObjectPart part, DeRezAction action, UUID destinationId, IClientAPI client)
{
// Turn off the timer on the async sog deleter - we'll crank it by hand within a unit test
AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
sogd.Enabled = false;
- scene.DeRezObject(client, part.LocalId, UUID.Zero, action, UUID.Zero);
+ scene.DeRezObject(client, part.LocalId, UUID.Zero, action, destinationId);
sogd.InventoryDeQueueAndDelete();
}
}
diff --git a/OpenSim/Region/Environment/Scenes/Tests/TestAssetDataPlugin.cs b/OpenSim/Region/Environment/Scenes/Tests/TestAssetDataPlugin.cs
new file mode 100644
index 0000000..9aeb5fa
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Tests/TestAssetDataPlugin.cs
@@ -0,0 +1,53 @@
+/*
+ * 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 OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+
+namespace OpenSim.Region.Environment.Scenes.Tests
+{
+ ///
+ /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the
+ /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit
+ /// tests are single threaded.
+ ///
+ public class TestAssetDataPlugin : IAssetProviderPlugin
+ {
+ public string Version { get { return "0"; } }
+ public string Name { get { return "TestAssetDataPlugin"; } }
+
+ public void Initialise() {}
+ public void Dispose() {}
+
+ public AssetBase FetchAsset(UUID uuid) { return null; }
+ public void CreateAsset(AssetBase asset) {}
+ public void UpdateAsset(AssetBase asset) {}
+ public bool ExistsAsset(UUID uuid) { return false; }
+ public void Initialise(string connect) {}
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/Tests/TestInventoryDataPlugin.cs b/OpenSim/Region/Environment/Scenes/Tests/TestInventoryDataPlugin.cs
index 2d4edd6..45fc36e 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/TestInventoryDataPlugin.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/TestInventoryDataPlugin.cs
@@ -32,8 +32,23 @@ using OpenSim.Framework;
namespace OpenSim.Region.Environment.Scenes.Tests
{
+ ///
+ /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the
+ /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit
+ /// tests are single threaded.
+ ///
public class TestInventoryDataPlugin : IInventoryDataPlugin
{
+ ///
+ /// Known inventory folders
+ ///
+ private Dictionary m_folders = new Dictionary();
+
+ ///
+ /// User root folders
+ ///
+ private Dictionary m_rootFolders = new Dictionary();
+
public string Version { get { return "0"; } }
public string Name { get { return "TestInventoryDataPlugin"; } }
@@ -41,17 +56,60 @@ namespace OpenSim.Region.Environment.Scenes.Tests
public void Initialise(string connect) {}
public void Dispose() {}
- public List getFolderHierarchy(UUID parentID) { return null; }
- public List getInventoryInFolder(UUID folderID) { return null; }
+ public List getFolderHierarchy(UUID parentID)
+ {
+ List folders = new List();
+
+ foreach (InventoryFolderBase folder in m_folders.Values)
+ {
+ if (folder.ParentID == parentID)
+ {
+ folders.AddRange(getFolderHierarchy(folder.ID));
+ folders.Add(folder);
+ }
+ }
+
+ return folders;
+ }
+
+ public List getInventoryInFolder(UUID folderID)
+ {
+ return new List();
+ }
+
public List getUserRootFolders(UUID user) { return null; }
- public InventoryFolderBase getUserRootFolder(UUID user) { return null; }
+
+ public InventoryFolderBase getUserRootFolder(UUID user)
+ {
+ InventoryFolderBase folder = null;
+ m_rootFolders.TryGetValue(user, out folder);
+
+ return folder;
+ }
+
public List getInventoryFolders(UUID parentID) { return null; }
public InventoryItemBase getInventoryItem(UUID item) { return null; }
- public InventoryFolderBase getInventoryFolder(UUID folder) { return null; }
+
+ public InventoryFolderBase getInventoryFolder(UUID folderId)
+ {
+ InventoryFolderBase folder = null;
+ m_folders.TryGetValue(folderId, out folder);
+
+ return folder;
+ }
+
public void addInventoryItem(InventoryItemBase item) {}
public void updateInventoryItem(InventoryItemBase item) {}
public void deleteInventoryItem(UUID item) {}
- public void addInventoryFolder(InventoryFolderBase folder) {}
+
+ public void addInventoryFolder(InventoryFolderBase folder)
+ {
+ m_folders[folder.ID] = folder;
+
+ if (folder.ParentID == UUID.Zero)
+ m_rootFolders[folder.Owner] = folder;
+ }
+
public void updateInventoryFolder(InventoryFolderBase folder) {}
public void moveInventoryFolder(InventoryFolderBase folder) {}
public void deleteInventoryFolder(UUID folder) {}
diff --git a/OpenSim/Region/Environment/Scenes/Tests/TestUserDataPlugin.cs b/OpenSim/Region/Environment/Scenes/Tests/TestUserDataPlugin.cs
index 85fa1f5..224c7c3 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/TestUserDataPlugin.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/TestUserDataPlugin.cs
@@ -34,7 +34,8 @@ namespace OpenSim.Region.Environment.Scenes.Tests
{
///
/// In memory user data provider. Might be quite useful as a proper user data plugin, though getting mono addins
- /// to load any plugins when running unit tests has proven impossible so far
+ /// to load any plugins when running unit tests has proven impossible so far. Currently no locking since unit
+ /// tests are single threaded.
///
public class TestUserDataPlugin : IUserDataPlugin
{
--
cgit v1.1