From 82690e138448ebac6456ab03dcca4b0a8a1cc57a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 24 Nov 2012 02:43:31 +0000
Subject: Fix bug where loading an OAR with a deeded parcel would always set
 the parcel owner ID to the estate owner even if the group UUID was present.

Aims to address http://opensimulator.org/mantis/view.php?id=6355
As part of this work, an incomplete IXGroupsData was added which currently only allows store/fetch/delete of group records
(i.e. no membership data etc)
This is subject to change and currently only an in-memory storage implementation exists for regression test purposes.
---
 .../Common/Mock/MockGroupsServicesConnector.cs     | 77 +++++++++++++++++++++-
 .../Tests/Common/Mock/TestXInventoryDataPlugin.cs  | 25 +------
 2 files changed, 76 insertions(+), 26 deletions(-)

(limited to 'OpenSim/Tests')

diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
index 6fb9df1..3035cea 100644
--- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
+++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
@@ -26,12 +26,15 @@
  */
 
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Reflection;
 using log4net;
 using Mono.Addins;
 using Nini.Config;
 using OpenMetaverse;
+using OpenSim.Data;
+using OpenSim.Data.Null;
 using OpenSim.Framework;
 using OpenSim.Region.Framework.Interfaces;
 using OpenSim.Region.Framework.Scenes;
@@ -44,6 +47,8 @@ namespace OpenSim.Tests.Common.Mock
     {
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
+        IXGroupData m_data = new NullXGroupData(null, null);
+
         public string Name
         {
             get { return "MockGroupsServicesConnector"; }
@@ -84,7 +89,33 @@ namespace OpenSim.Tests.Common.Mock
                                 int membershipFee, bool openEnrollment, bool allowPublish, 
                                 bool maturePublish, UUID founderID)
         {
-            return UUID.Zero;
+            XGroup group = new XGroup()
+            {
+                groupID = UUID.Random(),
+                ownerRoleID = UUID.Random(),
+                name = name,
+                charter = charter,
+                showInList = showInList,
+                insigniaID = insigniaID,
+                membershipFee = membershipFee,
+                openEnrollment = openEnrollment,
+                allowPublish = allowPublish,
+                maturePublish = maturePublish,
+                founderID = founderID,
+                everyonePowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultEveryonePowers,
+                ownersPowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultOwnerPowers
+            };
+
+            if (m_data.StoreGroup(group))
+            {
+                m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Created group {0} {1}", group.name, group.groupID);
+                return group.groupID;
+            }
+            else
+            {
+                m_log.ErrorFormat("[MOCK GROUPS SERVICES CONNECTOR]: Failed to create group {0}", name);
+                return UUID.Zero;
+            }
         }
 
         public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, 
@@ -107,9 +138,49 @@ namespace OpenSim.Tests.Common.Mock
         {
         }
 
-        public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
+        public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
         {
-            return null;
+            m_log.DebugFormat(
+                "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", 
+                groupID, groupName);
+
+            XGroup[] groups;
+            string field, val;
+
+            if (groupID != UUID.Zero)
+            {
+                field = "groupID";
+                val = groupID.ToString();
+            }
+            else
+            {
+                field = "name";
+                val = groupName;
+            }
+
+            groups = m_data.GetGroups(field, val);
+
+            if (groups.Length == 0)
+                return null;
+
+            XGroup xg = groups[0];
+
+            GroupRecord gr = new GroupRecord()
+            {
+                GroupID = xg.groupID,
+                GroupName = xg.name,
+                AllowPublish = xg.allowPublish,
+                MaturePublish = xg.maturePublish,
+                Charter = xg.charter,
+                FounderID = xg.founderID,
+                // FIXME: group picture storage location unknown
+                MembershipFee = xg.membershipFee,
+                OpenEnrollment = xg.openEnrollment,
+                OwnerRoleID = xg.ownerRoleID,
+                ShowInList = xg.showInList
+            };
+
+            return gr;
         }
 
         public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
index f9bf768..ccbdf81 100644
--- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
@@ -33,10 +33,11 @@ using log4net;
 using OpenMetaverse;
 using OpenSim.Framework;
 using OpenSim.Data;
+using OpenSim.Data.Null;
 
 namespace OpenSim.Tests.Common.Mock
 {
-    public class TestXInventoryDataPlugin : IXInventoryData
+    public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData
     {
         private Dictionary<UUID, XInventoryFolder> m_allFolders = new Dictionary<UUID, XInventoryFolder>();
         private Dictionary<UUID, XInventoryItem> m_allItems = new Dictionary<UUID, XInventoryItem>();
@@ -58,28 +59,6 @@ namespace OpenSim.Tests.Common.Mock
             return origFolders.Select(f => f.Clone()).ToArray();
         }
 
-        private List<T> Get<T>(string[] fields, string[] vals, List<T> inputEntities)
-        {
-            List<T> entities = inputEntities;
-
-            for (int i = 0; i < fields.Length; i++)
-            {
-                entities
-                    = entities.Where(
-                        e =>
-                        {
-                            FieldInfo fi = typeof(T).GetField(fields[i]);
-                            if (fi == null)
-                                throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i]));
-
-                            return fi.GetValue(e).ToString() == vals[i];
-                        }
-                    ).ToList();
-            }
-
-            return entities;
-        }
-
         public bool StoreFolder(XInventoryFolder folder)
         {
             m_allFolders[folder.folderID] = folder.Clone();
-- 
cgit v1.1


From 22d4c52ffc374e167cb674e0e20815615d8a6927 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 24 Nov 2012 03:15:24 +0000
Subject: Consistenly make NUnit test cases inherit from OpenSimTestCase which
 automatically turns off any logging enabled between tests

---
 OpenSim/Tests/ConfigurationLoaderTest.cs            | 3 ++-
 OpenSim/Tests/Performance/NPCPerformanceTests.cs    | 2 +-
 OpenSim/Tests/Performance/ObjectPerformanceTests.cs | 2 +-
 OpenSim/Tests/Performance/ScriptPerformanceTests.cs | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

(limited to 'OpenSim/Tests')

diff --git a/OpenSim/Tests/ConfigurationLoaderTest.cs b/OpenSim/Tests/ConfigurationLoaderTest.cs
index 067264d..e5186ae 100644
--- a/OpenSim/Tests/ConfigurationLoaderTest.cs
+++ b/OpenSim/Tests/ConfigurationLoaderTest.cs
@@ -29,11 +29,12 @@ using System.IO;
 using Nini.Config;
 using NUnit.Framework;
 using OpenSim.Framework;
+using OpenSim.Tests.Common;
 
 namespace OpenSim.Tests
 {
     [TestFixture]
-    public class ConfigurationLoaderTests
+    public class ConfigurationLoaderTests : OpenSimTestCase
     {
         private const string m_testSubdirectory = "test";
         private string m_basePath;
diff --git a/OpenSim/Tests/Performance/NPCPerformanceTests.cs b/OpenSim/Tests/Performance/NPCPerformanceTests.cs
index 627765b..2026a88 100644
--- a/OpenSim/Tests/Performance/NPCPerformanceTests.cs
+++ b/OpenSim/Tests/Performance/NPCPerformanceTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Tests.Performance
     /// earlier tests.
     /// </remarks>
     [TestFixture]
-    public class NPCPerformanceTests
+    public class NPCPerformanceTests : OpenSimTestCase
     {
         private TestScene scene;
         private AvatarFactoryModule afm;
diff --git a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
index 2264d86..656a971 100644
--- a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
+++ b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Tests.Performance
     /// earlier tests.
     /// </remarks>
     [TestFixture]
-    public class ObjectPerformanceTests
+    public class ObjectPerformanceTests : OpenSimTestCase
     {
         [TearDown]
         public void TearDown()
diff --git a/OpenSim/Tests/Performance/ScriptPerformanceTests.cs b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
index d708abd..4064edc 100644
--- a/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
+++ b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
@@ -53,7 +53,7 @@ namespace OpenSim.Tests.Performance
     /// earlier tests.
     /// </remarks>
     [TestFixture]
-    public class ScriptPerformanceTests
+    public class ScriptPerformanceTests : OpenSimTestCase
     {
         private TestScene m_scene;
         private XEngine m_xEngine;
-- 
cgit v1.1