diff options
author | Justin Clark-Casey (justincc) | 2014-10-08 20:17:51 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-11-25 23:18:40 +0000 |
commit | 52370ac94de4f449645eb0471fab4cc515fccbe2 (patch) | |
tree | 1b920cad4f0416420a8fec9f804b1272bf92166e /OpenSim/Tests/Common | |
parent | Fix recent regression in "debug lludp throttles get" command that stopped it ... (diff) | |
download | opensim-SC-52370ac94de4f449645eb0471fab4cc515fccbe2.zip opensim-SC-52370ac94de4f449645eb0471fab4cc515fccbe2.tar.gz opensim-SC-52370ac94de4f449645eb0471fab4cc515fccbe2.tar.bz2 opensim-SC-52370ac94de4f449645eb0471fab4cc515fccbe2.tar.xz |
refactor: Move test clientstack setup code out of BasicCircuitTests into OpenSim.Tests.Common.ClientStackHelpers
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs | 95 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestLLUDPServer.cs (renamed from OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs) | 3 |
2 files changed, 97 insertions, 1 deletions
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/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. |