aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs50
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs26
2 files changed, 66 insertions, 10 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
index d55f423..6210d0c 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
@@ -113,6 +113,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
113 } 113 }
114 114
115 /// <summary> 115 /// <summary>
116 /// Build an object name packet for test purposes
117 /// </summary>
118 /// <param name="objectLocalId"></param>
119 /// <param name="objectName"></param>
120 protected ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName)
121 {
122 ObjectNamePacket onp = new ObjectNamePacket();
123 ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock();
124 odb.LocalID = objectLocalId;
125 odb.Name = Utils.StringToBytes(objectName);
126 onp.ObjectData = new ObjectNamePacket.ObjectDataBlock[] { odb };
127 onp.Header.Zerocoded = false;
128
129 return onp;
130 }
131
132 /// <summary>
116 /// Test adding a client to the stack 133 /// Test adding a client to the stack
117 /// </summary> 134 /// </summary>
118 [Test] 135 [Test]
@@ -209,19 +226,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
209 226
210 // Check that sending a valid packet to same circuit still succeeds 227 // Check that sending a valid packet to same circuit still succeeds
211 Assert.That(scene.ObjectNameCallsReceived, Is.EqualTo(0)); 228 Assert.That(scene.ObjectNameCallsReceived, Is.EqualTo(0));
212
213 ObjectNamePacket onp = new ObjectNamePacket();
214 ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock();
215 odb.LocalID = 1;
216 odb.Name = Utils.StringToBytes("helloooo");
217 onp.ObjectData = new ObjectNamePacket.ObjectDataBlock[] { odb };
218 onp.Header.Zerocoded = false;
219 229
220 testLLUDPServer.LoadReceive(onp, testEp); 230 testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "helloooo"), testEp);
221 testLLUDPServer.ReceiveData(null); 231 testLLUDPServer.ReceiveData(null);
222 232
223 Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(1)); 233 Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(1));
224 Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(1)); 234 Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(1));
225 } 235 }
236
237 /// <summary>
238 /// Test that the stack continues to work even if some client has caused a
239 /// SocketException on Socket.BeginReceive()
240 /// </summary>
241 [Test]
242 public void TestExceptionOnBeginReceive()
243 {
244 /*
245 MockScene scene = new MockScene();
246
247 uint circuitCodeA = 130000;
248 EndPoint epA = new IPEndPoint(IPAddress.Loopback, 1300);
249 uint circuitCodeB = 130001;
250 EndPoint epB = new IPEndPoint(IPAddress.Loopback, 1301);
251
252 TestLLUDPServer testLLUDPServer;
253 TestLLPacketServer testLLPacketServer;
254 AgentCircuitManager acm;
255 SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);
256 AddClient(circuitCodeA, epA, testLLUDPServer, acm);
257 AddClient(circuitCodeB, epB, testLLUDPServer, acm);
258 */
259 }
226 } 260 }
227} 261}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs
index dd7afd3..002b493 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs
@@ -48,7 +48,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
48 48
49 protected override void BeginReceive() 49 protected override void BeginReceive()
50 { 50 {
51 // Do nothing 51 if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
52 {
53 ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
54 reusedEpSender = tuple.Sender;
55 throw new SocketException();
56 }
52 } 57 }
53 58
54 protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender) 59 protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
@@ -72,6 +77,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
72 } 77 }
73 78
74 /// <summary> 79 /// <summary>
80 /// Signal that this chunk should throw an exception on Socket.BeginReceive()
81 /// </summary>
82 /// <param name="epSender"></param>
83 public void LoadReceiveWithBeginException(EndPoint epSender)
84 {
85 ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
86 tuple.BeginReceiveException = true;
87 m_chunksToLoad.Enqueue(tuple);
88 }
89
90 /// <summary>
75 /// Load some data to be received by the LLUDPServer on the next receive call 91 /// Load some data to be received by the LLUDPServer on the next receive call
76 /// </summary> 92 /// </summary>
77 /// <param name="data"></param> 93 /// <param name="data"></param>
@@ -118,14 +134,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
118 /// Record the data and sender tuple 134 /// Record the data and sender tuple
119 /// </summary> 135 /// </summary>
120 public class ChunkSenderTuple 136 public class ChunkSenderTuple
121 { 137 {
122 public byte[] Data; 138 public byte[] Data;
123 public EndPoint Sender; 139 public EndPoint Sender;
140 public bool BeginReceiveException;
124 141
125 public ChunkSenderTuple(byte[] data, EndPoint sender) 142 public ChunkSenderTuple(byte[] data, EndPoint sender)
126 { 143 {
127 Data = data; 144 Data = data;
128 Sender = sender; 145 Sender = sender;
129 } 146 }
147
148 public ChunkSenderTuple(EndPoint sender)
149 {
150 Sender = sender;
151 }
130 } 152 }
131} \ No newline at end of file 153} \ No newline at end of file