diff options
author | Diva Canto | 2015-06-01 20:05:51 -0700 |
---|---|---|
committer | Diva Canto | 2015-06-01 20:05:51 -0700 |
commit | 8de65a8fb360f9ab99a609311dfb56e15a9de76c (patch) | |
tree | eccc4bd2a6802b0e8aab85e22f1da8ba69252cd0 /OpenSim | |
parent | Mantis #7594. Fixing the broken code I just introduced. (diff) | |
download | opensim-SC_OLD-8de65a8fb360f9ab99a609311dfb56e15a9de76c.zip opensim-SC_OLD-8de65a8fb360f9ab99a609311dfb56e15a9de76c.tar.gz opensim-SC_OLD-8de65a8fb360f9ab99a609311dfb56e15a9de76c.tar.bz2 opensim-SC_OLD-8de65a8fb360f9ab99a609311dfb56e15a9de76c.tar.xz |
Mantis #7594: putting things as they were before regarding duplicate removal. Also added test to check that duplicates are being removed. The test passes. I have no idea how duplicates would not be removed, as reported in the mantis.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | 7 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs | 39 |
2 files changed, 42 insertions, 4 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index 0c83b26..4798dc2 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | |||
@@ -111,10 +111,9 @@ namespace OpenSim.Capabilities.Handlers | |||
111 | } | 111 | } |
112 | 112 | ||
113 | // Filter duplicate folder ids that bad viewers may send | 113 | // Filter duplicate folder ids that bad viewers may send |
114 | var unique = folders.GroupBy(f => f.folder_id).Select(n => n.First()); | 114 | if (folders.Find(f => f.folder_id == llsdRequest.folder_id) == null) |
115 | folders.Clear(); | 115 | folders.Add(llsdRequest); |
116 | foreach (var f in unique) | 116 | |
117 | folders.Add(f); | ||
118 | } | 117 | } |
119 | 118 | ||
120 | if (folders.Count > 0) | 119 | if (folders.Count > 0) |
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs index d34423d..056b4db 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | 30 | using System.Linq; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Text.RegularExpressions; | ||
32 | using log4net; | 33 | using log4net; |
33 | using log4net.Config; | 34 | using log4net.Config; |
34 | using NUnit.Framework; | 35 | using NUnit.Framework; |
@@ -223,6 +224,44 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests | |||
223 | pos2 = llsdresponse.IndexOf("Link to Objects folder"); | 224 | pos2 = llsdresponse.IndexOf("Link to Objects folder"); |
224 | Assert.Less(pos1, pos2, "Contents of source of folder link is after folder link"); | 225 | Assert.Less(pos1, pos2, "Contents of source of folder link is after folder link"); |
225 | } | 226 | } |
227 | |||
228 | [Test] | ||
229 | public void Test_004_DuplicateFolders() | ||
230 | { | ||
231 | TestHelpers.InMethod(); | ||
232 | |||
233 | FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null); | ||
234 | TestOSHttpRequest req = new TestOSHttpRequest(); | ||
235 | TestOSHttpResponse resp = new TestOSHttpResponse(); | ||
236 | |||
237 | string request = "<llsd><map><key>folders</key><array>"; | ||
238 | request += "<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>"; | ||
239 | request += m_rootFolderID; | ||
240 | request += "</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>"; | ||
241 | request += "<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>"; | ||
242 | request += m_notecardsFolder; | ||
243 | request += "</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>"; | ||
244 | request += "<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>"; | ||
245 | request += m_rootFolderID; | ||
246 | request += "</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>"; | ||
247 | request += "<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>"; | ||
248 | request += m_notecardsFolder; | ||
249 | request += "</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>"; | ||
250 | request += "</array></map></llsd>"; | ||
251 | |||
252 | string llsdresponse = handler.FetchInventoryDescendentsRequest(request, "/FETCH", string.Empty, req, resp); | ||
253 | Console.WriteLine(llsdresponse); | ||
254 | |||
255 | string root_folder = "<key>folder_id</key><uuid>" + m_rootFolderID + "</uuid>"; | ||
256 | string notecards_folder = "<key>folder_id</key><uuid>" + m_notecardsFolder + "</uuid>"; | ||
257 | |||
258 | Assert.That(llsdresponse.Contains(root_folder), "Missing root folder"); | ||
259 | Assert.That(llsdresponse.Contains(notecards_folder), "Missing notecards folder"); | ||
260 | int count = Regex.Matches(llsdresponse, root_folder).Count; | ||
261 | Assert.AreEqual(1, count, "More than 1 root folder in response"); | ||
262 | count = Regex.Matches(llsdresponse, notecards_folder).Count; | ||
263 | Assert.AreEqual(2, count, "More than 1 notecards folder in response"); // Notecards will also be under root, so 2 | ||
264 | } | ||
226 | } | 265 | } |
227 | 266 | ||
228 | } \ No newline at end of file | 267 | } \ No newline at end of file |