From 3df472f10d1a2b8387e998c4f4c871eaf9a73ac2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 May 2015 08:52:12 -0700 Subject: Added inventory tests to Robust.Tests. --- .../Robust/Clients/Inventory/InventoryClient.cs | 152 +++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs (limited to 'OpenSim/Tests/Robust/Clients/Inventory') diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs new file mode 100644 index 0000000..78a7dc8 --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs @@ -0,0 +1,152 @@ +/* + * 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.Text; +using System.Reflection; + +using OpenMetaverse; +using NUnit.Framework; + +using OpenSim.Framework; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; + +namespace Robust.Tests +{ + [TestFixture] + public class InventoryClient + { +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); + + private UUID m_userID = new UUID("00000000-0000-0000-0000-333333333333"); + private UUID m_rootFolderID; + private UUID m_notecardsFolder; + private UUID m_objectsFolder; + + [Test] + public void Inventory_001_CreateInventory() + { + XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); + + // Create an inventory that looks like this: + // + // /My Inventory + // + // /Objects + // Some Object + // /Notecards + // Notecard 1 + // Notecard 2 + // /Test Folder + // Link to notecard -> /Notecards/Notecard 2 + // Link to Objects folder -> /Objects + + Console.WriteLine("Starting inventory test"); + bool success = m_Connector.CreateUserInventory(m_userID); + Assert.IsTrue(success, "Failed to create user inventory"); + + m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID; + Assert.AreNotEqual(m_rootFolderID, UUID.Zero, "Root folder ID must not be UUID.Zero"); + + InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, AssetType.Object); + Assert.IsNotNull(of, "Failed to retrieve Objects folder"); + m_objectsFolder = of.ID; + Assert.AreNotEqual(m_objectsFolder, UUID.Zero, "Objects folder ID must not be UUID.Zero"); + + // Add an object + InventoryItemBase item = new InventoryItemBase(new UUID("b0000000-0000-0000-0000-00000000000b"), m_userID); + item.AssetID = UUID.Random(); + item.AssetType = (int)AssetType.Object; + item.Folder = m_objectsFolder; + item.Name = "Some Object"; + item.Description = string.Empty; + success = m_Connector.AddItem(item); + Assert.IsTrue(success, "Failed to add object to inventory"); + + InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, AssetType.Notecard); + Assert.IsNotNull(of, "Failed to retrieve Notecards folder"); + m_notecardsFolder = ncf.ID; + Assert.AreNotEqual(m_notecardsFolder, UUID.Zero, "Notecards folder ID must not be UUID.Zero"); + m_notecardsFolder = ncf.ID; + + // Add a notecard + item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID); + item.AssetID = UUID.Random(); + item.AssetType = (int)AssetType.Notecard; + item.Folder = m_notecardsFolder; + item.Name = "Test Notecard 1"; + item.Description = string.Empty; + success = m_Connector.AddItem(item); + Assert.IsTrue(success, "Failed to add Notecard 1 to inventory"); + // Add another notecard + item.ID = new UUID("20000000-0000-0000-0000-000000000002"); + item.AssetID = new UUID("a0000000-0000-0000-0000-00000000000a"); + item.Name = "Test Notecard 2"; + item.Description = string.Empty; + success = m_Connector.AddItem(item); + Assert.IsTrue(success, "Failed to add Notecard 2 to inventory"); + + // Add a folder + InventoryFolderBase folder = new InventoryFolderBase(new UUID("f0000000-0000-0000-0000-00000000000f"), "Test Folder", m_userID, m_rootFolderID); + folder.Type = (int)AssetType.Folder; + success = m_Connector.AddFolder(folder); + Assert.IsTrue(success, "Failed to add Test Folder to inventory"); + + // Add a link to notecard 2 in Test Folder + item.AssetID = item.ID; // use item ID of notecard 2 + item.ID = new UUID("40000000-0000-0000-0000-000000000004"); + item.AssetType = (int)AssetType.Link; + item.Folder = folder.ID; + item.Name = "Link to notecard"; + item.Description = string.Empty; + success = m_Connector.AddItem(item); + Assert.IsTrue(success, "Failed to add link to notecard to inventory"); + + // Add a link to the Objects folder in Test Folder + item.AssetID = m_Connector.GetFolderForType(m_userID, AssetType.Object).ID; // use item ID of Objects folder + item.ID = new UUID("50000000-0000-0000-0000-000000000005"); + item.AssetType = (int)AssetType.LinkFolder; + item.Folder = folder.ID; + item.Name = "Link to Objects folder"; + item.Description = string.Empty; + success = m_Connector.AddItem(item); + Assert.IsTrue(success, "Failed to add link to objects folder to inventory"); + + InventoryCollection coll = m_Connector.GetFolderContent(m_userID, m_rootFolderID); + Assert.IsNotNull(coll, "Failed to retrieve contents of root folder"); + Assert.Greater(coll.Folders.Count, 0, "Root folder does not have any subfolders"); + + coll = m_Connector.GetFolderContent(m_userID, folder.ID); + Assert.IsNotNull(coll, "Failed to retrieve contents of Test Folder"); + Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside"); + } + } +} -- cgit v1.1 From c20a5dd75a31c99939046d5fb59769d8fff43531 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 May 2015 09:05:09 -0700 Subject: Trivial change just to trigger jenkins to build again --- OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Tests/Robust/Clients/Inventory') diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs index 78a7dc8..9d3f400 100644 --- a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs +++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs @@ -147,6 +147,7 @@ namespace Robust.Tests coll = m_Connector.GetFolderContent(m_userID, folder.ID); Assert.IsNotNull(coll, "Failed to retrieve contents of Test Folder"); Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside"); + } } } -- cgit v1.1 From 6f469ec0a5de7633e9380eb1b370590c288cff26 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 4 Jun 2015 08:52:57 -0700 Subject: Added tests that verify the absence of the bug fixed in the previous commits (cache issues). --- .../Robust/Clients/Inventory/InventoryClient.cs | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'OpenSim/Tests/Robust/Clients/Inventory') diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs index 9d3f400..1dcda0b 100644 --- a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs +++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs @@ -37,6 +37,8 @@ using OpenSim.Framework; using OpenSim.Services.Interfaces; using OpenSim.Services.Connectors; +using OpenSim.Tests.Common; + namespace Robust.Tests { [TestFixture] @@ -54,6 +56,7 @@ namespace Robust.Tests [Test] public void Inventory_001_CreateInventory() { + TestHelpers.InMethod(); XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); // Create an inventory that looks like this: @@ -69,7 +72,6 @@ namespace Robust.Tests // Link to notecard -> /Notecards/Notecard 2 // Link to Objects folder -> /Objects - Console.WriteLine("Starting inventory test"); bool success = m_Connector.CreateUserInventory(m_userID); Assert.IsTrue(success, "Failed to create user inventory"); @@ -149,5 +151,31 @@ namespace Robust.Tests Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside"); } + + [Test] + public void Inventory_002_DoubleItemsRequest() + { + TestHelpers.InMethod(); + XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); + + // Prefetch Notecard 1, will be cached from here on + InventoryItemBase item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID); + item = m_Connector.GetItem(item); + Assert.NotNull(item, "Failed to get Notecard 1"); + Assert.AreEqual("Test Notecard 1", item.Name, "Wrong name for Notecard 1"); + + UUID[] uuids = new UUID[2]; + uuids[0] = item.ID; + uuids[1] = new UUID("20000000-0000-0000-0000-000000000002"); + + InventoryItemBase[] items = m_Connector.GetMultipleItems(m_userID, uuids); + Assert.NotNull(items, "Failed to get multiple items"); + Assert.IsTrue(items.Length == 2, "Requested 2 items, but didn't receive 2 items"); + + // Now they should both be cached + items = m_Connector.GetMultipleItems(m_userID, uuids); + Assert.NotNull(items, "(Repeat) Failed to get multiple items"); + Assert.IsTrue(items.Length == 2, "(Repeat) Requested 2 items, but didn't receive 2 items"); + } } } -- cgit v1.1 From 2fff376762c8af8f777b54ac73067142f0b1e9e7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 4 Jun 2015 09:17:12 -0700 Subject: More assertions in inventory client tests to check for assorted combinations of cached/non-cached/existing/non-existing items --- .../Robust/Clients/Inventory/InventoryClient.cs | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'OpenSim/Tests/Robust/Clients/Inventory') diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs index 1dcda0b..c388ec1 100644 --- a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs +++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs @@ -153,7 +153,7 @@ namespace Robust.Tests } [Test] - public void Inventory_002_DoubleItemsRequest() + public void Inventory_002_MultipleItemsRequest() { TestHelpers.InMethod(); XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); @@ -176,6 +176,31 @@ namespace Robust.Tests items = m_Connector.GetMultipleItems(m_userID, uuids); Assert.NotNull(items, "(Repeat) Failed to get multiple items"); Assert.IsTrue(items.Length == 2, "(Repeat) Requested 2 items, but didn't receive 2 items"); + + // This item doesn't exist, but [0] does, and it's cached. + uuids[1] = new UUID("bb000000-0000-0000-0000-0000000000bb"); + // Fetching should return 2 items, but [1] should be null + items = m_Connector.GetMultipleItems(m_userID, uuids); + Assert.NotNull(items, "(Three times) Failed to get multiple items"); + Assert.IsTrue(items.Length == 2, "(Three times) Requested 2 items, but didn't receive 2 items"); + Assert.AreEqual("Test Notecard 1", items[0].Name, "(Three times) Wrong name for Notecard 1"); + Assert.IsNull(items[1], "(Three times) Expecting 2nd item to be null"); + + // Now both don't exist + uuids[0] = new UUID("aa000000-0000-0000-0000-0000000000aa"); + items = m_Connector.GetMultipleItems(m_userID, uuids); + Assert.Null(items[0], "Request to multiple non-existent items is supposed to return null [0]"); + Assert.Null(items[1], "Request to multiple non-existent items is supposed to return null [0]"); + + // This item exists, and it's not cached + uuids[1] = new UUID("b0000000-0000-0000-0000-00000000000b"); + // Fetching should return 2 items, but [0] should be null + items = m_Connector.GetMultipleItems(m_userID, uuids); + Assert.NotNull(items, "(Four times) Failed to get multiple items"); + Assert.IsTrue(items.Length == 2, "(Four times) Requested 2 items, but didn't receive 2 items"); + Assert.AreEqual("Some Object", items[1].Name, "(Four times) Wrong name for Some Object"); + Assert.IsNull(items[0], "(Four times) Expecting 1st item to be null"); + } } } -- cgit v1.1 From f63e7ec46f9a09d758791a4ed265d3384d6a14c5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 4 Jun 2015 09:30:41 -0700 Subject: Trivial: fix copy-paste typo in string --- OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Tests/Robust/Clients/Inventory') diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs index c388ec1..2fb0751 100644 --- a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs +++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs @@ -190,7 +190,7 @@ namespace Robust.Tests uuids[0] = new UUID("aa000000-0000-0000-0000-0000000000aa"); items = m_Connector.GetMultipleItems(m_userID, uuids); Assert.Null(items[0], "Request to multiple non-existent items is supposed to return null [0]"); - Assert.Null(items[1], "Request to multiple non-existent items is supposed to return null [0]"); + Assert.Null(items[1], "Request to multiple non-existent items is supposed to return null [1]"); // This item exists, and it's not cached uuids[1] = new UUID("b0000000-0000-0000-0000-00000000000b"); -- cgit v1.1 From 959872315f67a1a33a2bae7330749f7dd74a4774 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 8 Aug 2015 12:12:50 -0700 Subject: WARNING: massive refactor to follow libomv's latest changes regarding inventory folders. The newest version of libomv itself is committed here. Basically, everything that was using the AssetType enum has been combed through; many of those uses were changed to the new FolderType enum. This means that from now on, [new] root folders have code 8 (FolderType.Root), as the viewers expect, as opposed to 9, which was what we had been doing. Normal folders are as they were, -1. Also now sending folder code 100 for Suitcase folders to viewers, with no filter. All tests pass, but fingers crossed! --- OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Tests/Robust/Clients/Inventory') diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs index 2fb0751..0280b73 100644 --- a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs +++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs @@ -78,7 +78,7 @@ namespace Robust.Tests m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID; Assert.AreNotEqual(m_rootFolderID, UUID.Zero, "Root folder ID must not be UUID.Zero"); - InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, AssetType.Object); + InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, FolderType.Object); Assert.IsNotNull(of, "Failed to retrieve Objects folder"); m_objectsFolder = of.ID; Assert.AreNotEqual(m_objectsFolder, UUID.Zero, "Objects folder ID must not be UUID.Zero"); @@ -93,7 +93,7 @@ namespace Robust.Tests success = m_Connector.AddItem(item); Assert.IsTrue(success, "Failed to add object to inventory"); - InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, AssetType.Notecard); + InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, FolderType.Notecard); Assert.IsNotNull(of, "Failed to retrieve Notecards folder"); m_notecardsFolder = ncf.ID; Assert.AreNotEqual(m_notecardsFolder, UUID.Zero, "Notecards folder ID must not be UUID.Zero"); @@ -118,7 +118,7 @@ namespace Robust.Tests // Add a folder InventoryFolderBase folder = new InventoryFolderBase(new UUID("f0000000-0000-0000-0000-00000000000f"), "Test Folder", m_userID, m_rootFolderID); - folder.Type = (int)AssetType.Folder; + folder.Type = (int)FolderType.None; success = m_Connector.AddFolder(folder); Assert.IsTrue(success, "Failed to add Test Folder to inventory"); @@ -133,7 +133,7 @@ namespace Robust.Tests Assert.IsTrue(success, "Failed to add link to notecard to inventory"); // Add a link to the Objects folder in Test Folder - item.AssetID = m_Connector.GetFolderForType(m_userID, AssetType.Object).ID; // use item ID of Objects folder + item.AssetID = m_Connector.GetFolderForType(m_userID, FolderType.Object).ID; // use item ID of Objects folder item.ID = new UUID("50000000-0000-0000-0000-000000000005"); item.AssetType = (int)AssetType.LinkFolder; item.Folder = folder.ID; -- cgit v1.1