aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Mock
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 11:43:07 +0100
committerUbitUmarov2015-09-01 11:43:07 +0100
commitfb78b182520fc9bb0f971afd0322029c70278ea6 (patch)
treeb4e30d383938fdeef8c92d1d1c2f44bb61d329bd /OpenSim/Tests/Common/Mock
parentlixo (diff)
parentMantis #7713: fixed bug introduced by 1st MOSES patch. (diff)
downloadopensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.zip
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.gz
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.bz2
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.xz
Merge remote-tracking branch 'os/master'
Diffstat (limited to 'OpenSim/Tests/Common/Mock')
-rw-r--r--OpenSim/Tests/Common/Mock/BaseAssetRepository.cs62
-rw-r--r--OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs69
-rw-r--r--OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs436
-rw-r--r--OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs371
-rw-r--r--OpenSim/Tests/Common/Mock/MockScriptEngine.cs272
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs1323
-rw-r--r--OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs182
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpClientContext.cs110
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpRequest.cs174
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpResponse.cs171
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs219
-rw-r--r--OpenSim/Tests/Common/Mock/TestLLUDPServer.cs171
-rw-r--r--OpenSim/Tests/Common/Mock/TestLandChannel.cs115
-rw-r--r--OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs179
-rw-r--r--OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs133
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs77
-rw-r--r--OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs152
17 files changed, 4216 insertions, 0 deletions
diff --git a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs
new file mode 100644
index 0000000..cb4fb80
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs
@@ -0,0 +1,62 @@
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
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Tests.Common
34{
35 public class BaseAssetRepository
36 {
37 protected Dictionary<UUID, AssetBase> Assets = new Dictionary<UUID, AssetBase>();
38
39 public AssetBase FetchAsset(UUID uuid)
40 {
41 if (AssetsExist(new[] { uuid })[0])
42 return Assets[uuid];
43 else
44 return null;
45 }
46
47 public void CreateAsset(AssetBase asset)
48 {
49 Assets[asset.FullID] = asset;
50 }
51
52 public void UpdateAsset(AssetBase asset)
53 {
54 CreateAsset(asset);
55 }
56
57 public bool[] AssetsExist(UUID[] uuids)
58 {
59 return Array.ConvertAll(uuids, id => Assets.ContainsKey(id));
60 }
61 }
62} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
new file mode 100644
index 0000000..dddf75d
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
@@ -0,0 +1,69 @@
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
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Data;
33
34namespace OpenSim.Tests.Common
35{
36 /// <summary>
37 /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the
38 /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit
39 /// tests are single threaded.
40 /// </summary>
41 public class MockAssetDataPlugin : BaseAssetRepository, IAssetDataPlugin
42 {
43 public string Version { get { return "0"; } }
44 public string Name { get { return "MockAssetDataPlugin"; } }
45
46 public void Initialise() {}
47 public void Initialise(string connect) {}
48 public void Dispose() {}
49
50 private readonly List<AssetBase> assets = new List<AssetBase>();
51
52 public AssetBase GetAsset(UUID uuid)
53 {
54 return assets.Find(x=>x.FullID == uuid);
55 }
56
57 public void StoreAsset(AssetBase asset)
58 {
59 assets.Add(asset);
60 }
61
62 public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); }
63
64 public bool Delete(string id)
65 {
66 return false;
67 }
68 }
69}
diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
new file mode 100644
index 0000000..7f530d0
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
@@ -0,0 +1,436 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Data;
37using OpenSim.Data.Null;
38using OpenSim.Framework;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
42
43namespace OpenSim.Tests.Common
44{
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
46 public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 IXGroupData m_data = new NullXGroupData(null, null);
51
52 public string Name
53 {
54 get { return "MockGroupsServicesConnector"; }
55 }
56
57 public Type ReplaceableInterface
58 {
59 get { return null; }
60 }
61
62 public void Initialise(IConfigSource config)
63 {
64 }
65
66 public void Close()
67 {
68 }
69
70 public void AddRegion(Scene scene)
71 {
72 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Adding to region {0}", scene.RegionInfo.RegionName);
73 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
74 }
75
76 public void RemoveRegion(Scene scene)
77 {
78 }
79
80 public void RegionLoaded(Scene scene)
81 {
82 }
83
84 public void PostInitialise()
85 {
86 }
87
88 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
89 int membershipFee, bool openEnrollment, bool allowPublish,
90 bool maturePublish, UUID founderID)
91 {
92 XGroup group = new XGroup()
93 {
94 groupID = UUID.Random(),
95 ownerRoleID = UUID.Random(),
96 name = name,
97 charter = charter,
98 showInList = showInList,
99 insigniaID = insigniaID,
100 membershipFee = membershipFee,
101 openEnrollment = openEnrollment,
102 allowPublish = allowPublish,
103 maturePublish = maturePublish,
104 founderID = founderID,
105 everyonePowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultEveryonePowers,
106 ownersPowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultOwnerPowers
107 };
108
109 if (m_data.StoreGroup(group))
110 {
111 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Created group {0} {1}", group.name, group.groupID);
112 return group.groupID;
113 }
114 else
115 {
116 m_log.ErrorFormat("[MOCK GROUPS SERVICES CONNECTOR]: Failed to create group {0}", name);
117 return UUID.Zero;
118 }
119 }
120
121 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
122 UUID insigniaID, int membershipFee, bool openEnrollment,
123 bool allowPublish, bool maturePublish)
124 {
125 }
126
127 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
128 string title, ulong powers)
129 {
130 }
131
132 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
133 {
134 }
135
136 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
137 string title, ulong powers)
138 {
139 }
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
152 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
153 {
154 m_log.DebugFormat(
155 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}",
156 groupID, groupName);
157
158 XGroup xg = GetXGroup(groupID, groupName);
159
160 if (xg == null)
161 return null;
162
163 GroupRecord gr = new GroupRecord()
164 {
165 GroupID = xg.groupID,
166 GroupName = xg.name,
167 AllowPublish = xg.allowPublish,
168 MaturePublish = xg.maturePublish,
169 Charter = xg.charter,
170 FounderID = xg.founderID,
171 // FIXME: group picture storage location unknown
172 MembershipFee = xg.membershipFee,
173 OpenEnrollment = xg.openEnrollment,
174 OwnerRoleID = xg.ownerRoleID,
175 ShowInList = xg.showInList
176 };
177
178 return gr;
179 }
180
181 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
182 {
183 return default(GroupProfileData);
184 }
185
186 public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
187 {
188 }
189
190 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
191 {
192 }
193
194 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
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);
213 }
214
215 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
216 {
217 }
218
219 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
220 {
221 return null;
222 }
223
224 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
225 {
226 }
227
228 public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
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);
249 }
250
251 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
252 {
253 }
254
255 public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
256 {
257 }
258
259 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
260 {
261 }
262
263 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
264 {
265 return null;
266 }
267
268 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
269 {
270 return null;
271 }
272
273 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
274 {
275 return null;
276 }
277
278 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
279 {
280 return new List<GroupMembershipData>();
281 }
282
283 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
284 {
285 return null;
286 }
287
288 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
289 {
290 return null;
291 }
292
293 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID groupID)
294 {
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;
318 }
319
320 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
321 {
322 return null;
323 }
324
325 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID groupID)
326 {
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;
350 }
351
352 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
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
382 return null;
383 }
384
385 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
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);
412 }
413
414 public void ResetAgentGroupChatSessions(UUID agentID)
415 {
416 }
417
418 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
419 {
420 return false;
421 }
422
423 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
424 {
425 return false;
426 }
427
428 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
429 {
430 }
431
432 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
433 {
434 }
435 }
436} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
new file mode 100644
index 0000000..5df8e04
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
@@ -0,0 +1,371 @@
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
28using System.Reflection;
29using System.Collections.Generic;
30using log4net;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Data.Null
37{
38 public class NullDataService : ISimulationDataService
39 {
40 private NullDataStore m_store;
41
42 public NullDataService()
43 {
44 m_store = new NullDataStore();
45 }
46
47 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
48 {
49 m_store.StoreObject(obj, regionUUID);
50 }
51
52 public void RemoveObject(UUID uuid, UUID regionUUID)
53 {
54 m_store.RemoveObject(uuid, regionUUID);
55 }
56
57 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
58 {
59 m_store.StorePrimInventory(primID, items);
60 }
61
62 public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
63 {
64 return m_store.LoadObjects(regionUUID);
65 }
66
67 public void StoreTerrain(double[,] terrain, UUID regionID)
68 {
69 m_store.StoreTerrain(terrain, regionID);
70 }
71
72 public void StoreTerrain(TerrainData terrain, UUID regionID)
73 {
74 m_store.StoreTerrain(terrain, regionID);
75 }
76
77 public double[,] LoadTerrain(UUID regionID)
78 {
79 return m_store.LoadTerrain(regionID);
80 }
81
82 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
83 {
84 return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
85 }
86
87 public void StoreLandObject(ILandObject Parcel)
88 {
89 m_store.StoreLandObject(Parcel);
90 }
91
92 public void RemoveLandObject(UUID globalID)
93 {
94 m_store.RemoveLandObject(globalID);
95 }
96
97 public List<LandData> LoadLandObjects(UUID regionUUID)
98 {
99 return m_store.LoadLandObjects(regionUUID);
100 }
101
102 public void StoreRegionSettings(RegionSettings rs)
103 {
104 m_store.StoreRegionSettings(rs);
105 }
106
107 public RegionSettings LoadRegionSettings(UUID regionUUID)
108 {
109 return m_store.LoadRegionSettings(regionUUID);
110 }
111
112 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
113 {
114 return m_store.LoadRegionWindlightSettings(regionUUID);
115 }
116
117 public void RemoveRegionWindlightSettings(UUID regionID)
118 {
119 }
120
121 public void StoreRegionWindlightSettings(RegionLightShareData wl)
122 {
123 m_store.StoreRegionWindlightSettings(wl);
124 }
125
126 public string LoadRegionEnvironmentSettings(UUID regionUUID)
127 {
128 return m_store.LoadRegionEnvironmentSettings(regionUUID);
129 }
130
131 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
132 {
133 m_store.StoreRegionEnvironmentSettings(regionUUID, settings);
134 }
135
136 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
137 {
138 m_store.RemoveRegionEnvironmentSettings(regionUUID);
139 }
140
141 public void SaveExtra(UUID regionID, string name, string value)
142 {
143 }
144
145 public void RemoveExtra(UUID regionID, string name)
146 {
147 }
148
149 public Dictionary<string, string> GetExtra(UUID regionID)
150 {
151 return null;
152 }
153 }
154
155 /// <summary>
156 /// Mock region data plugin. This obeys the api contract for persistence but stores everything in memory, so that
157 /// tests can check correct persistence.
158 /// </summary>
159 public class NullDataStore : ISimulationDataStore
160 {
161// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
162
163 protected Dictionary<UUID, RegionSettings> m_regionSettings = new Dictionary<UUID, RegionSettings>();
164 protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>();
165 protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems
166 = new Dictionary<UUID, ICollection<TaskInventoryItem>>();
167 protected Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
168 protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>();
169
170 public void Initialise(string dbfile)
171 {
172 return;
173 }
174
175 public void Dispose()
176 {
177 }
178
179 public void StoreRegionSettings(RegionSettings rs)
180 {
181 m_regionSettings[rs.RegionUUID] = rs;
182 }
183
184 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
185 {
186 //This connector doesn't support the windlight module yet
187 //Return default LL windlight settings
188 return new RegionLightShareData();
189 }
190
191 public void RemoveRegionWindlightSettings(UUID regionID)
192 {
193 }
194
195 public void StoreRegionWindlightSettings(RegionLightShareData wl)
196 {
197 //This connector doesn't support the windlight module yet
198 }
199
200 #region Environment Settings
201 public string LoadRegionEnvironmentSettings(UUID regionUUID)
202 {
203 //This connector doesn't support the Environment module yet
204 return string.Empty;
205 }
206
207 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
208 {
209 //This connector doesn't support the Environment module yet
210 }
211
212 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
213 {
214 //This connector doesn't support the Environment module yet
215 }
216 #endregion
217
218 public RegionSettings LoadRegionSettings(UUID regionUUID)
219 {
220 RegionSettings rs = null;
221 m_regionSettings.TryGetValue(regionUUID, out rs);
222
223 if (rs == null)
224 rs = new RegionSettings();
225
226 return rs;
227 }
228
229 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
230 {
231 // We can't simply store groups here because on delinking, OpenSim will not update the original group
232 // directly. Rather, the newly delinked parts will be updated to be in their own scene object group
233 // Therefore, we need to store parts rather than groups.
234 foreach (SceneObjectPart prim in obj.Parts)
235 {
236// m_log.DebugFormat(
237// "[MOCK REGION DATA PLUGIN]: Storing part {0} {1} in object {2} {3} in region {4}",
238// prim.Name, prim.UUID, obj.Name, obj.UUID, regionUUID);
239
240 m_sceneObjectParts[prim.UUID] = prim;
241 }
242 }
243
244 public void RemoveObject(UUID obj, UUID regionUUID)
245 {
246 // All parts belonging to the object with the uuid are removed.
247 List<SceneObjectPart> parts = new List<SceneObjectPart>(m_sceneObjectParts.Values);
248 foreach (SceneObjectPart part in parts)
249 {
250 if (part.ParentGroup.UUID == obj)
251 {
252// m_log.DebugFormat(
253// "[MOCK REGION DATA PLUGIN]: Removing part {0} {1} as part of object {2} from {3}",
254// part.Name, part.UUID, obj, regionUUID);
255 m_sceneObjectParts.Remove(part.UUID);
256 }
257 }
258 }
259
260 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
261 {
262 m_primItems[primID] = items;
263 }
264
265 public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
266 {
267 Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>();
268
269 // Create all of the SOGs from the root prims first
270 foreach (SceneObjectPart prim in m_sceneObjectParts.Values)
271 {
272 if (prim.IsRoot)
273 {
274// m_log.DebugFormat(
275// "[MOCK REGION DATA PLUGIN]: Loading root part {0} {1} in {2}", prim.Name, prim.UUID, regionUUID);
276 objects[prim.UUID] = new SceneObjectGroup(prim);
277 }
278 }
279
280 // Add all of the children objects to the SOGs
281 foreach (SceneObjectPart prim in m_sceneObjectParts.Values)
282 {
283 SceneObjectGroup sog;
284 if (prim.UUID != prim.ParentUUID)
285 {
286 if (objects.TryGetValue(prim.ParentUUID, out sog))
287 {
288 int originalLinkNum = prim.LinkNum;
289
290 sog.AddPart(prim);
291
292 // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum.
293 // We override that here
294 if (originalLinkNum != 0)
295 prim.LinkNum = originalLinkNum;
296 }
297 else
298 {
299// m_log.WarnFormat(
300// "[MOCK REGION DATA PLUGIN]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.",
301// prim.Name, prim.UUID, regionUUID, prim.ParentUUID);
302 }
303 }
304 }
305
306 // TODO: Load items. This is assymetric - we store items as a separate method but don't retrieve them that
307 // way!
308
309 return new List<SceneObjectGroup>(objects.Values);
310 }
311
312 public void StoreTerrain(TerrainData ter, UUID regionID)
313 {
314 m_terrains[regionID] = ter;
315 }
316
317 public void StoreTerrain(double[,] ter, UUID regionID)
318 {
319 m_terrains[regionID] = new HeightmapTerrainData(ter);
320 }
321
322 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
323 {
324 if (m_terrains.ContainsKey(regionID))
325 return m_terrains[regionID];
326 else
327 return null;
328 }
329
330 public double[,] LoadTerrain(UUID regionID)
331 {
332 if (m_terrains.ContainsKey(regionID))
333 return m_terrains[regionID].GetDoubles();
334 else
335 return null;
336 }
337
338 public void RemoveLandObject(UUID globalID)
339 {
340 if (m_landData.ContainsKey(globalID))
341 m_landData.Remove(globalID);
342 }
343
344 public void StoreLandObject(ILandObject land)
345 {
346 m_landData[land.LandData.GlobalID] = land.LandData;
347 }
348
349 public List<LandData> LoadLandObjects(UUID regionUUID)
350 {
351 return new List<LandData>(m_landData.Values);
352 }
353
354 public void Shutdown()
355 {
356 }
357
358 public void SaveExtra(UUID regionID, string name, string value)
359 {
360 }
361
362 public void RemoveExtra(UUID regionID, string name)
363 {
364 }
365
366 public Dictionary<string, string> GetExtra(UUID regionID)
367 {
368 return null;
369 }
370 }
371}
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
new file mode 100644
index 0000000..d7a144c
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
@@ -0,0 +1,272 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.ScriptEngine.Interfaces;
38using OpenSim.Region.ScriptEngine.Shared;
39
40namespace OpenSim.Tests.Common
41{
42 public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
43 {
44 public IConfigSource ConfigSource { get; private set; }
45
46 public IConfig Config { get; private set; }
47
48 private Scene m_scene;
49
50 /// <summary>
51 /// Expose posted events to tests.
52 /// </summary>
53 public Dictionary<UUID, List<EventParams>> PostedEvents { get; private set; }
54
55 /// <summary>
56 /// A very primitive way of hooking text cose to a posed event.
57 /// </summary>
58 /// <remarks>
59 /// May be replaced with something that uses more original code in the future.
60 /// </remarks>
61 public event Action<UUID, EventParams> PostEventHook;
62
63 public void Initialise(IConfigSource source)
64 {
65 ConfigSource = source;
66
67 // Can set later on if required
68 Config = new IniConfig("MockScriptEngine", ConfigSource);
69
70 PostedEvents = new Dictionary<UUID, List<EventParams>>();
71 }
72
73 public void Close()
74 {
75 }
76
77 public void AddRegion(Scene scene)
78 {
79 m_scene = scene;
80
81 m_scene.StackModuleInterface<IScriptModule>(this);
82 }
83
84 public void RemoveRegion(Scene scene)
85 {
86 }
87
88 public void RegionLoaded(Scene scene)
89 {
90 }
91
92 public string Name { get { return "Mock Script Engine"; } }
93 public string ScriptEngineName { get { return Name; } }
94
95 public Type ReplaceableInterface { get { return null; } }
96
97#pragma warning disable 0067
98 public event ScriptRemoved OnScriptRemoved;
99 public event ObjectRemoved OnObjectRemoved;
100#pragma warning restore 0067
101
102 public string GetXMLState (UUID itemID)
103 {
104 throw new System.NotImplementedException ();
105 }
106
107 public bool SetXMLState(UUID itemID, string xml)
108 {
109 throw new System.NotImplementedException ();
110 }
111
112 public bool PostScriptEvent(UUID itemID, string name, object[] args)
113 {
114// Console.WriteLine("Posting event {0} for {1}", name, itemID);
115
116 return PostScriptEvent(itemID, new EventParams(name, args, null));
117 }
118
119 public bool PostScriptEvent(UUID itemID, EventParams evParams)
120 {
121 List<EventParams> eventsForItem;
122
123 if (!PostedEvents.ContainsKey(itemID))
124 {
125 eventsForItem = new List<EventParams>();
126 PostedEvents.Add(itemID, eventsForItem);
127 }
128 else
129 {
130 eventsForItem = PostedEvents[itemID];
131 }
132
133 eventsForItem.Add(evParams);
134
135 if (PostEventHook != null)
136 PostEventHook(itemID, evParams);
137
138 return true;
139 }
140
141 public bool PostObjectEvent(uint localID, EventParams evParams)
142 {
143 return PostObjectEvent(m_scene.GetSceneObjectPart(localID), evParams);
144 }
145
146 public bool PostObjectEvent(UUID itemID, string name, object[] args)
147 {
148 return PostObjectEvent(m_scene.GetSceneObjectPart(itemID), new EventParams(name, args, null));
149 }
150
151 private bool PostObjectEvent(SceneObjectPart part, EventParams evParams)
152 {
153 foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems(InventoryType.LSL))
154 PostScriptEvent(item.ItemID, evParams);
155
156 return true;
157 }
158
159 public void SuspendScript(UUID itemID)
160 {
161 throw new System.NotImplementedException ();
162 }
163
164 public void ResumeScript(UUID itemID)
165 {
166 throw new System.NotImplementedException ();
167 }
168
169 public ArrayList GetScriptErrors(UUID itemID)
170 {
171 throw new System.NotImplementedException ();
172 }
173
174 public bool HasScript(UUID itemID, out bool running)
175 {
176 throw new System.NotImplementedException ();
177 }
178
179 public bool GetScriptState(UUID itemID)
180 {
181 throw new System.NotImplementedException ();
182 }
183
184 public void SaveAllState()
185 {
186 throw new System.NotImplementedException ();
187 }
188
189 public void StartProcessing()
190 {
191 throw new System.NotImplementedException ();
192 }
193
194 public float GetScriptExecutionTime(List<UUID> itemIDs)
195 {
196 throw new System.NotImplementedException ();
197 }
198
199 public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
200 {
201 throw new System.NotImplementedException ();
202 }
203
204 public IScriptWorkItem QueueEventHandler(object parms)
205 {
206 throw new System.NotImplementedException ();
207 }
208
209 public DetectParams GetDetectParams(UUID item, int number)
210 {
211 throw new System.NotImplementedException ();
212 }
213
214 public void SetMinEventDelay(UUID itemID, double delay)
215 {
216 throw new System.NotImplementedException ();
217 }
218
219 public int GetStartParameter(UUID itemID)
220 {
221 throw new System.NotImplementedException ();
222 }
223
224 public void SetScriptState(UUID itemID, bool state)
225 {
226 throw new System.NotImplementedException ();
227 }
228
229 public void SetState(UUID itemID, string newState)
230 {
231 throw new System.NotImplementedException ();
232 }
233
234 public void ApiResetScript(UUID itemID)
235 {
236 throw new System.NotImplementedException ();
237 }
238
239 public void ResetScript (UUID itemID)
240 {
241 throw new System.NotImplementedException ();
242 }
243
244 public IScriptApi GetApi(UUID itemID, string name)
245 {
246 throw new System.NotImplementedException ();
247 }
248
249 public Scene World { get { return m_scene; } }
250
251 public IScriptModule ScriptModule { get { return this; } }
252
253 public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
254
255 public string ScriptClassName { get { throw new System.NotImplementedException (); } }
256
257 public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } }
258
259 public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
260
261 public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
262
263 public void ClearPostedEvents()
264 {
265 PostedEvents.Clear();
266 }
267
268 public void SleepScript(UUID itemID, int delay)
269 {
270 }
271 }
272}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
new file mode 100644
index 0000000..0e1bc8f
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -0,0 +1,1323 @@
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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenMetaverse.Packets;
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Framework.Client;
40
41namespace OpenSim.Tests.Common
42{
43 public class TestClient : IClientAPI, IClientCore
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
48
49 private Scene m_scene;
50
51 // Properties so that we can get at received data for test purposes
52 public List<uint> ReceivedKills { get; private set; }
53 public List<UUID> ReceivedOfflineNotifications { get; private set; }
54 public List<UUID> ReceivedOnlineNotifications { get; private set; }
55 public List<UUID> ReceivedFriendshipTerminations { get; private set; }
56
57 public List<ImageDataPacket> SentImageDataPackets { get; private set; }
58 public List<ImagePacketPacket> SentImagePacketPackets { get; private set; }
59 public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; }
60
61 // Test client specific events - for use by tests to implement some IClientAPI behaviour.
62 public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion;
63 public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour;
64 public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport;
65
66 public event Action<ISceneEntity, PrimUpdateFlags> OnReceivedEntityUpdate;
67
68 public event OnReceivedChatMessageDelegate OnReceivedChatMessage;
69 public event Action<GridInstantMessage> OnReceivedInstantMessage;
70
71 public event Action<UUID> OnReceivedSendRebakeAvatarTextures;
72
73 public delegate void TestClientOnSendRegionTeleportDelegate(
74 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
75 uint locationID, uint flags, string capsURL);
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
82// disable warning: public events, part of the public API
83#pragma warning disable 67
84
85 public event Action<IClientAPI> OnLogout;
86 public event ObjectPermissions OnObjectPermissions;
87
88 public event MoneyTransferRequest OnMoneyTransferRequest;
89 public event ParcelBuy OnParcelBuy;
90 public event Action<IClientAPI> OnConnectionClosed;
91
92 public event ImprovedInstantMessage OnInstantMessage;
93 public event ChatMessage OnChatFromClient;
94 public event TextureRequest OnRequestTexture;
95 public event RezObject OnRezObject;
96 public event ModifyTerrain OnModifyTerrain;
97 public event BakeTerrain OnBakeTerrain;
98 public event SetAppearance OnSetAppearance;
99 public event AvatarNowWearing OnAvatarNowWearing;
100 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
101 public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
102 public event UUIDNameRequest OnDetachAttachmentIntoInv;
103 public event ObjectAttach OnObjectAttach;
104 public event ObjectDeselect OnObjectDetach;
105 public event ObjectDrop OnObjectDrop;
106 public event StartAnim OnStartAnim;
107 public event StopAnim OnStopAnim;
108 public event LinkObjects OnLinkObjects;
109 public event DelinkObjects OnDelinkObjects;
110 public event RequestMapBlocks OnRequestMapBlocks;
111 public event RequestMapName OnMapNameRequest;
112 public event TeleportLocationRequest OnTeleportLocationRequest;
113 public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
114 public event TeleportCancel OnTeleportCancel;
115 public event DisconnectUser OnDisconnectUser;
116 public event RequestAvatarProperties OnRequestAvatarProperties;
117 public event SetAlwaysRun OnSetAlwaysRun;
118
119 public event DeRezObject OnDeRezObject;
120 public event Action<IClientAPI> OnRegionHandShakeReply;
121 public event GenericCall1 OnRequestWearables;
122 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
123 public event UpdateAgent OnPreAgentUpdate;
124 public event UpdateAgent OnAgentUpdate;
125 public event UpdateAgent OnAgentCameraUpdate;
126 public event AgentRequestSit OnAgentRequestSit;
127 public event AgentSit OnAgentSit;
128 public event AvatarPickerRequest OnAvatarPickerRequest;
129 public event Action<IClientAPI> OnRequestAvatarsData;
130 public event AddNewPrim OnAddPrim;
131 public event RequestGodlikePowers OnRequestGodlikePowers;
132 public event GodKickUser OnGodKickUser;
133 public event ObjectDuplicate OnObjectDuplicate;
134 public event GrabObject OnGrabObject;
135 public event DeGrabObject OnDeGrabObject;
136 public event MoveObject OnGrabUpdate;
137 public event SpinStart OnSpinStart;
138 public event SpinObject OnSpinUpdate;
139 public event SpinStop OnSpinStop;
140 public event ViewerEffectEventHandler OnViewerEffect;
141
142 public event FetchInventory OnAgentDataUpdateRequest;
143 public event TeleportLocationRequest OnSetStartLocationRequest;
144
145 public event UpdateShape OnUpdatePrimShape;
146 public event ObjectExtraParams OnUpdateExtraParams;
147 public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
148 public event ObjectSelect OnObjectSelect;
149 public event ObjectRequest OnObjectRequest;
150 public event GenericCall7 OnObjectDescription;
151 public event GenericCall7 OnObjectName;
152 public event GenericCall7 OnObjectClickAction;
153 public event GenericCall7 OnObjectMaterial;
154 public event UpdatePrimFlags OnUpdatePrimFlags;
155 public event UpdatePrimTexture OnUpdatePrimTexture;
156 public event UpdateVector OnUpdatePrimGroupPosition;
157 public event UpdateVector OnUpdatePrimSinglePosition;
158 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
159 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
160 public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
161 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
162 public event UpdateVector OnUpdatePrimScale;
163 public event UpdateVector OnUpdatePrimGroupScale;
164 public event StatusChange OnChildAgentStatus;
165 public event GenericCall2 OnStopMovement;
166 public event Action<UUID> OnRemoveAvatar;
167
168 public event CreateNewInventoryItem OnCreateNewInventoryItem;
169 public event LinkInventoryItem OnLinkInventoryItem;
170 public event CreateInventoryFolder OnCreateNewInventoryFolder;
171 public event UpdateInventoryFolder OnUpdateInventoryFolder;
172 public event MoveInventoryFolder OnMoveInventoryFolder;
173 public event RemoveInventoryFolder OnRemoveInventoryFolder;
174 public event RemoveInventoryItem OnRemoveInventoryItem;
175 public event FetchInventoryDescendents OnFetchInventoryDescendents;
176 public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
177 public event FetchInventory OnFetchInventory;
178 public event RequestTaskInventory OnRequestTaskInventory;
179 public event UpdateInventoryItem OnUpdateInventoryItem;
180 public event CopyInventoryItem OnCopyInventoryItem;
181 public event MoveInventoryItem OnMoveInventoryItem;
182 public event UDPAssetUploadRequest OnAssetUploadRequest;
183 public event RequestTerrain OnRequestTerrain;
184 public event RequestTerrain OnUploadTerrain;
185 public event XferReceive OnXferReceive;
186 public event RequestXfer OnRequestXfer;
187 public event ConfirmXfer OnConfirmXfer;
188 public event AbortXfer OnAbortXfer;
189 public event RezScript OnRezScript;
190 public event UpdateTaskInventory OnUpdateTaskInventory;
191 public event MoveTaskInventory OnMoveTaskItem;
192 public event RemoveTaskInventory OnRemoveTaskItem;
193 public event RequestAsset OnRequestAsset;
194 public event GenericMessage OnGenericMessage;
195 public event UUIDNameRequest OnNameFromUUIDRequest;
196 public event UUIDNameRequest OnUUIDGroupNameRequest;
197
198 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
199 public event ParcelDivideRequest OnParcelDivideRequest;
200 public event ParcelJoinRequest OnParcelJoinRequest;
201 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
202 public event ParcelAbandonRequest OnParcelAbandonRequest;
203 public event ParcelGodForceOwner OnParcelGodForceOwner;
204 public event ParcelReclaim OnParcelReclaim;
205 public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
206 public event ParcelAccessListRequest OnParcelAccessListRequest;
207 public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
208 public event ParcelSelectObjects OnParcelSelectObjects;
209 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
210 public event ParcelDeedToGroup OnParcelDeedToGroup;
211 public event ObjectDeselect OnObjectDeselect;
212 public event RegionInfoRequest OnRegionInfoRequest;
213 public event EstateCovenantRequest OnEstateCovenantRequest;
214 public event EstateChangeInfo OnEstateChangeInfo;
215 public event EstateManageTelehub OnEstateManageTelehub;
216 public event CachedTextureRequest OnCachedTextureRequest;
217
218 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
219
220 public event FriendActionDelegate OnApproveFriendRequest;
221 public event FriendActionDelegate OnDenyFriendRequest;
222 public event FriendshipTermination OnTerminateFriendship;
223 public event GrantUserFriendRights OnGrantUserRights;
224
225 public event EconomyDataRequest OnEconomyDataRequest;
226 public event MoneyBalanceRequest OnMoneyBalanceRequest;
227 public event UpdateAvatarProperties OnUpdateAvatarProperties;
228
229 public event ObjectIncludeInSearch OnObjectIncludeInSearch;
230 public event UUIDNameRequest OnTeleportHomeRequest;
231
232 public event ScriptAnswer OnScriptAnswer;
233 public event RequestPayPrice OnRequestPayPrice;
234 public event ObjectSaleInfo OnObjectSaleInfo;
235 public event ObjectBuy OnObjectBuy;
236 public event BuyObjectInventory OnBuyObjectInventory;
237 public event AgentSit OnUndo;
238 public event AgentSit OnRedo;
239 public event LandUndo OnLandUndo;
240
241 public event ForceReleaseControls OnForceReleaseControls;
242
243 public event GodLandStatRequest OnLandStatRequest;
244 public event RequestObjectPropertiesFamily OnObjectGroupRequest;
245
246 public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
247 public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
248 public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
249 public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
250 public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
251 public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
252 public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
253 public event EstateRestartSimRequest OnEstateRestartSimRequest;
254 public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
255 public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
256 public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
257 public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
258 public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
259 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
260 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
261 public event ScriptReset OnScriptReset;
262 public event GetScriptRunning OnGetScriptRunning;
263 public event SetScriptRunning OnSetScriptRunning;
264 public event Action<Vector3, bool, bool> OnAutoPilotGo;
265
266 public event TerrainUnacked OnUnackedTerrain;
267
268 public event RegionHandleRequest OnRegionHandleRequest;
269 public event ParcelInfoRequest OnParcelInfoRequest;
270
271 public event ActivateGesture OnActivateGesture;
272 public event DeactivateGesture OnDeactivateGesture;
273 public event ObjectOwner OnObjectOwner;
274
275 public event DirPlacesQuery OnDirPlacesQuery;
276 public event DirFindQuery OnDirFindQuery;
277 public event DirLandQuery OnDirLandQuery;
278 public event DirPopularQuery OnDirPopularQuery;
279 public event DirClassifiedQuery OnDirClassifiedQuery;
280 public event EventInfoRequest OnEventInfoRequest;
281 public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
282
283 public event MapItemRequest OnMapItemRequest;
284
285 public event OfferCallingCard OnOfferCallingCard;
286 public event AcceptCallingCard OnAcceptCallingCard;
287 public event DeclineCallingCard OnDeclineCallingCard;
288
289 public event SoundTrigger OnSoundTrigger;
290
291 public event StartLure OnStartLure;
292 public event TeleportLureRequest OnTeleportLureRequest;
293 public event NetworkStats OnNetworkStatsUpdate;
294
295 public event ClassifiedInfoRequest OnClassifiedInfoRequest;
296 public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
297 public event ClassifiedDelete OnClassifiedDelete;
298 public event ClassifiedDelete OnClassifiedGodDelete;
299
300 public event EventNotificationAddRequest OnEventNotificationAddRequest;
301 public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
302 public event EventGodDelete OnEventGodDelete;
303
304 public event ParcelDwellRequest OnParcelDwellRequest;
305
306 public event UserInfoRequest OnUserInfoRequest;
307 public event UpdateUserInfo OnUpdateUserInfo;
308
309 public event RetrieveInstantMessages OnRetrieveInstantMessages;
310
311 public event PickDelete OnPickDelete;
312 public event PickGodDelete OnPickGodDelete;
313 public event PickInfoUpdate OnPickInfoUpdate;
314 public event AvatarNotesUpdate OnAvatarNotesUpdate;
315
316 public event MuteListRequest OnMuteListRequest;
317
318 public event AvatarInterestUpdate OnAvatarInterestUpdate;
319
320 public event PlacesQuery OnPlacesQuery;
321
322 public event FindAgentUpdate OnFindAgent;
323 public event TrackAgentUpdate OnTrackAgent;
324 public event NewUserReport OnUserReport;
325 public event SaveStateHandler OnSaveState;
326 public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
327 public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
328 public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
329 public event FreezeUserUpdate OnParcelFreezeUser;
330 public event EjectUserUpdate OnParcelEjectUser;
331 public event ParcelBuyPass OnParcelBuyPass;
332 public event ParcelGodMark OnParcelGodMark;
333 public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
334 public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
335 public event SimWideDeletesDelegate OnSimWideDeletes;
336 public event SendPostcard OnSendPostcard;
337 public event MuteListEntryUpdate OnUpdateMuteListEntry;
338 public event MuteListEntryRemove OnRemoveMuteListEntry;
339 public event GodlikeMessage onGodlikeMessage;
340 public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
341
342#pragma warning restore 67
343
344 /// <value>
345 /// This agent's UUID
346 /// </value>
347 private UUID m_agentId;
348
349 public ISceneAgent SceneAgent { get; set; }
350
351 /// <value>
352 /// The last caps seed url that this client was given.
353 /// </value>
354 public string CapsSeedUrl;
355
356 private Vector3 startPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 2);
357
358 public virtual Vector3 StartPos
359 {
360 get { return startPos; }
361 set { }
362 }
363
364 public virtual UUID AgentId
365 {
366 get { return m_agentId; }
367 }
368
369 public UUID SessionId { get; set; }
370
371 public UUID SecureSessionId { get; set; }
372
373 public virtual string FirstName
374 {
375 get { return m_firstName; }
376 }
377 private string m_firstName;
378
379 public virtual string LastName
380 {
381 get { return m_lastName; }
382 }
383 private string m_lastName;
384
385 public virtual String Name
386 {
387 get { return FirstName + " " + LastName; }
388 }
389
390 public bool IsActive
391 {
392 get { return true; }
393 set { }
394 }
395
396 public bool IsLoggingOut { get; set; }
397
398 public UUID ActiveGroupId
399 {
400 get { return UUID.Zero; }
401 }
402
403 public string ActiveGroupName
404 {
405 get { return String.Empty; }
406 }
407
408 public ulong ActiveGroupPowers
409 {
410 get { return 0; }
411 }
412
413 public bool IsGroupMember(UUID groupID)
414 {
415 return false;
416 }
417
418 public ulong GetGroupPowers(UUID groupID)
419 {
420 return 0;
421 }
422
423 public virtual int NextAnimationSequenceNumber
424 {
425 get { return 1; }
426 }
427
428 public IScene Scene
429 {
430 get { return m_scene; }
431 }
432
433 public bool SendLogoutPacketWhenClosing
434 {
435 set { }
436 }
437
438 private uint m_circuitCode;
439
440 public uint CircuitCode
441 {
442 get { return m_circuitCode; }
443 set { m_circuitCode = value; }
444 }
445
446 public IPEndPoint RemoteEndPoint
447 {
448 get { return new IPEndPoint(IPAddress.Loopback, (ushort)m_circuitCode); }
449 }
450
451 /// <summary>
452 /// Constructor
453 /// </summary>
454 /// <param name="agentData"></param>
455 /// <param name="scene"></param>
456 /// <param name="sceneManager"></param>
457 public TestClient(AgentCircuitData agentData, Scene scene)
458 {
459 m_agentId = agentData.AgentID;
460 m_firstName = agentData.firstname;
461 m_lastName = agentData.lastname;
462 m_circuitCode = agentData.circuitcode;
463 m_scene = scene;
464 SessionId = agentData.SessionID;
465 SecureSessionId = agentData.SecureSessionID;
466 CapsSeedUrl = agentData.CapsPath;
467
468 ReceivedKills = new List<uint>();
469 ReceivedOfflineNotifications = new List<UUID>();
470 ReceivedOnlineNotifications = new List<UUID>();
471 ReceivedFriendshipTerminations = new List<UUID>();
472
473 SentImageDataPackets = new List<ImageDataPacket>();
474 SentImagePacketPackets = new List<ImagePacketPacket>();
475 SentImageNotInDatabasePackets = new List<ImageNotInDatabasePacket>();
476 }
477
478 /// <summary>
479 /// Trigger chat coming from this connection.
480 /// </summary>
481 /// <param name="channel"></param>
482 /// <param name="type"></param>
483 /// <param name="message"></param>
484 public bool Chat(int channel, ChatTypeEnum type, string message)
485 {
486 ChatMessage handlerChatFromClient = OnChatFromClient;
487
488 if (handlerChatFromClient != null)
489 {
490 OSChatMessage args = new OSChatMessage();
491 args.Channel = channel;
492 args.From = Name;
493 args.Message = message;
494 args.Type = type;
495
496 args.Scene = Scene;
497 args.Sender = this;
498 args.SenderUUID = AgentId;
499
500 handlerChatFromClient(this, args);
501 }
502
503 return true;
504 }
505
506 /// <summary>
507 /// Attempt a teleport to the given region.
508 /// </summary>
509 /// <param name="regionHandle"></param>
510 /// <param name="position"></param>
511 /// <param name="lookAt"></param>
512 public void Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt)
513 {
514 OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16);
515 }
516
517 public void CompleteMovement()
518 {
519 if (OnCompleteMovementToRegion != null)
520 OnCompleteMovementToRegion(this, true);
521 }
522
523 /// <summary>
524 /// Emulate sending an IM from the viewer to the simulator.
525 /// </summary>
526 /// <param name='im'></param>
527 public void HandleImprovedInstantMessage(GridInstantMessage im)
528 {
529 ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
530
531 if (handlerInstantMessage != null)
532 handlerInstantMessage(this, im);
533 }
534
535 public virtual void ActivateGesture(UUID assetId, UUID gestureId)
536 {
537 }
538
539 public virtual void SendWearables(AvatarWearable[] wearables, int serial)
540 {
541 }
542
543 public virtual void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
544 {
545 }
546
547 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
548 {
549
550 }
551
552 public virtual void Kick(string message)
553 {
554 }
555
556 public virtual void SendStartPingCheck(byte seq)
557 {
558 }
559
560 public virtual void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
561 {
562 }
563
564 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
565 {
566 }
567
568 public virtual void SendKillObject(List<uint> localID)
569 {
570 ReceivedKills.AddRange(localID);
571 }
572
573 public virtual void SetChildAgentThrottle(byte[] throttle)
574 {
575 }
576
577 public byte[] GetThrottlesPacked(float multiplier)
578 {
579 return new byte[0];
580 }
581
582 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
583 {
584 }
585
586 public virtual void SendChatMessage(
587 string message, byte type, Vector3 fromPos, string fromName,
588 UUID fromAgentID, UUID ownerID, byte source, byte audible)
589 {
590// Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId);
591 if (OnReceivedChatMessage != null)
592 OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible);
593 }
594
595 public void SendInstantMessage(GridInstantMessage im)
596 {
597 if (OnReceivedInstantMessage != null)
598 OnReceivedInstantMessage(im);
599 }
600
601 public void SendGenericMessage(string method, UUID invoice, List<string> message)
602 {
603
604 }
605
606 public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
607 {
608
609 }
610
611 public virtual void SendLayerData(float[] map)
612 {
613 }
614
615 public virtual void SendLayerData(int px, int py, float[] map)
616 {
617 }
618 public virtual void SendLayerData(int px, int py, float[] map, bool track)
619 {
620 }
621
622 public virtual void SendWindData(Vector2[] windSpeeds) { }
623
624 public virtual void SendCloudData(float[] cloudCover) { }
625
626 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
627 {
628 if (OnReceivedMoveAgentIntoRegion != null)
629 OnReceivedMoveAgentIntoRegion(regInfo, pos, look);
630 }
631
632 public virtual AgentCircuitData RequestClientInfo()
633 {
634 AgentCircuitData agentData = new AgentCircuitData();
635 agentData.AgentID = AgentId;
636 agentData.SessionID = SessionId;
637 agentData.SecureSessionID = UUID.Zero;
638 agentData.circuitcode = m_circuitCode;
639 agentData.child = false;
640 agentData.firstname = m_firstName;
641 agentData.lastname = m_lastName;
642
643 ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
644 if (capsModule != null)
645 {
646 agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
647 agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
648 }
649
650 return agentData;
651 }
652
653 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
654 {
655 if (OnTestClientInformClientOfNeighbour != null)
656 OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint);
657 }
658
659 public virtual void SendRegionTeleport(
660 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
661 uint locationID, uint flags, string capsURL)
662 {
663 m_log.DebugFormat(
664 "[TEST CLIENT]: Received SendRegionTeleport for {0} {1} on {2}", m_firstName, m_lastName, m_scene.Name);
665
666 CapsSeedUrl = capsURL;
667
668 if (OnTestClientSendRegionTeleport != null)
669 OnTestClientSendRegionTeleport(
670 regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
671 }
672
673 public virtual void SendTeleportFailed(string reason)
674 {
675 m_log.DebugFormat(
676 "[TEST CLIENT]: Teleport failed for {0} {1} on {2} with reason {3}",
677 m_firstName, m_lastName, m_scene.Name, reason);
678 }
679
680 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,
681 IPEndPoint newRegionExternalEndPoint, string capsURL)
682 {
683 // This is supposed to send a packet to the client telling it's ready to start region crossing.
684 // Instead I will just signal I'm ready, mimicking the communication behavior.
685 // It's ugly, but avoids needless communication setup. This is used in ScenePresenceTests.cs.
686 // Arthur V.
687
688 wh.Set();
689 }
690
691 public virtual void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
692 {
693 }
694
695 public virtual void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
696 {
697 }
698
699 public virtual void SendTeleportStart(uint flags)
700 {
701 }
702
703 public void SendTeleportProgress(uint flags, string message)
704 {
705 }
706
707 public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
708 {
709 }
710
711 public virtual void SendPayPrice(UUID objectID, int[] payPrice)
712 {
713 }
714
715 public virtual void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
716 {
717 }
718
719 public virtual void SendDialog(string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
720 {
721 }
722
723 public void SendAvatarDataImmediate(ISceneEntity avatar)
724 {
725 }
726
727 public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
728 {
729 if (OnReceivedEntityUpdate != null)
730 OnReceivedEntityUpdate(entity, updateFlags);
731 }
732
733 public void ReprioritizeUpdates()
734 {
735 }
736
737 public void FlushPrimUpdates()
738 {
739 }
740
741 public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID,
742 List<InventoryItemBase> items,
743 List<InventoryFolderBase> folders,
744 int version,
745 bool fetchFolders,
746 bool fetchItems)
747 {
748 }
749
750 public virtual void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
751 {
752 }
753
754 public virtual void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackID)
755 {
756 }
757
758 public virtual void SendRemoveInventoryItem(UUID itemID)
759 {
760 }
761
762 public virtual void SendBulkUpdateInventory(InventoryNodeBase node)
763 {
764 }
765
766 public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
767 {
768 }
769
770 public virtual void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
771 {
772 }
773
774 public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data)
775 {
776 }
777
778 public virtual void SendAbortXferPacket(ulong xferID)
779 {
780
781 }
782
783 public virtual void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
784 int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
785 int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
786 int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
787 {
788 }
789
790 public virtual void SendNameReply(UUID profileId, string firstname, string lastname)
791 {
792 }
793
794 public virtual void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
795 {
796 }
797
798 public virtual void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain,
799 byte flags)
800 {
801 }
802
803 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
804 {
805 }
806
807 public void SendAttachedSoundGainChange(UUID objectID, float gain)
808 {
809
810 }
811
812 public void SendAlertMessage(string message)
813 {
814 }
815
816 public void SendAgentAlertMessage(string message, bool modal)
817 {
818 }
819
820 public void SendSystemAlertMessage(string message)
821 {
822 }
823
824 public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
825 string url)
826 {
827 }
828
829 public virtual void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
830 {
831 if (OnRegionHandShakeReply != null)
832 {
833 OnRegionHandShakeReply(this);
834 }
835 }
836
837 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
838 {
839 }
840
841 public void SendConfirmXfer(ulong xferID, uint PacketID)
842 {
843 }
844
845 public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
846 {
847 }
848
849 public void SendInitiateDownload(string simFileName, string clientFileName)
850 {
851 }
852
853 public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
854 {
855 ImageDataPacket im = new ImageDataPacket();
856 im.Header.Reliable = false;
857 im.ImageID.Packets = numParts;
858 im.ImageID.ID = ImageUUID;
859
860 if (ImageSize > 0)
861 im.ImageID.Size = ImageSize;
862
863 im.ImageData.Data = ImageData;
864 im.ImageID.Codec = imageCodec;
865 im.Header.Zerocoded = true;
866 SentImageDataPackets.Add(im);
867 }
868
869 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
870 {
871 ImagePacketPacket im = new ImagePacketPacket();
872 im.Header.Reliable = false;
873 im.ImageID.Packet = partNumber;
874 im.ImageID.ID = imageUuid;
875 im.ImageData.Data = imageData;
876 SentImagePacketPackets.Add(im);
877 }
878
879 public void SendImageNotFound(UUID imageid)
880 {
881 ImageNotInDatabasePacket p = new ImageNotInDatabasePacket();
882 p.ImageID.ID = imageid;
883
884 SentImageNotInDatabasePackets.Add(p);
885 }
886
887 public void SendShutdownConnectionNotice()
888 {
889 }
890
891 public void SendSimStats(SimStats stats)
892 {
893 }
894
895 public void SendObjectPropertiesFamilyData(ISceneEntity Entity, uint RequestFlags)
896 {
897 }
898
899 public void SendObjectPropertiesReply(ISceneEntity entity)
900 {
901 }
902
903 public void SendAgentOffline(UUID[] agentIDs)
904 {
905 ReceivedOfflineNotifications.AddRange(agentIDs);
906 }
907
908 public void SendAgentOnline(UUID[] agentIDs)
909 {
910 ReceivedOnlineNotifications.AddRange(agentIDs);
911 }
912
913 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
914 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
915 {
916 }
917
918 public void SendAdminResponse(UUID Token, uint AdminLevel)
919 {
920
921 }
922
923 public void SendGroupMembership(GroupMembershipData[] GroupMembership)
924 {
925
926 }
927
928 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
929 {
930 }
931
932 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
933 {
934 }
935
936 public void SendViewerTime(int phase)
937 {
938 }
939
940 public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
941 string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
942 UUID partnerID)
943 {
944 }
945
946 public int DebugPacketLevel { get; set; }
947
948 public void InPacket(object NewPack)
949 {
950 }
951
952 public void ProcessInPacket(Packet NewPack)
953 {
954 }
955
956 /// <summary>
957 /// This is a TestClient only method to do shutdown tasks that are normally carried out by LLUDPServer.RemoveClient()
958 /// </summary>
959 public void Logout()
960 {
961 // We must set this here so that the presence is removed from the PresenceService by the PresenceDetector
962 IsLoggingOut = true;
963
964 Close();
965 }
966
967 public void Close()
968 {
969 Close(false);
970 }
971
972 public void Close(bool force)
973 {
974 // Fire the callback for this connection closing
975 // This is necesary to get the presence detector to notice that a client has logged out.
976 if (OnConnectionClosed != null)
977 OnConnectionClosed(this);
978
979 m_scene.RemoveClient(AgentId, true);
980 }
981
982 public void Start()
983 {
984 throw new NotImplementedException();
985 }
986
987 public void Stop()
988 {
989 }
990
991 public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
992 {
993
994 }
995 public void SendLogoutPacket()
996 {
997 }
998
999 public void Terminate()
1000 {
1001 }
1002
1003 public ClientInfo GetClientInfo()
1004 {
1005 return null;
1006 }
1007
1008 public void SetClientInfo(ClientInfo info)
1009 {
1010 }
1011
1012 public void SendScriptQuestion(UUID objectID, string taskName, string ownerName, UUID itemID, int question)
1013 {
1014 }
1015 public void SendHealth(float health)
1016 {
1017 }
1018
1019 public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
1020 {
1021 }
1022
1023 public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
1024 {
1025 }
1026
1027 public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID)
1028 {
1029 }
1030
1031 public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
1032 {
1033 }
1034
1035 public void SendEstateCovenantInformation(UUID covenant)
1036 {
1037 }
1038
1039 public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
1040 {
1041 }
1042
1043 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
1044 {
1045 }
1046
1047 public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
1048 {
1049 }
1050
1051 public void SendForceClientSelectObjects(List<uint> objectIDs)
1052 {
1053 }
1054
1055 public void SendCameraConstraint(Vector4 ConstraintPlane)
1056 {
1057 }
1058
1059 public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
1060 {
1061 }
1062
1063 public void SendLandParcelOverlay(byte[] data, int sequence_id)
1064 {
1065 }
1066
1067 public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
1068 {
1069 }
1070
1071 public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, byte autoScale, string mediaType,
1072 string mediaDesc, int mediaWidth, int mediaHeight, byte mediaLoop)
1073 {
1074 }
1075
1076 public void SendGroupNameReply(UUID groupLLUID, string GroupName)
1077 {
1078 }
1079
1080 public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
1081 {
1082 }
1083
1084 public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
1085 {
1086 }
1087
1088 public void SendAsset(AssetRequestToClient req)
1089 {
1090 }
1091
1092 public void SendTexture(AssetBase TextureAsset)
1093 {
1094
1095 }
1096
1097 public void SendSetFollowCamProperties (UUID objectID, SortedDictionary<int, float> parameters)
1098 {
1099 }
1100
1101 public void SendClearFollowCamProperties (UUID objectID)
1102 {
1103 }
1104
1105 public void SendRegionHandle (UUID regoinID, ulong handle)
1106 {
1107 }
1108
1109 public void SendParcelInfo (RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
1110 {
1111 }
1112
1113 public void SetClientOption(string option, string value)
1114 {
1115 }
1116
1117 public string GetClientOption(string option)
1118 {
1119 return string.Empty;
1120 }
1121
1122 public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
1123 {
1124 }
1125
1126 public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
1127 {
1128 }
1129
1130 public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
1131 {
1132 }
1133
1134 public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
1135 {
1136 }
1137
1138 public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
1139 {
1140 }
1141
1142 public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
1143 {
1144 }
1145
1146 public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
1147 {
1148 }
1149
1150 public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
1151 {
1152 }
1153
1154 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
1155 {
1156 }
1157
1158 public void SendEventInfoReply (EventData info)
1159 {
1160 }
1161
1162 public void SendOfferCallingCard (UUID destID, UUID transactionID)
1163 {
1164 }
1165
1166 public void SendAcceptCallingCard (UUID transactionID)
1167 {
1168 }
1169
1170 public void SendDeclineCallingCard (UUID transactionID)
1171 {
1172 }
1173
1174 public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
1175 {
1176 }
1177
1178 public void SendJoinGroupReply(UUID groupID, bool success)
1179 {
1180 }
1181
1182 public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool succss)
1183 {
1184 }
1185
1186 public void SendLeaveGroupReply(UUID groupID, bool success)
1187 {
1188 }
1189
1190 public void SendTerminateFriend(UUID exFriendID)
1191 {
1192 ReceivedFriendshipTerminations.Add(exFriendID);
1193 }
1194
1195 public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
1196 {
1197 //throw new NotImplementedException();
1198 return false;
1199 }
1200
1201 public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
1202 {
1203 }
1204
1205 public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price)
1206 {
1207 }
1208
1209 public void SendAgentDropGroup(UUID groupID)
1210 {
1211 }
1212
1213 public void SendAvatarNotesReply(UUID targetID, string text)
1214 {
1215 }
1216
1217 public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
1218 {
1219 }
1220
1221 public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
1222 {
1223 }
1224
1225 public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
1226 {
1227 }
1228
1229 public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
1230 {
1231 }
1232
1233 public void SendCreateGroupReply(UUID groupID, bool success, string message)
1234 {
1235 }
1236
1237 public void RefreshGroupMembership()
1238 {
1239 }
1240
1241 public void SendUseCachedMuteList()
1242 {
1243 }
1244
1245 public void SendMuteListUpdate(string filename)
1246 {
1247 }
1248
1249 public void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled)
1250 {
1251 }
1252
1253 public bool TryGet<T>(out T iface)
1254 {
1255 iface = default(T);
1256 return false;
1257 }
1258
1259 public T Get<T>()
1260 {
1261 return default(T);
1262 }
1263
1264 public void Disconnect(string reason)
1265 {
1266 }
1267
1268 public void Disconnect()
1269 {
1270 }
1271
1272 public void SendRebakeAvatarTextures(UUID textureID)
1273 {
1274 if (OnReceivedSendRebakeAvatarTextures != null)
1275 OnReceivedSendRebakeAvatarTextures(textureID);
1276 }
1277
1278 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
1279 {
1280 }
1281
1282 public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
1283 {
1284 }
1285
1286 public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
1287 {
1288 }
1289
1290 public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt)
1291 {
1292 }
1293
1294 public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
1295 {
1296 }
1297
1298 public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
1299 {
1300 }
1301
1302 public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
1303 {
1304 }
1305
1306 public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
1307 {
1308 }
1309
1310 public void SendAgentTerseUpdate(ISceneEntity presence)
1311 {
1312 }
1313
1314 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
1315 {
1316 }
1317
1318 public void SendPartPhysicsProprieties(ISceneEntity entity)
1319 {
1320 }
1321
1322 }
1323}
diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
new file mode 100644
index 0000000..f2bae58
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
@@ -0,0 +1,182 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Threading;
34using log4net;
35using Nini.Config;
36using Mono.Addins;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers;
41using OpenSim.Region.ClientStack.Linden;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44
45namespace OpenSim.Tests.Common
46{
47 public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule
48 {
49 public class Event
50 {
51 public string Name { get; set; }
52 public object[] Args { get; set; }
53
54 public Event(string name, object[] args)
55 {
56 name = Name;
57 args = Args;
58 }
59 }
60
61 public Dictionary<UUID, List<Event>> Events { get; set; }
62
63 public void Initialise(IConfigSource source) {}
64
65 public void Close() {}
66
67 public void AddRegion(Scene scene)
68 {
69 Events = new Dictionary<UUID, List<Event>>();
70 scene.RegisterModuleInterface<IEventQueue>(this);
71 }
72
73 public void RemoveRegion (Scene scene) {}
74
75 public void RegionLoaded (Scene scene) {}
76
77 public string Name { get { return "TestEventQueueGetModule"; } }
78
79 public Type ReplaceableInterface { get { return null; } }
80
81 private void AddEvent(UUID avatarID, string name, params object[] args)
82 {
83 Console.WriteLine("Adding event {0} for {1}", name, avatarID);
84
85 List<Event> avEvents;
86
87 if (!Events.ContainsKey(avatarID))
88 {
89 avEvents = new List<Event>();
90 Events[avatarID] = avEvents;
91 }
92 else
93 {
94 avEvents = Events[avatarID];
95 }
96
97 avEvents.Add(new Event(name, args));
98 }
99
100 public void ClearEvents()
101 {
102 if (Events != null)
103 Events.Clear();
104 }
105
106 public bool Enqueue(OSD o, UUID avatarID)
107 {
108 AddEvent(avatarID, "Enqueue", o);
109 return true;
110 }
111
112 public void DisableSimulator(ulong handle, UUID avatarID)
113 {
114 AddEvent(avatarID, "DisableSimulator", handle);
115 }
116
117 public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
118 {
119 AddEvent(avatarID, "EnableSimulator", handle);
120 }
121
122 public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath,
123 ulong regionHandle, int regionSizeX, int regionSizeY)
124 {
125 AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
126 }
127
128 public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
129 uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY)
130 {
131 AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
132 }
133
134 public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint,
135 string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
136 {
137 AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
138 }
139
140 public void ChatterboxInvitation(
141 UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
142 byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
143 UUID transactionID, bool fromGroup, byte[] binaryBucket)
144 {
145 AddEvent(
146 toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
147 timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
148 }
149
150 public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute)
151 {
152 AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute);
153 }
154
155 public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
156 {
157 AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
158 }
159
160 public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID)
161 {
162 AddEvent(avatarID, "GroupMembership", groupUpdate);
163 }
164
165 public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono)
166 {
167 Console.WriteLine("ONE");
168 throw new System.NotImplementedException ();
169 }
170
171 public OSD BuildEvent(string eventName, OSD eventBody)
172 {
173 Console.WriteLine("TWO");
174 throw new System.NotImplementedException ();
175 }
176
177 public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
178 {
179 AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
180 }
181 }
182} \ No newline at end of file
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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Net.Sockets;
33using System.Text;
34using HttpServer;
35using OpenSim.Framework;
36
37namespace 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
28using System;
29using System.Collections.Specialized;
30using System.IO;
31using HttpServer;
32using HttpServer.FormDecoders;
33
34namespace 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
28using System;
29using System.IO;
30using System.Net;
31using System.Text;
32using HttpServer;
33
34namespace 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
new file mode 100644
index 0000000..c97a765
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
@@ -0,0 +1,219 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Data;
35
36namespace OpenSim.Tests.Common
37{
38 /// <summary>
39 /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the
40 /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit
41 /// tests are single threaded.
42 /// </summary>
43 public class TestInventoryDataPlugin : IInventoryDataPlugin
44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 /// <value>
48 /// Inventory folders
49 /// </value>
50 private Dictionary<UUID, InventoryFolderBase> m_folders = new Dictionary<UUID, InventoryFolderBase>();
51
52 //// <value>
53 /// Inventory items
54 /// </value>
55 private Dictionary<UUID, InventoryItemBase> m_items = new Dictionary<UUID, InventoryItemBase>();
56
57 /// <value>
58 /// User root folders
59 /// </value>
60 private Dictionary<UUID, InventoryFolderBase> m_rootFolders = new Dictionary<UUID, InventoryFolderBase>();
61
62 public string Version { get { return "0"; } }
63 public string Name { get { return "TestInventoryDataPlugin"; } }
64
65 public void Initialise() {}
66 public void Initialise(string connect) {}
67 public void Dispose() {}
68
69 public List<InventoryFolderBase> getFolderHierarchy(UUID parentID)
70 {
71 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
72
73 foreach (InventoryFolderBase folder in m_folders.Values)
74 {
75 if (folder.ParentID == parentID)
76 {
77 folders.AddRange(getFolderHierarchy(folder.ID));
78 folders.Add(folder);
79 }
80 }
81
82 return folders;
83 }
84
85 public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
86 {
87// InventoryFolderBase folder = m_folders[folderID];
88
89// m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0} {1}", folder.Name, folder.ID);
90
91 List<InventoryItemBase> items = new List<InventoryItemBase>();
92
93 foreach (InventoryItemBase item in m_items.Values)
94 {
95 if (item.Folder == folderID)
96 {
97// m_log.DebugFormat("[MOCK INV DB]: getInventoryInFolder() adding item {0}", item.Name);
98 items.Add(item);
99 }
100 }
101
102 return items;
103 }
104
105 public List<InventoryFolderBase> getUserRootFolders(UUID user) { return null; }
106
107 public InventoryFolderBase getUserRootFolder(UUID user)
108 {
109// m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user);
110
111 InventoryFolderBase folder = null;
112 m_rootFolders.TryGetValue(user, out folder);
113
114 return folder;
115 }
116
117 public List<InventoryFolderBase> getInventoryFolders(UUID parentID)
118 {
119// InventoryFolderBase parentFolder = m_folders[parentID];
120
121// m_log.DebugFormat("[MOCK INV DB]: Getting folders in folder {0} {1}", parentFolder.Name, parentFolder.ID);
122
123 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
124
125 foreach (InventoryFolderBase folder in m_folders.Values)
126 {
127 if (folder.ParentID == parentID)
128 {
129// m_log.DebugFormat(
130// "[MOCK INV DB]: Found folder {0} {1} in {2} {3}",
131// folder.Name, folder.ID, parentFolder.Name, parentFolder.ID);
132
133 folders.Add(folder);
134 }
135 }
136
137 return folders;
138 }
139
140 public InventoryFolderBase getInventoryFolder(UUID folderId)
141 {
142 InventoryFolderBase folder = null;
143 m_folders.TryGetValue(folderId, out folder);
144
145 return folder;
146 }
147
148 public InventoryFolderBase queryInventoryFolder(UUID folderID)
149 {
150 return getInventoryFolder(folderID);
151 }
152
153 public void addInventoryFolder(InventoryFolderBase folder)
154 {
155// m_log.DebugFormat(
156// "[MOCK INV DB]: Adding inventory folder {0} {1} type {2}",
157// folder.Name, folder.ID, (AssetType)folder.Type);
158
159 m_folders[folder.ID] = folder;
160
161 if (folder.ParentID == UUID.Zero)
162 {
163// m_log.DebugFormat(
164// "[MOCK INV DB]: Adding root folder {0} {1} for {2}", folder.Name, folder.ID, folder.Owner);
165 m_rootFolders[folder.Owner] = folder;
166 }
167 }
168
169 public void updateInventoryFolder(InventoryFolderBase folder)
170 {
171 m_folders[folder.ID] = folder;
172 }
173
174 public void moveInventoryFolder(InventoryFolderBase folder)
175 {
176 // Simple replace
177 updateInventoryFolder(folder);
178 }
179
180 public void deleteInventoryFolder(UUID folderId)
181 {
182 if (m_folders.ContainsKey(folderId))
183 m_folders.Remove(folderId);
184 }
185
186 public void addInventoryItem(InventoryItemBase item)
187 {
188 InventoryFolderBase folder = m_folders[item.Folder];
189
190// m_log.DebugFormat(
191// "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID);
192
193 m_items[item.ID] = item;
194 }
195
196 public void updateInventoryItem(InventoryItemBase item) { addInventoryItem(item); }
197
198 public void deleteInventoryItem(UUID itemId)
199 {
200 if (m_items.ContainsKey(itemId))
201 m_items.Remove(itemId);
202 }
203
204 public InventoryItemBase getInventoryItem(UUID itemId)
205 {
206 if (m_items.ContainsKey(itemId))
207 return m_items[itemId];
208 else
209 return null;
210 }
211
212 public InventoryItemBase queryInventoryItem(UUID item)
213 {
214 return null;
215 }
216
217 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) { return null; }
218 }
219}
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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using Nini.Config;
33using OpenMetaverse.Packets;
34using OpenSim.Framework;
35using OpenSim.Region.ClientStack.LindenUDP;
36
37namespace 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
new file mode 100644
index 0000000..89ebcd5
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
@@ -0,0 +1,115 @@
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
28using System.Collections.Generic;
29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.CoreModules.World.Land;
34
35namespace OpenSim.Tests.Common
36{
37 /// <summary>
38 /// Land channel for test purposes
39 /// </summary>
40 public class TestLandChannel : ILandChannel
41 {
42 private Scene m_scene;
43 private List<ILandObject> m_parcels;
44
45 public TestLandChannel(Scene scene)
46 {
47 m_scene = scene;
48 m_parcels = new List<ILandObject>();
49 SetupDefaultParcel();
50 }
51
52 private void SetupDefaultParcel()
53 {
54 ILandObject obj = new LandObject(UUID.Zero, false, m_scene);
55 obj.LandData.Name = "Your Parcel";
56 m_parcels.Add(obj);
57 }
58
59 public List<ILandObject> ParcelsNearPoint(Vector3 position)
60 {
61 return new List<ILandObject>();
62 }
63
64 public List<ILandObject> AllParcels()
65 {
66 return m_parcels;
67 }
68
69 public void Clear(bool setupDefaultParcel)
70 {
71 m_parcels.Clear();
72
73 if (setupDefaultParcel)
74 SetupDefaultParcel();
75 }
76
77 protected ILandObject GetNoLand()
78 {
79 ILandObject obj = new LandObject(UUID.Zero, false, m_scene);
80 obj.LandData.Name = "NO LAND";
81 return obj;
82 }
83
84 public ILandObject GetLandObject(Vector3 position)
85 {
86 return GetLandObject(position.X, position.Y);
87 }
88
89 public ILandObject GetLandObject(int x, int y)
90 {
91 return GetNoLand();
92 }
93
94 public ILandObject GetLandObject(int localID)
95 {
96 return GetNoLand();
97 }
98
99 public ILandObject GetLandObject(float x, float y)
100 {
101 return GetNoLand();
102 }
103
104 public bool IsLandPrimCountTainted() { return false; }
105 public bool IsForcefulBansAllowed() { return false; }
106 public void UpdateLandObject(int localID, LandData data) {}
107 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) {}
108 public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) {}
109 public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) {}
110 public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) {}
111
112 public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {}
113 public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {}
114 }
115} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs
new file mode 100644
index 0000000..7b1d2b5
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs
@@ -0,0 +1,179 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Collections.Specialized;
32using System.IO;
33using System.Net;
34using System.Text;
35using System.Web;
36using OpenSim.Framework.Servers.HttpServer;
37
38namespace OpenSim.Tests.Common
39{
40 public class TestOSHttpRequest : IOSHttpRequest
41 {
42 public string[] AcceptTypes
43 {
44 get
45 {
46 throw new NotImplementedException ();
47 }
48 }
49
50 public Encoding ContentEncoding
51 {
52 get
53 {
54 throw new NotImplementedException ();
55 }
56 }
57
58 public long ContentLength
59 {
60 get
61 {
62 throw new NotImplementedException ();
63 }
64 }
65
66 public long ContentLength64
67 {
68 get
69 {
70 throw new NotImplementedException ();
71 }
72 }
73
74 public string ContentType
75 {
76 get
77 {
78 throw new NotImplementedException ();
79 }
80 }
81
82 public HttpCookieCollection Cookies
83 {
84 get
85 {
86 throw new NotImplementedException ();
87 }
88 }
89
90 public bool HasEntityBody
91 {
92 get
93 {
94 throw new NotImplementedException ();
95 }
96 }
97
98 public NameValueCollection Headers { get; set; }
99
100 public string HttpMethod
101 {
102 get
103 {
104 throw new NotImplementedException ();
105 }
106 }
107
108 public Stream InputStream
109 {
110 get
111 {
112 throw new NotImplementedException ();
113 }
114 }
115
116 public bool IsSecured
117 {
118 get
119 {
120 throw new NotImplementedException ();
121 }
122 }
123
124 public bool KeepAlive
125 {
126 get
127 {
128 throw new NotImplementedException ();
129 }
130 }
131
132 public NameValueCollection QueryString
133 {
134 get
135 {
136 throw new NotImplementedException ();
137 }
138 }
139
140 public Hashtable Query
141 {
142 get
143 {
144 throw new NotImplementedException ();
145 }
146 }
147
148 public string RawUrl
149 {
150 get
151 {
152 throw new NotImplementedException ();
153 }
154 }
155
156 public IPEndPoint RemoteIPEndPoint
157 {
158 get
159 {
160 throw new NotImplementedException ();
161 }
162 }
163
164 public Uri Url { get; set; }
165
166 public string UserAgent
167 {
168 get
169 {
170 throw new NotImplementedException ();
171 }
172 }
173
174 public TestOSHttpRequest()
175 {
176 Headers = new NameValueCollection();
177 }
178 }
179} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs
new file mode 100644
index 0000000..2e17f1e
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs
@@ -0,0 +1,133 @@
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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Text;
32using System.Web;
33using OpenSim.Framework.Servers.HttpServer;
34
35namespace OpenSim.Tests.Common
36{
37 public class TestOSHttpResponse : IOSHttpResponse
38 {
39 /// <summary>
40 /// Content type property.
41 /// </summary>
42 /// <remarks>
43 /// Setting this property will also set IsContentTypeSet to
44 /// true.
45 /// </remarks>
46 public string ContentType { get; set; }
47
48 /// <summary>
49 /// Boolean property indicating whether the content type
50 /// property actively has been set.
51 /// </summary>
52 /// <remarks>
53 /// IsContentTypeSet will go away together with .NET base.
54 /// </remarks>
55 // public bool IsContentTypeSet
56 // {
57 // get { return _contentTypeSet; }
58 // }
59 // private bool _contentTypeSet;
60
61 /// <summary>
62 /// Length of the body content; 0 if there is no body.
63 /// </summary>
64 public long ContentLength { get; set; }
65
66 /// <summary>
67 /// Alias for ContentLength.
68 /// </summary>
69 public long ContentLength64 { get; set; }
70
71 /// <summary>
72 /// Encoding of the body content.
73 /// </summary>
74 public Encoding ContentEncoding { get; set; }
75
76 public bool KeepAlive { get; set; }
77
78 /// <summary>
79 /// Get or set the keep alive timeout property (default is
80 /// 20). Setting this to 0 also disables KeepAlive. Setting
81 /// this to something else but 0 also enable KeepAlive.
82 /// </summary>
83 public int KeepAliveTimeout { get; set; }
84
85 /// <summary>
86 /// Return the output stream feeding the body.
87 /// </summary>
88 /// <remarks>
89 /// On its way out...
90 /// </remarks>
91 public Stream OutputStream { get; private set; }
92
93 public string ProtocolVersion { get; set; }
94
95 /// <summary>
96 /// Return the output stream feeding the body.
97 /// </summary>
98 public Stream Body { get; private set; }
99
100 /// <summary>
101 /// Set a redirct location.
102 /// </summary>
103 public string RedirectLocation { private get; set; }
104
105 /// <summary>
106 /// Chunk transfers.
107 /// </summary>
108 public bool SendChunked { get; set; }
109
110 /// <summary>
111 /// HTTP status code.
112 /// </summary>
113 public int StatusCode { get; set; }
114
115 /// <summary>
116 /// HTTP status description.
117 /// </summary>
118 public string StatusDescription { get; set; }
119
120 public bool ReuseContext { get; set; }
121
122 /// <summary>
123 /// Add a header field and content to the response.
124 /// </summary>
125 /// <param name="key">string containing the header field
126 /// name</param>
127 /// <param name="value">string containing the header field
128 /// value</param>
129 public void AddHeader(string key, string value) { throw new NotImplementedException(); }
130
131 public void Send() { }
132 }
133} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
new file mode 100644
index 0000000..45acf91
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -0,0 +1,77 @@
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
28using System;
29using Nini.Config;
30using OpenSim.Framework;
31using OpenSim.Framework.Communications;
32using OpenSim.Framework.Servers;
33using OpenSim.Region.Framework;
34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Physics.Manager;
37using OpenSim.Services.Interfaces;
38
39namespace OpenSim.Tests.Common
40{
41 public class TestScene : Scene
42 {
43 public TestScene(
44 RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene,
45 SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService,
46 IConfigSource config, string simulatorVersion)
47 : base(regInfo, authen, physicsScene, sceneGridService, simDataService, estateDataService,
48 config, simulatorVersion)
49 {
50 }
51
52 ~TestScene()
53 {
54 //Console.WriteLine("TestScene destructor called for {0}", RegionInfo.RegionName);
55 Console.WriteLine("TestScene destructor called");
56 }
57
58 /// <summary>
59 /// Temporarily override session authentication for tests (namely teleport).
60 /// </summary>
61 /// <remarks>
62 /// TODO: This needs to be mocked out properly.
63 /// </remarks>
64 /// <param name="agent"></param>
65 /// <returns></returns>
66 public override bool VerifyUserPresence(AgentCircuitData agent, out string reason)
67 {
68 reason = String.Empty;
69 return true;
70 }
71
72 public AsyncSceneObjectGroupDeleter SceneObjectGroupDeleter
73 {
74 get { return m_asyncSceneObjectDeleter; }
75 }
76 }
77}
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
new file mode 100644
index 0000000..2b272e6
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
@@ -0,0 +1,152 @@
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
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Data;
36using OpenSim.Data.Null;
37
38namespace OpenSim.Tests.Common
39{
40 public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData
41 {
42 private Dictionary<UUID, XInventoryFolder> m_allFolders = new Dictionary<UUID, XInventoryFolder>();
43 private Dictionary<UUID, XInventoryItem> m_allItems = new Dictionary<UUID, XInventoryItem>();
44
45 public TestXInventoryDataPlugin(string conn, string realm) {}
46
47 public XInventoryItem[] GetItems(string[] fields, string[] vals)
48 {
49// Console.WriteLine(
50// "Requesting items, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals));
51
52 List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList());
53
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;
60 }
61
62 public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
63 {
64// Console.WriteLine(
65// "Requesting folders, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals));
66
67 List<XInventoryFolder> origFolders
68 = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList());
69
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;
76 }
77
78 public bool StoreFolder(XInventoryFolder folder)
79 {
80 m_allFolders[folder.folderID] = folder.Clone();
81
82// Console.WriteLine("Added folder {0} {1}", folder.folderName, folder.folderID);
83
84 return true;
85 }
86
87 public bool StoreItem(XInventoryItem item)
88 {
89 m_allItems[item.inventoryID] = item.Clone();
90
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);
94
95 return true;
96 }
97
98 public bool DeleteFolders(string field, string val)
99 {
100 return DeleteFolders(new string[] { field }, new string[] { val });
101 }
102
103 public bool DeleteFolders(string[] fields, string[] vals)
104 {
105 XInventoryFolder[] foldersToDelete = GetFolders(fields, vals);
106 Array.ForEach(foldersToDelete, f => m_allFolders.Remove(f.folderID));
107
108 return true;
109 }
110
111 public bool DeleteItems(string field, string val)
112 {
113 return DeleteItems(new string[] { field }, new string[] { val });
114 }
115
116 public bool DeleteItems(string[] fields, string[] vals)
117 {
118 XInventoryItem[] itemsToDelete = GetItems(fields, vals);
119 Array.ForEach(itemsToDelete, i => m_allItems.Remove(i.inventoryID));
120
121 return true;
122 }
123
124 public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); }
125
126 public bool MoveFolder(string id, string newParent)
127 {
128 // Don't use GetFolders() here - it takes a clone!
129 XInventoryFolder folder = m_allFolders[new UUID(id)];
130
131 if (folder == null)
132 return false;
133
134 folder.parentFolderID = new UUID(newParent);
135
136// XInventoryFolder[] newParentFolders
137// = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() });
138
139// Console.WriteLine(
140// "Moved folder {0} {1}, to {2} {3}",
141// folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID);
142
143 // TODO: Really need to implement folder version incrementing, though this should be common code anyway,
144 // not reimplemented in each db plugin.
145
146 return true;
147 }
148
149 public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); }
150 public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); }
151 }
152} \ No newline at end of file