diff options
Diffstat (limited to '')
22 files changed, 935 insertions, 86 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; | |||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Servers; | 33 | using OpenSim.Framework.Servers; |
34 | using OpenSim.Framework.Servers.HttpServer; | 34 | using OpenSim.Framework.Servers.HttpServer; |
35 | using OpenSim.Tests.Common.Mock; | ||
36 | 35 | ||
37 | namespace OpenSim.Tests.Common | 36 | namespace 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 | |||
28 | using System; | ||
29 | using System.Net; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenMetaverse.Packets; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.ClientStack.LindenUDP; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | |||
37 | namespace 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 index 84de47f..e6adcf7 100644 --- a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs | |||
@@ -43,7 +43,6 @@ using OpenSim.Region.Framework.Interfaces; | |||
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.CoreModules.Framework; | 44 | using OpenSim.Region.CoreModules.Framework; |
45 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | ||
47 | 46 | ||
48 | namespace OpenSim.Tests.Common | 47 | namespace OpenSim.Tests.Common |
49 | { | 48 | { |
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index d36e42e..9ed3eae 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs | |||
@@ -30,6 +30,7 @@ using System.Net; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Data.Null; | ||
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
@@ -48,7 +49,6 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | |||
48 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; | 49 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; |
49 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; | 50 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; |
50 | using OpenSim.Services.Interfaces; | 51 | using OpenSim.Services.Interfaces; |
51 | using OpenSim.Tests.Common.Mock; | ||
52 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 52 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
53 | 53 | ||
54 | namespace OpenSim.Tests.Common | 54 | namespace OpenSim.Tests.Common |
@@ -63,9 +63,9 @@ namespace OpenSim.Tests.Common | |||
63 | /// </summary> | 63 | /// </summary> |
64 | public SceneManager SceneManager { get; private set; } | 64 | public SceneManager SceneManager { get; private set; } |
65 | 65 | ||
66 | public ISimulationDataService SimDataService { get; private set; } | ||
67 | |||
66 | private AgentCircuitManager m_acm = new AgentCircuitManager(); | 68 | 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; | 69 | private IEstateDataService m_estateDataService = null; |
70 | 70 | ||
71 | private LocalAssetServicesConnector m_assetService; | 71 | private LocalAssetServicesConnector m_assetService; |
@@ -96,6 +96,9 @@ namespace OpenSim.Tests.Common | |||
96 | m_presenceService.PostInitialise(); | 96 | m_presenceService.PostInitialise(); |
97 | 97 | ||
98 | m_cache = cache; | 98 | m_cache = cache; |
99 | |||
100 | SimDataService | ||
101 | = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); | ||
99 | } | 102 | } |
100 | 103 | ||
101 | /// <summary> | 104 | /// <summary> |
@@ -115,6 +118,11 @@ namespace OpenSim.Tests.Common | |||
115 | return SetupScene(name, id, x, y, new IniConfigSource()); | 118 | return SetupScene(name, id, x, y, new IniConfigSource()); |
116 | } | 119 | } |
117 | 120 | ||
121 | public TestScene SetupScene(string name, UUID id, uint x, uint y, IConfigSource configSource) | ||
122 | { | ||
123 | return SetupScene(name, id, x, y, Constants.RegionSize, Constants.RegionSize, configSource); | ||
124 | } | ||
125 | |||
118 | /// <summary> | 126 | /// <summary> |
119 | /// Set up a scene. | 127 | /// Set up a scene. |
120 | /// </summary> | 128 | /// </summary> |
@@ -122,10 +130,12 @@ namespace OpenSim.Tests.Common | |||
122 | /// <param name="id">ID of the region</param> | 130 | /// <param name="id">ID of the region</param> |
123 | /// <param name="x">X co-ordinate of the region</param> | 131 | /// <param name="x">X co-ordinate of the region</param> |
124 | /// <param name="y">Y co-ordinate of the region</param> | 132 | /// <param name="y">Y co-ordinate of the region</param> |
133 | /// <param name="sizeX">X size of scene</param> | ||
134 | /// <param name="sizeY">Y size of scene</param> | ||
125 | /// <param name="configSource"></param> | 135 | /// <param name="configSource"></param> |
126 | /// <returns></returns> | 136 | /// <returns></returns> |
127 | public TestScene SetupScene( | 137 | public TestScene SetupScene( |
128 | string name, UUID id, uint x, uint y, IConfigSource configSource) | 138 | string name, UUID id, uint x, uint y, uint sizeX, uint sizeY, IConfigSource configSource) |
129 | { | 139 | { |
130 | Console.WriteLine("Setting up test scene {0}", name); | 140 | Console.WriteLine("Setting up test scene {0}", name); |
131 | 141 | ||
@@ -135,18 +145,29 @@ namespace OpenSim.Tests.Common | |||
135 | RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); | 145 | RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); |
136 | regInfo.RegionName = name; | 146 | regInfo.RegionName = name; |
137 | regInfo.RegionID = id; | 147 | regInfo.RegionID = id; |
148 | regInfo.RegionSizeX = sizeX; | ||
149 | regInfo.RegionSizeY = sizeY; | ||
138 | 150 | ||
139 | SceneCommunicationService scs = new SceneCommunicationService(); | 151 | SceneCommunicationService scs = new SceneCommunicationService(); |
140 | 152 | ||
141 | PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); | 153 | PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); |
142 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); | 154 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); |
155 | <<<<<<< HEAD | ||
156 | Vector3 regionExtent = new Vector3( regInfo.RegionSizeX, regInfo.RegionSizeY, regInfo.RegionSizeZ); | ||
157 | PhysicsScene physicsScene | ||
158 | ======= | ||
143 | Vector3 regionExtent = new Vector3(regInfo.RegionSizeX, regInfo.RegionSizeY, regInfo.RegionSizeZ); | 159 | Vector3 regionExtent = new Vector3(regInfo.RegionSizeX, regInfo.RegionSizeY, regInfo.RegionSizeZ); |
144 | PhysicsScene physicsScene | 160 | PhysicsScene physicsScene |
161 | >>>>>>> avn/ubitvar | ||
145 | = physicsPluginManager.GetPhysicsScene( | 162 | = physicsPluginManager.GetPhysicsScene( |
146 | "basicphysics", "ZeroMesher", new IniConfigSource(), "test", regionExtent); | 163 | "basicphysics", "ZeroMesher", new IniConfigSource(), "test", regionExtent); |
147 | 164 | ||
148 | TestScene testScene = new TestScene( | 165 | TestScene testScene = new TestScene( |
166 | <<<<<<< HEAD | ||
167 | regInfo, m_acm, physicsScene, scs, SimDataService, m_estateDataService, configSource, null); | ||
168 | ======= | ||
149 | regInfo, m_acm, physicsScene, scs, m_simDataService, m_estateDataService, configSource, null); | 169 | regInfo, m_acm, physicsScene, scs, m_simDataService, m_estateDataService, configSource, null); |
170 | >>>>>>> avn/ubitvar | ||
150 | 171 | ||
151 | INonSharedRegionModule godsModule = new GodsModule(); | 172 | INonSharedRegionModule godsModule = new GodsModule(); |
152 | godsModule.Initialise(new IniConfigSource()); | 173 | godsModule.Initialise(new IniConfigSource()); |
@@ -189,7 +210,11 @@ namespace OpenSim.Tests.Common | |||
189 | testScene.SetModuleInterfaces(); | 210 | testScene.SetModuleInterfaces(); |
190 | 211 | ||
191 | testScene.LandChannel = new TestLandChannel(testScene); | 212 | testScene.LandChannel = new TestLandChannel(testScene); |
213 | <<<<<<< HEAD | ||
214 | testScene.LoadWorldMap(); | ||
215 | ======= | ||
192 | testScene.LoadWorldMap(); | 216 | testScene.LoadWorldMap(); |
217 | >>>>>>> avn/ubitvar | ||
193 | 218 | ||
194 | testScene.RegionInfo.EstateSettings = new EstateSettings(); | 219 | testScene.RegionInfo.EstateSettings = new EstateSettings(); |
195 | testScene.LoginsEnabled = true; | 220 | testScene.LoginsEnabled = true; |
@@ -299,6 +324,11 @@ namespace OpenSim.Tests.Common | |||
299 | /// <param name="testScene"></param> | 324 | /// <param name="testScene"></param> |
300 | private static LocalPresenceServicesConnector StartPresenceService() | 325 | private static LocalPresenceServicesConnector StartPresenceService() |
301 | { | 326 | { |
327 | // Unfortunately, some services share data via statics, so we need to null every time to stop interference | ||
328 | // between tests. | ||
329 | // This is a massive non-obvious pita. | ||
330 | NullPresenceData.Instance = null; | ||
331 | |||
302 | IConfigSource config = new IniConfigSource(); | 332 | IConfigSource config = new IniConfigSource(); |
303 | config.AddConfig("Modules"); | 333 | config.AddConfig("Modules"); |
304 | config.AddConfig("PresenceService"); | 334 | config.AddConfig("PresenceService"); |
@@ -546,7 +576,7 @@ namespace OpenSim.Tests.Common | |||
546 | string reason; | 576 | string reason; |
547 | 577 | ||
548 | // Stage 1: tell the scene to expect a new user connection | 578 | // Stage 1: tell the scene to expect a new user connection |
549 | if (!scene.NewUserConnection(agentData, (uint)tf, out reason)) | 579 | if (!scene.NewUserConnection(agentData, (uint)tf, null, out reason)) |
550 | Console.WriteLine("NewUserConnection failed: " + reason); | 580 | Console.WriteLine("NewUserConnection failed: " + reason); |
551 | 581 | ||
552 | // 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 |
@@ -557,7 +587,11 @@ namespace OpenSim.Tests.Common | |||
557 | 587 | ||
558 | public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) | 588 | public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) |
559 | { | 589 | { |
560 | AgentCircuitData acd = GenerateAgentData(agentId); | 590 | return AddChildScenePresence(scene, GenerateAgentData(agentId)); |
591 | } | ||
592 | |||
593 | public static ScenePresence AddChildScenePresence(Scene scene, AgentCircuitData acd) | ||
594 | { | ||
561 | acd.child = true; | 595 | acd.child = true; |
562 | 596 | ||
563 | // XXX: ViaLogin may not be correct for child agents | 597 | // XXX: ViaLogin may not be correct for child agents |
@@ -589,6 +623,32 @@ namespace OpenSim.Tests.Common | |||
589 | //part.UpdatePrimFlags(false, false, true); | 623 | //part.UpdatePrimFlags(false, false, true); |
590 | //part.ObjectFlags |= (uint)PrimFlags.Phantom; | 624 | //part.ObjectFlags |= (uint)PrimFlags.Phantom; |
591 | 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 | |||
592 | scene.AddNewSceneObject(so, false); | 652 | scene.AddNewSceneObject(so, false); |
593 | 653 | ||
594 | return so; | 654 | return so; |
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index bb4b55f..3a3b33a 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | |||
@@ -43,7 +43,7 @@ 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> | 47 | /// <param name="part"></param> |
48 | /// <param name="itemName"></param> | 48 | /// <param name="itemName"></param> |
49 | /// <param name="itemIDFrag">UUID or UUID stem</param> | 49 | /// <param name="itemIDFrag">UUID or UUID stem</param> |
@@ -51,16 +51,16 @@ namespace OpenSim.Tests.Common | |||
51 | /// <param name="text">The tex to put in the notecard.</param> | 51 | /// <param name="text">The tex to put in the notecard.</param> |
52 | /// <returns>The item that was added</returns> | 52 | /// <returns>The item that was added</returns> |
53 | public static TaskInventoryItem AddNotecard( | 53 | public static TaskInventoryItem AddNotecard( |
54 | Scene scene, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text) | 54 | IAssetService assetService, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text) |
55 | { | 55 | { |
56 | return AddNotecard( | 56 | return AddNotecard( |
57 | scene, part, itemName, TestHelpers.ParseStem(itemIDStem), TestHelpers.ParseStem(assetIDStem), text); | 57 | assetService, part, itemName, TestHelpers.ParseStem(itemIDStem), TestHelpers.ParseStem(assetIDStem), text); |
58 | } | 58 | } |
59 | 59 | ||
60 | /// <summary> | 60 | /// <summary> |
61 | /// Add a notecard item to the given part. | 61 | /// Add a notecard item to the given part. |
62 | /// </summary> | 62 | /// </summary> |
63 | /// <param name="scene"></param> | 63 | /// <param name="assetService"></param> |
64 | /// <param name="part"></param> | 64 | /// <param name="part"></param> |
65 | /// <param name="itemName"></param> | 65 | /// <param name="itemName"></param> |
66 | /// <param name="itemID"></param> | 66 | /// <param name="itemID"></param> |
@@ -68,7 +68,7 @@ namespace OpenSim.Tests.Common | |||
68 | /// <param name="text">The tex to put in the notecard.</param> | 68 | /// <param name="text">The tex to put in the notecard.</param> |
69 | /// <returns>The item that was added</returns> | 69 | /// <returns>The item that was added</returns> |
70 | public static TaskInventoryItem AddNotecard( | 70 | public static TaskInventoryItem AddNotecard( |
71 | Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text) | 71 | IAssetService assetService, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text) |
72 | { | 72 | { |
73 | AssetNotecard nc = new AssetNotecard(); | 73 | AssetNotecard nc = new AssetNotecard(); |
74 | nc.BodyText = text; | 74 | nc.BodyText = text; |
@@ -76,7 +76,7 @@ namespace OpenSim.Tests.Common | |||
76 | 76 | ||
77 | AssetBase ncAsset | 77 | AssetBase ncAsset |
78 | = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); | 78 | = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); |
79 | scene.AssetService.Store(ncAsset); | 79 | assetService.Store(ncAsset); |
80 | 80 | ||
81 | TaskInventoryItem ncItem | 81 | TaskInventoryItem ncItem |
82 | = new TaskInventoryItem | 82 | = new TaskInventoryItem |
@@ -94,12 +94,12 @@ namespace OpenSim.Tests.Common | |||
94 | /// 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 |
95 | /// functions more than once in a test. | 95 | /// functions more than once in a test. |
96 | /// </remarks> | 96 | /// </remarks> |
97 | /// <param name="scene"></param> | 97 | /// <param name="assetService"></param> |
98 | /// <param name="part"></param> | 98 | /// <param name="part"></param> |
99 | /// <returns>The item that was added</returns> | 99 | /// <returns>The item that was added</returns> |
100 | public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) | 100 | public static TaskInventoryItem AddScript(IAssetService assetService, SceneObjectPart part) |
101 | { | 101 | { |
102 | 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\"); } }"); |
103 | } | 103 | } |
104 | 104 | ||
105 | /// <summary> | 105 | /// <summary> |
@@ -109,30 +109,47 @@ namespace OpenSim.Tests.Common | |||
109 | /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather | 109 | /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather |
110 | /// than a random component. | 110 | /// than a random component. |
111 | /// </remarks> | 111 | /// </remarks> |
112 | /// <param name="scene"></param> | 112 | /// <param name="assetService"></param> |
113 | /// <param name="part"></param> | 113 | /// <param name="part"></param> |
114 | /// <param name="scriptName">Name of the script to add</param> | 114 | /// <param name="scriptName">Name of the script to add</param> |
115 | /// <param name="scriptSource">LSL script source</param> | 115 | /// <param name="scriptSource">LSL script source</param> |
116 | /// <returns>The item that was added</returns> | 116 | /// <returns>The item that was added</returns> |
117 | public static TaskInventoryItem AddScript( | 117 | public static TaskInventoryItem AddScript( |
118 | Scene scene, SceneObjectPart part, string scriptName, string scriptSource) | 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. | ||
129 | /// </remarks> | ||
130 | /// <param name="assetService"></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> | ||
134 | /// <param name="scriptName">Name of the script to add</param> | ||
135 | /// <param name="scriptSource">LSL script source</param> | ||
136 | /// <returns>The item that was added</returns> | ||
137 | public static TaskInventoryItem AddScript( | ||
138 | IAssetService assetService, SceneObjectPart part, UUID itemId, UUID assetId, string scriptName, string scriptSource) | ||
119 | { | 139 | { |
120 | AssetScriptText ast = new AssetScriptText(); | 140 | AssetScriptText ast = new AssetScriptText(); |
121 | ast.Source = scriptSource; | 141 | ast.Source = scriptSource; |
122 | ast.Encode(); | 142 | ast.Encode(); |
123 | 143 | ||
124 | UUID assetUuid = UUID.Random(); | ||
125 | UUID itemUuid = UUID.Random(); | ||
126 | |||
127 | AssetBase asset | 144 | AssetBase asset |
128 | = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); | 145 | = AssetHelpers.CreateAsset(assetId, AssetType.LSLText, ast.AssetData, UUID.Zero); |
129 | scene.AssetService.Store(asset); | 146 | assetService.Store(asset); |
130 | TaskInventoryItem item | 147 | TaskInventoryItem item |
131 | = new TaskInventoryItem | 148 | = new TaskInventoryItem |
132 | { Name = scriptName, AssetID = assetUuid, ItemID = itemUuid, | 149 | { Name = scriptName, AssetID = assetId, ItemID = itemId, |
133 | Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; | 150 | Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; |
134 | part.Inventory.AddInventoryItem(item, true); | 151 | part.Inventory.AddInventoryItem(item, true); |
135 | 152 | ||
136 | return item; | 153 | return item; |
137 | } | 154 | } |
138 | 155 | ||
@@ -144,28 +161,50 @@ namespace OpenSim.Tests.Common | |||
144 | /// functions more than once in a test. | 161 | /// functions more than once in a test. |
145 | /// </remarks> | 162 | /// </remarks> |
146 | /// | 163 | /// |
147 | /// <param name="scene"></param> | 164 | /// <param name="assetService"></param> |
148 | /// <param name="sop"></param> | 165 | /// <param name="sop"></param> |
149 | /// <param name="itemName"></param> | 166 | /// <param name="itemName"></param> |
150 | /// <param name="id"></param> | 167 | /// <param name="itemId"></param> |
151 | /// <param name="userId"></param> | 168 | /// <param name="soToAdd"></param> |
169 | /// <param name="soAssetId"></param> | ||
152 | public static TaskInventoryItem AddSceneObject( | 170 | public static TaskInventoryItem AddSceneObject( |
153 | Scene scene, SceneObjectPart sop, string itemName, UUID id, UUID userId) | 171 | IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, SceneObjectGroup soToAdd, UUID soAssetId) |
154 | { | 172 | { |
155 | SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero); | 173 | AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(soAssetId, soToAdd); |
156 | AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); | 174 | assetService.Store(taskSceneObjectAsset); |
157 | scene.AssetService.Store(taskSceneObjectAsset); | ||
158 | TaskInventoryItem taskSceneObjectItem | 175 | TaskInventoryItem taskSceneObjectItem |
159 | = new TaskInventoryItem | 176 | = new TaskInventoryItem |
160 | { Name = itemName, | 177 | { Name = itemName, |
161 | AssetID = taskSceneObjectAsset.FullID, | 178 | AssetID = taskSceneObjectAsset.FullID, |
162 | ItemID = id, | 179 | ItemID = itemId, |
163 | OwnerID = userId, | 180 | OwnerID = soToAdd.OwnerID, |
164 | Type = (int)AssetType.Object, | 181 | Type = (int)AssetType.Object, |
165 | InvType = (int)InventoryType.Object }; | 182 | InvType = (int)InventoryType.Object }; |
166 | sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); | 183 | sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); |
167 | 184 | ||
168 | return taskSceneObjectItem; | 185 | return taskSceneObjectItem; |
169 | } | 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 | } | ||
170 | } | 209 | } |
171 | } \ No newline at end of file | 210 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs index b3b75af..5a36332 100644 --- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs | |||
@@ -102,7 +102,7 @@ namespace OpenSim.Tests.Common | |||
102 | { | 102 | { |
103 | return AddInventoryItem( | 103 | return AddInventoryItem( |
104 | scene, itemName, itemId, itemType, asset, userId, | 104 | scene, itemName, itemId, itemType, asset, userId, |
105 | scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type).Name); | 105 | scene.InventoryService.GetFolderForType(userId, (FolderType)asset.Type).Name); |
106 | } | 106 | } |
107 | 107 | ||
108 | /// <summary> | 108 | /// <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 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
31 | 32 | ||
32 | namespace OpenSim.Tests.Common.Mock | 33 | namespace 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 5bab62c..aaf61e7 100644 --- a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs | |||
@@ -31,7 +31,7 @@ using OpenMetaverse; | |||
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Data; | 32 | using OpenSim.Data; |
33 | 33 | ||
34 | namespace OpenSim.Tests.Common.Mock | 34 | namespace 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; | |||
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; | 41 | using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; |
42 | 42 | ||
43 | namespace OpenSim.Tests.Common.Mock | 43 | namespace 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/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs index b444241..d7a144c 100644 --- a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs +++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs | |||
@@ -94,8 +94,10 @@ namespace OpenSim.Tests.Common | |||
94 | 94 | ||
95 | public Type ReplaceableInterface { get { return null; } } | 95 | public Type ReplaceableInterface { get { return null; } } |
96 | 96 | ||
97 | #pragma warning disable 0067 | ||
97 | public event ScriptRemoved OnScriptRemoved; | 98 | public event ScriptRemoved OnScriptRemoved; |
98 | public event ObjectRemoved OnObjectRemoved; | 99 | public event ObjectRemoved OnObjectRemoved; |
100 | #pragma warning restore 0067 | ||
99 | 101 | ||
100 | public string GetXMLState (UUID itemID) | 102 | public string GetXMLState (UUID itemID) |
101 | { | 103 | { |
@@ -262,5 +264,9 @@ namespace OpenSim.Tests.Common | |||
262 | { | 264 | { |
263 | PostedEvents.Clear(); | 265 | PostedEvents.Clear(); |
264 | } | 266 | } |
267 | |||
268 | public void SleepScript(UUID itemID, int delay) | ||
269 | { | ||
270 | } | ||
265 | } | 271 | } |
266 | } \ No newline at end of file | 272 | } |
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 5daca1e..f034443 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -38,7 +38,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Framework.Client; | 39 | using OpenSim.Framework.Client; |
40 | 40 | ||
41 | namespace OpenSim.Tests.Common.Mock | 41 | namespace OpenSim.Tests.Common |
42 | { | 42 | { |
43 | public class TestClient : IClientAPI, IClientCore | 43 | public class TestClient : IClientAPI, IClientCore |
44 | { | 44 | { |
@@ -62,12 +62,23 @@ namespace OpenSim.Tests.Common.Mock | |||
62 | public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion; | 62 | public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion; |
63 | public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour; | 63 | public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour; |
64 | public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport; | 64 | public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport; |
65 | |||
66 | public event Action<ISceneEntity, PrimUpdateFlags> OnReceivedEntityUpdate; | ||
67 | |||
68 | public event OnReceivedChatMessageDelegate OnReceivedChatMessage; | ||
65 | public event Action<GridInstantMessage> OnReceivedInstantMessage; | 69 | public event Action<GridInstantMessage> OnReceivedInstantMessage; |
66 | 70 | ||
71 | public event Action<UUID> OnReceivedSendRebakeAvatarTextures; | ||
72 | |||
67 | public delegate void TestClientOnSendRegionTeleportDelegate( | 73 | public delegate void TestClientOnSendRegionTeleportDelegate( |
68 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 74 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
69 | uint locationID, uint flags, string capsURL); | 75 | uint locationID, uint flags, string capsURL); |
70 | 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 | |||
71 | // disable warning: public events, part of the public API | 82 | // disable warning: public events, part of the public API |
72 | #pragma warning disable 67 | 83 | #pragma warning disable 67 |
73 | 84 | ||
@@ -472,6 +483,34 @@ namespace OpenSim.Tests.Common.Mock | |||
472 | } | 483 | } |
473 | 484 | ||
474 | /// <summary> | 485 | /// <summary> |
486 | /// Trigger chat coming from this connection. | ||
487 | /// </summary> | ||
488 | /// <param name="channel"></param> | ||
489 | /// <param name="type"></param> | ||
490 | /// <param name="message"></param> | ||
491 | public bool Chat(int channel, ChatTypeEnum type, string message) | ||
492 | { | ||
493 | ChatMessage handlerChatFromClient = OnChatFromClient; | ||
494 | |||
495 | if (handlerChatFromClient != null) | ||
496 | { | ||
497 | OSChatMessage args = new OSChatMessage(); | ||
498 | args.Channel = channel; | ||
499 | args.From = Name; | ||
500 | args.Message = message; | ||
501 | args.Type = type; | ||
502 | |||
503 | args.Scene = Scene; | ||
504 | args.Sender = this; | ||
505 | args.SenderUUID = AgentId; | ||
506 | |||
507 | handlerChatFromClient(this, args); | ||
508 | } | ||
509 | |||
510 | return true; | ||
511 | } | ||
512 | |||
513 | /// <summary> | ||
475 | /// Attempt a teleport to the given region. | 514 | /// Attempt a teleport to the given region. |
476 | /// </summary> | 515 | /// </summary> |
477 | /// <param name="regionHandle"></param> | 516 | /// <param name="regionHandle"></param> |
@@ -572,6 +611,9 @@ namespace OpenSim.Tests.Common.Mock | |||
572 | string message, byte type, Vector3 fromPos, string fromName, | 611 | string message, byte type, Vector3 fromPos, string fromName, |
573 | UUID fromAgentID, UUID ownerID, byte source, byte audible) | 612 | UUID fromAgentID, UUID ownerID, byte source, byte audible) |
574 | { | 613 | { |
614 | // Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId); | ||
615 | if (OnReceivedChatMessage != null) | ||
616 | OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); | ||
575 | } | 617 | } |
576 | 618 | ||
577 | public void SendInstantMessage(GridInstantMessage im) | 619 | public void SendInstantMessage(GridInstantMessage im) |
@@ -713,6 +755,8 @@ namespace OpenSim.Tests.Common.Mock | |||
713 | 755 | ||
714 | public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) | 756 | public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) |
715 | { | 757 | { |
758 | if (OnReceivedEntityUpdate != null) | ||
759 | OnReceivedEntityUpdate(entity, updateFlags); | ||
716 | } | 760 | } |
717 | 761 | ||
718 | public void ReprioritizeUpdates() | 762 | public void ReprioritizeUpdates() |
@@ -1260,6 +1304,8 @@ namespace OpenSim.Tests.Common.Mock | |||
1260 | 1304 | ||
1261 | public void SendRebakeAvatarTextures(UUID textureID) | 1305 | public void SendRebakeAvatarTextures(UUID textureID) |
1262 | { | 1306 | { |
1307 | if (OnReceivedSendRebakeAvatarTextures != null) | ||
1308 | OnReceivedSendRebakeAvatarTextures(textureID); | ||
1263 | } | 1309 | } |
1264 | 1310 | ||
1265 | public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) | 1311 | public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) |
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Net.Sockets; | ||
33 | using System.Text; | ||
34 | using HttpServer; | ||
35 | using OpenSim.Framework; | ||
36 | |||
37 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections.Specialized; | ||
30 | using System.IO; | ||
31 | using HttpServer; | ||
32 | using HttpServer.FormDecoders; | ||
33 | |||
34 | namespace 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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Net; | ||
31 | using System.Text; | ||
32 | using HttpServer; | ||
33 | |||
34 | namespace 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; | |||
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Data; | 34 | using OpenSim.Data; |
35 | 35 | ||
36 | namespace OpenSim.Tests.Common.Mock | 36 | namespace 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/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs index 27b9e5b..26887c9 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs +++ b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs | |||
@@ -32,8 +32,9 @@ using System.Net.Sockets; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse.Packets; | 33 | using OpenMetaverse.Packets; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.ClientStack.LindenUDP; | ||
35 | 36 | ||
36 | namespace OpenSim.Region.ClientStack.LindenUDP.Tests | 37 | namespace OpenSim.Tests.Common |
37 | { | 38 | { |
38 | /// <summary> | 39 | /// <summary> |
39 | /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data. | 40 | /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data. |
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs index 8135bfc..23258ad 100644 --- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs +++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs | |||
@@ -32,7 +32,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
32 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Region.CoreModules.World.Land; | 33 | using OpenSim.Region.CoreModules.World.Land; |
34 | 34 | ||
35 | namespace OpenSim.Tests.Common.Mock | 35 | namespace OpenSim.Tests.Common |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// Land channel for test purposes | 38 | /// Land channel for test purposes |
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; | |||
35 | using System.Web; | 35 | using System.Web; |
36 | using OpenSim.Framework.Servers.HttpServer; | 36 | using OpenSim.Framework.Servers.HttpServer; |
37 | 37 | ||
38 | namespace OpenSim.Tests.Common.Mock | 38 | namespace 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; | |||
32 | using System.Web; | 32 | using System.Web; |
33 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
34 | 34 | ||
35 | namespace OpenSim.Tests.Common.Mock | 35 | namespace 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 53a311e..e559871 100644 --- a/OpenSim/Tests/Common/Mock/TestScene.cs +++ b/OpenSim/Tests/Common/Mock/TestScene.cs | |||
@@ -34,8 +34,12 @@ using OpenSim.Region.Framework; | |||
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Physics.Manager; | 36 | using OpenSim.Region.Physics.Manager; |
37 | <<<<<<< HEAD | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | ======= | ||
40 | >>>>>>> avn/ubitvar | ||
37 | 41 | ||
38 | namespace OpenSim.Tests.Common.Mock | 42 | namespace OpenSim.Tests.Common |
39 | { | 43 | { |
40 | public class TestScene : Scene | 44 | public class TestScene : Scene |
41 | { | 45 | { |
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs index 2be5524..2b272e6 100644 --- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs | |||
@@ -35,7 +35,7 @@ using OpenSim.Framework; | |||
35 | using OpenSim.Data; | 35 | using OpenSim.Data; |
36 | using OpenSim.Data.Null; | 36 | using OpenSim.Data.Null; |
37 | 37 | ||
38 | namespace OpenSim.Tests.Common.Mock | 38 | namespace OpenSim.Tests.Common |
39 | { | 39 | { |
40 | public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData | 40 | public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData |
41 | { | 41 | { |
@@ -46,20 +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 | { |
56 | // Console.WriteLine( | 64 | // Console.WriteLine( |
57 | // "Requesting folders, fields {0}, vals {1}", string.Join(",", fields), string.Join(",", vals)); | 65 | // "Requesting folders, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); |
58 | 66 | ||
59 | List<XInventoryFolder> origFolders | 67 | List<XInventoryFolder> origFolders |
60 | = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); | 68 | = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); |
61 | 69 | ||
62 | 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; | ||
63 | } | 76 | } |
64 | 77 | ||
65 | public bool StoreFolder(XInventoryFolder folder) | 78 | public bool StoreFolder(XInventoryFolder folder) |
@@ -75,7 +88,9 @@ namespace OpenSim.Tests.Common.Mock | |||
75 | { | 88 | { |
76 | m_allItems[item.inventoryID] = item.Clone(); | 89 | m_allItems[item.inventoryID] = item.Clone(); |
77 | 90 | ||
78 | // 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); | ||
79 | 94 | ||
80 | return true; | 95 | return true; |
81 | } | 96 | } |
diff --git a/OpenSim/Tests/Common/OpenSimTestCase.cs b/OpenSim/Tests/Common/OpenSimTestCase.cs index 3c47faa..c1415af 100644 --- a/OpenSim/Tests/Common/OpenSimTestCase.cs +++ b/OpenSim/Tests/Common/OpenSimTestCase.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using NUnit.Framework; | 29 | using NUnit.Framework; |
30 | using OpenSim.Framework; | ||
30 | using OpenSim.Framework.Servers; | 31 | using OpenSim.Framework.Servers; |
31 | 32 | ||
32 | namespace OpenSim.Tests.Common | 33 | namespace OpenSim.Tests.Common |