diff options
Diffstat (limited to 'OpenSim/Tests/Common/Mock')
-rw-r--r-- | OpenSim/Tests/Common/Mock/BaseAssetRepository.cs | 11 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs | 2 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs | 178 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockScriptEngine.cs | 8 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestClient.cs | 48 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestHttpClientContext.cs | 110 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestHttpRequest.cs | 174 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestHttpResponse.cs | 171 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs | 4 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestLLUDPServer.cs | 171 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestLandChannel.cs | 2 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs | 2 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs | 2 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestScene.cs | 6 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs | 25 |
15 files changed, 870 insertions, 44 deletions
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/Tests/Common/Mock/TestLLUDPServer.cs b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs new file mode 100644 index 0000000..26887c9 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs | |||
@@ -0,0 +1,171 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Net.Sockets; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse.Packets; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.ClientStack.LindenUDP; | ||
36 | |||
37 | namespace OpenSim.Tests.Common | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data. | ||
41 | /// </summary> | ||
42 | public class TestLLUDPServer : LLUDPServer | ||
43 | { | ||
44 | public List<Packet> PacketsSent { get; private set; } | ||
45 | |||
46 | public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) | ||
47 | : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager) | ||
48 | { | ||
49 | PacketsSent = new List<Packet>(); | ||
50 | } | ||
51 | |||
52 | public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack) | ||
53 | { | ||
54 | PacketsSent.Add(ack); | ||
55 | } | ||
56 | |||
57 | public override void SendPacket( | ||
58 | LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method) | ||
59 | { | ||
60 | PacketsSent.Add(packet); | ||
61 | } | ||
62 | |||
63 | public void ClientOutgoingPacketHandler(IClientAPI client, bool resendUnacked, bool sendAcks, bool sendPing) | ||
64 | { | ||
65 | m_resendUnacked = resendUnacked; | ||
66 | m_sendAcks = sendAcks; | ||
67 | m_sendPing = sendPing; | ||
68 | |||
69 | ClientOutgoingPacketHandler(client); | ||
70 | } | ||
71 | |||
72 | //// /// <summary> | ||
73 | //// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive | ||
74 | //// /// </summary> | ||
75 | //// protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>(); | ||
76 | // | ||
77 | //// protected override void BeginReceive() | ||
78 | //// { | ||
79 | //// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException) | ||
80 | //// { | ||
81 | //// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); | ||
82 | //// reusedEpSender = tuple.Sender; | ||
83 | //// throw new SocketException(); | ||
84 | //// } | ||
85 | //// } | ||
86 | // | ||
87 | //// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender) | ||
88 | //// { | ||
89 | //// numBytes = 0; | ||
90 | //// | ||
91 | //// //m_log.Debug("Queue size " + m_chunksToLoad.Count); | ||
92 | //// | ||
93 | //// if (m_chunksToLoad.Count <= 0) | ||
94 | //// return false; | ||
95 | //// | ||
96 | //// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); | ||
97 | //// RecvBuffer = tuple.Data; | ||
98 | //// numBytes = tuple.Data.Length; | ||
99 | //// epSender = tuple.Sender; | ||
100 | //// | ||
101 | //// return true; | ||
102 | //// } | ||
103 | // | ||
104 | //// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) | ||
105 | //// { | ||
106 | //// // Don't do anything just yet | ||
107 | //// } | ||
108 | // | ||
109 | // /// <summary> | ||
110 | // /// Signal that this chunk should throw an exception on Socket.BeginReceive() | ||
111 | // /// </summary> | ||
112 | // /// <param name="epSender"></param> | ||
113 | // public void LoadReceiveWithBeginException(EndPoint epSender) | ||
114 | // { | ||
115 | // ChunkSenderTuple tuple = new ChunkSenderTuple(epSender); | ||
116 | // tuple.BeginReceiveException = true; | ||
117 | // m_chunksToLoad.Enqueue(tuple); | ||
118 | // } | ||
119 | // | ||
120 | // /// <summary> | ||
121 | // /// Load some data to be received by the LLUDPServer on the next receive call | ||
122 | // /// </summary> | ||
123 | // /// <param name="data"></param> | ||
124 | // /// <param name="epSender"></param> | ||
125 | // public void LoadReceive(byte[] data, EndPoint epSender) | ||
126 | // { | ||
127 | // m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender)); | ||
128 | // } | ||
129 | // | ||
130 | // /// <summary> | ||
131 | // /// Load a packet to be received by the LLUDPServer on the next receive call | ||
132 | // /// </summary> | ||
133 | // /// <param name="packet"></param> | ||
134 | // public void LoadReceive(Packet packet, EndPoint epSender) | ||
135 | // { | ||
136 | // LoadReceive(packet.ToBytes(), epSender); | ||
137 | // } | ||
138 | // | ||
139 | // /// <summary> | ||
140 | // /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send | ||
141 | // /// </summary> | ||
142 | // /// <param name="result"></param> | ||
143 | // public void ReceiveData(IAsyncResult result) | ||
144 | // { | ||
145 | // // Doesn't work the same way anymore | ||
146 | //// while (m_chunksToLoad.Count > 0) | ||
147 | //// OnReceivedData(result); | ||
148 | // } | ||
149 | } | ||
150 | |||
151 | /// <summary> | ||
152 | /// Record the data and sender tuple | ||
153 | /// </summary> | ||
154 | public class ChunkSenderTuple | ||
155 | { | ||
156 | public byte[] Data; | ||
157 | public EndPoint Sender; | ||
158 | public bool BeginReceiveException; | ||
159 | |||
160 | public ChunkSenderTuple(byte[] data, EndPoint sender) | ||
161 | { | ||
162 | Data = data; | ||
163 | Sender = sender; | ||
164 | } | ||
165 | |||
166 | public ChunkSenderTuple(EndPoint sender) | ||
167 | { | ||
168 | Sender = sender; | ||
169 | } | ||
170 | } | ||
171 | } | ||
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs index 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 | } |