diff options
author | Diva Canto | 2015-05-11 08:52:12 -0700 |
---|---|---|
committer | Diva Canto | 2015-05-11 08:52:12 -0700 |
commit | 3df472f10d1a2b8387e998c4f4c871eaf9a73ac2 (patch) | |
tree | 12cc5eb3981f92f2a6d4ca0cbb0917ac9e711f10 | |
parent | Knocked off a few compiler warnings regarding unused variables. (diff) | |
download | opensim-SC_OLD-3df472f10d1a2b8387e998c4f4c871eaf9a73ac2.zip opensim-SC_OLD-3df472f10d1a2b8387e998c4f4c871eaf9a73ac2.tar.gz opensim-SC_OLD-3df472f10d1a2b8387e998c4f4c871eaf9a73ac2.tar.bz2 opensim-SC_OLD-3df472f10d1a2b8387e998c4f4c871eaf9a73ac2.tar.xz |
Added inventory tests to Robust.Tests.
-rw-r--r-- | OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs | 6 | ||||
-rw-r--r-- | OpenSim/Services/InventoryService/XInventoryService.cs | 12 | ||||
-rw-r--r-- | OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs | 152 | ||||
-rw-r--r-- | OpenSim/Tests/Robust/Server/DemonServer.cs | 2 | ||||
-rw-r--r-- | bin/Robust.Tests.ini | 2 |
5 files changed, 166 insertions, 8 deletions
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 0cea4a1..db3c857 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs | |||
@@ -406,9 +406,13 @@ namespace OpenSim.Services.Connectors | |||
406 | 406 | ||
407 | public bool AddItem(InventoryItemBase item) | 407 | public bool AddItem(InventoryItemBase item) |
408 | { | 408 | { |
409 | if (item.Description == null) | ||
410 | item.Description = String.Empty; | ||
409 | if (item.CreatorData == null) | 411 | if (item.CreatorData == null) |
410 | item.CreatorData = String.Empty; | 412 | item.CreatorData = String.Empty; |
411 | Dictionary<string,object> ret = MakeRequest("ADDITEM", | 413 | if (item.CreatorId == null) |
414 | item.CreatorId = String.Empty; | ||
415 | Dictionary<string, object> ret = MakeRequest("ADDITEM", | ||
412 | new Dictionary<string,object> { | 416 | new Dictionary<string,object> { |
413 | { "AssetID", item.AssetID.ToString() }, | 417 | { "AssetID", item.AssetID.ToString() }, |
414 | { "AssetType", item.AssetType.ToString() }, | 418 | { "AssetType", item.AssetType.ToString() }, |
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 50cadab..64f727c 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs | |||
@@ -261,7 +261,7 @@ namespace OpenSim.Services.InventoryService | |||
261 | 261 | ||
262 | private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, AssetType type) | 262 | private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, AssetType type) |
263 | { | 263 | { |
264 | // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID); | 264 | //m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0}", type); |
265 | 265 | ||
266 | if (type == AssetType.RootFolder) | 266 | if (type == AssetType.RootFolder) |
267 | return rootFolder; | 267 | return rootFolder; |
@@ -272,13 +272,13 @@ namespace OpenSim.Services.InventoryService | |||
272 | 272 | ||
273 | if (folders.Length == 0) | 273 | if (folders.Length == 0) |
274 | { | 274 | { |
275 | // m_log.WarnFormat("[XINVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID); | 275 | //m_log.WarnFormat("[XINVENTORY SERVICE]: Found no folder for type {0} ", type); |
276 | return null; | 276 | return null; |
277 | } | 277 | } |
278 | 278 | ||
279 | // m_log.DebugFormat( | 279 | //m_log.DebugFormat( |
280 | // "[XINVENTORY SERVICE]: Found folder {0} {1} for type {2} for user {3}", | 280 | // "[XINVENTORY SERVICE]: Found folder {0} {1} for type {2}", |
281 | // folders[0].folderName, folders[0].folderID, type, principalID); | 281 | // folders[0].folderName, folders[0].folderID, type); |
282 | 282 | ||
283 | return ConvertToOpenSim(folders[0]); | 283 | return ConvertToOpenSim(folders[0]); |
284 | } | 284 | } |
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 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using NUnit.Framework; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Services.Connectors; | ||
39 | |||
40 | namespace Robust.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class InventoryClient | ||
44 | { | ||
45 | // private static readonly ILog m_log = | ||
46 | // LogManager.GetLogger( | ||
47 | // MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private UUID m_userID = new UUID("00000000-0000-0000-0000-333333333333"); | ||
50 | private UUID m_rootFolderID; | ||
51 | private UUID m_notecardsFolder; | ||
52 | private UUID m_objectsFolder; | ||
53 | |||
54 | [Test] | ||
55 | public void Inventory_001_CreateInventory() | ||
56 | { | ||
57 | XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); | ||
58 | |||
59 | // Create an inventory that looks like this: | ||
60 | // | ||
61 | // /My Inventory | ||
62 | // <other system folders> | ||
63 | // /Objects | ||
64 | // Some Object | ||
65 | // /Notecards | ||
66 | // Notecard 1 | ||
67 | // Notecard 2 | ||
68 | // /Test Folder | ||
69 | // Link to notecard -> /Notecards/Notecard 2 | ||
70 | // Link to Objects folder -> /Objects | ||
71 | |||
72 | Console.WriteLine("Starting inventory test"); | ||
73 | bool success = m_Connector.CreateUserInventory(m_userID); | ||
74 | Assert.IsTrue(success, "Failed to create user inventory"); | ||
75 | |||
76 | m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID; | ||
77 | Assert.AreNotEqual(m_rootFolderID, UUID.Zero, "Root folder ID must not be UUID.Zero"); | ||
78 | |||
79 | InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, AssetType.Object); | ||
80 | Assert.IsNotNull(of, "Failed to retrieve Objects folder"); | ||
81 | m_objectsFolder = of.ID; | ||
82 | Assert.AreNotEqual(m_objectsFolder, UUID.Zero, "Objects folder ID must not be UUID.Zero"); | ||
83 | |||
84 | // Add an object | ||
85 | InventoryItemBase item = new InventoryItemBase(new UUID("b0000000-0000-0000-0000-00000000000b"), m_userID); | ||
86 | item.AssetID = UUID.Random(); | ||
87 | item.AssetType = (int)AssetType.Object; | ||
88 | item.Folder = m_objectsFolder; | ||
89 | item.Name = "Some Object"; | ||
90 | item.Description = string.Empty; | ||
91 | success = m_Connector.AddItem(item); | ||
92 | Assert.IsTrue(success, "Failed to add object to inventory"); | ||
93 | |||
94 | InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, AssetType.Notecard); | ||
95 | Assert.IsNotNull(of, "Failed to retrieve Notecards folder"); | ||
96 | m_notecardsFolder = ncf.ID; | ||
97 | Assert.AreNotEqual(m_notecardsFolder, UUID.Zero, "Notecards folder ID must not be UUID.Zero"); | ||
98 | m_notecardsFolder = ncf.ID; | ||
99 | |||
100 | // Add a notecard | ||
101 | item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID); | ||
102 | item.AssetID = UUID.Random(); | ||
103 | item.AssetType = (int)AssetType.Notecard; | ||
104 | item.Folder = m_notecardsFolder; | ||
105 | item.Name = "Test Notecard 1"; | ||
106 | item.Description = string.Empty; | ||
107 | success = m_Connector.AddItem(item); | ||
108 | Assert.IsTrue(success, "Failed to add Notecard 1 to inventory"); | ||
109 | // Add another notecard | ||
110 | item.ID = new UUID("20000000-0000-0000-0000-000000000002"); | ||
111 | item.AssetID = new UUID("a0000000-0000-0000-0000-00000000000a"); | ||
112 | item.Name = "Test Notecard 2"; | ||
113 | item.Description = string.Empty; | ||
114 | success = m_Connector.AddItem(item); | ||
115 | Assert.IsTrue(success, "Failed to add Notecard 2 to inventory"); | ||
116 | |||
117 | // Add a folder | ||
118 | InventoryFolderBase folder = new InventoryFolderBase(new UUID("f0000000-0000-0000-0000-00000000000f"), "Test Folder", m_userID, m_rootFolderID); | ||
119 | folder.Type = (int)AssetType.Folder; | ||
120 | success = m_Connector.AddFolder(folder); | ||
121 | Assert.IsTrue(success, "Failed to add Test Folder to inventory"); | ||
122 | |||
123 | // Add a link to notecard 2 in Test Folder | ||
124 | item.AssetID = item.ID; // use item ID of notecard 2 | ||
125 | item.ID = new UUID("40000000-0000-0000-0000-000000000004"); | ||
126 | item.AssetType = (int)AssetType.Link; | ||
127 | item.Folder = folder.ID; | ||
128 | item.Name = "Link to notecard"; | ||
129 | item.Description = string.Empty; | ||
130 | success = m_Connector.AddItem(item); | ||
131 | Assert.IsTrue(success, "Failed to add link to notecard to inventory"); | ||
132 | |||
133 | // Add a link to the Objects folder in Test Folder | ||
134 | item.AssetID = m_Connector.GetFolderForType(m_userID, AssetType.Object).ID; // use item ID of Objects folder | ||
135 | item.ID = new UUID("50000000-0000-0000-0000-000000000005"); | ||
136 | item.AssetType = (int)AssetType.LinkFolder; | ||
137 | item.Folder = folder.ID; | ||
138 | item.Name = "Link to Objects folder"; | ||
139 | item.Description = string.Empty; | ||
140 | success = m_Connector.AddItem(item); | ||
141 | Assert.IsTrue(success, "Failed to add link to objects folder to inventory"); | ||
142 | |||
143 | InventoryCollection coll = m_Connector.GetFolderContent(m_userID, m_rootFolderID); | ||
144 | Assert.IsNotNull(coll, "Failed to retrieve contents of root folder"); | ||
145 | Assert.Greater(coll.Folders.Count, 0, "Root folder does not have any subfolders"); | ||
146 | |||
147 | coll = m_Connector.GetFolderContent(m_userID, folder.ID); | ||
148 | Assert.IsNotNull(coll, "Failed to retrieve contents of Test Folder"); | ||
149 | Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside"); | ||
150 | } | ||
151 | } | ||
152 | } | ||
diff --git a/OpenSim/Tests/Robust/Server/DemonServer.cs b/OpenSim/Tests/Robust/Server/DemonServer.cs index b51a6bb..1e0797e 100644 --- a/OpenSim/Tests/Robust/Server/DemonServer.cs +++ b/OpenSim/Tests/Robust/Server/DemonServer.cs | |||
@@ -54,6 +54,8 @@ namespace Robust.Tests | |||
54 | Console.WriteLine("**** Starting demon Robust server ****"); | 54 | Console.WriteLine("**** Starting demon Robust server ****"); |
55 | m_demon = new Thread( () => Main(new string[] {"-inifile=Robust.Tests.ini"})); | 55 | m_demon = new Thread( () => Main(new string[] {"-inifile=Robust.Tests.ini"})); |
56 | m_demon.Start(); | 56 | m_demon.Start(); |
57 | // Give some time for the server to instantiate all services | ||
58 | Thread.Sleep(3000); | ||
57 | Console.WriteLine("**** Setup Finished ****"); | 59 | Console.WriteLine("**** Setup Finished ****"); |
58 | } | 60 | } |
59 | 61 | ||
diff --git a/bin/Robust.Tests.ini b/bin/Robust.Tests.ini index e2568df..357434e 100644 --- a/bin/Robust.Tests.ini +++ b/bin/Robust.Tests.ini | |||
@@ -153,7 +153,7 @@ | |||
153 | [InventoryService] | 153 | [InventoryService] |
154 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:XInventoryService" | 154 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:XInventoryService" |
155 | 155 | ||
156 | StorageProvider = "OpenSim.Tests.Common.dll" | 156 | StorageProvider = "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin" |
157 | ConnectionString = "" | 157 | ConnectionString = "" |
158 | 158 | ||
159 | ; Will calls to purge folders (empty trash) and immediately delete/update items or folders (not move to trash first) succeed? | 159 | ; Will calls to purge folders (empty trash) and immediately delete/update items or folders (not move to trash first) succeed? |