diff options
author | Justin Clark-Casey (justincc) | 2012-08-29 02:01:43 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-08-29 02:01:43 +0100 |
commit | 7ea832d47c827ad9ef8eb0ce24702fbee585b1ee (patch) | |
tree | 9afe94690870999a66608b3b5cd51c4d068ec579 | |
parent | Add experimental DynamicTextureModule.ReuseTextures flag, currently only conf... (diff) | |
download | opensim-SC_OLD-7ea832d47c827ad9ef8eb0ce24702fbee585b1ee.zip opensim-SC_OLD-7ea832d47c827ad9ef8eb0ce24702fbee585b1ee.tar.gz opensim-SC_OLD-7ea832d47c827ad9ef8eb0ce24702fbee585b1ee.tar.bz2 opensim-SC_OLD-7ea832d47c827ad9ef8eb0ce24702fbee585b1ee.tar.xz |
Fix regression introduced in a0d178b2 (Sat Aug 25 02:00:17 2012) where folders with asset type of 'Folder' and 'Unknown' were accidentally treated as system folders.
This prevented more than one additional ordinary folder from being created in the base "My Inventory" user folder.
Added regression test for this case.
Switched tests to use XInventoryService with mostly implemented TestXInventoryDataPlugin rather than InventoryService
Disabled TestLoadIarV0_1SameNameCreator() since this has not been working for a very long time (ever since XInventoryService) started being used
since it doesnt' preserve creator data in the same way as InventoryService did and so effectively lost the OSPAs.
However, nobody noticed/complained about this issue and OSPAs have been superseded by HG like creator information via the --home save oar/iar switch.
10 files changed, 231 insertions, 52 deletions
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs index 85a5c08..e64a828 100644 --- a/OpenSim/Data/IXInventoryData.cs +++ b/OpenSim/Data/IXInventoryData.cs | |||
@@ -40,6 +40,11 @@ namespace OpenSim.Data | |||
40 | public UUID folderID; | 40 | public UUID folderID; |
41 | public UUID agentID; | 41 | public UUID agentID; |
42 | public UUID parentFolderID; | 42 | public UUID parentFolderID; |
43 | |||
44 | public XInventoryFolder Clone() | ||
45 | { | ||
46 | return (XInventoryFolder)MemberwiseClone(); | ||
47 | } | ||
43 | } | 48 | } |
44 | 49 | ||
45 | public class XInventoryItem | 50 | public class XInventoryItem |
@@ -64,6 +69,11 @@ namespace OpenSim.Data | |||
64 | public UUID avatarID; | 69 | public UUID avatarID; |
65 | public UUID parentFolderID; | 70 | public UUID parentFolderID; |
66 | public int inventoryGroupPermissions; | 71 | public int inventoryGroupPermissions; |
72 | |||
73 | public XInventoryItem Clone() | ||
74 | { | ||
75 | return (XInventoryItem)MemberwiseClone(); | ||
76 | } | ||
67 | } | 77 | } |
68 | 78 | ||
69 | public interface IXInventoryData | 79 | public interface IXInventoryData |
diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs index a12183c..b3457a6 100644 --- a/OpenSim/Framework/InventoryFolderBase.cs +++ b/OpenSim/Framework/InventoryFolderBase.cs | |||
@@ -73,33 +73,27 @@ namespace OpenSim.Framework | |||
73 | { | 73 | { |
74 | } | 74 | } |
75 | 75 | ||
76 | public InventoryFolderBase(UUID id) | 76 | public InventoryFolderBase(UUID id) : this() |
77 | { | 77 | { |
78 | ID = id; | 78 | ID = id; |
79 | } | 79 | } |
80 | 80 | ||
81 | public InventoryFolderBase(UUID id, UUID owner) | 81 | public InventoryFolderBase(UUID id, UUID owner) : this(id) |
82 | { | 82 | { |
83 | ID = id; | ||
84 | Owner = owner; | 83 | Owner = owner; |
85 | } | 84 | } |
86 | 85 | ||
87 | public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent) | 86 | public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent) : this(id, owner) |
88 | { | 87 | { |
89 | ID = id; | ||
90 | Name = name; | 88 | Name = name; |
91 | Owner = owner; | ||
92 | ParentID = parent; | 89 | ParentID = parent; |
93 | } | 90 | } |
94 | 91 | ||
95 | public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version) | 92 | public InventoryFolderBase( |
93 | UUID id, string name, UUID owner, short type, UUID parent, ushort version) : this(id, name, owner, parent) | ||
96 | { | 94 | { |
97 | ID = id; | ||
98 | Name = name; | ||
99 | Owner = owner; | ||
100 | Type = type; | 95 | Type = type; |
101 | ParentID = parent; | ||
102 | Version = version; | 96 | Version = version; |
103 | } | 97 | } |
104 | } | 98 | } |
105 | } | 99 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs index d31d27c..fa7160f 100644 --- a/OpenSim/Framework/Serialization/External/OspResolver.cs +++ b/OpenSim/Framework/Serialization/External/OspResolver.cs | |||
@@ -65,9 +65,14 @@ namespace OpenSim.Framework.Serialization | |||
65 | 65 | ||
66 | UserAccount account = userService.GetUserAccount(UUID.Zero, userId); | 66 | UserAccount account = userService.GetUserAccount(UUID.Zero, userId); |
67 | if (account != null) | 67 | if (account != null) |
68 | { | ||
68 | return MakeOspa(account.FirstName, account.LastName); | 69 | return MakeOspa(account.FirstName, account.LastName); |
70 | } | ||
69 | // else | 71 | // else |
72 | // { | ||
70 | // m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId); | 73 | // m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId); |
74 | // System.Console.WriteLine("[OSP RESOLVER]: No user account for {0}", userId); | ||
75 | // } | ||
71 | 76 | ||
72 | return null; | 77 | return null; |
73 | } | 78 | } |
@@ -79,10 +84,13 @@ namespace OpenSim.Framework.Serialization | |||
79 | /// <returns></returns> | 84 | /// <returns></returns> |
80 | public static string MakeOspa(string firstName, string lastName) | 85 | public static string MakeOspa(string firstName, string lastName) |
81 | { | 86 | { |
82 | // m_log.DebugFormat("[OSP RESOLVER]: Making OSPA for {0} {1}", firstName, lastName); | 87 | string ospa |
88 | = OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; | ||
89 | |||
90 | // m_log.DebugFormat("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); | ||
91 | // System.Console.WriteLine("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); | ||
83 | 92 | ||
84 | return | 93 | return ospa; |
85 | OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; | ||
86 | } | 94 | } |
87 | 95 | ||
88 | /// <summary> | 96 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index b112b6d..12a05b3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -350,38 +350,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
350 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID)); | 350 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID)); |
351 | } | 351 | } |
352 | 352 | ||
353 | /// <summary> | 353 | // /// <summary> |
354 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 354 | // /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
355 | /// an account exists with the same name as the creator, though not the same id. | 355 | // /// an account exists with the same name as the creator, though not the same id. |
356 | /// </summary> | 356 | // /// </summary> |
357 | [Test] | 357 | // [Test] |
358 | public void TestLoadIarV0_1SameNameCreator() | 358 | // public void TestLoadIarV0_1SameNameCreator() |
359 | { | 359 | // { |
360 | TestHelpers.InMethod(); | 360 | // TestHelpers.InMethod(); |
361 | // log4net.Config.XmlConfigurator.Configure(); | 361 | // TestHelpers.EnableLogging(); |
362 | 362 | // | |
363 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); | 363 | // UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); |
364 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); | 364 | // UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); |
365 | 365 | // | |
366 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); | 366 | // m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); |
367 | InventoryItemBase foundItem1 | 367 | // InventoryItemBase foundItem1 |
368 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); | 368 | // = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
369 | 369 | // | |
370 | Assert.That( | 370 | // Assert.That( |
371 | foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()), | 371 | // foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()), |
372 | "Loaded item non-uuid creator doesn't match original"); | 372 | // "Loaded item non-uuid creator doesn't match original"); |
373 | Assert.That( | 373 | // Assert.That( |
374 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID), | 374 | // foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID), |
375 | "Loaded item uuid creator doesn't match original"); | 375 | // "Loaded item uuid creator doesn't match original"); |
376 | Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID), | 376 | // Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID), |
377 | "Loaded item owner doesn't match inventory reciever"); | 377 | // "Loaded item owner doesn't match inventory reciever"); |
378 | 378 | // | |
379 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); | 379 | // AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
380 | string xmlData = Utils.BytesToString(asset1.Data); | 380 | // string xmlData = Utils.BytesToString(asset1.Data); |
381 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 381 | // SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
382 | 382 | // | |
383 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID)); | 383 | // Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID)); |
384 | } | 384 | // } |
385 | 385 | ||
386 | /// <summary> | 386 | /// <summary> |
387 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 387 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs index 44d2d45..9457ebb 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs | |||
@@ -50,9 +50,41 @@ using OpenSim.Tests.Common.Mock; | |||
50 | namespace OpenSim.Region.Framework.Tests | 50 | namespace OpenSim.Region.Framework.Tests |
51 | { | 51 | { |
52 | [TestFixture] | 52 | [TestFixture] |
53 | public class UserInventoryTests | 53 | public class UserInventoryTests : OpenSimTestCase |
54 | { | 54 | { |
55 | [Test] | 55 | [Test] |
56 | public void TestCreateInventoryFolders() | ||
57 | { | ||
58 | TestHelpers.InMethod(); | ||
59 | // TestHelpers.EnableLogging(); | ||
60 | |||
61 | // For this test both folders will have the same name which is legal in SL user inventories. | ||
62 | string foldersName = "f1"; | ||
63 | |||
64 | Scene scene = new SceneHelpers().SetupScene(); | ||
65 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); | ||
66 | |||
67 | UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName); | ||
68 | |||
69 | List<InventoryFolderBase> oneFolder | ||
70 | = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName); | ||
71 | |||
72 | Assert.That(oneFolder.Count, Is.EqualTo(1)); | ||
73 | InventoryFolderBase firstRetrievedFolder = oneFolder[0]; | ||
74 | Assert.That(firstRetrievedFolder.Name, Is.EqualTo(foldersName)); | ||
75 | |||
76 | UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName); | ||
77 | |||
78 | List<InventoryFolderBase> twoFolders | ||
79 | = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName); | ||
80 | |||
81 | Assert.That(twoFolders.Count, Is.EqualTo(2)); | ||
82 | Assert.That(twoFolders[0].Name, Is.EqualTo(foldersName)); | ||
83 | Assert.That(twoFolders[1].Name, Is.EqualTo(foldersName)); | ||
84 | Assert.That(twoFolders[0].ID, Is.Not.EqualTo(twoFolders[1].ID)); | ||
85 | } | ||
86 | |||
87 | [Test] | ||
56 | public void TestGiveInventoryItem() | 88 | public void TestGiveInventoryItem() |
57 | { | 89 | { |
58 | TestHelpers.InMethod(); | 90 | TestHelpers.InMethod(); |
@@ -83,7 +115,7 @@ namespace OpenSim.Region.Framework.Tests | |||
83 | public void TestGiveInventoryFolder() | 115 | public void TestGiveInventoryFolder() |
84 | { | 116 | { |
85 | TestHelpers.InMethod(); | 117 | TestHelpers.InMethod(); |
86 | // log4net.Config.XmlConfigurator.Configure(); | 118 | // TestHelpers.EnableLogging(); |
87 | 119 | ||
88 | Scene scene = new SceneHelpers().SetupScene(); | 120 | Scene scene = new SceneHelpers().SetupScene(); |
89 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); | 121 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); |
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index deacd5a..309dab4 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs | |||
@@ -94,6 +94,7 @@ namespace OpenSim.Services.InventoryService | |||
94 | 94 | ||
95 | m_Database = LoadPlugin<IXInventoryData>(dllName, | 95 | m_Database = LoadPlugin<IXInventoryData>(dllName, |
96 | new Object[] {connString, String.Empty}); | 96 | new Object[] {connString, String.Empty}); |
97 | |||
97 | if (m_Database == null) | 98 | if (m_Database == null) |
98 | throw new Exception("Could not find a storage interface in the given module"); | 99 | throw new Exception("Could not find a storage interface in the given module"); |
99 | } | 100 | } |
@@ -326,7 +327,7 @@ namespace OpenSim.Services.InventoryService | |||
326 | if (check != null) | 327 | if (check != null) |
327 | return false; | 328 | return false; |
328 | 329 | ||
329 | if (folder.Type != (short)AssetType.Folder || folder.Type != (short)AssetType.Unknown) | 330 | if (folder.Type != (short)AssetType.Folder && folder.Type != (short)AssetType.Unknown) |
330 | { | 331 | { |
331 | InventoryFolderBase rootFolder = GetRootFolder(folder.Owner); | 332 | InventoryFolderBase rootFolder = GetRootFolder(folder.Owner); |
332 | 333 | ||
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 7598cc3..fc49169 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs | |||
@@ -245,7 +245,7 @@ namespace OpenSim.Tests.Common | |||
245 | config.AddConfig("Modules"); | 245 | config.AddConfig("Modules"); |
246 | config.AddConfig("InventoryService"); | 246 | config.AddConfig("InventoryService"); |
247 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); | 247 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); |
248 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); | 248 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService"); |
249 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 249 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
250 | 250 | ||
251 | LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); | 251 | LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); |
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs index b3a7c9e..87d9410 100644 --- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs | |||
@@ -199,7 +199,9 @@ namespace OpenSim.Tests.Common | |||
199 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | 199 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); |
200 | 200 | ||
201 | InventoryFolderBase newFolder | 201 | InventoryFolderBase newFolder |
202 | = new InventoryFolderBase(UUID.Random(), components[0], parentFolder.Owner, parentFolder.ID); | 202 | = new InventoryFolderBase( |
203 | UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0); | ||
204 | |||
203 | inventoryService.AddFolder(newFolder); | 205 | inventoryService.AddFolder(newFolder); |
204 | 206 | ||
205 | if (components.Length > 1) | 207 | if (components.Length > 1) |
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs new file mode 100644 index 0000000..bca5979 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs | |||
@@ -0,0 +1,131 @@ | |||
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.Linq; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Data; | ||
36 | |||
37 | namespace OpenSim.Tests.Common.Mock | ||
38 | { | ||
39 | public class TestXInventoryDataPlugin : IXInventoryData | ||
40 | { | ||
41 | private Dictionary<UUID, XInventoryFolder> m_allFolders = new Dictionary<UUID, XInventoryFolder>(); | ||
42 | private Dictionary<UUID, XInventoryItem> m_allItems = new Dictionary<UUID, XInventoryItem>(); | ||
43 | |||
44 | public TestXInventoryDataPlugin(string conn, string realm) {} | ||
45 | |||
46 | public XInventoryItem[] GetItems(string[] fields, string[] vals) | ||
47 | { | ||
48 | List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList()); | ||
49 | |||
50 | return origItems.Select(i => i.Clone()).ToArray(); | ||
51 | } | ||
52 | |||
53 | public XInventoryFolder[] GetFolders(string[] fields, string[] vals) | ||
54 | { | ||
55 | List<XInventoryFolder> origFolders | ||
56 | = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); | ||
57 | |||
58 | return origFolders.Select(f => f.Clone()).ToArray(); | ||
59 | } | ||
60 | |||
61 | private List<T> Get<T>(string[] fields, string[] vals, List<T> inputEntities) | ||
62 | { | ||
63 | List<T> entities = inputEntities; | ||
64 | |||
65 | for (int i = 0; i < fields.Length; i++) | ||
66 | { | ||
67 | entities | ||
68 | = entities.Where( | ||
69 | e => | ||
70 | { | ||
71 | FieldInfo fi = typeof(T).GetField(fields[i]); | ||
72 | if (fi == null) | ||
73 | throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i])); | ||
74 | |||
75 | return fi.GetValue(e).ToString() == vals[i]; | ||
76 | } | ||
77 | ).ToList(); | ||
78 | } | ||
79 | |||
80 | return entities; | ||
81 | } | ||
82 | |||
83 | public bool StoreFolder(XInventoryFolder folder) | ||
84 | { | ||
85 | m_allFolders[folder.folderID] = folder.Clone(); | ||
86 | |||
87 | // Console.WriteLine("Added folder {0} {1}", folder.folderName, folder.folderID); | ||
88 | |||
89 | return true; | ||
90 | } | ||
91 | |||
92 | public bool StoreItem(XInventoryItem item) | ||
93 | { | ||
94 | m_allItems[item.inventoryID] = item.Clone(); | ||
95 | |||
96 | // Console.WriteLine("Added item {0} {1}, creator {2}, owner {3}", item.inventoryName, item.inventoryID, item.creatorID, item.avatarID); | ||
97 | |||
98 | return true; | ||
99 | } | ||
100 | |||
101 | public bool DeleteFolders(string field, string val) | ||
102 | { | ||
103 | return DeleteFolders(new string[] { field }, new string[] { val }); | ||
104 | } | ||
105 | |||
106 | public bool DeleteFolders(string[] fields, string[] vals) | ||
107 | { | ||
108 | XInventoryFolder[] foldersToDelete = GetFolders(fields, vals); | ||
109 | Array.ForEach(foldersToDelete, f => m_allFolders.Remove(f.folderID)); | ||
110 | |||
111 | return true; | ||
112 | } | ||
113 | |||
114 | public bool DeleteItems(string field, string val) | ||
115 | { | ||
116 | return DeleteItems(new string[] { field }, new string[] { val }); | ||
117 | } | ||
118 | |||
119 | public bool DeleteItems(string[] fields, string[] vals) | ||
120 | { | ||
121 | XInventoryItem[] itemsToDelete = GetItems(fields, vals); | ||
122 | Array.ForEach(itemsToDelete, i => m_allItems.Remove(i.inventoryID)); | ||
123 | |||
124 | return true; | ||
125 | } | ||
126 | |||
127 | public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } | ||
128 | public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } | ||
129 | public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } | ||
130 | } | ||
131 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index 30121fe..57da802 100644 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ b/OpenSim/Tests/Common/TestHelpers.cs | |||
@@ -95,6 +95,7 @@ namespace OpenSim.Tests.Common | |||
95 | public static void EnableLogging() | 95 | public static void EnableLogging() |
96 | { | 96 | { |
97 | log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream); | 97 | log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream); |
98 | EnableLoggingConfigStream.Position = 0; | ||
98 | } | 99 | } |
99 | 100 | ||
100 | /// <summary> | 101 | /// <summary> |