aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Tests/Common
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r--OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs1
-rw-r--r--OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs95
-rw-r--r--OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs123
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs139
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs121
-rw-r--r--OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs2
-rw-r--r--OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs142
-rw-r--r--OpenSim/Tests/Common/Mock/BaseAssetRepository.cs11
-rw-r--r--OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs178
-rw-r--r--OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs29
-rw-r--r--OpenSim/Tests/Common/Mock/MockScriptEngine.cs272
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs179
-rw-r--r--OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs182
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpClientContext.cs110
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpRequest.cs174
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpResponse.cs171
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs4
-rw-r--r--OpenSim/Tests/Common/Mock/TestLLUDPServer.cs171
-rw-r--r--OpenSim/Tests/Common/Mock/TestLandChannel.cs7
-rw-r--r--OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs15
-rw-r--r--OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs51
-rw-r--r--OpenSim/Tests/Common/OpenSimTestCase.cs15
-rw-r--r--OpenSim/Tests/Common/TestHelpers.cs38
26 files changed, 2011 insertions, 225 deletions
diff --git a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs
index 49c99c5..82ecf9a 100644
--- a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs
@@ -32,7 +32,6 @@ using NUnit.Framework;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Servers; 33using OpenSim.Framework.Servers;
34using OpenSim.Framework.Servers.HttpServer; 34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Tests.Common.Mock;
36 35
37namespace OpenSim.Tests.Common 36namespace OpenSim.Tests.Common
38{ 37{
diff --git a/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs
new file mode 100644
index 0000000..33cd8a2
--- /dev/null
+++ b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs
@@ -0,0 +1,95 @@
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.Net;
30using Nini.Config;
31using OpenMetaverse;
32using OpenMetaverse.Packets;
33using OpenSim.Framework;
34using OpenSim.Region.ClientStack.LindenUDP;
35using OpenSim.Region.Framework.Scenes;
36
37namespace OpenSim.Tests.Common
38{
39 /// <summary>
40 /// This class adds full UDP client classes and associated scene presence to scene.
41 /// </summary>
42 /// <remarks>
43 /// This is used for testing client stack code. For testing other code, use SceneHelper methods instead since
44 /// they operate without the burden of setting up UDP structures which should be unnecessary for testing scene
45 /// code.
46 /// </remarks>
47 public static class ClientStackHelpers
48 {
49 public static ScenePresence AddChildClient(
50 Scene scene, LLUDPServer udpServer, UUID agentId, UUID sessionId, uint circuitCode)
51 {
52 IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
53
54 UseCircuitCodePacket uccp = new UseCircuitCodePacket();
55
56 UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
57 = new UseCircuitCodePacket.CircuitCodeBlock();
58 uccpCcBlock.Code = circuitCode;
59 uccpCcBlock.ID = agentId;
60 uccpCcBlock.SessionID = sessionId;
61 uccp.CircuitCode = uccpCcBlock;
62
63 byte[] uccpBytes = uccp.ToBytes();
64 UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length);
65 upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor.
66 Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length);
67
68 AgentCircuitData acd = new AgentCircuitData();
69 acd.AgentID = agentId;
70 acd.SessionID = sessionId;
71
72 scene.AuthenticateHandler.AddNewCircuit(circuitCode, acd);
73
74 udpServer.PacketReceived(upb);
75
76 return scene.GetScenePresence(agentId);
77 }
78
79 public static TestLLUDPServer AddUdpServer(Scene scene)
80 {
81 return AddUdpServer(scene, new IniConfigSource());
82 }
83
84 public static TestLLUDPServer AddUdpServer(Scene scene, IniConfigSource configSource)
85 {
86 uint port = 0;
87 AgentCircuitManager acm = scene.AuthenticateHandler;
88
89 TestLLUDPServer udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm);
90 udpServer.AddScene(scene);
91
92 return udpServer;
93 }
94 }
95} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
new file mode 100644
index 0000000..b215f1e
--- /dev/null
+++ b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
@@ -0,0 +1,123 @@
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 System.Threading;
35using log4net;
36using Nini.Config;
37using NUnit.Framework;
38using OpenMetaverse;
39using OpenSim.Framework;
40
41using OpenSim.Framework.Servers;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.CoreModules.Framework;
45using OpenSim.Tests.Common;
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 SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
63 TestClient tc, List<TestClient> neighbourTcs)
64 {
65 // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the
66 // event queue).
67
68 tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) =>
69 {
70 uint x, y;
71 Util.RegionHandleToRegionLoc(neighbourHandle, out x, out y);
72
73 m_log.DebugFormat(
74 "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}",
75 x, y, neighbourExternalEndPoint);
76
77 AgentCircuitData newAgent = tc.RequestClientInfo();
78
79 Scene neighbourScene;
80 SceneManager.Instance.TryGetScene(x, y, out neighbourScene);
81
82 TestClient neighbourTc = new TestClient(newAgent, neighbourScene);
83 neighbourTcs.Add(neighbourTc);
84 neighbourScene.AddNewAgent(neighbourTc, PresenceType.User);
85 };
86 }
87
88 /// <summary>
89 /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
90 /// viewer to setup a connection with the destination region.
91 /// </summary>
92 /// <param name='tc'></param>
93 /// <param name='neighbourTcs'>
94 /// A list that will be populated with any TestClients set up in response to
95 /// being informed about a destination region.
96 /// </param>
97 public static void SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
98 TestClient client, List<TestClient> destinationClients)
99 {
100 client.OnTestClientSendRegionTeleport
101 += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) =>
102 {
103 uint x, y;
104 Util.RegionHandleToRegionLoc(regionHandle, out x, out y);
105
106 m_log.DebugFormat(
107 "[TEST CLIENT]: Processing send region teleport for destination at {0},{1} at {2}",
108 x, y, regionExternalEndPoint);
109
110 AgentCircuitData newAgent = client.RequestClientInfo();
111
112 Scene destinationScene;
113 SceneManager.Instance.TryGetScene(x, y, out destinationScene);
114
115 TestClient destinationClient = new TestClient(newAgent, destinationScene);
116 destinationClients.Add(destinationClient);
117 destinationScene.AddNewAgent(destinationClient, PresenceType.User);
118
119 ThreadPool.UnsafeQueueUserWorkItem(o => destinationClient.CompleteMovement(), null);
120 };
121 }
122 }
123} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index ea3e348..df8b14c 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -30,12 +30,13 @@ using System.Net;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using Nini.Config; 31using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Data.Null;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Framework.Communications; 35
35using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
37using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.PhysicsModules.SharedBase;
39using OpenSim.Region.Framework; 40using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
@@ -47,8 +48,8 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
47using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; 48using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
48using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; 49using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
49using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; 50using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
51using OpenSim.Region.PhysicsModule.BasicPhysics;
50using OpenSim.Services.Interfaces; 52using OpenSim.Services.Interfaces;
51using OpenSim.Tests.Common.Mock;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion; 53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
53 54
54namespace OpenSim.Tests.Common 55namespace OpenSim.Tests.Common
@@ -63,9 +64,9 @@ namespace OpenSim.Tests.Common
63 /// </summary> 64 /// </summary>
64 public SceneManager SceneManager { get; private set; } 65 public SceneManager SceneManager { get; private set; }
65 66
67 public ISimulationDataService SimDataService { get; private set; }
68
66 private AgentCircuitManager m_acm = new AgentCircuitManager(); 69 private AgentCircuitManager m_acm = new AgentCircuitManager();
67 private ISimulationDataService m_simDataService
68 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
69 private IEstateDataService m_estateDataService = null; 70 private IEstateDataService m_estateDataService = null;
70 71
71 private LocalAssetServicesConnector m_assetService; 72 private LocalAssetServicesConnector m_assetService;
@@ -77,6 +78,8 @@ namespace OpenSim.Tests.Common
77 78
78 private CoreAssetCache m_cache; 79 private CoreAssetCache m_cache;
79 80
81 private PhysicsScene m_physicsScene;
82
80 public SceneHelpers() : this(null) {} 83 public SceneHelpers() : this(null) {}
81 84
82 public SceneHelpers(CoreAssetCache cache) 85 public SceneHelpers(CoreAssetCache cache)
@@ -96,6 +99,11 @@ namespace OpenSim.Tests.Common
96 m_presenceService.PostInitialise(); 99 m_presenceService.PostInitialise();
97 100
98 m_cache = cache; 101 m_cache = cache;
102
103 m_physicsScene = StartPhysicsScene();
104
105 SimDataService
106 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
99 } 107 }
100 108
101 /// <summary> 109 /// <summary>
@@ -115,6 +123,11 @@ namespace OpenSim.Tests.Common
115 return SetupScene(name, id, x, y, new IniConfigSource()); 123 return SetupScene(name, id, x, y, new IniConfigSource());
116 } 124 }
117 125
126 public TestScene SetupScene(string name, UUID id, uint x, uint y, IConfigSource configSource)
127 {
128 return SetupScene(name, id, x, y, Constants.RegionSize, Constants.RegionSize, configSource);
129 }
130
118 /// <summary> 131 /// <summary>
119 /// Set up a scene. 132 /// Set up a scene.
120 /// </summary> 133 /// </summary>
@@ -122,10 +135,12 @@ namespace OpenSim.Tests.Common
122 /// <param name="id">ID of the region</param> 135 /// <param name="id">ID of the region</param>
123 /// <param name="x">X co-ordinate of the region</param> 136 /// <param name="x">X co-ordinate of the region</param>
124 /// <param name="y">Y co-ordinate of the region</param> 137 /// <param name="y">Y co-ordinate of the region</param>
138 /// <param name="sizeX">X size of scene</param>
139 /// <param name="sizeY">Y size of scene</param>
125 /// <param name="configSource"></param> 140 /// <param name="configSource"></param>
126 /// <returns></returns> 141 /// <returns></returns>
127 public TestScene SetupScene( 142 public TestScene SetupScene(
128 string name, UUID id, uint x, uint y, IConfigSource configSource) 143 string name, UUID id, uint x, uint y, uint sizeX, uint sizeY, IConfigSource configSource)
129 { 144 {
130 Console.WriteLine("Setting up test scene {0}", name); 145 Console.WriteLine("Setting up test scene {0}", name);
131 146
@@ -135,16 +150,20 @@ namespace OpenSim.Tests.Common
135 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); 150 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
136 regInfo.RegionName = name; 151 regInfo.RegionName = name;
137 regInfo.RegionID = id; 152 regInfo.RegionID = id;
138 153 regInfo.RegionSizeX = sizeX;
139 SceneCommunicationService scs = new SceneCommunicationService(); 154 regInfo.RegionSizeY = sizeY;
140 155
141 TestScene testScene = new TestScene( 156 TestScene testScene = new TestScene(
142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, false, configSource, null); 157 regInfo, m_acm, SimDataService, m_estateDataService, configSource, null);
143 158
144 INonSharedRegionModule godsModule = new GodsModule(); 159 INonSharedRegionModule godsModule = new GodsModule();
145 godsModule.Initialise(new IniConfigSource()); 160 godsModule.Initialise(new IniConfigSource());
146 godsModule.AddRegion(testScene); 161 godsModule.AddRegion(testScene);
147 162
163 // Add scene to physics
164 ((INonSharedRegionModule)m_physicsScene).AddRegion(testScene);
165 ((INonSharedRegionModule)m_physicsScene).RegionLoaded(testScene);
166
148 // Add scene to services 167 // Add scene to services
149 m_assetService.AddRegion(testScene); 168 m_assetService.AddRegion(testScene);
150 169
@@ -182,12 +201,7 @@ namespace OpenSim.Tests.Common
182 testScene.SetModuleInterfaces(); 201 testScene.SetModuleInterfaces();
183 202
184 testScene.LandChannel = new TestLandChannel(testScene); 203 testScene.LandChannel = new TestLandChannel(testScene);
185 testScene.LoadWorldMap(); 204 testScene.LoadWorldMap();
186
187 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
188 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
189 testScene.PhysicsScene
190 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
191 205
192 testScene.RegionInfo.EstateSettings = new EstateSettings(); 206 testScene.RegionInfo.EstateSettings = new EstateSettings();
193 testScene.LoginsEnabled = true; 207 testScene.LoginsEnabled = true;
@@ -297,6 +311,11 @@ namespace OpenSim.Tests.Common
297 /// <param name="testScene"></param> 311 /// <param name="testScene"></param>
298 private static LocalPresenceServicesConnector StartPresenceService() 312 private static LocalPresenceServicesConnector StartPresenceService()
299 { 313 {
314 // Unfortunately, some services share data via statics, so we need to null every time to stop interference
315 // between tests.
316 // This is a massive non-obvious pita.
317 NullPresenceData.Instance = null;
318
300 IConfigSource config = new IniConfigSource(); 319 IConfigSource config = new IniConfigSource();
301 config.AddConfig("Modules"); 320 config.AddConfig("Modules");
302 config.AddConfig("PresenceService"); 321 config.AddConfig("PresenceService");
@@ -311,6 +330,19 @@ namespace OpenSim.Tests.Common
311 return presenceService; 330 return presenceService;
312 } 331 }
313 332
333 private static PhysicsScene StartPhysicsScene()
334 {
335 IConfigSource config = new IniConfigSource();
336 config.AddConfig("Startup");
337 config.Configs["Startup"].Set("physics", "basicphysics");
338
339 PhysicsScene pScene = new BasicScene();
340 INonSharedRegionModule mod = pScene as INonSharedRegionModule;
341 mod.Initialise(config);
342
343 return pScene;
344 }
345
314 /// <summary> 346 /// <summary>
315 /// Setup modules for a scene using their default settings. 347 /// Setup modules for a scene using their default settings.
316 /// </summary> 348 /// </summary>
@@ -447,9 +479,6 @@ namespace OpenSim.Tests.Common
447 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test 479 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
448 /// </summary> 480 /// </summary>
449 /// <remarks> 481 /// <remarks>
450 /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
451 /// and teleport doesn't take place.
452 ///
453 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will 482 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
454 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. 483 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
455 /// </remarks> 484 /// </remarks>
@@ -462,22 +491,6 @@ namespace OpenSim.Tests.Common
462 } 491 }
463 492
464 /// <summary> 493 /// <summary>
465 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
466 /// </summary>
467 /// <remarks>
468 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
469 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
470 /// </remarks>
471 /// <param name="scene"></param>
472 /// <param name="agentId"></param>
473 /// <param name="sceneManager"></param>
474 /// <returns></returns>
475 public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager)
476 {
477 return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
478 }
479
480 /// <summary>
481 /// Add a root agent. 494 /// Add a root agent.
482 /// </summary> 495 /// </summary>
483 /// <param name="scene"></param> 496 /// <param name="scene"></param>
@@ -508,7 +521,7 @@ namespace OpenSim.Tests.Common
508 /// <returns></returns> 521 /// <returns></returns>
509 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) 522 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
510 { 523 {
511 return AddScenePresence(scene, agentData, null); 524 return AddScenePresence(scene, new TestClient(agentData, scene), agentData);
512 } 525 }
513 526
514 /// <summary> 527 /// <summary>
@@ -528,9 +541,9 @@ namespace OpenSim.Tests.Common
528 /// </remarks> 541 /// </remarks>
529 /// <param name="scene"></param> 542 /// <param name="scene"></param>
530 /// <param name="agentData"></param> 543 /// <param name="agentData"></param>
531 /// <param name="sceneManager"></param>
532 /// <returns></returns> 544 /// <returns></returns>
533 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) 545 public static ScenePresence AddScenePresence(
546 Scene scene, IClientAPI client, AgentCircuitData agentData)
534 { 547 {
535 // We emulate the proper login sequence here by doing things in four stages 548 // We emulate the proper login sequence here by doing things in four stages
536 549
@@ -541,7 +554,7 @@ namespace OpenSim.Tests.Common
541 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); 554 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
542 555
543 // Stages 1 & 2 556 // Stages 1 & 2
544 ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin); 557 ScenePresence sp = IntroduceClientToScene(scene, client, agentData, TeleportFlags.ViaLogin);
545 558
546 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. 559 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
547 sp.CompleteMovement(sp.ControllingClient, true); 560 sp.CompleteMovement(sp.ControllingClient, true);
@@ -553,37 +566,37 @@ namespace OpenSim.Tests.Common
553 /// Introduce an agent into the scene by adding a new client. 566 /// Introduce an agent into the scene by adding a new client.
554 /// </summary> 567 /// </summary>
555 /// <returns>The scene presence added</returns> 568 /// <returns>The scene presence added</returns>
556 /// <param name='sceneManager'>
557 /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not
558 /// neighbours and where no teleporting takes place.
559 /// </param>
560 /// <param name='scene'></param> 569 /// <param name='scene'></param>
561 /// <param name='sceneManager></param> 570 /// <param name='testClient'></param>
562 /// <param name='agentData'></param> 571 /// <param name='agentData'></param>
563 /// <param name='tf'></param> 572 /// <param name='tf'></param>
564 private static ScenePresence IntroduceClientToScene( 573 private static ScenePresence IntroduceClientToScene(
565 Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf) 574 Scene scene, IClientAPI client, AgentCircuitData agentData, TeleportFlags tf)
566 { 575 {
567 string reason; 576 string reason;
568 577
569 // Stage 1: tell the scene to expect a new user connection 578 // Stage 1: tell the scene to expect a new user connection
570 if (!scene.NewUserConnection(agentData, (uint)tf, out reason)) 579 if (!scene.NewUserConnection(agentData, (uint)tf, null, out reason))
571 Console.WriteLine("NewUserConnection failed: " + reason); 580 Console.WriteLine("NewUserConnection failed: " + reason);
572 581
573 // Stage 2: add the new client as a child agent to the scene 582 // Stage 2: add the new client as a child agent to the scene
574 TestClient client = new TestClient(agentData, scene, sceneManager); 583 scene.AddNewAgent(client, PresenceType.User);
575 scene.AddNewClient(client, PresenceType.User);
576 584
577 return scene.GetScenePresence(agentData.AgentID); 585 return scene.GetScenePresence(client.AgentId);
578 } 586 }
579 587
580 public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) 588 public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId)
581 { 589 {
582 AgentCircuitData acd = GenerateAgentData(agentId); 590 return AddChildScenePresence(scene, GenerateAgentData(agentId));
591 }
592
593 public static ScenePresence AddChildScenePresence(Scene scene, AgentCircuitData acd)
594 {
583 acd.child = true; 595 acd.child = true;
584 596
585 // XXX: ViaLogin may not be correct for child agents 597 // XXX: ViaLogin may not be correct for child agents
586 return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin); 598 TestClient client = new TestClient(acd, scene);
599 return IntroduceClientToScene(scene, client, acd, TeleportFlags.ViaLogin);
587 } 600 }
588 601
589 /// <summary> 602 /// <summary>
@@ -610,6 +623,32 @@ namespace OpenSim.Tests.Common
610 //part.UpdatePrimFlags(false, false, true); 623 //part.UpdatePrimFlags(false, false, true);
611 //part.ObjectFlags |= (uint)PrimFlags.Phantom; 624 //part.ObjectFlags |= (uint)PrimFlags.Phantom;
612 625
626 scene.AddNewSceneObject(so, true);
627
628 return so;
629 }
630
631 /// <summary>
632 /// Add a test object
633 /// </summary>
634 /// <param name="scene"></param>
635 /// <param name="parts">
636 /// The number of parts that should be in the scene object
637 /// </param>
638 /// <param name="ownerId"></param>
639 /// <param name="partNamePrefix">
640 /// The prefix to be given to part names. This will be suffixed with "Part<part no>"
641 /// (e.g. mynamePart1 for the root part)
642 /// </param>
643 /// <param name="uuidTail">
644 /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
645 /// will be given to the root part, and incremented for each part thereafter.
646 /// </param>
647 /// <returns></returns>
648 public static SceneObjectGroup AddSceneObject(Scene scene, int parts, UUID ownerId, string partNamePrefix, int uuidTail)
649 {
650 SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail);
651
613 scene.AddNewSceneObject(so, false); 652 scene.AddNewSceneObject(so, false);
614 653
615 return so; 654 return so;
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
index 0a2b30a..3a3b33a 100644
--- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -43,21 +43,40 @@ namespace OpenSim.Tests.Common
43 /// <summary> 43 /// <summary>
44 /// Add a notecard item to the given part. 44 /// Add a notecard item to the given part.
45 /// </summary> 45 /// </summary>
46 /// <param name="scene"></param> 46 /// <param name="assetService"></param>
47 /// <param name="part"></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 IAssetService assetService, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text)
55 {
56 return AddNotecard(
57 assetService, 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="assetService"></param>
47 /// <param name="part"></param> 64 /// <param name="part"></param>
48 /// <param name="itemName"></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 IAssetService assetService, 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
59 = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); 78 = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero);
60 scene.AssetService.Store(ncAsset); 79 assetService.Store(ncAsset);
61 80
62 TaskInventoryItem ncItem 81 TaskInventoryItem ncItem
63 = new TaskInventoryItem 82 = new TaskInventoryItem
@@ -75,44 +94,62 @@ namespace OpenSim.Tests.Common
75 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these 94 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
76 /// functions more than once in a test. 95 /// functions more than once in a test.
77 /// </remarks> 96 /// </remarks>
78 /// <param name="scene"></param> 97 /// <param name="assetService"></param>
79 /// <param name="part"></param> 98 /// <param name="part"></param>
80 /// <returns>The item that was added</returns> 99 /// <returns>The item that was added</returns>
81 public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) 100 public static TaskInventoryItem AddScript(IAssetService assetService, SceneObjectPart part)
82 { 101 {
83 return AddScript(scene, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }"); 102 return AddScript(assetService, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }");
84 } 103 }
85 104
86 /// <summary> 105 /// <summary>
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.
111 /// </remarks>
112 /// <param name="assetService"></param>
113 /// <param name="part"></param>
114 /// <param name="scriptName">Name of the script to add</param>
115 /// <param name="scriptSource">LSL script source</param>
116 /// <returns>The item that was added</returns>
117 public static TaskInventoryItem AddScript(
118 IAssetService assetService, SceneObjectPart part, string scriptName, string scriptSource)
119 {
120 return AddScript(assetService, part, UUID.Random(), UUID.Random(), scriptName, scriptSource);
121 }
122
123 /// <summary>
124 /// Add a simple script to the given part.
125 /// </summary>
126 /// <remarks>
127 /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather
128 /// than a random component.
92 /// </remarks> 129 /// </remarks>
93 /// <param name="scene"></param> 130 /// <param name="assetService"></param>
94 /// <param name="part"></param> 131 /// <param name="part"></param>
132 /// <param name="itemId">Item UUID for the script</param>
133 /// <param name="assetId">Asset UUID for the script</param>
95 /// <param name="scriptName">Name of the script to add</param> 134 /// <param name="scriptName">Name of the script to add</param>
96 /// <param name="scriptSource">LSL script source</param> 135 /// <param name="scriptSource">LSL script source</param>
97 /// <returns>The item that was added</returns> 136 /// <returns>The item that was added</returns>
98 public static TaskInventoryItem AddScript( 137 public static TaskInventoryItem AddScript(
99 Scene scene, SceneObjectPart part, string scriptName, string scriptSource) 138 IAssetService assetService, SceneObjectPart part, UUID itemId, UUID assetId, string scriptName, string scriptSource)
100 { 139 {
101 AssetScriptText ast = new AssetScriptText(); 140 AssetScriptText ast = new AssetScriptText();
102 ast.Source = scriptSource; 141 ast.Source = scriptSource;
103 ast.Encode(); 142 ast.Encode();
104 143
105 UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000");
106 UUID itemUuid = new UUID("00000000-0000-0000-1100-000000000000");
107 AssetBase asset 144 AssetBase asset
108 = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); 145 = AssetHelpers.CreateAsset(assetId, AssetType.LSLText, ast.AssetData, UUID.Zero);
109 scene.AssetService.Store(asset); 146 assetService.Store(asset);
110 TaskInventoryItem item 147 TaskInventoryItem item
111 = new TaskInventoryItem 148 = new TaskInventoryItem
112 { Name = scriptName, AssetID = assetUuid, ItemID = itemUuid, 149 { Name = scriptName, AssetID = assetId, ItemID = itemId,
113 Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; 150 Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL };
114 part.Inventory.AddInventoryItem(item, true); 151 part.Inventory.AddInventoryItem(item, true);
115 152
116 return item; 153 return item;
117 } 154 }
118 155
@@ -124,28 +161,50 @@ namespace OpenSim.Tests.Common
124 /// functions more than once in a test. 161 /// functions more than once in a test.
125 /// </remarks> 162 /// </remarks>
126 /// 163 ///
127 /// <param name="scene"></param> 164 /// <param name="assetService"></param>
128 /// <param name="sop"></param> 165 /// <param name="sop"></param>
129 /// <param name="itemName"></param> 166 /// <param name="itemName"></param>
130 /// <param name="id"></param> 167 /// <param name="itemId"></param>
131 /// <param name="userId"></param> 168 /// <param name="soToAdd"></param>
169 /// <param name="soAssetId"></param>
132 public static TaskInventoryItem AddSceneObject( 170 public static TaskInventoryItem AddSceneObject(
133 Scene scene, SceneObjectPart sop, string itemName, UUID id, UUID userId) 171 IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, SceneObjectGroup soToAdd, UUID soAssetId)
134 { 172 {
135 SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero); 173 AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(soAssetId, soToAdd);
136 AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); 174 assetService.Store(taskSceneObjectAsset);
137 scene.AssetService.Store(taskSceneObjectAsset);
138 TaskInventoryItem taskSceneObjectItem 175 TaskInventoryItem taskSceneObjectItem
139 = new TaskInventoryItem 176 = new TaskInventoryItem
140 { Name = itemName, 177 { Name = itemName,
141 AssetID = taskSceneObjectAsset.FullID, 178 AssetID = taskSceneObjectAsset.FullID,
142 ItemID = id, 179 ItemID = itemId,
143 OwnerID = userId, 180 OwnerID = soToAdd.OwnerID,
144 Type = (int)AssetType.Object, 181 Type = (int)AssetType.Object,
145 InvType = (int)InventoryType.Object }; 182 InvType = (int)InventoryType.Object };
146 sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); 183 sop.Inventory.AddInventoryItem(taskSceneObjectItem, true);
147 184
148 return taskSceneObjectItem; 185 return taskSceneObjectItem;
149 } 186 }
187
188 /// <summary>
189 /// Add a scene object item to the given part.
190 /// </summary>
191 /// <remarks>
192 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
193 /// functions more than once in a test.
194 /// </remarks>
195 ///
196 /// <param name="assetService"></param>
197 /// <param name="sop"></param>
198 /// <param name="itemName"></param>
199 /// <param name="id"></param>
200 /// <param name="userId"></param>
201 public static TaskInventoryItem AddSceneObject(
202 IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, UUID userId)
203 {
204 SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, userId);
205
206 return TaskInventoryHelpers.AddSceneObject(
207 assetService, sop, itemName, itemId, taskSceneObject, TestHelpers.ParseTail(0x10));
208 }
150 } 209 }
151} \ No newline at end of file 210} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
index 2fbebc4..c62b58e 100644
--- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
@@ -27,7 +27,7 @@
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Framework.Communications; 30
31using OpenSim.Region.Framework.Scenes; 31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Services.Interfaces; 32using OpenSim.Services.Interfaces;
33 33
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index 87d9410..5a36332 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, (FolderType)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,116 @@ 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)
220 {
221 return CreateInventoryFolder(inventoryService, userId, UUID.Random(), path, useExistingFolders);
222 }
223
224 /// <summary>
225 /// Create inventory folders starting from the user's root folder.
226 /// </summary>
227 /// <param name="inventoryService"></param>
228 /// <param name="userId"></param>
229 /// <param name="folderId"></param>
230 /// <param name="path">
231 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
232 /// </param>
233 /// <param name="useExistingFolders">
234 /// If true, then folders in the path which already the same name are
235 /// used. This applies to the terminal folder as well.
236 /// If false, then all folders in the path are created, even if there is already a folder at a particular
237 /// level with the same name.
238 /// </param>
239 /// <returns>
240 /// The folder created. If the path contains multiple folders then the last one created is returned.
241 /// Will return null if the root folder could not be found.
242 /// </returns>
243 public static InventoryFolderBase CreateInventoryFolder(
244 IInventoryService inventoryService, UUID userId, UUID folderId, string path, bool useExistingFolders)
173 { 245 {
174 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); 246 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
175 247
176 if (null == rootFolder) 248 if (null == rootFolder)
177 return null; 249 return null;
178 250
179 return CreateInventoryFolder(inventoryService, rootFolder, path); 251 return CreateInventoryFolder(inventoryService, folderId, rootFolder, path, useExistingFolders);
180 } 252 }
181 253
182 /// <summary> 254 /// <summary>
183 /// Create inventory folders starting from a given parent folder 255 /// Create inventory folders starting from a given parent folder
184 /// </summary> 256 /// </summary>
185 /// 257 /// <remarks>
186 /// Ignores any existing folders with the same name 258 /// If any stem of the path names folders that already exist then these are not recreated. This includes the
187 /// 259 /// final folder.
260 /// TODO: May need to make it an option to create duplicate folders.
261 /// </remarks>
188 /// <param name="inventoryService"></param> 262 /// <param name="inventoryService"></param>
263 /// <param name="folderId">ID of the folder to create</param>
189 /// <param name="parentFolder"></param> 264 /// <param name="parentFolder"></param>
190 /// <param name="path"> 265 /// <param name="path">
191 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER 266 /// The folder to create.
267 /// </param>
268 /// <param name="useExistingFolders">
269 /// If true, then folders in the path which already the same name are
270 /// used. This applies to the terminal folder as well.
271 /// If false, then all folders in the path are created, even if there is already a folder at a particular
272 /// level with the same name.
192 /// </param> 273 /// </param>
193 /// <returns> 274 /// <returns>
194 /// The folder created. If the path contains multiple folders then the last one created is returned. 275 /// The folder created. If the path contains multiple folders then the last one created is returned.
195 /// </returns> 276 /// </returns>
196 public static InventoryFolderBase CreateInventoryFolder( 277 public static InventoryFolderBase CreateInventoryFolder(
197 IInventoryService inventoryService, InventoryFolderBase parentFolder, string path) 278 IInventoryService inventoryService, UUID folderId, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
198 { 279 {
199 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); 280 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
200 281
201 InventoryFolderBase newFolder 282 InventoryFolderBase folder = null;
202 = new InventoryFolderBase( 283
203 UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0); 284 if (useExistingFolders)
204 285 folder = InventoryArchiveUtils.FindFolderByPath(inventoryService, parentFolder, components[0]);
205 inventoryService.AddFolder(newFolder); 286
287 if (folder == null)
288 {
289// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name);
290
291 UUID folderIdForCreate;
292
293 if (components.Length > 1)
294 folderIdForCreate = UUID.Random();
295 else
296 folderIdForCreate = folderId;
297
298 folder
299 = new InventoryFolderBase(
300 folderIdForCreate, components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
301
302 inventoryService.AddFolder(folder);
303 }
304// else
305// {
306// Console.WriteLine("Found existing folder {0}", folder.Name);
307// }
206 308
207 if (components.Length > 1) 309 if (components.Length > 1)
208 return CreateInventoryFolder(inventoryService, newFolder, components[1]); 310 return CreateInventoryFolder(inventoryService, folderId, folder, components[1], useExistingFolders);
209 else 311 else
210 return newFolder; 312 return folder;
211 } 313 }
212 314
213 /// <summary> 315 /// <summary>
@@ -237,7 +339,7 @@ namespace OpenSim.Tests.Common
237 /// <returns>An empty list if no matching folders were found</returns> 339 /// <returns>An empty list if no matching folders were found</returns>
238 public static List<InventoryFolderBase> GetInventoryFolders(IInventoryService inventoryService, UUID userId, string path) 340 public static List<InventoryFolderBase> GetInventoryFolders(IInventoryService inventoryService, UUID userId, string path)
239 { 341 {
240 return InventoryArchiveUtils.FindFolderByPath(inventoryService, userId, path); 342 return InventoryArchiveUtils.FindFoldersByPath(inventoryService, userId, path);
241 } 343 }
242 344
243 /// <summary> 345 /// <summary>
diff --git a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs
index cfefd38..cb4fb80 100644
--- a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs
+++ b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs
@@ -25,11 +25,12 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
30using OpenSim.Framework; 31using OpenSim.Framework;
31 32
32namespace OpenSim.Tests.Common.Mock 33namespace OpenSim.Tests.Common
33{ 34{
34 public class BaseAssetRepository 35 public class BaseAssetRepository
35 { 36 {
@@ -37,7 +38,7 @@ namespace OpenSim.Tests.Common.Mock
37 38
38 public AssetBase FetchAsset(UUID uuid) 39 public AssetBase FetchAsset(UUID uuid)
39 { 40 {
40 if (ExistsAsset(uuid)) 41 if (AssetsExist(new[] { uuid })[0])
41 return Assets[uuid]; 42 return Assets[uuid];
42 else 43 else
43 return null; 44 return null;
@@ -53,9 +54,9 @@ namespace OpenSim.Tests.Common.Mock
53 CreateAsset(asset); 54 CreateAsset(asset);
54 } 55 }
55 56
56 public bool ExistsAsset(UUID uuid) 57 public bool[] AssetsExist(UUID[] uuids)
57 { 58 {
58 return Assets.ContainsKey(uuid); 59 return Array.ConvertAll(uuids, id => Assets.ContainsKey(id));
59 } 60 }
60 } 61 }
61} \ No newline at end of file 62} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
index 4a15cf2..dddf75d 100644
--- a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
@@ -31,7 +31,7 @@ using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Data; 32using OpenSim.Data;
33 33
34namespace OpenSim.Tests.Common.Mock 34namespace OpenSim.Tests.Common
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the 37 /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the
diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
index 3035cea..7f530d0 100644
--- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
+++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
@@ -40,7 +40,7 @@ using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; 41using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
42 42
43namespace OpenSim.Tests.Common.Mock 43namespace OpenSim.Tests.Common
44{ 44{
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
46 public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector 46 public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector
@@ -138,33 +138,28 @@ namespace OpenSim.Tests.Common.Mock
138 { 138 {
139 } 139 }
140 140
141 private XGroup GetXGroup(UUID groupID, string name)
142 {
143 XGroup group = m_data.GetGroup(groupID);
144
145
146 if (group == null)
147 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID);
148
149 return group;
150 }
151
141 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) 152 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
142 { 153 {
143 m_log.DebugFormat( 154 m_log.DebugFormat(
144 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", 155 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}",
145 groupID, groupName); 156 groupID, groupName);
146 157
147 XGroup[] groups; 158 XGroup xg = GetXGroup(groupID, groupName);
148 string field, val;
149 159
150 if (groupID != UUID.Zero) 160 if (xg == null)
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; 161 return null;
165 162
166 XGroup xg = groups[0];
167
168 GroupRecord gr = new GroupRecord() 163 GroupRecord gr = new GroupRecord()
169 { 164 {
170 GroupID = xg.groupID, 165 GroupID = xg.groupID,
@@ -196,8 +191,25 @@ namespace OpenSim.Tests.Common.Mock
196 { 191 {
197 } 192 }
198 193
199 public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) 194 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
200 { 195 {
196 m_log.DebugFormat(
197 "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}",
198 requestingAgentID, agentID, groupID, acceptNotices, listInProfile);
199
200 XGroup group = GetXGroup(groupID, null);
201
202 if (group == null)
203 return;
204
205 XGroupMember xgm = null;
206 if (!group.members.TryGetValue(agentID, out xgm))
207 return;
208
209 xgm.acceptNotices = acceptNotices;
210 xgm.listInProfile = listInProfile;
211
212 m_data.StoreGroup(group);
201 } 213 }
202 214
203 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) 215 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
@@ -213,8 +225,27 @@ namespace OpenSim.Tests.Common.Mock
213 { 225 {
214 } 226 }
215 227
216 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) 228 public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
217 { 229 {
230 m_log.DebugFormat(
231 "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}",
232 requestingAgentID, agentID, groupID, roleID);
233
234 XGroup group = GetXGroup(groupID, null);
235
236 if (group == null)
237 return;
238
239 XGroupMember groupMember = new XGroupMember()
240 {
241 agentID = agentID,
242 groupID = groupID,
243 roleID = roleID
244 };
245
246 group.members[agentID] = groupMember;
247
248 m_data.StoreGroup(group);
218 } 249 }
219 250
220 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) 251 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
@@ -259,9 +290,31 @@ namespace OpenSim.Tests.Common.Mock
259 return null; 290 return null;
260 } 291 }
261 292
262 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) 293 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID groupID)
263 { 294 {
264 return null; 295 m_log.DebugFormat(
296 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupMembers, requestingAgentID {0}, groupID {1}",
297 requestingAgentID, groupID);
298
299 List<GroupMembersData> groupMembers = new List<GroupMembersData>();
300
301 XGroup group = GetXGroup(groupID, null);
302
303 if (group == null)
304 return groupMembers;
305
306 foreach (XGroupMember xgm in group.members.Values)
307 {
308 GroupMembersData gmd = new GroupMembersData();
309 gmd.AgentID = xgm.agentID;
310 gmd.IsOwner = group.founderID == gmd.AgentID;
311 gmd.AcceptNotices = xgm.acceptNotices;
312 gmd.ListInProfile = xgm.listInProfile;
313
314 groupMembers.Add(gmd);
315 }
316
317 return groupMembers;
265 } 318 }
266 319
267 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) 320 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
@@ -269,18 +322,93 @@ namespace OpenSim.Tests.Common.Mock
269 return null; 322 return null;
270 } 323 }
271 324
272 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) 325 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID groupID)
273 { 326 {
274 return null; 327 XGroup group = GetXGroup(groupID, null);
328
329 if (group == null)
330 return null;
331
332 List<GroupNoticeData> notices = new List<GroupNoticeData>();
333
334 foreach (XGroupNotice notice in group.notices.Values)
335 {
336 GroupNoticeData gnd = new GroupNoticeData()
337 {
338 NoticeID = notice.noticeID,
339 Timestamp = notice.timestamp,
340 FromName = notice.fromName,
341 Subject = notice.subject,
342 HasAttachment = notice.hasAttachment,
343 AssetType = (byte)notice.assetType
344 };
345
346 notices.Add(gnd);
347 }
348
349 return notices;
275 } 350 }
276 351
277 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) 352 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
278 { 353 {
354 m_log.DebugFormat(
355 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupNotices, requestingAgentID {0}, noticeID {1}",
356 requestingAgentID, noticeID);
357
358 // Yes, not an efficient way to do it.
359 Dictionary<UUID, XGroup> groups = m_data.GetGroups();
360
361 foreach (XGroup group in groups.Values)
362 {
363 if (group.notices.ContainsKey(noticeID))
364 {
365 XGroupNotice n = group.notices[noticeID];
366
367 GroupNoticeInfo gni = new GroupNoticeInfo();
368 gni.GroupID = n.groupID;
369 gni.Message = n.message;
370 gni.BinaryBucket = n.binaryBucket;
371 gni.noticeData.NoticeID = n.noticeID;
372 gni.noticeData.Timestamp = n.timestamp;
373 gni.noticeData.FromName = n.fromName;
374 gni.noticeData.Subject = n.subject;
375 gni.noticeData.HasAttachment = n.hasAttachment;
376 gni.noticeData.AssetType = (byte)n.assetType;
377
378 return gni;
379 }
380 }
381
279 return null; 382 return null;
280 } 383 }
281 384
282 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) 385 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
283 { 386 {
387 m_log.DebugFormat(
388 "[MOCK GROUPS SERVICES CONNECTOR]: AddGroupNotice, requestingAgentID {0}, groupID {1}, noticeID {2}, fromName {3}, subject {4}, message {5}, binaryBucket.Length {6}",
389 requestingAgentID, groupID, noticeID, fromName, subject, message, binaryBucket.Length);
390
391 XGroup group = GetXGroup(groupID, null);
392
393 if (group == null)
394 return;
395
396 XGroupNotice groupNotice = new XGroupNotice()
397 {
398 groupID = groupID,
399 noticeID = noticeID,
400 fromName = fromName,
401 subject = subject,
402 message = message,
403 timestamp = (uint)Util.UnixTimeSinceEpoch(),
404 hasAttachment = false,
405 assetType = 0,
406 binaryBucket = binaryBucket
407 };
408
409 group.notices[noticeID] = groupNotice;
410
411 m_data.StoreGroup(group);
284 } 412 }
285 413
286 public void ResetAgentGroupChatSessions(UUID agentID) 414 public void ResetAgentGroupChatSessions(UUID agentID)
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
index ed29c39..5df8e04 100644
--- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
@@ -69,11 +69,21 @@ namespace OpenSim.Data.Null
69 m_store.StoreTerrain(terrain, regionID); 69 m_store.StoreTerrain(terrain, regionID);
70 } 70 }
71 71
72 public void StoreTerrain(TerrainData terrain, UUID regionID)
73 {
74 m_store.StoreTerrain(terrain, regionID);
75 }
76
72 public double[,] LoadTerrain(UUID regionID) 77 public double[,] LoadTerrain(UUID regionID)
73 { 78 {
74 return m_store.LoadTerrain(regionID); 79 return m_store.LoadTerrain(regionID);
75 } 80 }
76 81
82 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
83 {
84 return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
85 }
86
77 public void StoreLandObject(ILandObject Parcel) 87 public void StoreLandObject(ILandObject Parcel)
78 { 88 {
79 m_store.StoreLandObject(Parcel); 89 m_store.StoreLandObject(Parcel);
@@ -154,7 +164,7 @@ namespace OpenSim.Data.Null
154 protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>(); 164 protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>();
155 protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems 165 protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems
156 = new Dictionary<UUID, ICollection<TaskInventoryItem>>(); 166 = new Dictionary<UUID, ICollection<TaskInventoryItem>>();
157 protected Dictionary<UUID, double[,]> m_terrains = new Dictionary<UUID, double[,]>(); 167 protected Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
158 protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>(); 168 protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>();
159 169
160 public void Initialise(string dbfile) 170 public void Initialise(string dbfile)
@@ -299,12 +309,17 @@ namespace OpenSim.Data.Null
299 return new List<SceneObjectGroup>(objects.Values); 309 return new List<SceneObjectGroup>(objects.Values);
300 } 310 }
301 311
302 public void StoreTerrain(double[,] ter, UUID regionID) 312 public void StoreTerrain(TerrainData ter, UUID regionID)
303 { 313 {
304 m_terrains[regionID] = ter; 314 m_terrains[regionID] = ter;
305 } 315 }
306 316
307 public double[,] LoadTerrain(UUID regionID) 317 public void StoreTerrain(double[,] ter, UUID regionID)
318 {
319 m_terrains[regionID] = new HeightmapTerrainData(ter);
320 }
321
322 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
308 { 323 {
309 if (m_terrains.ContainsKey(regionID)) 324 if (m_terrains.ContainsKey(regionID))
310 return m_terrains[regionID]; 325 return m_terrains[regionID];
@@ -312,6 +327,14 @@ namespace OpenSim.Data.Null
312 return null; 327 return null;
313 } 328 }
314 329
330 public double[,] LoadTerrain(UUID regionID)
331 {
332 if (m_terrains.ContainsKey(regionID))
333 return m_terrains[regionID].GetDoubles();
334 else
335 return null;
336 }
337
315 public void RemoveLandObject(UUID globalID) 338 public void RemoveLandObject(UUID globalID)
316 { 339 {
317 if (m_landData.ContainsKey(globalID)) 340 if (m_landData.ContainsKey(globalID))
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
new file mode 100644
index 0000000..d7a144c
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
@@ -0,0 +1,272 @@
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#pragma warning disable 0067
98 public event ScriptRemoved OnScriptRemoved;
99 public event ObjectRemoved OnObjectRemoved;
100#pragma warning restore 0067
101
102 public string GetXMLState (UUID itemID)
103 {
104 throw new System.NotImplementedException ();
105 }
106
107 public bool SetXMLState(UUID itemID, string xml)
108 {
109 throw new System.NotImplementedException ();
110 }
111
112 public bool PostScriptEvent(UUID itemID, string name, object[] args)
113 {
114// Console.WriteLine("Posting event {0} for {1}", name, itemID);
115
116 return PostScriptEvent(itemID, new EventParams(name, args, null));
117 }
118
119 public bool PostScriptEvent(UUID itemID, EventParams evParams)
120 {
121 List<EventParams> eventsForItem;
122
123 if (!PostedEvents.ContainsKey(itemID))
124 {
125 eventsForItem = new List<EventParams>();
126 PostedEvents.Add(itemID, eventsForItem);
127 }
128 else
129 {
130 eventsForItem = PostedEvents[itemID];
131 }
132
133 eventsForItem.Add(evParams);
134
135 if (PostEventHook != null)
136 PostEventHook(itemID, evParams);
137
138 return true;
139 }
140
141 public bool PostObjectEvent(uint localID, EventParams evParams)
142 {
143 return PostObjectEvent(m_scene.GetSceneObjectPart(localID), evParams);
144 }
145
146 public bool PostObjectEvent(UUID itemID, string name, object[] args)
147 {
148 return PostObjectEvent(m_scene.GetSceneObjectPart(itemID), new EventParams(name, args, null));
149 }
150
151 private bool PostObjectEvent(SceneObjectPart part, EventParams evParams)
152 {
153 foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems(InventoryType.LSL))
154 PostScriptEvent(item.ItemID, evParams);
155
156 return true;
157 }
158
159 public void SuspendScript(UUID itemID)
160 {
161 throw new System.NotImplementedException ();
162 }
163
164 public void ResumeScript(UUID itemID)
165 {
166 throw new System.NotImplementedException ();
167 }
168
169 public ArrayList GetScriptErrors(UUID itemID)
170 {
171 throw new System.NotImplementedException ();
172 }
173
174 public bool HasScript(UUID itemID, out bool running)
175 {
176 throw new System.NotImplementedException ();
177 }
178
179 public bool GetScriptState(UUID itemID)
180 {
181 throw new System.NotImplementedException ();
182 }
183
184 public void SaveAllState()
185 {
186 throw new System.NotImplementedException ();
187 }
188
189 public void StartProcessing()
190 {
191 throw new System.NotImplementedException ();
192 }
193
194 public float GetScriptExecutionTime(List<UUID> itemIDs)
195 {
196 throw new System.NotImplementedException ();
197 }
198
199 public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
200 {
201 throw new System.NotImplementedException ();
202 }
203
204 public IScriptWorkItem QueueEventHandler(object parms)
205 {
206 throw new System.NotImplementedException ();
207 }
208
209 public DetectParams GetDetectParams(UUID item, int number)
210 {
211 throw new System.NotImplementedException ();
212 }
213
214 public void SetMinEventDelay(UUID itemID, double delay)
215 {
216 throw new System.NotImplementedException ();
217 }
218
219 public int GetStartParameter(UUID itemID)
220 {
221 throw new System.NotImplementedException ();
222 }
223
224 public void SetScriptState(UUID itemID, bool state)
225 {
226 throw new System.NotImplementedException ();
227 }
228
229 public void SetState(UUID itemID, string newState)
230 {
231 throw new System.NotImplementedException ();
232 }
233
234 public void ApiResetScript(UUID itemID)
235 {
236 throw new System.NotImplementedException ();
237 }
238
239 public void ResetScript (UUID itemID)
240 {
241 throw new System.NotImplementedException ();
242 }
243
244 public IScriptApi GetApi(UUID itemID, string name)
245 {
246 throw new System.NotImplementedException ();
247 }
248
249 public Scene World { get { return m_scene; } }
250
251 public IScriptModule ScriptModule { get { return this; } }
252
253 public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
254
255 public string ScriptClassName { get { throw new System.NotImplementedException (); } }
256
257 public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } }
258
259 public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
260
261 public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
262
263 public void ClearPostedEvents()
264 {
265 PostedEvents.Clear();
266 }
267
268 public void SleepScript(UUID itemID, int delay)
269 {
270 }
271 }
272}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index dde37ab..0e1bc8f 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -38,7 +38,7 @@ using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Framework.Client; 39using OpenSim.Framework.Client;
40 40
41namespace OpenSim.Tests.Common.Mock 41namespace OpenSim.Tests.Common
42{ 42{
43 public class TestClient : IClientAPI, IClientCore 43 public class TestClient : IClientAPI, IClientCore
44 { 44 {
@@ -46,12 +46,10 @@ 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;
53 50
54 // Properties so that we can get at received data for test purposes 51 // Properties so that we can get at received data for test purposes
52 public List<uint> ReceivedKills { get; private set; }
55 public List<UUID> ReceivedOfflineNotifications { get; private set; } 53 public List<UUID> ReceivedOfflineNotifications { get; private set; }
56 public List<UUID> ReceivedOnlineNotifications { get; private set; } 54 public List<UUID> ReceivedOnlineNotifications { get; private set; }
57 public List<UUID> ReceivedFriendshipTerminations { get; private set; } 55 public List<UUID> ReceivedFriendshipTerminations { get; private set; }
@@ -60,6 +58,27 @@ 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 public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport;
65
66 public event Action<ISceneEntity, PrimUpdateFlags> OnReceivedEntityUpdate;
67
68 public event OnReceivedChatMessageDelegate OnReceivedChatMessage;
69 public event Action<GridInstantMessage> OnReceivedInstantMessage;
70
71 public event Action<UUID> OnReceivedSendRebakeAvatarTextures;
72
73 public delegate void TestClientOnSendRegionTeleportDelegate(
74 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
75 uint locationID, uint flags, string capsURL);
76
77 public delegate void OnReceivedChatMessageDelegate(
78 string message, byte type, Vector3 fromPos, string fromName,
79 UUID fromAgentID, UUID ownerID, byte source, byte audible);
80
81
63// disable warning: public events, part of the public API 82// disable warning: public events, part of the public API
64#pragma warning disable 67 83#pragma warning disable 67
65 84
@@ -103,6 +122,7 @@ namespace OpenSim.Tests.Common.Mock
103 public event Action<IClientAPI, bool> OnCompleteMovementToRegion; 122 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
104 public event UpdateAgent OnPreAgentUpdate; 123 public event UpdateAgent OnPreAgentUpdate;
105 public event UpdateAgent OnAgentUpdate; 124 public event UpdateAgent OnAgentUpdate;
125 public event UpdateAgent OnAgentCameraUpdate;
106 public event AgentRequestSit OnAgentRequestSit; 126 public event AgentRequestSit OnAgentRequestSit;
107 public event AgentSit OnAgentSit; 127 public event AgentSit OnAgentSit;
108 public event AvatarPickerRequest OnAvatarPickerRequest; 128 public event AvatarPickerRequest OnAvatarPickerRequest;
@@ -193,6 +213,7 @@ namespace OpenSim.Tests.Common.Mock
193 public event EstateCovenantRequest OnEstateCovenantRequest; 213 public event EstateCovenantRequest OnEstateCovenantRequest;
194 public event EstateChangeInfo OnEstateChangeInfo; 214 public event EstateChangeInfo OnEstateChangeInfo;
195 public event EstateManageTelehub OnEstateManageTelehub; 215 public event EstateManageTelehub OnEstateManageTelehub;
216 public event CachedTextureRequest OnCachedTextureRequest;
196 217
197 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; 218 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
198 219
@@ -430,33 +451,21 @@ namespace OpenSim.Tests.Common.Mock
430 /// <summary> 451 /// <summary>
431 /// Constructor 452 /// Constructor
432 /// </summary> 453 /// </summary>
433 /// <remarks>
434 /// Can be used for a test where there is only one region or where there are multiple regions that are not
435 /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a
436 /// scene manager should be used.
437 /// </remarks>
438 /// <param name="agentData"></param>
439 /// <param name="scene"></param>
440 public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {}
441
442 /// <summary>
443 /// Constructor
444 /// </summary>
445 /// <param name="agentData"></param> 454 /// <param name="agentData"></param>
446 /// <param name="scene"></param> 455 /// <param name="scene"></param>
447 /// <param name="sceneManager"></param> 456 /// <param name="sceneManager"></param>
448 public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager) 457 public TestClient(AgentCircuitData agentData, Scene scene)
449 { 458 {
450 m_agentId = agentData.AgentID; 459 m_agentId = agentData.AgentID;
451 m_firstName = agentData.firstname; 460 m_firstName = agentData.firstname;
452 m_lastName = agentData.lastname; 461 m_lastName = agentData.lastname;
453 m_circuitCode = agentData.circuitcode; 462 m_circuitCode = agentData.circuitcode;
454 m_scene = scene; 463 m_scene = scene;
455 m_sceneManager = sceneManager;
456 SessionId = agentData.SessionID; 464 SessionId = agentData.SessionID;
457 SecureSessionId = agentData.SecureSessionID; 465 SecureSessionId = agentData.SecureSessionID;
458 CapsSeedUrl = agentData.CapsPath; 466 CapsSeedUrl = agentData.CapsPath;
459 467
468 ReceivedKills = new List<uint>();
460 ReceivedOfflineNotifications = new List<UUID>(); 469 ReceivedOfflineNotifications = new List<UUID>();
461 ReceivedOnlineNotifications = new List<UUID>(); 470 ReceivedOnlineNotifications = new List<UUID>();
462 ReceivedFriendshipTerminations = new List<UUID>(); 471 ReceivedFriendshipTerminations = new List<UUID>();
@@ -467,6 +476,34 @@ namespace OpenSim.Tests.Common.Mock
467 } 476 }
468 477
469 /// <summary> 478 /// <summary>
479 /// Trigger chat coming from this connection.
480 /// </summary>
481 /// <param name="channel"></param>
482 /// <param name="type"></param>
483 /// <param name="message"></param>
484 public bool Chat(int channel, ChatTypeEnum type, string message)
485 {
486 ChatMessage handlerChatFromClient = OnChatFromClient;
487
488 if (handlerChatFromClient != null)
489 {
490 OSChatMessage args = new OSChatMessage();
491 args.Channel = channel;
492 args.From = Name;
493 args.Message = message;
494 args.Type = type;
495
496 args.Scene = Scene;
497 args.Sender = this;
498 args.SenderUUID = AgentId;
499
500 handlerChatFromClient(this, args);
501 }
502
503 return true;
504 }
505
506 /// <summary>
470 /// Attempt a teleport to the given region. 507 /// Attempt a teleport to the given region.
471 /// </summary> 508 /// </summary>
472 /// <param name="regionHandle"></param> 509 /// <param name="regionHandle"></param>
@@ -479,7 +516,20 @@ namespace OpenSim.Tests.Common.Mock
479 516
480 public void CompleteMovement() 517 public void CompleteMovement()
481 { 518 {
482 OnCompleteMovementToRegion(this, true); 519 if (OnCompleteMovementToRegion != null)
520 OnCompleteMovementToRegion(this, true);
521 }
522
523 /// <summary>
524 /// Emulate sending an IM from the viewer to the simulator.
525 /// </summary>
526 /// <param name='im'></param>
527 public void HandleImprovedInstantMessage(GridInstantMessage im)
528 {
529 ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
530
531 if (handlerInstantMessage != null)
532 handlerInstantMessage(this, im);
483 } 533 }
484 534
485 public virtual void ActivateGesture(UUID assetId, UUID gestureId) 535 public virtual void ActivateGesture(UUID assetId, UUID gestureId)
@@ -494,6 +544,11 @@ namespace OpenSim.Tests.Common.Mock
494 { 544 {
495 } 545 }
496 546
547 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
548 {
549
550 }
551
497 public virtual void Kick(string message) 552 public virtual void Kick(string message)
498 { 553 {
499 } 554 }
@@ -508,22 +563,22 @@ namespace OpenSim.Tests.Common.Mock
508 563
509 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) 564 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
510 { 565 {
511
512 } 566 }
513 567
514 public virtual void SendKillObject(ulong regionHandle, List<uint> localID) 568 public virtual void SendKillObject(List<uint> localID)
515 { 569 {
570 ReceivedKills.AddRange(localID);
516 } 571 }
517 572
518 public virtual void SetChildAgentThrottle(byte[] throttle) 573 public virtual void SetChildAgentThrottle(byte[] throttle)
519 { 574 {
520 } 575 }
576
521 public byte[] GetThrottlesPacked(float multiplier) 577 public byte[] GetThrottlesPacked(float multiplier)
522 { 578 {
523 return new byte[0]; 579 return new byte[0];
524 } 580 }
525 581
526
527 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) 582 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
528 { 583 {
529 } 584 }
@@ -532,19 +587,23 @@ namespace OpenSim.Tests.Common.Mock
532 string message, byte type, Vector3 fromPos, string fromName, 587 string message, byte type, Vector3 fromPos, string fromName,
533 UUID fromAgentID, UUID ownerID, byte source, byte audible) 588 UUID fromAgentID, UUID ownerID, byte source, byte audible)
534 { 589 {
590// Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId);
591 if (OnReceivedChatMessage != null)
592 OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible);
535 } 593 }
536 594
537 public void SendInstantMessage(GridInstantMessage im) 595 public void SendInstantMessage(GridInstantMessage im)
538 { 596 {
539 597 if (OnReceivedInstantMessage != null)
598 OnReceivedInstantMessage(im);
540 } 599 }
541 600
542 public void SendGenericMessage(string method, List<string> message) 601 public void SendGenericMessage(string method, UUID invoice, List<string> message)
543 { 602 {
544 603
545 } 604 }
546 605
547 public void SendGenericMessage(string method, List<byte[]> message) 606 public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
548 { 607 {
549 608
550 } 609 }
@@ -566,13 +625,15 @@ namespace OpenSim.Tests.Common.Mock
566 625
567 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 626 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
568 { 627 {
628 if (OnReceivedMoveAgentIntoRegion != null)
629 OnReceivedMoveAgentIntoRegion(regInfo, pos, look);
569 } 630 }
570 631
571 public virtual AgentCircuitData RequestClientInfo() 632 public virtual AgentCircuitData RequestClientInfo()
572 { 633 {
573 AgentCircuitData agentData = new AgentCircuitData(); 634 AgentCircuitData agentData = new AgentCircuitData();
574 agentData.AgentID = AgentId; 635 agentData.AgentID = AgentId;
575 agentData.SessionID = UUID.Zero; 636 agentData.SessionID = SessionId;
576 agentData.SecureSessionID = UUID.Zero; 637 agentData.SecureSessionID = UUID.Zero;
577 agentData.circuitcode = m_circuitCode; 638 agentData.circuitcode = m_circuitCode;
578 agentData.child = false; 639 agentData.child = false;
@@ -591,46 +652,29 @@ namespace OpenSim.Tests.Common.Mock
591 652
592 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) 653 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
593 { 654 {
594 m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); 655 if (OnTestClientInformClientOfNeighbour != null)
595 656 OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint);
596 // In response to this message, we are going to make a teleport to the scene we've previous been told
597 // about by test code (this needs to be improved).
598 AgentCircuitData newAgent = RequestClientInfo();
599
600 // Stage 2: add the new client as a child agent to the scene
601 uint x, y;
602 Utils.LongToUInts(neighbourHandle, out x, out y);
603 x /= Constants.RegionSize;
604 y /= Constants.RegionSize;
605
606 Scene neighbourScene;
607 m_sceneManager.TryGetScene(x, y, out neighbourScene);
608
609 TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager);
610 neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User);
611 } 657 }
612 658
613 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, 659 public virtual void SendRegionTeleport(
614 uint locationID, uint flags, string capsURL) 660 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
661 uint locationID, uint flags, string capsURL)
615 { 662 {
616 m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport"); 663 m_log.DebugFormat(
664 "[TEST CLIENT]: Received SendRegionTeleport for {0} {1} on {2}", m_firstName, m_lastName, m_scene.Name);
617 665
618 CapsSeedUrl = capsURL; 666 CapsSeedUrl = capsURL;
619 667
620 // We don't do this here so that the source region can complete processing first in a single-threaded 668 if (OnTestClientSendRegionTeleport != null)
621 // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport 669 OnTestClientSendRegionTeleport(
622 // CompleteTeleportClientSide(); 670 regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
623 }
624
625 public void CompleteTeleportClientSide()
626 {
627 TeleportSceneClient.CompleteMovement();
628 //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false);
629 } 671 }
630 672
631 public virtual void SendTeleportFailed(string reason) 673 public virtual void SendTeleportFailed(string reason)
632 { 674 {
633 m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); 675 m_log.DebugFormat(
676 "[TEST CLIENT]: Teleport failed for {0} {1} on {2} with reason {3}",
677 m_firstName, m_lastName, m_scene.Name, reason);
634 } 678 }
635 679
636 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, 680 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,
@@ -660,7 +704,7 @@ namespace OpenSim.Tests.Common.Mock
660 { 704 {
661 } 705 }
662 706
663 public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance) 707 public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
664 { 708 {
665 } 709 }
666 710
@@ -682,6 +726,8 @@ namespace OpenSim.Tests.Common.Mock
682 726
683 public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 727 public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
684 { 728 {
729 if (OnReceivedEntityUpdate != null)
730 OnReceivedEntityUpdate(entity, updateFlags);
685 } 731 }
686 732
687 public void ReprioritizeUpdates() 733 public void ReprioritizeUpdates()
@@ -786,11 +832,6 @@ namespace OpenSim.Tests.Common.Mock
786 { 832 {
787 OnRegionHandShakeReply(this); 833 OnRegionHandShakeReply(this);
788 } 834 }
789
790 if (OnCompleteMovementToRegion != null)
791 {
792 OnCompleteMovementToRegion(this, true);
793 }
794 } 835 }
795 836
796 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 837 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
@@ -884,11 +925,6 @@ namespace OpenSim.Tests.Common.Mock
884 925
885 } 926 }
886 927
887 public bool AddMoney(int debit)
888 {
889 return false;
890 }
891
892 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) 928 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
893 { 929 {
894 } 930 }
@@ -1235,6 +1271,8 @@ namespace OpenSim.Tests.Common.Mock
1235 1271
1236 public void SendRebakeAvatarTextures(UUID textureID) 1272 public void SendRebakeAvatarTextures(UUID textureID)
1237 { 1273 {
1274 if (OnReceivedSendRebakeAvatarTextures != null)
1275 OnReceivedSendRebakeAvatarTextures(textureID);
1238 } 1276 }
1239 1277
1240 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) 1278 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
@@ -1269,12 +1307,17 @@ namespace OpenSim.Tests.Common.Mock
1269 { 1307 {
1270 } 1308 }
1271 1309
1272 public void StopFlying(ISceneEntity presence) 1310 public void SendAgentTerseUpdate(ISceneEntity presence)
1273 { 1311 {
1274 } 1312 }
1275 1313
1276 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) 1314 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
1277 { 1315 {
1278 } 1316 }
1317
1318 public void SendPartPhysicsProprieties(ISceneEntity entity)
1319 {
1320 }
1321
1279 } 1322 }
1280} 1323}
diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
new file mode 100644
index 0000000..f2bae58
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
@@ -0,0 +1,182 @@
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.ClientStack.Linden;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44
45namespace OpenSim.Tests.Common
46{
47 public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule
48 {
49 public class Event
50 {
51 public string Name { get; set; }
52 public object[] Args { get; set; }
53
54 public Event(string name, object[] args)
55 {
56 name = Name;
57 args = Args;
58 }
59 }
60
61 public Dictionary<UUID, List<Event>> Events { get; set; }
62
63 public void Initialise(IConfigSource source) {}
64
65 public void Close() {}
66
67 public void AddRegion(Scene scene)
68 {
69 Events = new Dictionary<UUID, List<Event>>();
70 scene.RegisterModuleInterface<IEventQueue>(this);
71 }
72
73 public void RemoveRegion (Scene scene) {}
74
75 public void RegionLoaded (Scene scene) {}
76
77 public string Name { get { return "TestEventQueueGetModule"; } }
78
79 public Type ReplaceableInterface { get { return null; } }
80
81 private void AddEvent(UUID avatarID, string name, params object[] args)
82 {
83 Console.WriteLine("Adding event {0} for {1}", name, avatarID);
84
85 List<Event> avEvents;
86
87 if (!Events.ContainsKey(avatarID))
88 {
89 avEvents = new List<Event>();
90 Events[avatarID] = avEvents;
91 }
92 else
93 {
94 avEvents = Events[avatarID];
95 }
96
97 avEvents.Add(new Event(name, args));
98 }
99
100 public void ClearEvents()
101 {
102 if (Events != null)
103 Events.Clear();
104 }
105
106 public bool Enqueue(OSD o, UUID avatarID)
107 {
108 AddEvent(avatarID, "Enqueue", o);
109 return true;
110 }
111
112 public void DisableSimulator(ulong handle, UUID avatarID)
113 {
114 AddEvent(avatarID, "DisableSimulator", handle);
115 }
116
117 public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
118 {
119 AddEvent(avatarID, "EnableSimulator", handle);
120 }
121
122 public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath,
123 ulong regionHandle, int regionSizeX, int regionSizeY)
124 {
125 AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
126 }
127
128 public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
129 uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY)
130 {
131 AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
132 }
133
134 public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint,
135 string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
136 {
137 AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
138 }
139
140 public void ChatterboxInvitation(
141 UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
142 byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
143 UUID transactionID, bool fromGroup, byte[] binaryBucket)
144 {
145 AddEvent(
146 toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
147 timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
148 }
149
150 public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute)
151 {
152 AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute);
153 }
154
155 public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
156 {
157 AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
158 }
159
160 public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID)
161 {
162 AddEvent(avatarID, "GroupMembership", groupUpdate);
163 }
164
165 public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono)
166 {
167 Console.WriteLine("ONE");
168 throw new System.NotImplementedException ();
169 }
170
171 public OSD BuildEvent(string eventName, OSD eventBody)
172 {
173 Console.WriteLine("TWO");
174 throw new System.NotImplementedException ();
175 }
176
177 public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
178 {
179 AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
180 }
181 }
182} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs b/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs
new file mode 100644
index 0000000..5a55b09
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs
@@ -0,0 +1,110 @@
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.Net.Sockets;
33using System.Text;
34using HttpServer;
35using OpenSim.Framework;
36
37namespace OpenSim.Tests.Common
38{
39 public class TestHttpClientContext: IHttpClientContext
40 {
41 /// <summary>
42 /// Bodies of responses from the server.
43 /// </summary>
44 public string ResponseBody
45 {
46 get { return Encoding.UTF8.GetString(m_responseStream.ToArray()); }
47 }
48
49 public Byte[] ResponseBodyBytes
50 {
51 get{ return m_responseStream.ToArray(); }
52 }
53
54 private MemoryStream m_responseStream = new MemoryStream();
55
56 public bool IsSecured { get; set; }
57
58 public bool Secured
59 {
60 get { return IsSecured; }
61 set { IsSecured = value; }
62 }
63
64 public TestHttpClientContext(bool secured)
65 {
66 Secured = secured;
67 }
68
69 public void Disconnect(SocketError error)
70 {
71// Console.WriteLine("TestHttpClientContext.Disconnect Received disconnect with status {0}", error);
72 }
73
74 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body) {Console.WriteLine("x");}
75 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) {Console.WriteLine("xx");}
76 public void Respond(string body) { Console.WriteLine("xxx");}
77
78 public void Send(byte[] buffer)
79 {
80 // Getting header data here
81// Console.WriteLine("xxxx: Got {0}", Encoding.UTF8.GetString(buffer));
82 }
83
84 public void Send(byte[] buffer, int offset, int size)
85 {
86// Util.PrintCallStack();
87//
88// Console.WriteLine(
89// "TestHttpClientContext.Send(byte[], int, int) got offset={0}, size={1}, buffer={2}",
90// offset, size, Encoding.UTF8.GetString(buffer));
91
92 m_responseStream.Write(buffer, offset, size);
93 }
94
95 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {Console.WriteLine("xxxxxx");}
96 public void Close() { }
97 public bool EndWhenDone { get { return false;} set { return;}}
98
99 public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing()
100 {
101 return new HTTPNetworkContext();
102 }
103
104 public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { };
105 /// <summary>
106 /// A request have been received in the context.
107 /// </summary>
108 public event EventHandler<RequestEventArgs> RequestReceived = delegate { };
109 }
110} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs
new file mode 100644
index 0000000..b868895
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs
@@ -0,0 +1,174 @@
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.Specialized;
30using System.IO;
31using HttpServer;
32using HttpServer.FormDecoders;
33
34namespace OpenSim.Tests.Common
35{
36 public class TestHttpRequest: IHttpRequest
37 {
38 private string _uriPath;
39 public bool BodyIsComplete
40 {
41 get { return true; }
42 }
43 public string[] AcceptTypes
44 {
45 get {return _acceptTypes; }
46 }
47 private string[] _acceptTypes;
48 public Stream Body
49 {
50 get { return _body; }
51 set { _body = value;}
52 }
53 private Stream _body;
54 public ConnectionType Connection
55 {
56 get { return _connection; }
57 set { _connection = value; }
58 }
59 private ConnectionType _connection;
60 public int ContentLength
61 {
62 get { return _contentLength; }
63 set { _contentLength = value; }
64 }
65 private int _contentLength;
66 public NameValueCollection Headers
67 {
68 get { return _headers; }
69 }
70 private NameValueCollection _headers = new NameValueCollection();
71
72 public string HttpVersion { get; set; }
73
74 public string Method
75 {
76 get { return _method; }
77 set { _method = value; }
78 }
79 private string _method = null;
80 public HttpInput QueryString
81 {
82 get { return _queryString; }
83 }
84 private HttpInput _queryString = null;
85 public Uri Uri
86 {
87 get { return _uri; }
88 set { _uri = value; }
89 }
90 private Uri _uri = null;
91 public string[] UriParts
92 {
93 get { return _uri.Segments; }
94 }
95 public HttpParam Param
96 {
97 get { return null; }
98 }
99 public HttpForm Form
100 {
101 get { return null; }
102 }
103 public bool IsAjax
104 {
105 get { return false; }
106 }
107 public RequestCookies Cookies
108 {
109 get { return null; }
110 }
111
112 public TestHttpRequest()
113 {
114 HttpVersion = "HTTP/1.1";
115 }
116
117 public TestHttpRequest(string contentEncoding, string contentType, string userAgent,
118 string remoteAddr, string remotePort, string[] acceptTypes,
119 ConnectionType connectionType, int contentLength, Uri uri) : base()
120 {
121 _headers["content-encoding"] = contentEncoding;
122 _headers["content-type"] = contentType;
123 _headers["user-agent"] = userAgent;
124 _headers["remote_addr"] = remoteAddr;
125 _headers["remote_port"] = remotePort;
126
127 _acceptTypes = acceptTypes;
128 _connection = connectionType;
129 _contentLength = contentLength;
130 _uri = uri;
131 }
132
133 public void DecodeBody(FormDecoderProvider providers) {}
134 public void SetCookies(RequestCookies cookies) {}
135 public void AddHeader(string name, string value)
136 {
137 _headers.Add(name, value);
138 }
139 public int AddToBody(byte[] bytes, int offset, int length)
140 {
141 return 0;
142 }
143 public void Clear() {}
144
145 public object Clone()
146 {
147 TestHttpRequest clone = new TestHttpRequest();
148 clone._acceptTypes = _acceptTypes;
149 clone._connection = _connection;
150 clone._contentLength = _contentLength;
151 clone._uri = _uri;
152 clone._headers = new NameValueCollection(_headers);
153
154 return clone;
155 }
156 public IHttpResponse CreateResponse(IHttpClientContext context)
157 {
158 return new HttpResponse(context, this);
159 }
160 /// <summary>
161 /// Path and query (will be merged with the host header) and put in Uri
162 /// </summary>
163 /// <see cref="Uri"/>
164 public string UriPath
165 {
166 get { return _uriPath; }
167 set
168 {
169 _uriPath = value;
170
171 }
172 }
173 }
174} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs
new file mode 100644
index 0000000..ff47c10
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs
@@ -0,0 +1,171 @@
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.IO;
30using System.Net;
31using System.Text;
32using HttpServer;
33
34namespace OpenSim.Tests.Common
35{
36 public class TestHttpResponse: IHttpResponse
37 {
38 public Stream Body
39 {
40 get { return _body; }
41
42 set { _body = value; }
43 }
44 private Stream _body;
45
46 public string ProtocolVersion
47 {
48 get { return _protocolVersion; }
49 set { _protocolVersion = value; }
50 }
51 private string _protocolVersion;
52
53 public bool Chunked
54 {
55 get { return _chunked; }
56
57 set { _chunked = value; }
58 }
59 private bool _chunked;
60
61 public ConnectionType Connection
62 {
63 get { return _connection; }
64
65 set { _connection = value; }
66 }
67 private ConnectionType _connection;
68
69 public Encoding Encoding
70 {
71 get { return _encoding; }
72
73 set { _encoding = value; }
74 }
75 private Encoding _encoding;
76
77 public int KeepAlive
78 {
79 get { return _keepAlive; }
80
81 set { _keepAlive = value; }
82 }
83 private int _keepAlive;
84
85 public HttpStatusCode Status
86 {
87 get { return _status; }
88
89 set { _status = value; }
90 }
91 private HttpStatusCode _status;
92
93 public string Reason
94 {
95 get { return _reason; }
96
97 set { _reason = value; }
98 }
99 private string _reason;
100
101 public long ContentLength
102 {
103 get { return _contentLength; }
104
105 set { _contentLength = value; }
106 }
107 private long _contentLength;
108
109 public string ContentType
110 {
111 get { return _contentType; }
112
113 set { _contentType = value; }
114 }
115 private string _contentType;
116
117 public bool HeadersSent
118 {
119 get { return _headersSent; }
120 }
121 private bool _headersSent;
122
123 public bool Sent
124 {
125 get { return _sent; }
126 }
127 private bool _sent;
128
129 public ResponseCookies Cookies
130 {
131 get { return _cookies; }
132 }
133 private ResponseCookies _cookies = null;
134
135 public TestHttpResponse()
136 {
137 _headersSent = false;
138 _sent = false;
139 }
140
141 public void AddHeader(string name, string value) {}
142
143 public void Send()
144 {
145 if (!_headersSent) SendHeaders();
146 if (_sent) throw new InvalidOperationException("stuff already sent");
147 _sent = true;
148 }
149
150 public void SendBody(byte[] buffer, int offset, int count)
151 {
152 if (!_headersSent) SendHeaders();
153 _sent = true;
154 }
155
156 public void SendBody(byte[] buffer)
157 {
158 if (!_headersSent) SendHeaders();
159 _sent = true;
160 }
161
162 public void SendHeaders()
163 {
164 if (_headersSent) throw new InvalidOperationException("headers already sent");
165 _headersSent = true;
166 }
167
168 public void Redirect(Uri uri) {}
169 public void Redirect(string url) {}
170 }
171} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
index fc44358..c97a765 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
@@ -33,7 +33,7 @@ using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Data; 34using OpenSim.Data;
35 35
36namespace OpenSim.Tests.Common.Mock 36namespace OpenSim.Tests.Common
37{ 37{
38 /// <summary> 38 /// <summary>
39 /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the 39 /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the
@@ -185,7 +185,7 @@ namespace OpenSim.Tests.Common.Mock
185 185
186 public void addInventoryItem(InventoryItemBase item) 186 public void addInventoryItem(InventoryItemBase item)
187 { 187 {
188// InventoryFolderBase folder = m_folders[item.Folder]; 188 InventoryFolderBase folder = m_folders[item.Folder];
189 189
190// m_log.DebugFormat( 190// m_log.DebugFormat(
191// "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); 191// "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID);
diff --git a/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs
new file mode 100644
index 0000000..26887c9
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs
@@ -0,0 +1,171 @@
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.Net;
31using System.Net.Sockets;
32using Nini.Config;
33using OpenMetaverse.Packets;
34using OpenSim.Framework;
35using OpenSim.Region.ClientStack.LindenUDP;
36
37namespace OpenSim.Tests.Common
38{
39 /// <summary>
40 /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data.
41 /// </summary>
42 public class TestLLUDPServer : LLUDPServer
43 {
44 public List<Packet> PacketsSent { get; private set; }
45
46 public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
47 : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager)
48 {
49 PacketsSent = new List<Packet>();
50 }
51
52 public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
53 {
54 PacketsSent.Add(ack);
55 }
56
57 public override void SendPacket(
58 LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
59 {
60 PacketsSent.Add(packet);
61 }
62
63 public void ClientOutgoingPacketHandler(IClientAPI client, bool resendUnacked, bool sendAcks, bool sendPing)
64 {
65 m_resendUnacked = resendUnacked;
66 m_sendAcks = sendAcks;
67 m_sendPing = sendPing;
68
69 ClientOutgoingPacketHandler(client);
70 }
71
72//// /// <summary>
73//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
74//// /// </summary>
75//// protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
76//
77//// protected override void BeginReceive()
78//// {
79//// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
80//// {
81//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
82//// reusedEpSender = tuple.Sender;
83//// throw new SocketException();
84//// }
85//// }
86//
87//// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
88//// {
89//// numBytes = 0;
90////
91//// //m_log.Debug("Queue size " + m_chunksToLoad.Count);
92////
93//// if (m_chunksToLoad.Count <= 0)
94//// return false;
95////
96//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
97//// RecvBuffer = tuple.Data;
98//// numBytes = tuple.Data.Length;
99//// epSender = tuple.Sender;
100////
101//// return true;
102//// }
103//
104//// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
105//// {
106//// // Don't do anything just yet
107//// }
108//
109// /// <summary>
110// /// Signal that this chunk should throw an exception on Socket.BeginReceive()
111// /// </summary>
112// /// <param name="epSender"></param>
113// public void LoadReceiveWithBeginException(EndPoint epSender)
114// {
115// ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
116// tuple.BeginReceiveException = true;
117// m_chunksToLoad.Enqueue(tuple);
118// }
119//
120// /// <summary>
121// /// Load some data to be received by the LLUDPServer on the next receive call
122// /// </summary>
123// /// <param name="data"></param>
124// /// <param name="epSender"></param>
125// public void LoadReceive(byte[] data, EndPoint epSender)
126// {
127// m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
128// }
129//
130// /// <summary>
131// /// Load a packet to be received by the LLUDPServer on the next receive call
132// /// </summary>
133// /// <param name="packet"></param>
134// public void LoadReceive(Packet packet, EndPoint epSender)
135// {
136// LoadReceive(packet.ToBytes(), epSender);
137// }
138//
139// /// <summary>
140// /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
141// /// </summary>
142// /// <param name="result"></param>
143// public void ReceiveData(IAsyncResult result)
144// {
145// // Doesn't work the same way anymore
146//// while (m_chunksToLoad.Count > 0)
147//// OnReceivedData(result);
148// }
149 }
150
151 /// <summary>
152 /// Record the data and sender tuple
153 /// </summary>
154 public class ChunkSenderTuple
155 {
156 public byte[] Data;
157 public EndPoint Sender;
158 public bool BeginReceiveException;
159
160 public ChunkSenderTuple(byte[] data, EndPoint sender)
161 {
162 Data = data;
163 Sender = sender;
164 }
165
166 public ChunkSenderTuple(EndPoint sender)
167 {
168 Sender = sender;
169 }
170 }
171}
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
index 4b4d52d..89ebcd5 100644
--- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs
+++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
@@ -32,7 +32,7 @@ using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes; 32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.CoreModules.World.Land; 33using OpenSim.Region.CoreModules.World.Land;
34 34
35namespace OpenSim.Tests.Common.Mock 35namespace OpenSim.Tests.Common
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// Land channel for test purposes 38 /// Land channel for test purposes
@@ -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/TestOSHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs
index e769d30..7b1d2b5 100644
--- a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs
+++ b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs
@@ -35,7 +35,7 @@ using System.Text;
35using System.Web; 35using System.Web;
36using OpenSim.Framework.Servers.HttpServer; 36using OpenSim.Framework.Servers.HttpServer;
37 37
38namespace OpenSim.Tests.Common.Mock 38namespace OpenSim.Tests.Common
39{ 39{
40 public class TestOSHttpRequest : IOSHttpRequest 40 public class TestOSHttpRequest : IOSHttpRequest
41 { 41 {
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs
index e10fe82..2e17f1e 100644
--- a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs
+++ b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs
@@ -32,7 +32,7 @@ using System.Text;
32using System.Web; 32using System.Web;
33using OpenSim.Framework.Servers.HttpServer; 33using OpenSim.Framework.Servers.HttpServer;
34 34
35namespace OpenSim.Tests.Common.Mock 35namespace OpenSim.Tests.Common
36{ 36{
37 public class TestOSHttpResponse : IOSHttpResponse 37 public class TestOSHttpResponse : IOSHttpResponse
38 { 38 {
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index d4b5648..1a93c9f 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -28,23 +28,24 @@
28using System; 28using System;
29using Nini.Config; 29using Nini.Config;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Framework.Communications; 31
32using OpenSim.Framework.Servers; 32using OpenSim.Framework.Servers;
33using OpenSim.Region.Framework; 33using OpenSim.Region.Framework;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.PhysicsModules.SharedBase;
37using OpenSim.Services.Interfaces;
36 38
37namespace OpenSim.Tests.Common.Mock 39namespace OpenSim.Tests.Common
38{ 40{
39 public class TestScene : Scene 41 public class TestScene : Scene
40 { 42 {
41 public TestScene( 43 public TestScene(
42 RegionInfo regInfo, AgentCircuitManager authen, 44 RegionInfo regInfo, AgentCircuitManager authen,
43 SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, 45 ISimulationDataService simDataService, IEstateDataService estateDataService,
44 bool dumpAssetsToFile,
45 IConfigSource config, string simulatorVersion) 46 IConfigSource config, string simulatorVersion)
46 : base(regInfo, authen, sceneGridService, simDataService, estateDataService, 47 : base(regInfo, authen, simDataService, estateDataService,
47 dumpAssetsToFile, config, simulatorVersion) 48 config, simulatorVersion)
48 { 49 {
49 } 50 }
50 51
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
index ccbdf81..2b272e6 100644
--- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
@@ -35,7 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Data; 35using OpenSim.Data;
36using OpenSim.Data.Null; 36using OpenSim.Data.Null;
37 37
38namespace OpenSim.Tests.Common.Mock 38namespace OpenSim.Tests.Common
39{ 39{
40 public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData 40 public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData
41 { 41 {
@@ -46,17 +46,33 @@ namespace OpenSim.Tests.Common.Mock
46 46
47 public XInventoryItem[] GetItems(string[] fields, string[] vals) 47 public XInventoryItem[] GetItems(string[] fields, string[] vals)
48 { 48 {
49// Console.WriteLine(
50// "Requesting items, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals));
51
49 List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList()); 52 List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList());
50 53
51 return origItems.Select(i => i.Clone()).ToArray(); 54 XInventoryItem[] items = origItems.Select(i => i.Clone()).ToArray();
55
56// Console.WriteLine("Found {0} items", items.Length);
57// Array.ForEach(items, i => Console.WriteLine("Found item {0} {1}", i.inventoryName, i.inventoryID));
58
59 return items;
52 } 60 }
53 61
54 public XInventoryFolder[] GetFolders(string[] fields, string[] vals) 62 public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
55 { 63 {
64// Console.WriteLine(
65// "Requesting folders, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals));
66
56 List<XInventoryFolder> origFolders 67 List<XInventoryFolder> origFolders
57 = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); 68 = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList());
58 69
59 return origFolders.Select(f => f.Clone()).ToArray(); 70 XInventoryFolder[] folders = origFolders.Select(f => f.Clone()).ToArray();
71
72// Console.WriteLine("Found {0} folders", folders.Length);
73// Array.ForEach(folders, f => Console.WriteLine("Found folder {0} {1}", f.folderName, f.folderID));
74
75 return folders;
60 } 76 }
61 77
62 public bool StoreFolder(XInventoryFolder folder) 78 public bool StoreFolder(XInventoryFolder folder)
@@ -72,7 +88,9 @@ namespace OpenSim.Tests.Common.Mock
72 { 88 {
73 m_allItems[item.inventoryID] = item.Clone(); 89 m_allItems[item.inventoryID] = item.Clone();
74 90
75// Console.WriteLine("Added item {0} {1}, creator {2}, owner {3}", item.inventoryName, item.inventoryID, item.creatorID, item.avatarID); 91// Console.WriteLine(
92// "Added item {0} {1}, folder {2}, creator {3}, owner {4}",
93// item.inventoryName, item.inventoryID, item.parentFolderID, item.creatorID, item.avatarID);
76 94
77 return true; 95 return true;
78 } 96 }
@@ -104,7 +122,30 @@ namespace OpenSim.Tests.Common.Mock
104 } 122 }
105 123
106 public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } 124 public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); }
107 public bool MoveFolder(string id, string newParent) { throw new NotImplementedException(); } 125
126 public bool MoveFolder(string id, string newParent)
127 {
128 // Don't use GetFolders() here - it takes a clone!
129 XInventoryFolder folder = m_allFolders[new UUID(id)];
130
131 if (folder == null)
132 return false;
133
134 folder.parentFolderID = new UUID(newParent);
135
136// XInventoryFolder[] newParentFolders
137// = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() });
138
139// Console.WriteLine(
140// "Moved folder {0} {1}, to {2} {3}",
141// folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID);
142
143 // TODO: Really need to implement folder version incrementing, though this should be common code anyway,
144 // not reimplemented in each db plugin.
145
146 return true;
147 }
148
108 public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } 149 public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); }
109 public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } 150 public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); }
110 } 151 }
diff --git a/OpenSim/Tests/Common/OpenSimTestCase.cs b/OpenSim/Tests/Common/OpenSimTestCase.cs
index 8c40923..9fea348 100644
--- a/OpenSim/Tests/Common/OpenSimTestCase.cs
+++ b/OpenSim/Tests/Common/OpenSimTestCase.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenSim.Framework;
31using OpenSim.Framework.Servers;
30 32
31namespace OpenSim.Tests.Common 33namespace OpenSim.Tests.Common
32{ 34{
@@ -36,11 +38,18 @@ namespace OpenSim.Tests.Common
36 [SetUp] 38 [SetUp]
37 public virtual void SetUp() 39 public virtual void SetUp()
38 { 40 {
39// TestHelpers.InMethod(); 41 //TestHelpers.InMethod();
40 // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests 42 // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests
41 // to have logging on if it failed with an exception. 43 // to have logging on if it failed with an exception.
42 TestHelpers.DisableLogging(); 44 TestHelpers.DisableLogging();
45
46 // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
47 // variables and the VM is not restarted between tests.
48 if (MainServer.Instance != null)
49 {
50 MainServer.RemoveHttpServer(MainServer.Instance.Port);
51// MainServer.Instance = null;
52 }
43 } 53 }
44 } 54 }
45} 55} \ No newline at end of file
46
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs
index 57da802..6bf23f8 100644
--- a/OpenSim/Tests/Common/TestHelpers.cs
+++ b/OpenSim/Tests/Common/TestHelpers.cs
@@ -114,6 +114,25 @@ 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 /// The fragment will come at the start of the UUID. The rest will be 0s
121 /// </remarks>
122 /// <returns></returns>
123 /// <param name='frag'>
124 /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain
125 /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is
126 /// given as the 'fragment'.
127 /// </param>
128 public static UUID ParseStem(string stem)
129 {
130 string rawUuid = stem.PadRight(32, '0');
131
132 return UUID.Parse(rawUuid);
133 }
134
135 /// <summary>
117 /// Parse tail section into full UUID. 136 /// Parse tail section into full UUID.
118 /// </summary> 137 /// </summary>
119 /// <param name="tail"></param> 138 /// <param name="tail"></param>
@@ -122,5 +141,24 @@ namespace OpenSim.Tests.Common
122 { 141 {
123 return new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", tail)); 142 return new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", tail));
124 } 143 }
144
145 /// <summary>
146 /// Parse a UUID tail section into a full UUID.
147 /// </summary>
148 /// <remarks>
149 /// The fragment will come at the end of the UUID. The rest will be 0s
150 /// </remarks>
151 /// <returns></returns>
152 /// <param name='frag'>
153 /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain
154 /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is
155 /// given as the 'fragment'.
156 /// </param>
157 public static UUID ParseTail(string stem)
158 {
159 string rawUuid = stem.PadLeft(32, '0');
160
161 return UUID.Parse(rawUuid);
162 }
125 } 163 }
126} 164}