29 using System.Collections.Generic;
32 using System.Text.RegularExpressions;
35 using NUnit.Framework;
37 using OpenSim.Capabilities.Handlers;
38 using OpenSim.Framework;
39 using OpenSim.Framework.Servers.HttpServer;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Services.Interfaces;
42 using OpenSim.Tests.Common;
49 private UUID m_userID = UUID.Zero;
50 private Scene m_scene;
51 private UUID m_rootFolderID;
52 private int m_rootDescendents;
53 private UUID m_notecardsFolder;
54 private UUID m_objectsFolder;
73 m_scene.InventoryService.CreateUserInventory(m_userID);
75 m_rootFolderID = m_scene.InventoryService.GetRootFolder(m_userID).ID;
77 InventoryFolderBase of = m_scene.InventoryService.GetFolderForType(m_userID, FolderType.Object);
78 m_objectsFolder = of.ID;
82 item.AssetID = UUID.Random();
83 item.AssetType = (int)AssetType.Object;
84 item.
Folder = m_objectsFolder;
85 item.
Name =
"Some Object";
86 m_scene.InventoryService.AddItem(item);
88 InventoryFolderBase ncf = m_scene.InventoryService.GetFolderForType(m_userID, FolderType.Notecard);
89 m_notecardsFolder = ncf.ID;
92 item =
new InventoryItemBase(
new UUID(
"10000000-0000-0000-0000-000000000001"), m_userID);
93 item.AssetID = UUID.Random();
94 item.AssetType = (int)AssetType.Notecard;
95 item.
Folder = m_notecardsFolder;
96 item.
Name =
"Test Notecard 1";
97 m_scene.InventoryService.AddItem(item);
99 item.ID =
new UUID(
"20000000-0000-0000-0000-000000000002");
100 item.AssetID =
new UUID(
"a0000000-0000-0000-0000-00000000000a");
101 item.Name =
"Test Notecard 2";
102 m_scene.InventoryService.AddItem(item);
106 m_scene.InventoryService.AddFolder(folder);
109 item.AssetID = item.ID;
110 item.ID =
new UUID(
"40000000-0000-0000-0000-000000000004");
111 item.AssetType = (int)AssetType.Link;
113 item.
Name =
"Link to notecard";
114 m_scene.InventoryService.AddItem(item);
117 item.AssetID = m_scene.InventoryService.GetFolderForType(m_userID, FolderType.Object).ID;
118 item.ID =
new UUID(
"50000000-0000-0000-0000-000000000005");
119 item.AssetType = (int)AssetType.LinkFolder;
121 item.
Name =
"Link to Objects folder";
122 m_scene.InventoryService.AddItem(item);
124 InventoryCollection coll = m_scene.InventoryService.GetFolderContent(m_userID, m_rootFolderID);
125 m_rootDescendents = coll.Items.Count + coll.Folders.Count;
126 Console.WriteLine(
"Number of descendents: " + m_rootDescendents);
132 TestHelpers.InMethod();
140 string request =
"<llsd><map><key>folders</key><array><map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
141 request += m_rootFolderID;
142 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map></array></map></llsd>";
144 string llsdresponse = handler.FetchInventoryDescendentsRequest(request,
"/FETCH", string.Empty, req, resp);
146 Assert.That(llsdresponse != null, Is.True,
"Incorrect null response");
147 Assert.That(llsdresponse != string.Empty, Is.True,
"Incorrect empty response");
148 Assert.That(llsdresponse.Contains(
"00000000-0000-0000-0000-000000000000"), Is.True,
"Response should contain userID");
150 string descendents =
"descendents</key><integer>" + m_rootDescendents +
"</integer>";
151 Assert.That(llsdresponse.Contains(descendents), Is.True,
"Incorrect number of descendents");
152 Console.WriteLine(llsdresponse);
158 TestHelpers.InMethod();
164 string request =
"<llsd><map><key>folders</key><array>";
165 request +=
"<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
166 request += m_rootFolderID;
167 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
168 request +=
"<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
169 request += m_notecardsFolder;
170 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
171 request +=
"</array></map></llsd>";
173 string llsdresponse = handler.FetchInventoryDescendentsRequest(request,
"/FETCH", string.Empty, req, resp);
174 Console.WriteLine(llsdresponse);
176 string descendents =
"descendents</key><integer>" + m_rootDescendents +
"</integer>";
177 Assert.That(llsdresponse.Contains(descendents), Is.True,
"Incorrect number of descendents for root folder");
178 descendents =
"descendents</key><integer>2</integer>";
179 Assert.That(llsdresponse.Contains(descendents), Is.True,
"Incorrect number of descendents for Notecard folder");
181 Assert.That(llsdresponse.Contains(
"10000000-0000-0000-0000-000000000001"), Is.True,
"Notecard 1 is missing from response");
182 Assert.That(llsdresponse.Contains(
"20000000-0000-0000-0000-000000000002"), Is.True,
"Notecard 2 is missing from response");
188 TestHelpers.InMethod();
194 string request =
"<llsd><map><key>folders</key><array><map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
195 request +=
"f0000000-0000-0000-0000-00000000000f";
196 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map></array></map></llsd>";
198 string llsdresponse = handler.FetchInventoryDescendentsRequest(request,
"/FETCH", string.Empty, req, resp);
199 Console.WriteLine(llsdresponse);
201 string descendents =
"descendents</key><integer>2</integer>";
202 Assert.That(llsdresponse.Contains(descendents), Is.True,
"Incorrect number of descendents for Test Folder");
205 Assert.That(llsdresponse.Contains(
"Link to notecard"), Is.True,
"Link to notecard is missing");
208 Assert.That(llsdresponse.Contains(
"Test Notecard 2"), Is.True,
"Notecard 2 item (the source) is missing");
211 int pos1 = llsdresponse.IndexOf(
"Test Notecard 2");
212 int pos2 = llsdresponse.IndexOf(
"Link to notecard");
213 Assert.Less(pos1, pos2,
"Source of link is after link");
216 Assert.That(llsdresponse.Contains(
"Link to Objects folder"), Is.True,
"Link to Objects folder is missing");
224 pos1 = llsdresponse.IndexOf(
"Some Object");
225 pos2 = llsdresponse.IndexOf(
"Link to Objects folder");
226 Assert.Less(pos1, pos2,
"Contents of source of folder link is after folder link");
232 TestHelpers.InMethod();
238 string request =
"<llsd><map><key>folders</key><array>";
239 request +=
"<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
240 request += m_rootFolderID;
241 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
242 request +=
"<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
243 request += m_notecardsFolder;
244 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
245 request +=
"<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
246 request += m_rootFolderID;
247 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
248 request +=
"<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
249 request += m_notecardsFolder;
250 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
251 request +=
"</array></map></llsd>";
253 string llsdresponse = handler.FetchInventoryDescendentsRequest(request,
"/FETCH", string.Empty, req, resp);
254 Console.WriteLine(llsdresponse);
256 string root_folder =
"<key>folder_id</key><uuid>" + m_rootFolderID +
"</uuid>";
257 string notecards_folder =
"<key>folder_id</key><uuid>" + m_notecardsFolder +
"</uuid>";
259 Assert.That(llsdresponse.Contains(root_folder),
"Missing root folder");
260 Assert.That(llsdresponse.Contains(notecards_folder),
"Missing notecards folder");
261 int count = Regex.Matches(llsdresponse, root_folder).Count;
262 Assert.AreEqual(1, count,
"More than 1 root folder in response");
263 count = Regex.Matches(llsdresponse, notecards_folder).Count;
264 Assert.AreEqual(2, count,
"More than 1 notecards folder in response");
270 TestHelpers.InMethod();
278 string request =
"<llsd><map><key>folders</key><array><map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
279 request += UUID.Zero;
280 request +=
"</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map></array></map></llsd>";
282 string llsdresponse = handler.FetchInventoryDescendentsRequest(request,
"/FETCH", string.Empty, req, resp);
284 Assert.That(llsdresponse != null, Is.True,
"Incorrect null response");
285 Assert.That(llsdresponse != string.Empty, Is.True,
"Incorrect empty response");
286 Assert.That(llsdresponse.Contains(
"bad_folders</key><array><uuid>00000000-0000-0000-0000-000000000000"), Is.True,
"Folder Zero should be a bad folder");
288 Console.WriteLine(llsdresponse);
void Test_002_MultipleFolders()
void Test_001_SimpleFolder()
Inventory Item - contains all the properties associated with an individual inventory piece...
void Test_004_DuplicateFolders()
void Test_005_FolderZero()
Helpers for setting up scenes.
virtual string Name
The name of the node (64 characters or less)
delegate void FetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
Used to serialize a whole inventory for transfer over the network.