aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r--OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs91
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs39
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs32
-rw-r--r--OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs109
-rw-r--r--OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs77
-rw-r--r--OpenSim/Tests/Common/Mock/MockScriptEngine.cs266
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs37
-rw-r--r--OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs178
-rw-r--r--OpenSim/Tests/Common/Mock/TestLandChannel.cs5
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs3
-rw-r--r--OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs25
-rw-r--r--OpenSim/Tests/Common/TestHelpers.cs21
12 files changed, 795 insertions, 88 deletions
diff --git a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
new file mode 100644
index 0000000..6cc7ff2
--- /dev/null
+++ b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
@@ -0,0 +1,91 @@
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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using System.Text;
34using log4net;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Servers;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.CoreModules.Framework;
44using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock;
46
47namespace OpenSim.Tests.Common
48{
49 public static class EntityTransferHelpers
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 /// <summary>
54 /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
55 /// viewer to setup a connection with the destination region.
56 /// </summary>
57 /// <param name='tc'></param>
58 /// <param name='neighbourTcs'>
59 /// A list that will be populated with any TestClients set up in response to
60 /// being informed about a destination region.
61 /// </param>
62 public static void SetUpInformClientOfNeighbour(TestClient tc, List<TestClient> neighbourTcs)
63 {
64 // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the
65 // event queue).
66
67 tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) =>
68 {
69 uint x, y;
70 Utils.LongToUInts(neighbourHandle, out x, out y);
71 x /= Constants.RegionSize;
72 y /= Constants.RegionSize;
73
74 m_log.DebugFormat(
75 "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}",
76 x, y, neighbourExternalEndPoint);
77
78 // In response to this message, we are going to make a teleport to the scene we've previous been told
79 // about by test code (this needs to be improved).
80 AgentCircuitData newAgent = tc.RequestClientInfo();
81
82 Scene neighbourScene;
83 SceneManager.Instance.TryGetScene(x, y, out neighbourScene);
84
85 TestClient neighbourTc = new TestClient(newAgent, neighbourScene, SceneManager.Instance);
86 neighbourTcs.Add(neighbourTc);
87 neighbourScene.AddNewClient(neighbourTc, PresenceType.User);
88 };
89 }
90 }
91} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index ea3e348..bdd9093 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -139,7 +139,7 @@ namespace OpenSim.Tests.Common
139 SceneCommunicationService scs = new SceneCommunicationService(); 139 SceneCommunicationService scs = new SceneCommunicationService();
140 140
141 TestScene testScene = new TestScene( 141 TestScene testScene = new TestScene(
142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, false, configSource, null); 142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, configSource, null);
143 143
144 INonSharedRegionModule godsModule = new GodsModule(); 144 INonSharedRegionModule godsModule = new GodsModule();
145 godsModule.Initialise(new IniConfigSource()); 145 godsModule.Initialise(new IniConfigSource());
@@ -532,6 +532,31 @@ namespace OpenSim.Tests.Common
532 /// <returns></returns> 532 /// <returns></returns>
533 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) 533 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager)
534 { 534 {
535 return AddScenePresence(scene, new TestClient(agentData, scene, sceneManager), agentData, sceneManager);
536 }
537
538 /// <summary>
539 /// Add a root agent.
540 /// </summary>
541 /// <remarks>
542 /// This function
543 ///
544 /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the
545 /// userserver if grid) would give initial login data back to the client and separately tell the scene that the
546 /// agent was coming.
547 ///
548 /// 2) Connects the agent with the scene
549 ///
550 /// This function performs actions equivalent with notifying the scene that an agent is
551 /// coming and then actually connecting the agent to the scene. The one step missed out is the very first
552 /// </remarks>
553 /// <param name="scene"></param>
554 /// <param name="agentData"></param>
555 /// <param name="sceneManager"></param>
556 /// <returns></returns>
557 public static ScenePresence AddScenePresence(
558 Scene scene, IClientAPI client, AgentCircuitData agentData, SceneManager sceneManager)
559 {
535 // We emulate the proper login sequence here by doing things in four stages 560 // We emulate the proper login sequence here by doing things in four stages
536 561
537 // Stage 0: login 562 // Stage 0: login
@@ -541,7 +566,7 @@ namespace OpenSim.Tests.Common
541 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); 566 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
542 567
543 // Stages 1 & 2 568 // Stages 1 & 2
544 ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin); 569 ScenePresence sp = IntroduceClientToScene(scene, client, agentData, TeleportFlags.ViaLogin);
545 570
546 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. 571 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
547 sp.CompleteMovement(sp.ControllingClient, true); 572 sp.CompleteMovement(sp.ControllingClient, true);
@@ -558,11 +583,11 @@ namespace OpenSim.Tests.Common
558 /// neighbours and where no teleporting takes place. 583 /// neighbours and where no teleporting takes place.
559 /// </param> 584 /// </param>
560 /// <param name='scene'></param> 585 /// <param name='scene'></param>
561 /// <param name='sceneManager></param> 586 /// <param name='testClient'></param>
562 /// <param name='agentData'></param> 587 /// <param name='agentData'></param>
563 /// <param name='tf'></param> 588 /// <param name='tf'></param>
564 private static ScenePresence IntroduceClientToScene( 589 private static ScenePresence IntroduceClientToScene(
565 Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf) 590 Scene scene, IClientAPI client, AgentCircuitData agentData, TeleportFlags tf)
566 { 591 {
567 string reason; 592 string reason;
568 593
@@ -571,10 +596,9 @@ namespace OpenSim.Tests.Common
571 Console.WriteLine("NewUserConnection failed: " + reason); 596 Console.WriteLine("NewUserConnection failed: " + reason);
572 597
573 // Stage 2: add the new client as a child agent to the scene 598 // Stage 2: add the new client as a child agent to the scene
574 TestClient client = new TestClient(agentData, scene, sceneManager);
575 scene.AddNewClient(client, PresenceType.User); 599 scene.AddNewClient(client, PresenceType.User);
576 600
577 return scene.GetScenePresence(agentData.AgentID); 601 return scene.GetScenePresence(client.AgentId);
578 } 602 }
579 603
580 public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) 604 public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId)
@@ -583,7 +607,8 @@ namespace OpenSim.Tests.Common
583 acd.child = true; 607 acd.child = true;
584 608
585 // XXX: ViaLogin may not be correct for child agents 609 // XXX: ViaLogin may not be correct for child agents
586 return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin); 610 TestClient client = new TestClient(acd, scene, null);
611 return IntroduceClientToScene(scene, client, acd, TeleportFlags.ViaLogin);
587 } 612 }
588 613
589 /// <summary> 614 /// <summary>
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
index 0a2b30a..bb4b55f 100644
--- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -46,13 +46,32 @@ namespace OpenSim.Tests.Common
46 /// <param name="scene"></param> 46 /// <param name="scene"></param>
47 /// <param name="part"></param> 47 /// <param name="part"></param>
48 /// <param name="itemName"></param> 48 /// <param name="itemName"></param>
49 /// <param name="itemIDFrag">UUID or UUID stem</param>
50 /// <param name="assetIDFrag">UUID or UUID stem</param>
51 /// <param name="text">The tex to put in the notecard.</param>
52 /// <returns>The item that was added</returns>
53 public static TaskInventoryItem AddNotecard(
54 Scene scene, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text)
55 {
56 return AddNotecard(
57 scene, part, itemName, TestHelpers.ParseStem(itemIDStem), TestHelpers.ParseStem(assetIDStem), text);
58 }
59
60 /// <summary>
61 /// Add a notecard item to the given part.
62 /// </summary>
63 /// <param name="scene"></param>
64 /// <param name="part"></param>
65 /// <param name="itemName"></param>
49 /// <param name="itemID"></param> 66 /// <param name="itemID"></param>
50 /// <param name="assetID"></param> 67 /// <param name="assetID"></param>
68 /// <param name="text">The tex to put in the notecard.</param>
51 /// <returns>The item that was added</returns> 69 /// <returns>The item that was added</returns>
52 public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID) 70 public static TaskInventoryItem AddNotecard(
71 Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text)
53 { 72 {
54 AssetNotecard nc = new AssetNotecard(); 73 AssetNotecard nc = new AssetNotecard();
55 nc.BodyText = "Hello World!"; 74 nc.BodyText = text;
56 nc.Encode(); 75 nc.Encode();
57 76
58 AssetBase ncAsset 77 AssetBase ncAsset
@@ -87,8 +106,8 @@ namespace OpenSim.Tests.Common
87 /// Add a simple script to the given part. 106 /// Add a simple script to the given part.
88 /// </summary> 107 /// </summary>
89 /// <remarks> 108 /// <remarks>
90 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these 109 /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather
91 /// functions more than once in a test. 110 /// than a random component.
92 /// </remarks> 111 /// </remarks>
93 /// <param name="scene"></param> 112 /// <param name="scene"></param>
94 /// <param name="part"></param> 113 /// <param name="part"></param>
@@ -102,8 +121,9 @@ namespace OpenSim.Tests.Common
102 ast.Source = scriptSource; 121 ast.Source = scriptSource;
103 ast.Encode(); 122 ast.Encode();
104 123
105 UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); 124 UUID assetUuid = UUID.Random();
106 UUID itemUuid = new UUID("00000000-0000-0000-1100-000000000000"); 125 UUID itemUuid = UUID.Random();
126
107 AssetBase asset 127 AssetBase asset
108 = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); 128 = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero);
109 scene.AssetService.Store(asset); 129 scene.AssetService.Store(asset);
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index 87d9410..a1794c9 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -45,6 +45,9 @@ namespace OpenSim.Tests.Common
45 /// <summary> 45 /// <summary>
46 /// Add an existing scene object as an item in the user's inventory. 46 /// Add an existing scene object as an item in the user's inventory.
47 /// </summary> 47 /// </summary>
48 /// <remarks>
49 /// Will be added to the system Objects folder.
50 /// </remarks>
48 /// <param name='scene'></param> 51 /// <param name='scene'></param>
49 /// <param name='so'></param> 52 /// <param name='so'></param>
50 /// <param name='inventoryIdTail'></param> 53 /// <param name='inventoryIdTail'></param>
@@ -63,7 +66,29 @@ namespace OpenSim.Tests.Common
63 } 66 }
64 67
65 /// <summary> 68 /// <summary>
66 /// Creates a notecard in the objects folder and specify an item id. 69 /// Add an existing scene object as an item in the user's inventory at the given path.
70 /// </summary>
71 /// <param name='scene'></param>
72 /// <param name='so'></param>
73 /// <param name='inventoryIdTail'></param>
74 /// <param name='assetIdTail'></param>
75 /// <returns>The inventory item created.</returns>
76 public static InventoryItemBase AddInventoryItem(
77 Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail, string path)
78 {
79 return AddInventoryItem(
80 scene,
81 so.Name,
82 TestHelpers.ParseTail(inventoryIdTail),
83 InventoryType.Object,
84 AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
85 so.OwnerID,
86 path);
87 }
88
89 /// <summary>
90 /// Adds the given item to the existing system folder for its type (e.g. an object will go in the "Objects"
91 /// folder).
67 /// </summary> 92 /// </summary>
68 /// <param name="scene"></param> 93 /// <param name="scene"></param>
69 /// <param name="itemName"></param> 94 /// <param name="itemName"></param>
@@ -75,6 +100,25 @@ namespace OpenSim.Tests.Common
75 private static InventoryItemBase AddInventoryItem( 100 private static InventoryItemBase AddInventoryItem(
76 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId) 101 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
77 { 102 {
103 return AddInventoryItem(
104 scene, itemName, itemId, itemType, asset, userId,
105 scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type).Name);
106 }
107
108 /// <summary>
109 /// Adds the given item to an inventory folder
110 /// </summary>
111 /// <param name="scene"></param>
112 /// <param name="itemName"></param>
113 /// <param name="itemId"></param>
114 /// <param name="itemType"></param>
115 /// <param name="asset">The serialized asset for this item</param>
116 /// <param name="userId"></param>
117 /// <param name="path">Existing inventory path at which to add.</param>
118 /// <returns></returns>
119 private static InventoryItemBase AddInventoryItem(
120 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId, string path)
121 {
78 scene.AssetService.Store(asset); 122 scene.AssetService.Store(asset);
79 123
80 InventoryItemBase item = new InventoryItemBase(); 124 InventoryItemBase item = new InventoryItemBase();
@@ -85,7 +129,7 @@ namespace OpenSim.Tests.Common
85 item.AssetType = asset.Type; 129 item.AssetType = asset.Type;
86 item.InvType = (int)itemType; 130 item.InvType = (int)itemType;
87 131
88 InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type); 132 InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, path)[0];
89 133
90 item.Folder = folder.ID; 134 item.Folder = folder.ID;
91 scene.AddInventoryItem(item); 135 scene.AddInventoryItem(item);
@@ -156,58 +200,83 @@ namespace OpenSim.Tests.Common
156 /// <summary> 200 /// <summary>
157 /// Create inventory folders starting from the user's root folder. 201 /// Create inventory folders starting from the user's root folder.
158 /// </summary> 202 /// </summary>
159 ///
160 /// Ignores any existing folders with the same name
161 ///
162 /// <param name="inventoryService"></param> 203 /// <param name="inventoryService"></param>
163 /// <param name="userId"></param> 204 /// <param name="userId"></param>
164 /// <param name="path"> 205 /// <param name="path">
165 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER 206 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
166 /// </param> 207 /// </param>
208 /// <param name="useExistingFolders">
209 /// If true, then folders in the path which already the same name are
210 /// used. This applies to the terminal folder as well.
211 /// If false, then all folders in the path are created, even if there is already a folder at a particular
212 /// level with the same name.
213 /// </param>
167 /// <returns> 214 /// <returns>
168 /// The folder created. If the path contains multiple folders then the last one created is returned. 215 /// The folder created. If the path contains multiple folders then the last one created is returned.
169 /// Will return null if the root folder could not be found. 216 /// Will return null if the root folder could not be found.
170 /// </returns> 217 /// </returns>
171 public static InventoryFolderBase CreateInventoryFolder( 218 public static InventoryFolderBase CreateInventoryFolder(
172 IInventoryService inventoryService, UUID userId, string path) 219 IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders)
173 { 220 {
174 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); 221 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
175 222
176 if (null == rootFolder) 223 if (null == rootFolder)
177 return null; 224 return null;
178 225
179 return CreateInventoryFolder(inventoryService, rootFolder, path); 226 return CreateInventoryFolder(inventoryService, rootFolder, path, useExistingFolders);
180 } 227 }
181 228
182 /// <summary> 229 /// <summary>
183 /// Create inventory folders starting from a given parent folder 230 /// Create inventory folders starting from a given parent folder
184 /// </summary> 231 /// </summary>
185 /// 232 /// <remarks>
186 /// Ignores any existing folders with the same name 233 /// If any stem of the path names folders that already exist then these are not recreated. This includes the
187 /// 234 /// final folder.
235 /// TODO: May need to make it an option to create duplicate folders.
236 /// </remarks>
188 /// <param name="inventoryService"></param> 237 /// <param name="inventoryService"></param>
189 /// <param name="parentFolder"></param> 238 /// <param name="parentFolder"></param>
190 /// <param name="path"> 239 /// <param name="path">
191 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER 240 /// The folder to create.
241 /// </param>
242 /// <param name="useExistingFolders">
243 /// If true, then folders in the path which already the same name are
244 /// used. This applies to the terminal folder as well.
245 /// If false, then all folders in the path are created, even if there is already a folder at a particular
246 /// level with the same name.
192 /// </param> 247 /// </param>
193 /// <returns> 248 /// <returns>
194 /// The folder created. If the path contains multiple folders then the last one created is returned. 249 /// The folder created. If the path contains multiple folders then the last one created is returned.
195 /// </returns> 250 /// </returns>
196 public static InventoryFolderBase CreateInventoryFolder( 251 public static InventoryFolderBase CreateInventoryFolder(
197 IInventoryService inventoryService, InventoryFolderBase parentFolder, string path) 252 IInventoryService inventoryService, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
198 { 253 {
199 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); 254 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
200 255
201 InventoryFolderBase newFolder 256 InventoryFolderBase folder = null;
202 = new InventoryFolderBase( 257
203 UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0); 258 if (useExistingFolders)
204 259 folder = InventoryArchiveUtils.FindFolderByPath(inventoryService, parentFolder, components[0]);
205 inventoryService.AddFolder(newFolder); 260
261 if (folder == null)
262 {
263// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name);
264
265 folder
266 = new InventoryFolderBase(
267 UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
268
269 inventoryService.AddFolder(folder);
270 }
271// else
272// {
273// Console.WriteLine("Found existing folder {0}", folder.Name);
274// }
206 275
207 if (components.Length > 1) 276 if (components.Length > 1)
208 return CreateInventoryFolder(inventoryService, newFolder, components[1]); 277 return CreateInventoryFolder(inventoryService, folder, components[1], useExistingFolders);
209 else 278 else
210 return newFolder; 279 return folder;
211 } 280 }
212 281
213 /// <summary> 282 /// <summary>
@@ -237,7 +306,7 @@ namespace OpenSim.Tests.Common
237 /// <returns>An empty list if no matching folders were found</returns> 306 /// <returns>An empty list if no matching folders were found</returns>
238 public static List<InventoryFolderBase> GetInventoryFolders(IInventoryService inventoryService, UUID userId, string path) 307 public static List<InventoryFolderBase> GetInventoryFolders(IInventoryService inventoryService, UUID userId, string path)
239 { 308 {
240 return InventoryArchiveUtils.FindFolderByPath(inventoryService, userId, path); 309 return InventoryArchiveUtils.FindFoldersByPath(inventoryService, userId, path);
241 } 310 }
242 311
243 /// <summary> 312 /// <summary>
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 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using log4net; 32using log4net;
32using Mono.Addins; 33using Mono.Addins;
33using Nini.Config; 34using Nini.Config;
34using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Data;
37using OpenSim.Data.Null;
35using OpenSim.Framework; 38using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
@@ -44,6 +47,8 @@ namespace OpenSim.Tests.Common.Mock
44 { 47 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 49
50 IXGroupData m_data = new NullXGroupData(null, null);
51
47 public string Name 52 public string Name
48 { 53 {
49 get { return "MockGroupsServicesConnector"; } 54 get { return "MockGroupsServicesConnector"; }
@@ -84,7 +89,33 @@ namespace OpenSim.Tests.Common.Mock
84 int membershipFee, bool openEnrollment, bool allowPublish, 89 int membershipFee, bool openEnrollment, bool allowPublish,
85 bool maturePublish, UUID founderID) 90 bool maturePublish, UUID founderID)
86 { 91 {
87 return UUID.Zero; 92 XGroup group = new XGroup()
93 {
94 groupID = UUID.Random(),
95 ownerRoleID = UUID.Random(),
96 name = name,
97 charter = charter,
98 showInList = showInList,
99 insigniaID = insigniaID,
100 membershipFee = membershipFee,
101 openEnrollment = openEnrollment,
102 allowPublish = allowPublish,
103 maturePublish = maturePublish,
104 founderID = founderID,
105 everyonePowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultEveryonePowers,
106 ownersPowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultOwnerPowers
107 };
108
109 if (m_data.StoreGroup(group))
110 {
111 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Created group {0} {1}", group.name, group.groupID);
112 return group.groupID;
113 }
114 else
115 {
116 m_log.ErrorFormat("[MOCK GROUPS SERVICES CONNECTOR]: Failed to create group {0}", name);
117 return UUID.Zero;
118 }
88 } 119 }
89 120
90 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, 121 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
@@ -107,9 +138,49 @@ namespace OpenSim.Tests.Common.Mock
107 { 138 {
108 } 139 }
109 140
110 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName) 141 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
111 { 142 {
112 return null; 143 m_log.DebugFormat(
144 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}",
145 groupID, groupName);
146
147 XGroup[] groups;
148 string field, val;
149
150 if (groupID != UUID.Zero)
151 {
152 field = "groupID";
153 val = groupID.ToString();
154 }
155 else
156 {
157 field = "name";
158 val = groupName;
159 }
160
161 groups = m_data.GetGroups(field, val);
162
163 if (groups.Length == 0)
164 return null;
165
166 XGroup xg = groups[0];
167
168 GroupRecord gr = new GroupRecord()
169 {
170 GroupID = xg.groupID,
171 GroupName = xg.name,
172 AllowPublish = xg.allowPublish,
173 MaturePublish = xg.maturePublish,
174 Charter = xg.charter,
175 FounderID = xg.founderID,
176 // FIXME: group picture storage location unknown
177 MembershipFee = xg.membershipFee,
178 OpenEnrollment = xg.openEnrollment,
179 OwnerRoleID = xg.ownerRoleID,
180 ShowInList = xg.showInList
181 };
182
183 return gr;
113 } 184 }
114 185
115 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID) 186 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
new file mode 100644
index 0000000..b444241
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
@@ -0,0 +1,266 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.ScriptEngine.Interfaces;
38using OpenSim.Region.ScriptEngine.Shared;
39
40namespace OpenSim.Tests.Common
41{
42 public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
43 {
44 public IConfigSource ConfigSource { get; private set; }
45
46 public IConfig Config { get; private set; }
47
48 private Scene m_scene;
49
50 /// <summary>
51 /// Expose posted events to tests.
52 /// </summary>
53 public Dictionary<UUID, List<EventParams>> PostedEvents { get; private set; }
54
55 /// <summary>
56 /// A very primitive way of hooking text cose to a posed event.
57 /// </summary>
58 /// <remarks>
59 /// May be replaced with something that uses more original code in the future.
60 /// </remarks>
61 public event Action<UUID, EventParams> PostEventHook;
62
63 public void Initialise(IConfigSource source)
64 {
65 ConfigSource = source;
66
67 // Can set later on if required
68 Config = new IniConfig("MockScriptEngine", ConfigSource);
69
70 PostedEvents = new Dictionary<UUID, List<EventParams>>();
71 }
72
73 public void Close()
74 {
75 }
76
77 public void AddRegion(Scene scene)
78 {
79 m_scene = scene;
80
81 m_scene.StackModuleInterface<IScriptModule>(this);
82 }
83
84 public void RemoveRegion(Scene scene)
85 {
86 }
87
88 public void RegionLoaded(Scene scene)
89 {
90 }
91
92 public string Name { get { return "Mock Script Engine"; } }
93 public string ScriptEngineName { get { return Name; } }
94
95 public Type ReplaceableInterface { get { return null; } }
96
97 public event ScriptRemoved OnScriptRemoved;
98 public event ObjectRemoved OnObjectRemoved;
99
100 public string GetXMLState (UUID itemID)
101 {
102 throw new System.NotImplementedException ();
103 }
104
105 public bool SetXMLState(UUID itemID, string xml)
106 {
107 throw new System.NotImplementedException ();
108 }
109
110 public bool PostScriptEvent(UUID itemID, string name, object[] args)
111 {
112// Console.WriteLine("Posting event {0} for {1}", name, itemID);
113
114 return PostScriptEvent(itemID, new EventParams(name, args, null));
115 }
116
117 public bool PostScriptEvent(UUID itemID, EventParams evParams)
118 {
119 List<EventParams> eventsForItem;
120
121 if (!PostedEvents.ContainsKey(itemID))
122 {
123 eventsForItem = new List<EventParams>();
124 PostedEvents.Add(itemID, eventsForItem);
125 }
126 else
127 {
128 eventsForItem = PostedEvents[itemID];
129 }
130
131 eventsForItem.Add(evParams);
132
133 if (PostEventHook != null)
134 PostEventHook(itemID, evParams);
135
136 return true;
137 }
138
139 public bool PostObjectEvent(uint localID, EventParams evParams)
140 {
141 return PostObjectEvent(m_scene.GetSceneObjectPart(localID), evParams);
142 }
143
144 public bool PostObjectEvent(UUID itemID, string name, object[] args)
145 {
146 return PostObjectEvent(m_scene.GetSceneObjectPart(itemID), new EventParams(name, args, null));
147 }
148
149 private bool PostObjectEvent(SceneObjectPart part, EventParams evParams)
150 {
151 foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems(InventoryType.LSL))
152 PostScriptEvent(item.ItemID, evParams);
153
154 return true;
155 }
156
157 public void SuspendScript(UUID itemID)
158 {
159 throw new System.NotImplementedException ();
160 }
161
162 public void ResumeScript(UUID itemID)
163 {
164 throw new System.NotImplementedException ();
165 }
166
167 public ArrayList GetScriptErrors(UUID itemID)
168 {
169 throw new System.NotImplementedException ();
170 }
171
172 public bool HasScript(UUID itemID, out bool running)
173 {
174 throw new System.NotImplementedException ();
175 }
176
177 public bool GetScriptState(UUID itemID)
178 {
179 throw new System.NotImplementedException ();
180 }
181
182 public void SaveAllState()
183 {
184 throw new System.NotImplementedException ();
185 }
186
187 public void StartProcessing()
188 {
189 throw new System.NotImplementedException ();
190 }
191
192 public float GetScriptExecutionTime(List<UUID> itemIDs)
193 {
194 throw new System.NotImplementedException ();
195 }
196
197 public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
198 {
199 throw new System.NotImplementedException ();
200 }
201
202 public IScriptWorkItem QueueEventHandler(object parms)
203 {
204 throw new System.NotImplementedException ();
205 }
206
207 public DetectParams GetDetectParams(UUID item, int number)
208 {
209 throw new System.NotImplementedException ();
210 }
211
212 public void SetMinEventDelay(UUID itemID, double delay)
213 {
214 throw new System.NotImplementedException ();
215 }
216
217 public int GetStartParameter(UUID itemID)
218 {
219 throw new System.NotImplementedException ();
220 }
221
222 public void SetScriptState(UUID itemID, bool state)
223 {
224 throw new System.NotImplementedException ();
225 }
226
227 public void SetState(UUID itemID, string newState)
228 {
229 throw new System.NotImplementedException ();
230 }
231
232 public void ApiResetScript(UUID itemID)
233 {
234 throw new System.NotImplementedException ();
235 }
236
237 public void ResetScript (UUID itemID)
238 {
239 throw new System.NotImplementedException ();
240 }
241
242 public IScriptApi GetApi(UUID itemID, string name)
243 {
244 throw new System.NotImplementedException ();
245 }
246
247 public Scene World { get { return m_scene; } }
248
249 public IScriptModule ScriptModule { get { return this; } }
250
251 public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
252
253 public string ScriptClassName { get { throw new System.NotImplementedException (); } }
254
255 public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } }
256
257 public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
258
259 public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
260
261 public void ClearPostedEvents()
262 {
263 PostedEvents.Clear();
264 }
265 }
266} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 2714429..07de06c 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -46,8 +46,6 @@ namespace OpenSim.Tests.Common.Mock
46 46
47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); 47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
48 48
49 private TestClient TeleportSceneClient;
50
51 private Scene m_scene; 49 private Scene m_scene;
52 private SceneManager m_sceneManager; 50 private SceneManager m_sceneManager;
53 51
@@ -60,6 +58,10 @@ namespace OpenSim.Tests.Common.Mock
60 public List<ImagePacketPacket> SentImagePacketPackets { get; private set; } 58 public List<ImagePacketPacket> SentImagePacketPackets { get; private set; }
61 public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; } 59 public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; }
62 60
61 // Test client specific events - for use by tests to implement some IClientAPI behaviour.
62 public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion;
63 public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour;
64
63// disable warning: public events, part of the public API 65// disable warning: public events, part of the public API
64#pragma warning disable 67 66#pragma warning disable 67
65 67
@@ -548,12 +550,12 @@ namespace OpenSim.Tests.Common.Mock
548 550
549 } 551 }
550 552
551 public void SendGenericMessage(string method, List<string> message) 553 public void SendGenericMessage(string method, UUID invoice, List<string> message)
552 { 554 {
553 555
554 } 556 }
555 557
556 public void SendGenericMessage(string method, List<byte[]> message) 558 public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
557 { 559 {
558 560
559 } 561 }
@@ -575,6 +577,8 @@ namespace OpenSim.Tests.Common.Mock
575 577
576 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 578 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
577 { 579 {
580 if (OnReceivedMoveAgentIntoRegion != null)
581 OnReceivedMoveAgentIntoRegion(regInfo, pos, look);
578 } 582 }
579 583
580 public virtual AgentCircuitData RequestClientInfo() 584 public virtual AgentCircuitData RequestClientInfo()
@@ -600,23 +604,8 @@ namespace OpenSim.Tests.Common.Mock
600 604
601 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) 605 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
602 { 606 {
603 m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); 607 if (OnTestClientInformClientOfNeighbour != null)
604 608 OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint);
605 // In response to this message, we are going to make a teleport to the scene we've previous been told
606 // about by test code (this needs to be improved).
607 AgentCircuitData newAgent = RequestClientInfo();
608
609 // Stage 2: add the new client as a child agent to the scene
610 uint x, y;
611 Utils.LongToUInts(neighbourHandle, out x, out y);
612 x /= Constants.RegionSize;
613 y /= Constants.RegionSize;
614
615 Scene neighbourScene;
616 m_sceneManager.TryGetScene(x, y, out neighbourScene);
617
618 TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager);
619 neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User);
620 } 609 }
621 610
622 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, 611 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
@@ -631,12 +620,6 @@ namespace OpenSim.Tests.Common.Mock
631 // CompleteTeleportClientSide(); 620 // CompleteTeleportClientSide();
632 } 621 }
633 622
634 public void CompleteTeleportClientSide()
635 {
636 TeleportSceneClient.CompleteMovement();
637 //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false);
638 }
639
640 public virtual void SendTeleportFailed(string reason) 623 public virtual void SendTeleportFailed(string reason)
641 { 624 {
642 m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); 625 m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason);
diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
new file mode 100644
index 0000000..6707019
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
@@ -0,0 +1,178 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Threading;
34using log4net;
35using Nini.Config;
36using Mono.Addins;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43
44namespace OpenSim.Tests.Common
45{
46 public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule
47 {
48 public class Event
49 {
50 public string Name { get; set; }
51 public object[] Args { get; set; }
52
53 public Event(string name, object[] args)
54 {
55 name = Name;
56 args = Args;
57 }
58 }
59
60 public Dictionary<UUID, List<Event>> Events { get; set; }
61
62 public void Initialise(IConfigSource source) {}
63
64 public void Close() {}
65
66 public void AddRegion(Scene scene)
67 {
68 Events = new Dictionary<UUID, List<Event>>();
69 scene.RegisterModuleInterface<IEventQueue>(this);
70 }
71
72 public void RemoveRegion (Scene scene) {}
73
74 public void RegionLoaded (Scene scene) {}
75
76 public string Name { get { return "TestEventQueueGetModule"; } }
77
78 public Type ReplaceableInterface { get { return null; } }
79
80 private void AddEvent(UUID avatarID, string name, params object[] args)
81 {
82 Console.WriteLine("Adding event {0} for {1}", name, avatarID);
83
84 List<Event> avEvents;
85
86 if (!Events.ContainsKey(avatarID))
87 {
88 avEvents = new List<Event>();
89 Events[avatarID] = avEvents;
90 }
91 else
92 {
93 avEvents = Events[avatarID];
94 }
95
96 avEvents.Add(new Event(name, args));
97 }
98
99 public void ClearEvents()
100 {
101 if (Events != null)
102 Events.Clear();
103 }
104
105 public bool Enqueue(OSD o, UUID avatarID)
106 {
107 AddEvent(avatarID, "Enqueue", o);
108 return true;
109 }
110
111 public void DisableSimulator(ulong handle, UUID avatarID)
112 {
113 AddEvent(avatarID, "DisableSimulator", handle);
114 }
115
116 public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID)
117 {
118 AddEvent(avatarID, "EnableSimulator", handle);
119 }
120
121 public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath)
122 {
123 AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
124 }
125
126 public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, UUID agentID)
127 {
128 AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
129 }
130
131 public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL, UUID avatarID, UUID sessionID)
132 {
133 AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
134 }
135
136 public void ChatterboxInvitation(
137 UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
138 byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
139 UUID transactionID, bool fromGroup, byte[] binaryBucket)
140 {
141 AddEvent(
142 toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
143 timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
144 }
145
146 public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute)
147 {
148 AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute);
149 }
150
151 public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
152 {
153 AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
154 }
155
156 public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID)
157 {
158 AddEvent(avatarID, "GroupMembership", groupUpdate);
159 }
160
161 public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono)
162 {
163 Console.WriteLine("ONE");
164 throw new System.NotImplementedException ();
165 }
166
167 public OSD BuildEvent (string eventName, OSD eventBody)
168 {
169 Console.WriteLine("TWO");
170 throw new System.NotImplementedException ();
171 }
172
173 public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
174 {
175 AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
176 }
177 }
178} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
index 4b4d52d..3115035 100644
--- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs
+++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
@@ -81,6 +81,11 @@ namespace OpenSim.Tests.Common.Mock
81 return obj; 81 return obj;
82 } 82 }
83 83
84 public ILandObject GetLandObject(Vector3 position)
85 {
86 return GetLandObject(position.X, position.Y);
87 }
88
84 public ILandObject GetLandObject(int x, int y) 89 public ILandObject GetLandObject(int x, int y)
85 { 90 {
86 return GetNoLand(); 91 return GetNoLand();
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index d4b5648..a7e0dfb 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -41,10 +41,9 @@ namespace OpenSim.Tests.Common.Mock
41 public TestScene( 41 public TestScene(
42 RegionInfo regInfo, AgentCircuitManager authen, 42 RegionInfo regInfo, AgentCircuitManager authen,
43 SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, 43 SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService,
44 bool dumpAssetsToFile,
45 IConfigSource config, string simulatorVersion) 44 IConfigSource config, string simulatorVersion)
46 : base(regInfo, authen, sceneGridService, simDataService, estateDataService, 45 : base(regInfo, authen, sceneGridService, simDataService, estateDataService,
47 dumpAssetsToFile, config, simulatorVersion) 46 config, simulatorVersion)
48 { 47 {
49 } 48 }
50 49
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;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Data; 35using OpenSim.Data;
36using OpenSim.Data.Null;
36 37
37namespace OpenSim.Tests.Common.Mock 38namespace OpenSim.Tests.Common.Mock
38{ 39{
39 public class TestXInventoryDataPlugin : IXInventoryData 40 public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData
40 { 41 {
41 private Dictionary<UUID, XInventoryFolder> m_allFolders = new Dictionary<UUID, XInventoryFolder>(); 42 private Dictionary<UUID, XInventoryFolder> m_allFolders = new Dictionary<UUID, XInventoryFolder>();
42 private Dictionary<UUID, XInventoryItem> m_allItems = new Dictionary<UUID, XInventoryItem>(); 43 private Dictionary<UUID, XInventoryItem> m_allItems = new Dictionary<UUID, XInventoryItem>();
@@ -58,28 +59,6 @@ namespace OpenSim.Tests.Common.Mock
58 return origFolders.Select(f => f.Clone()).ToArray(); 59 return origFolders.Select(f => f.Clone()).ToArray();
59 } 60 }
60 61
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) 62 public bool StoreFolder(XInventoryFolder folder)
84 { 63 {
85 m_allFolders[folder.folderID] = folder.Clone(); 64 m_allFolders[folder.folderID] = folder.Clone();
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs
index 57da802..a684d72 100644
--- a/OpenSim/Tests/Common/TestHelpers.cs
+++ b/OpenSim/Tests/Common/TestHelpers.cs
@@ -114,6 +114,27 @@ namespace OpenSim.Tests.Common
114 } 114 }
115 115
116 /// <summary> 116 /// <summary>
117 /// Parse a UUID stem into a full UUID.
118 /// </summary>
119 /// <remarks>
120 /// Yes, this is completely inconsistent with ParseTail but this is probably a better way to do it,
121 /// UUIDs are conceptually not hexadecmial numbers.
122 /// The fragment will come at the start of the UUID. The rest will be 0s
123 /// </remarks>
124 /// <returns></returns>
125 /// <param name='frag'>
126 /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain
127 /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is
128 /// given as the 'fragment'.
129 /// </param>
130 public static UUID ParseStem(string stem)
131 {
132 string rawUuid = stem.PadRight(32, '0');
133
134 return UUID.Parse(rawUuid);
135 }
136
137 /// <summary>
117 /// Parse tail section into full UUID. 138 /// Parse tail section into full UUID.
118 /// </summary> 139 /// </summary>
119 /// <param name="tail"></param> 140 /// <param name="tail"></param>