diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs index c75a5b3..352f697 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs | |||
@@ -26,9 +26,9 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Net; | 28 | using System.Net; |
29 | //using System.Threading; | ||
30 | using log4net; | 29 | using log4net; |
31 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenMetaverse.Packets; | 33 | using OpenMetaverse.Packets; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -60,9 +60,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
60 | /// <summary> | 60 | /// <summary> |
61 | /// Add a client for testing | 61 | /// Add a client for testing |
62 | /// </summary> | 62 | /// </summary> |
63 | /// <param name="scene"></param> | ||
63 | /// <param name="testLLUDPServer"></param> | 64 | /// <param name="testLLUDPServer"></param> |
65 | /// <param name="testPacketServer"></param> | ||
64 | /// <param name="acm">Agent circuit manager used in setting up the stack</param> | 66 | /// <param name="acm">Agent circuit manager used in setting up the stack</param> |
65 | protected void SetupStack(out TestLLUDPServer testLLUDPServer, out AgentCircuitManager acm) | 67 | protected void SetupStack( |
68 | IScene scene, out TestLLUDPServer testLLUDPServer, out TestLLPacketServer testPacketServer, | ||
69 | out AgentCircuitManager acm) | ||
66 | { | 70 | { |
67 | ClientStackUserSettings userSettings = new ClientStackUserSettings(); | 71 | ClientStackUserSettings userSettings = new ClientStackUserSettings(); |
68 | testLLUDPServer = new TestLLUDPServer(); | 72 | testLLUDPServer = new TestLLUDPServer(); |
@@ -70,8 +74,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
70 | 74 | ||
71 | uint port = 666; | 75 | uint port = 666; |
72 | testLLUDPServer.Initialise(null, ref port, 0, false, userSettings, null, acm); | 76 | testLLUDPServer.Initialise(null, ref port, 0, false, userSettings, null, acm); |
73 | new LLPacketServer(testLLUDPServer, userSettings); | 77 | testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings); |
74 | testLLUDPServer.LocalScene = new MockScene(); | 78 | testLLUDPServer.LocalScene = scene; |
75 | } | 79 | } |
76 | 80 | ||
77 | /// <summary> | 81 | /// <summary> |
@@ -117,8 +121,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
117 | UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); | 121 | UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); |
118 | 122 | ||
119 | TestLLUDPServer testLLUDPServer; | 123 | TestLLUDPServer testLLUDPServer; |
124 | TestLLPacketServer testLLPacketServer; | ||
120 | AgentCircuitManager acm; | 125 | AgentCircuitManager acm; |
121 | SetupStack(out testLLUDPServer, out acm); | 126 | SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm); |
122 | 127 | ||
123 | AgentCircuitData acd = new AgentCircuitData(); | 128 | AgentCircuitData acd = new AgentCircuitData(); |
124 | acd.AgentID = myAgentUuid; | 129 | acd.AgentID = myAgentUuid; |
@@ -160,8 +165,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
160 | uint myCircuitCode = 123457; | 165 | uint myCircuitCode = 123457; |
161 | 166 | ||
162 | TestLLUDPServer testLLUDPServer; | 167 | TestLLUDPServer testLLUDPServer; |
168 | TestLLPacketServer testLLPacketServer; | ||
163 | AgentCircuitManager acm; | 169 | AgentCircuitManager acm; |
164 | SetupStack(out testLLUDPServer, out acm); | 170 | SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm); |
165 | AddClient(myCircuitCode, new IPEndPoint(IPAddress.Loopback, 1000), testLLUDPServer, acm); | 171 | AddClient(myCircuitCode, new IPEndPoint(IPAddress.Loopback, 1000), testLLUDPServer, acm); |
166 | 172 | ||
167 | testLLUDPServer.RemoveClientCircuit(myCircuitCode); | 173 | testLLUDPServer.RemoveClientCircuit(myCircuitCode); |
@@ -179,20 +185,41 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
179 | public void TestMalformedPacketSend() | 185 | public void TestMalformedPacketSend() |
180 | { | 186 | { |
181 | uint myCircuitCode = 123458; | 187 | uint myCircuitCode = 123458; |
182 | EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 1001); | 188 | EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 1001); |
189 | MockScene scene = new MockScene(); | ||
183 | 190 | ||
184 | TestLLUDPServer testLLUDPServer; | 191 | TestLLUDPServer testLLUDPServer; |
192 | TestLLPacketServer testLLPacketServer; | ||
185 | AgentCircuitManager acm; | 193 | AgentCircuitManager acm; |
186 | SetupStack(out testLLUDPServer, out acm); | 194 | SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm); |
187 | AddClient(myCircuitCode, testEp, testLLUDPServer, acm); | 195 | AddClient(myCircuitCode, testEp, testLLUDPServer, acm); |
188 | 196 | ||
189 | byte[] data = new byte[] { 0x01, 0x02, 0x03, 0x04 }; | 197 | byte[] data = new byte[] { 0x01, 0x02, 0x03, 0x04 }; |
190 | 198 | ||
199 | // Send two garbled 'packets' in succession | ||
200 | testLLUDPServer.LoadReceive(data, testEp); | ||
191 | testLLUDPServer.LoadReceive(data, testEp); | 201 | testLLUDPServer.LoadReceive(data, testEp); |
192 | testLLUDPServer.ReceiveData(null); | 202 | testLLUDPServer.ReceiveData(null); |
193 | 203 | ||
194 | // Check that we are still here | 204 | // Check that we are still here |
195 | Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); | 205 | Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); |
206 | Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(0)); | ||
207 | |||
208 | // Check that sending a valid packet to same circuit still succeeds | ||
209 | Assert.That(scene.ObjectNameCallsReceived, Is.EqualTo(0)); | ||
210 | |||
211 | ObjectNamePacket onp = new ObjectNamePacket(); | ||
212 | ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); | ||
213 | odb.LocalID = 1; | ||
214 | odb.Name = Utils.StringToBytes("helloooo"); | ||
215 | onp.ObjectData = new ObjectNamePacket.ObjectDataBlock[] { odb }; | ||
216 | onp.Header.Zerocoded = false; | ||
217 | |||
218 | testLLUDPServer.LoadReceive(onp, testEp); | ||
219 | testLLUDPServer.ReceiveData(null); | ||
220 | |||
221 | Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(1)); | ||
222 | Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(1)); | ||
196 | } | 223 | } |
197 | } | 224 | } |
198 | } | 225 | } |