diff options
Diffstat (limited to '')
17 files changed, 1272 insertions, 120 deletions
diff --git a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs index cfefd38..cb4fb80 100644 --- a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs +++ b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs | |||
@@ -25,11 +25,12 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
31 | 32 | ||
32 | namespace OpenSim.Tests.Common.Mock | 33 | namespace OpenSim.Tests.Common |
33 | { | 34 | { |
34 | public class BaseAssetRepository | 35 | public class BaseAssetRepository |
35 | { | 36 | { |
@@ -37,7 +38,7 @@ namespace OpenSim.Tests.Common.Mock | |||
37 | 38 | ||
38 | public AssetBase FetchAsset(UUID uuid) | 39 | public AssetBase FetchAsset(UUID uuid) |
39 | { | 40 | { |
40 | if (ExistsAsset(uuid)) | 41 | if (AssetsExist(new[] { uuid })[0]) |
41 | return Assets[uuid]; | 42 | return Assets[uuid]; |
42 | else | 43 | else |
43 | return null; | 44 | return null; |
@@ -53,9 +54,9 @@ namespace OpenSim.Tests.Common.Mock | |||
53 | CreateAsset(asset); | 54 | CreateAsset(asset); |
54 | } | 55 | } |
55 | 56 | ||
56 | public bool ExistsAsset(UUID uuid) | 57 | public bool[] AssetsExist(UUID[] uuids) |
57 | { | 58 | { |
58 | return Assets.ContainsKey(uuid); | 59 | return Array.ConvertAll(uuids, id => Assets.ContainsKey(id)); |
59 | } | 60 | } |
60 | } | 61 | } |
61 | } \ No newline at end of file | 62 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs index 4a15cf2..dddf75d 100644 --- a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs | |||
@@ -31,7 +31,7 @@ using OpenMetaverse; | |||
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Data; | 32 | using OpenSim.Data; |
33 | 33 | ||
34 | namespace OpenSim.Tests.Common.Mock | 34 | namespace OpenSim.Tests.Common |
35 | { | 35 | { |
36 | /// <summary> | 36 | /// <summary> |
37 | /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the | 37 | /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the |
diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs index 3035cea..7f530d0 100644 --- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs +++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs | |||
@@ -40,7 +40,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; | 41 | using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; |
42 | 42 | ||
43 | namespace OpenSim.Tests.Common.Mock | 43 | namespace OpenSim.Tests.Common |
44 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
46 | public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector | 46 | public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector |
@@ -138,33 +138,28 @@ namespace OpenSim.Tests.Common.Mock | |||
138 | { | 138 | { |
139 | } | 139 | } |
140 | 140 | ||
141 | private XGroup GetXGroup(UUID groupID, string name) | ||
142 | { | ||
143 | XGroup group = m_data.GetGroup(groupID); | ||
144 | |||
145 | |||
146 | if (group == null) | ||
147 | m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID); | ||
148 | |||
149 | return group; | ||
150 | } | ||
151 | |||
141 | public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) | 152 | public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) |
142 | { | 153 | { |
143 | m_log.DebugFormat( | 154 | m_log.DebugFormat( |
144 | "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", | 155 | "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", |
145 | groupID, groupName); | 156 | groupID, groupName); |
146 | 157 | ||
147 | XGroup[] groups; | 158 | XGroup xg = GetXGroup(groupID, groupName); |
148 | string field, val; | ||
149 | 159 | ||
150 | if (groupID != UUID.Zero) | 160 | if (xg == null) |
151 | { | ||
152 | field = "groupID"; | ||
153 | val = groupID.ToString(); | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | field = "name"; | ||
158 | val = groupName; | ||
159 | } | ||
160 | |||
161 | groups = m_data.GetGroups(field, val); | ||
162 | |||
163 | if (groups.Length == 0) | ||
164 | return null; | 161 | return null; |
165 | 162 | ||
166 | XGroup xg = groups[0]; | ||
167 | |||
168 | GroupRecord gr = new GroupRecord() | 163 | GroupRecord gr = new GroupRecord() |
169 | { | 164 | { |
170 | GroupID = xg.groupID, | 165 | GroupID = xg.groupID, |
@@ -196,8 +191,25 @@ namespace OpenSim.Tests.Common.Mock | |||
196 | { | 191 | { |
197 | } | 192 | } |
198 | 193 | ||
199 | public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) | 194 | public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile) |
200 | { | 195 | { |
196 | m_log.DebugFormat( | ||
197 | "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}", | ||
198 | requestingAgentID, agentID, groupID, acceptNotices, listInProfile); | ||
199 | |||
200 | XGroup group = GetXGroup(groupID, null); | ||
201 | |||
202 | if (group == null) | ||
203 | return; | ||
204 | |||
205 | XGroupMember xgm = null; | ||
206 | if (!group.members.TryGetValue(agentID, out xgm)) | ||
207 | return; | ||
208 | |||
209 | xgm.acceptNotices = acceptNotices; | ||
210 | xgm.listInProfile = listInProfile; | ||
211 | |||
212 | m_data.StoreGroup(group); | ||
201 | } | 213 | } |
202 | 214 | ||
203 | public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) | 215 | public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) |
@@ -213,8 +225,27 @@ namespace OpenSim.Tests.Common.Mock | |||
213 | { | 225 | { |
214 | } | 226 | } |
215 | 227 | ||
216 | public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) | 228 | public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) |
217 | { | 229 | { |
230 | m_log.DebugFormat( | ||
231 | "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}", | ||
232 | requestingAgentID, agentID, groupID, roleID); | ||
233 | |||
234 | XGroup group = GetXGroup(groupID, null); | ||
235 | |||
236 | if (group == null) | ||
237 | return; | ||
238 | |||
239 | XGroupMember groupMember = new XGroupMember() | ||
240 | { | ||
241 | agentID = agentID, | ||
242 | groupID = groupID, | ||
243 | roleID = roleID | ||
244 | }; | ||
245 | |||
246 | group.members[agentID] = groupMember; | ||
247 | |||
248 | m_data.StoreGroup(group); | ||
218 | } | 249 | } |
219 | 250 | ||
220 | public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) | 251 | public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) |
@@ -259,9 +290,31 @@ namespace OpenSim.Tests.Common.Mock | |||
259 | return null; | 290 | return null; |
260 | } | 291 | } |
261 | 292 | ||
262 | public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) | 293 | public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID groupID) |
263 | { | 294 | { |
264 | return null; | 295 | m_log.DebugFormat( |
296 | "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupMembers, requestingAgentID {0}, groupID {1}", | ||
297 | requestingAgentID, groupID); | ||
298 | |||
299 | List<GroupMembersData> groupMembers = new List<GroupMembersData>(); | ||
300 | |||
301 | XGroup group = GetXGroup(groupID, null); | ||
302 | |||
303 | if (group == null) | ||
304 | return groupMembers; | ||
305 | |||
306 | foreach (XGroupMember xgm in group.members.Values) | ||
307 | { | ||
308 | GroupMembersData gmd = new GroupMembersData(); | ||
309 | gmd.AgentID = xgm.agentID; | ||
310 | gmd.IsOwner = group.founderID == gmd.AgentID; | ||
311 | gmd.AcceptNotices = xgm.acceptNotices; | ||
312 | gmd.ListInProfile = xgm.listInProfile; | ||
313 | |||
314 | groupMembers.Add(gmd); | ||
315 | } | ||
316 | |||
317 | return groupMembers; | ||
265 | } | 318 | } |
266 | 319 | ||
267 | public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) | 320 | public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) |
@@ -269,18 +322,93 @@ namespace OpenSim.Tests.Common.Mock | |||
269 | return null; | 322 | return null; |
270 | } | 323 | } |
271 | 324 | ||
272 | public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) | 325 | public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID groupID) |
273 | { | 326 | { |
274 | return null; | 327 | XGroup group = GetXGroup(groupID, null); |
328 | |||
329 | if (group == null) | ||
330 | return null; | ||
331 | |||
332 | List<GroupNoticeData> notices = new List<GroupNoticeData>(); | ||
333 | |||
334 | foreach (XGroupNotice notice in group.notices.Values) | ||
335 | { | ||
336 | GroupNoticeData gnd = new GroupNoticeData() | ||
337 | { | ||
338 | NoticeID = notice.noticeID, | ||
339 | Timestamp = notice.timestamp, | ||
340 | FromName = notice.fromName, | ||
341 | Subject = notice.subject, | ||
342 | HasAttachment = notice.hasAttachment, | ||
343 | AssetType = (byte)notice.assetType | ||
344 | }; | ||
345 | |||
346 | notices.Add(gnd); | ||
347 | } | ||
348 | |||
349 | return notices; | ||
275 | } | 350 | } |
276 | 351 | ||
277 | public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) | 352 | public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) |
278 | { | 353 | { |
354 | m_log.DebugFormat( | ||
355 | "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupNotices, requestingAgentID {0}, noticeID {1}", | ||
356 | requestingAgentID, noticeID); | ||
357 | |||
358 | // Yes, not an efficient way to do it. | ||
359 | Dictionary<UUID, XGroup> groups = m_data.GetGroups(); | ||
360 | |||
361 | foreach (XGroup group in groups.Values) | ||
362 | { | ||
363 | if (group.notices.ContainsKey(noticeID)) | ||
364 | { | ||
365 | XGroupNotice n = group.notices[noticeID]; | ||
366 | |||
367 | GroupNoticeInfo gni = new GroupNoticeInfo(); | ||
368 | gni.GroupID = n.groupID; | ||
369 | gni.Message = n.message; | ||
370 | gni.BinaryBucket = n.binaryBucket; | ||
371 | gni.noticeData.NoticeID = n.noticeID; | ||
372 | gni.noticeData.Timestamp = n.timestamp; | ||
373 | gni.noticeData.FromName = n.fromName; | ||
374 | gni.noticeData.Subject = n.subject; | ||
375 | gni.noticeData.HasAttachment = n.hasAttachment; | ||
376 | gni.noticeData.AssetType = (byte)n.assetType; | ||
377 | |||
378 | return gni; | ||
379 | } | ||
380 | } | ||
381 | |||
279 | return null; | 382 | return null; |
280 | } | 383 | } |
281 | 384 | ||
282 | public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) | 385 | public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) |
283 | { | 386 | { |
387 | m_log.DebugFormat( | ||
388 | "[MOCK GROUPS SERVICES CONNECTOR]: AddGroupNotice, requestingAgentID {0}, groupID {1}, noticeID {2}, fromName {3}, subject {4}, message {5}, binaryBucket.Length {6}", | ||
389 | requestingAgentID, groupID, noticeID, fromName, subject, message, binaryBucket.Length); | ||
390 | |||
391 | XGroup group = GetXGroup(groupID, null); | ||
392 | |||
393 | if (group == null) | ||
394 | return; | ||
395 | |||
396 | XGroupNotice groupNotice = new XGroupNotice() | ||
397 | { | ||
398 | groupID = groupID, | ||
399 | noticeID = noticeID, | ||
400 | fromName = fromName, | ||
401 | subject = subject, | ||
402 | message = message, | ||
403 | timestamp = (uint)Util.UnixTimeSinceEpoch(), | ||
404 | hasAttachment = false, | ||
405 | assetType = 0, | ||
406 | binaryBucket = binaryBucket | ||
407 | }; | ||
408 | |||
409 | group.notices[noticeID] = groupNotice; | ||
410 | |||
411 | m_data.StoreGroup(group); | ||
284 | } | 412 | } |
285 | 413 | ||
286 | public void ResetAgentGroupChatSessions(UUID agentID) | 414 | public void ResetAgentGroupChatSessions(UUID agentID) |
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs index ed29c39..5df8e04 100644 --- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs | |||
@@ -69,11 +69,21 @@ namespace OpenSim.Data.Null | |||
69 | m_store.StoreTerrain(terrain, regionID); | 69 | m_store.StoreTerrain(terrain, regionID); |
70 | } | 70 | } |
71 | 71 | ||
72 | public void StoreTerrain(TerrainData terrain, UUID regionID) | ||
73 | { | ||
74 | m_store.StoreTerrain(terrain, regionID); | ||
75 | } | ||
76 | |||
72 | public double[,] LoadTerrain(UUID regionID) | 77 | public double[,] LoadTerrain(UUID regionID) |
73 | { | 78 | { |
74 | return m_store.LoadTerrain(regionID); | 79 | return m_store.LoadTerrain(regionID); |
75 | } | 80 | } |
76 | 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 | |||
77 | public void StoreLandObject(ILandObject Parcel) | 87 | public void StoreLandObject(ILandObject Parcel) |
78 | { | 88 | { |
79 | m_store.StoreLandObject(Parcel); | 89 | m_store.StoreLandObject(Parcel); |
@@ -154,7 +164,7 @@ namespace OpenSim.Data.Null | |||
154 | protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>(); | 164 | protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>(); |
155 | protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems | 165 | protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems |
156 | = new Dictionary<UUID, ICollection<TaskInventoryItem>>(); | 166 | = new Dictionary<UUID, ICollection<TaskInventoryItem>>(); |
157 | protected Dictionary<UUID, double[,]> m_terrains = new Dictionary<UUID, double[,]>(); | 167 | protected Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>(); |
158 | protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>(); | 168 | protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>(); |
159 | 169 | ||
160 | public void Initialise(string dbfile) | 170 | public void Initialise(string dbfile) |
@@ -299,12 +309,17 @@ namespace OpenSim.Data.Null | |||
299 | return new List<SceneObjectGroup>(objects.Values); | 309 | return new List<SceneObjectGroup>(objects.Values); |
300 | } | 310 | } |
301 | 311 | ||
302 | public void StoreTerrain(double[,] ter, UUID regionID) | 312 | public void StoreTerrain(TerrainData ter, UUID regionID) |
303 | { | 313 | { |
304 | m_terrains[regionID] = ter; | 314 | m_terrains[regionID] = ter; |
305 | } | 315 | } |
306 | 316 | ||
307 | public double[,] LoadTerrain(UUID regionID) | 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) | ||
308 | { | 323 | { |
309 | if (m_terrains.ContainsKey(regionID)) | 324 | if (m_terrains.ContainsKey(regionID)) |
310 | return m_terrains[regionID]; | 325 | return m_terrains[regionID]; |
@@ -312,6 +327,14 @@ namespace OpenSim.Data.Null | |||
312 | return null; | 327 | return null; |
313 | } | 328 | } |
314 | 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 | |||
315 | public void RemoveLandObject(UUID globalID) | 338 | public void RemoveLandObject(UUID globalID) |
316 | { | 339 | { |
317 | if (m_landData.ContainsKey(globalID)) | 340 | if (m_landData.ContainsKey(globalID)) |
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
38 | using OpenSim.Region.ScriptEngine.Shared; | ||
39 | |||
40 | namespace 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 index dde37ab..0e1bc8f 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -38,7 +38,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Framework.Client; | 39 | using OpenSim.Framework.Client; |
40 | 40 | ||
41 | namespace OpenSim.Tests.Common.Mock | 41 | namespace OpenSim.Tests.Common |
42 | { | 42 | { |
43 | public class TestClient : IClientAPI, IClientCore | 43 | public class TestClient : IClientAPI, IClientCore |
44 | { | 44 | { |
@@ -46,12 +46,10 @@ namespace OpenSim.Tests.Common.Mock | |||
46 | 46 | ||
47 | EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); | 47 | EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); |
48 | 48 | ||
49 | private TestClient TeleportSceneClient; | ||
50 | |||
51 | private Scene m_scene; | 49 | private Scene m_scene; |
52 | private SceneManager m_sceneManager; | ||
53 | 50 | ||
54 | // Properties so that we can get at received data for test purposes | 51 | // Properties so that we can get at received data for test purposes |
52 | public List<uint> ReceivedKills { get; private set; } | ||
55 | public List<UUID> ReceivedOfflineNotifications { get; private set; } | 53 | public List<UUID> ReceivedOfflineNotifications { get; private set; } |
56 | public List<UUID> ReceivedOnlineNotifications { get; private set; } | 54 | public List<UUID> ReceivedOnlineNotifications { get; private set; } |
57 | public List<UUID> ReceivedFriendshipTerminations { get; private set; } | 55 | public List<UUID> ReceivedFriendshipTerminations { get; private set; } |
@@ -60,6 +58,27 @@ namespace OpenSim.Tests.Common.Mock | |||
60 | public List<ImagePacketPacket> SentImagePacketPackets { get; private set; } | 58 | public List<ImagePacketPacket> SentImagePacketPackets { get; private set; } |
61 | public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; } | 59 | public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; } |
62 | 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 | |||
63 | // disable warning: public events, part of the public API | 82 | // disable warning: public events, part of the public API |
64 | #pragma warning disable 67 | 83 | #pragma warning disable 67 |
65 | 84 | ||
@@ -103,6 +122,7 @@ namespace OpenSim.Tests.Common.Mock | |||
103 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; | 122 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; |
104 | public event UpdateAgent OnPreAgentUpdate; | 123 | public event UpdateAgent OnPreAgentUpdate; |
105 | public event UpdateAgent OnAgentUpdate; | 124 | public event UpdateAgent OnAgentUpdate; |
125 | public event UpdateAgent OnAgentCameraUpdate; | ||
106 | public event AgentRequestSit OnAgentRequestSit; | 126 | public event AgentRequestSit OnAgentRequestSit; |
107 | public event AgentSit OnAgentSit; | 127 | public event AgentSit OnAgentSit; |
108 | public event AvatarPickerRequest OnAvatarPickerRequest; | 128 | public event AvatarPickerRequest OnAvatarPickerRequest; |
@@ -193,6 +213,7 @@ namespace OpenSim.Tests.Common.Mock | |||
193 | public event EstateCovenantRequest OnEstateCovenantRequest; | 213 | public event EstateCovenantRequest OnEstateCovenantRequest; |
194 | public event EstateChangeInfo OnEstateChangeInfo; | 214 | public event EstateChangeInfo OnEstateChangeInfo; |
195 | public event EstateManageTelehub OnEstateManageTelehub; | 215 | public event EstateManageTelehub OnEstateManageTelehub; |
216 | public event CachedTextureRequest OnCachedTextureRequest; | ||
196 | 217 | ||
197 | public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; | 218 | public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; |
198 | 219 | ||
@@ -430,33 +451,21 @@ namespace OpenSim.Tests.Common.Mock | |||
430 | /// <summary> | 451 | /// <summary> |
431 | /// Constructor | 452 | /// Constructor |
432 | /// </summary> | 453 | /// </summary> |
433 | /// <remarks> | ||
434 | /// Can be used for a test where there is only one region or where there are multiple regions that are not | ||
435 | /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a | ||
436 | /// scene manager should be used. | ||
437 | /// </remarks> | ||
438 | /// <param name="agentData"></param> | ||
439 | /// <param name="scene"></param> | ||
440 | public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {} | ||
441 | |||
442 | /// <summary> | ||
443 | /// Constructor | ||
444 | /// </summary> | ||
445 | /// <param name="agentData"></param> | 454 | /// <param name="agentData"></param> |
446 | /// <param name="scene"></param> | 455 | /// <param name="scene"></param> |
447 | /// <param name="sceneManager"></param> | 456 | /// <param name="sceneManager"></param> |
448 | public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager) | 457 | public TestClient(AgentCircuitData agentData, Scene scene) |
449 | { | 458 | { |
450 | m_agentId = agentData.AgentID; | 459 | m_agentId = agentData.AgentID; |
451 | m_firstName = agentData.firstname; | 460 | m_firstName = agentData.firstname; |
452 | m_lastName = agentData.lastname; | 461 | m_lastName = agentData.lastname; |
453 | m_circuitCode = agentData.circuitcode; | 462 | m_circuitCode = agentData.circuitcode; |
454 | m_scene = scene; | 463 | m_scene = scene; |
455 | m_sceneManager = sceneManager; | ||
456 | SessionId = agentData.SessionID; | 464 | SessionId = agentData.SessionID; |
457 | SecureSessionId = agentData.SecureSessionID; | 465 | SecureSessionId = agentData.SecureSessionID; |
458 | CapsSeedUrl = agentData.CapsPath; | 466 | CapsSeedUrl = agentData.CapsPath; |
459 | 467 | ||
468 | ReceivedKills = new List<uint>(); | ||
460 | ReceivedOfflineNotifications = new List<UUID>(); | 469 | ReceivedOfflineNotifications = new List<UUID>(); |
461 | ReceivedOnlineNotifications = new List<UUID>(); | 470 | ReceivedOnlineNotifications = new List<UUID>(); |
462 | ReceivedFriendshipTerminations = new List<UUID>(); | 471 | ReceivedFriendshipTerminations = new List<UUID>(); |
@@ -467,6 +476,34 @@ namespace OpenSim.Tests.Common.Mock | |||
467 | } | 476 | } |
468 | 477 | ||
469 | /// <summary> | 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> | ||
470 | /// Attempt a teleport to the given region. | 507 | /// Attempt a teleport to the given region. |
471 | /// </summary> | 508 | /// </summary> |
472 | /// <param name="regionHandle"></param> | 509 | /// <param name="regionHandle"></param> |
@@ -479,7 +516,20 @@ namespace OpenSim.Tests.Common.Mock | |||
479 | 516 | ||
480 | public void CompleteMovement() | 517 | public void CompleteMovement() |
481 | { | 518 | { |
482 | OnCompleteMovementToRegion(this, true); | 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); | ||
483 | } | 533 | } |
484 | 534 | ||
485 | public virtual void ActivateGesture(UUID assetId, UUID gestureId) | 535 | public virtual void ActivateGesture(UUID assetId, UUID gestureId) |
@@ -494,6 +544,11 @@ namespace OpenSim.Tests.Common.Mock | |||
494 | { | 544 | { |
495 | } | 545 | } |
496 | 546 | ||
547 | public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures) | ||
548 | { | ||
549 | |||
550 | } | ||
551 | |||
497 | public virtual void Kick(string message) | 552 | public virtual void Kick(string message) |
498 | { | 553 | { |
499 | } | 554 | } |
@@ -508,22 +563,22 @@ namespace OpenSim.Tests.Common.Mock | |||
508 | 563 | ||
509 | public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) | 564 | public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) |
510 | { | 565 | { |
511 | |||
512 | } | 566 | } |
513 | 567 | ||
514 | public virtual void SendKillObject(ulong regionHandle, List<uint> localID) | 568 | public virtual void SendKillObject(List<uint> localID) |
515 | { | 569 | { |
570 | ReceivedKills.AddRange(localID); | ||
516 | } | 571 | } |
517 | 572 | ||
518 | public virtual void SetChildAgentThrottle(byte[] throttle) | 573 | public virtual void SetChildAgentThrottle(byte[] throttle) |
519 | { | 574 | { |
520 | } | 575 | } |
576 | |||
521 | public byte[] GetThrottlesPacked(float multiplier) | 577 | public byte[] GetThrottlesPacked(float multiplier) |
522 | { | 578 | { |
523 | return new byte[0]; | 579 | return new byte[0]; |
524 | } | 580 | } |
525 | 581 | ||
526 | |||
527 | public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) | 582 | public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) |
528 | { | 583 | { |
529 | } | 584 | } |
@@ -532,19 +587,23 @@ namespace OpenSim.Tests.Common.Mock | |||
532 | string message, byte type, Vector3 fromPos, string fromName, | 587 | string message, byte type, Vector3 fromPos, string fromName, |
533 | UUID fromAgentID, UUID ownerID, byte source, byte audible) | 588 | UUID fromAgentID, UUID ownerID, byte source, byte audible) |
534 | { | 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); | ||
535 | } | 593 | } |
536 | 594 | ||
537 | public void SendInstantMessage(GridInstantMessage im) | 595 | public void SendInstantMessage(GridInstantMessage im) |
538 | { | 596 | { |
539 | 597 | if (OnReceivedInstantMessage != null) | |
598 | OnReceivedInstantMessage(im); | ||
540 | } | 599 | } |
541 | 600 | ||
542 | public void SendGenericMessage(string method, List<string> message) | 601 | public void SendGenericMessage(string method, UUID invoice, List<string> message) |
543 | { | 602 | { |
544 | 603 | ||
545 | } | 604 | } |
546 | 605 | ||
547 | public void SendGenericMessage(string method, List<byte[]> message) | 606 | public void SendGenericMessage(string method, UUID invoice, List<byte[]> message) |
548 | { | 607 | { |
549 | 608 | ||
550 | } | 609 | } |
@@ -566,13 +625,15 @@ namespace OpenSim.Tests.Common.Mock | |||
566 | 625 | ||
567 | public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) | 626 | public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) |
568 | { | 627 | { |
628 | if (OnReceivedMoveAgentIntoRegion != null) | ||
629 | OnReceivedMoveAgentIntoRegion(regInfo, pos, look); | ||
569 | } | 630 | } |
570 | 631 | ||
571 | public virtual AgentCircuitData RequestClientInfo() | 632 | public virtual AgentCircuitData RequestClientInfo() |
572 | { | 633 | { |
573 | AgentCircuitData agentData = new AgentCircuitData(); | 634 | AgentCircuitData agentData = new AgentCircuitData(); |
574 | agentData.AgentID = AgentId; | 635 | agentData.AgentID = AgentId; |
575 | agentData.SessionID = UUID.Zero; | 636 | agentData.SessionID = SessionId; |
576 | agentData.SecureSessionID = UUID.Zero; | 637 | agentData.SecureSessionID = UUID.Zero; |
577 | agentData.circuitcode = m_circuitCode; | 638 | agentData.circuitcode = m_circuitCode; |
578 | agentData.child = false; | 639 | agentData.child = false; |
@@ -591,46 +652,29 @@ namespace OpenSim.Tests.Common.Mock | |||
591 | 652 | ||
592 | public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) | 653 | public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) |
593 | { | 654 | { |
594 | m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); | 655 | if (OnTestClientInformClientOfNeighbour != null) |
595 | 656 | OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint); | |
596 | // In response to this message, we are going to make a teleport to the scene we've previous been told | ||
597 | // about by test code (this needs to be improved). | ||
598 | AgentCircuitData newAgent = RequestClientInfo(); | ||
599 | |||
600 | // Stage 2: add the new client as a child agent to the scene | ||
601 | uint x, y; | ||
602 | Utils.LongToUInts(neighbourHandle, out x, out y); | ||
603 | x /= Constants.RegionSize; | ||
604 | y /= Constants.RegionSize; | ||
605 | |||
606 | Scene neighbourScene; | ||
607 | m_sceneManager.TryGetScene(x, y, out neighbourScene); | ||
608 | |||
609 | TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager); | ||
610 | neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User); | ||
611 | } | 657 | } |
612 | 658 | ||
613 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 659 | public virtual void SendRegionTeleport( |
614 | uint locationID, uint flags, string capsURL) | 660 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
661 | uint locationID, uint flags, string capsURL) | ||
615 | { | 662 | { |
616 | m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport"); | 663 | m_log.DebugFormat( |
664 | "[TEST CLIENT]: Received SendRegionTeleport for {0} {1} on {2}", m_firstName, m_lastName, m_scene.Name); | ||
617 | 665 | ||
618 | CapsSeedUrl = capsURL; | 666 | CapsSeedUrl = capsURL; |
619 | 667 | ||
620 | // We don't do this here so that the source region can complete processing first in a single-threaded | 668 | if (OnTestClientSendRegionTeleport != null) |
621 | // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport | 669 | OnTestClientSendRegionTeleport( |
622 | // CompleteTeleportClientSide(); | 670 | regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL); |
623 | } | ||
624 | |||
625 | public void CompleteTeleportClientSide() | ||
626 | { | ||
627 | TeleportSceneClient.CompleteMovement(); | ||
628 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); | ||
629 | } | 671 | } |
630 | 672 | ||
631 | public virtual void SendTeleportFailed(string reason) | 673 | public virtual void SendTeleportFailed(string reason) |
632 | { | 674 | { |
633 | m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); | 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); | ||
634 | } | 678 | } |
635 | 679 | ||
636 | public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, | 680 | public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, |
@@ -660,7 +704,7 @@ namespace OpenSim.Tests.Common.Mock | |||
660 | { | 704 | { |
661 | } | 705 | } |
662 | 706 | ||
663 | public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance) | 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) |
664 | { | 708 | { |
665 | } | 709 | } |
666 | 710 | ||
@@ -682,6 +726,8 @@ namespace OpenSim.Tests.Common.Mock | |||
682 | 726 | ||
683 | public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) | 727 | public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) |
684 | { | 728 | { |
729 | if (OnReceivedEntityUpdate != null) | ||
730 | OnReceivedEntityUpdate(entity, updateFlags); | ||
685 | } | 731 | } |
686 | 732 | ||
687 | public void ReprioritizeUpdates() | 733 | public void ReprioritizeUpdates() |
@@ -786,11 +832,6 @@ namespace OpenSim.Tests.Common.Mock | |||
786 | { | 832 | { |
787 | OnRegionHandShakeReply(this); | 833 | OnRegionHandShakeReply(this); |
788 | } | 834 | } |
789 | |||
790 | if (OnCompleteMovementToRegion != null) | ||
791 | { | ||
792 | OnCompleteMovementToRegion(this, true); | ||
793 | } | ||
794 | } | 835 | } |
795 | 836 | ||
796 | public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) | 837 | public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) |
@@ -884,11 +925,6 @@ namespace OpenSim.Tests.Common.Mock | |||
884 | 925 | ||
885 | } | 926 | } |
886 | 927 | ||
887 | public bool AddMoney(int debit) | ||
888 | { | ||
889 | return false; | ||
890 | } | ||
891 | |||
892 | public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) | 928 | public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) |
893 | { | 929 | { |
894 | } | 930 | } |
@@ -1235,6 +1271,8 @@ namespace OpenSim.Tests.Common.Mock | |||
1235 | 1271 | ||
1236 | public void SendRebakeAvatarTextures(UUID textureID) | 1272 | public void SendRebakeAvatarTextures(UUID textureID) |
1237 | { | 1273 | { |
1274 | if (OnReceivedSendRebakeAvatarTextures != null) | ||
1275 | OnReceivedSendRebakeAvatarTextures(textureID); | ||
1238 | } | 1276 | } |
1239 | 1277 | ||
1240 | public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) | 1278 | public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) |
@@ -1269,12 +1307,17 @@ namespace OpenSim.Tests.Common.Mock | |||
1269 | { | 1307 | { |
1270 | } | 1308 | } |
1271 | 1309 | ||
1272 | public void StopFlying(ISceneEntity presence) | 1310 | public void SendAgentTerseUpdate(ISceneEntity presence) |
1273 | { | 1311 | { |
1274 | } | 1312 | } |
1275 | 1313 | ||
1276 | public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) | 1314 | public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) |
1277 | { | 1315 | { |
1278 | } | 1316 | } |
1317 | |||
1318 | public void SendPartPhysicsProprieties(ISceneEntity entity) | ||
1319 | { | ||
1320 | } | ||
1321 | |||
1279 | } | 1322 | } |
1280 | } | 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Threading; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using Mono.Addins; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Region.ClientStack.Linden; | ||
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | |||
45 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Net.Sockets; | ||
33 | using System.Text; | ||
34 | using HttpServer; | ||
35 | using OpenSim.Framework; | ||
36 | |||
37 | namespace OpenSim.Tests.Common | ||
38 | { | ||
39 | public class TestHttpClientContext: IHttpClientContext | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Bodies of responses from the server. | ||
43 | /// </summary> | ||
44 | public string ResponseBody | ||
45 | { | ||
46 | get { return Encoding.UTF8.GetString(m_responseStream.ToArray()); } | ||
47 | } | ||
48 | |||
49 | public Byte[] ResponseBodyBytes | ||
50 | { | ||
51 | get{ return m_responseStream.ToArray(); } | ||
52 | } | ||
53 | |||
54 | private MemoryStream m_responseStream = new MemoryStream(); | ||
55 | |||
56 | public bool IsSecured { get; set; } | ||
57 | |||
58 | public bool Secured | ||
59 | { | ||
60 | get { return IsSecured; } | ||
61 | set { IsSecured = value; } | ||
62 | } | ||
63 | |||
64 | public TestHttpClientContext(bool secured) | ||
65 | { | ||
66 | Secured = secured; | ||
67 | } | ||
68 | |||
69 | public void Disconnect(SocketError error) | ||
70 | { | ||
71 | // Console.WriteLine("TestHttpClientContext.Disconnect Received disconnect with status {0}", error); | ||
72 | } | ||
73 | |||
74 | public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body) {Console.WriteLine("x");} | ||
75 | public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) {Console.WriteLine("xx");} | ||
76 | public void Respond(string body) { Console.WriteLine("xxx");} | ||
77 | |||
78 | public void Send(byte[] buffer) | ||
79 | { | ||
80 | // Getting header data here | ||
81 | // Console.WriteLine("xxxx: Got {0}", Encoding.UTF8.GetString(buffer)); | ||
82 | } | ||
83 | |||
84 | public void Send(byte[] buffer, int offset, int size) | ||
85 | { | ||
86 | // Util.PrintCallStack(); | ||
87 | // | ||
88 | // Console.WriteLine( | ||
89 | // "TestHttpClientContext.Send(byte[], int, int) got offset={0}, size={1}, buffer={2}", | ||
90 | // offset, size, Encoding.UTF8.GetString(buffer)); | ||
91 | |||
92 | m_responseStream.Write(buffer, offset, size); | ||
93 | } | ||
94 | |||
95 | public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {Console.WriteLine("xxxxxx");} | ||
96 | public void Close() { } | ||
97 | public bool EndWhenDone { get { return false;} set { return;}} | ||
98 | |||
99 | public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing() | ||
100 | { | ||
101 | return new HTTPNetworkContext(); | ||
102 | } | ||
103 | |||
104 | public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { }; | ||
105 | /// <summary> | ||
106 | /// A request have been received in the context. | ||
107 | /// </summary> | ||
108 | public event EventHandler<RequestEventArgs> RequestReceived = delegate { }; | ||
109 | } | ||
110 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tests/Common/Mock/TestHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs new file mode 100644 index 0000000..b868895 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs | |||
@@ -0,0 +1,174 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Specialized; | ||
30 | using System.IO; | ||
31 | using HttpServer; | ||
32 | using HttpServer.FormDecoders; | ||
33 | |||
34 | namespace OpenSim.Tests.Common | ||
35 | { | ||
36 | public class TestHttpRequest: IHttpRequest | ||
37 | { | ||
38 | private string _uriPath; | ||
39 | public bool BodyIsComplete | ||
40 | { | ||
41 | get { return true; } | ||
42 | } | ||
43 | public string[] AcceptTypes | ||
44 | { | ||
45 | get {return _acceptTypes; } | ||
46 | } | ||
47 | private string[] _acceptTypes; | ||
48 | public Stream Body | ||
49 | { | ||
50 | get { return _body; } | ||
51 | set { _body = value;} | ||
52 | } | ||
53 | private Stream _body; | ||
54 | public ConnectionType Connection | ||
55 | { | ||
56 | get { return _connection; } | ||
57 | set { _connection = value; } | ||
58 | } | ||
59 | private ConnectionType _connection; | ||
60 | public int ContentLength | ||
61 | { | ||
62 | get { return _contentLength; } | ||
63 | set { _contentLength = value; } | ||
64 | } | ||
65 | private int _contentLength; | ||
66 | public NameValueCollection Headers | ||
67 | { | ||
68 | get { return _headers; } | ||
69 | } | ||
70 | private NameValueCollection _headers = new NameValueCollection(); | ||
71 | |||
72 | public string HttpVersion { get; set; } | ||
73 | |||
74 | public string Method | ||
75 | { | ||
76 | get { return _method; } | ||
77 | set { _method = value; } | ||
78 | } | ||
79 | private string _method = null; | ||
80 | public HttpInput QueryString | ||
81 | { | ||
82 | get { return _queryString; } | ||
83 | } | ||
84 | private HttpInput _queryString = null; | ||
85 | public Uri Uri | ||
86 | { | ||
87 | get { return _uri; } | ||
88 | set { _uri = value; } | ||
89 | } | ||
90 | private Uri _uri = null; | ||
91 | public string[] UriParts | ||
92 | { | ||
93 | get { return _uri.Segments; } | ||
94 | } | ||
95 | public HttpParam Param | ||
96 | { | ||
97 | get { return null; } | ||
98 | } | ||
99 | public HttpForm Form | ||
100 | { | ||
101 | get { return null; } | ||
102 | } | ||
103 | public bool IsAjax | ||
104 | { | ||
105 | get { return false; } | ||
106 | } | ||
107 | public RequestCookies Cookies | ||
108 | { | ||
109 | get { return null; } | ||
110 | } | ||
111 | |||
112 | public TestHttpRequest() | ||
113 | { | ||
114 | HttpVersion = "HTTP/1.1"; | ||
115 | } | ||
116 | |||
117 | public TestHttpRequest(string contentEncoding, string contentType, string userAgent, | ||
118 | string remoteAddr, string remotePort, string[] acceptTypes, | ||
119 | ConnectionType connectionType, int contentLength, Uri uri) : base() | ||
120 | { | ||
121 | _headers["content-encoding"] = contentEncoding; | ||
122 | _headers["content-type"] = contentType; | ||
123 | _headers["user-agent"] = userAgent; | ||
124 | _headers["remote_addr"] = remoteAddr; | ||
125 | _headers["remote_port"] = remotePort; | ||
126 | |||
127 | _acceptTypes = acceptTypes; | ||
128 | _connection = connectionType; | ||
129 | _contentLength = contentLength; | ||
130 | _uri = uri; | ||
131 | } | ||
132 | |||
133 | public void DecodeBody(FormDecoderProvider providers) {} | ||
134 | public void SetCookies(RequestCookies cookies) {} | ||
135 | public void AddHeader(string name, string value) | ||
136 | { | ||
137 | _headers.Add(name, value); | ||
138 | } | ||
139 | public int AddToBody(byte[] bytes, int offset, int length) | ||
140 | { | ||
141 | return 0; | ||
142 | } | ||
143 | public void Clear() {} | ||
144 | |||
145 | public object Clone() | ||
146 | { | ||
147 | TestHttpRequest clone = new TestHttpRequest(); | ||
148 | clone._acceptTypes = _acceptTypes; | ||
149 | clone._connection = _connection; | ||
150 | clone._contentLength = _contentLength; | ||
151 | clone._uri = _uri; | ||
152 | clone._headers = new NameValueCollection(_headers); | ||
153 | |||
154 | return clone; | ||
155 | } | ||
156 | public IHttpResponse CreateResponse(IHttpClientContext context) | ||
157 | { | ||
158 | return new HttpResponse(context, this); | ||
159 | } | ||
160 | /// <summary> | ||
161 | /// Path and query (will be merged with the host header) and put in Uri | ||
162 | /// </summary> | ||
163 | /// <see cref="Uri"/> | ||
164 | public string UriPath | ||
165 | { | ||
166 | get { return _uriPath; } | ||
167 | set | ||
168 | { | ||
169 | _uriPath = value; | ||
170 | |||
171 | } | ||
172 | } | ||
173 | } | ||
174 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tests/Common/Mock/TestHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs new file mode 100644 index 0000000..ff47c10 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs | |||
@@ -0,0 +1,171 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Net; | ||
31 | using System.Text; | ||
32 | using HttpServer; | ||
33 | |||
34 | namespace OpenSim.Tests.Common | ||
35 | { | ||
36 | public class TestHttpResponse: IHttpResponse | ||
37 | { | ||
38 | public Stream Body | ||
39 | { | ||
40 | get { return _body; } | ||
41 | |||
42 | set { _body = value; } | ||
43 | } | ||
44 | private Stream _body; | ||
45 | |||
46 | public string ProtocolVersion | ||
47 | { | ||
48 | get { return _protocolVersion; } | ||
49 | set { _protocolVersion = value; } | ||
50 | } | ||
51 | private string _protocolVersion; | ||
52 | |||
53 | public bool Chunked | ||
54 | { | ||
55 | get { return _chunked; } | ||
56 | |||
57 | set { _chunked = value; } | ||
58 | } | ||
59 | private bool _chunked; | ||
60 | |||
61 | public ConnectionType Connection | ||
62 | { | ||
63 | get { return _connection; } | ||
64 | |||
65 | set { _connection = value; } | ||
66 | } | ||
67 | private ConnectionType _connection; | ||
68 | |||
69 | public Encoding Encoding | ||
70 | { | ||
71 | get { return _encoding; } | ||
72 | |||
73 | set { _encoding = value; } | ||
74 | } | ||
75 | private Encoding _encoding; | ||
76 | |||
77 | public int KeepAlive | ||
78 | { | ||
79 | get { return _keepAlive; } | ||
80 | |||
81 | set { _keepAlive = value; } | ||
82 | } | ||
83 | private int _keepAlive; | ||
84 | |||
85 | public HttpStatusCode Status | ||
86 | { | ||
87 | get { return _status; } | ||
88 | |||
89 | set { _status = value; } | ||
90 | } | ||
91 | private HttpStatusCode _status; | ||
92 | |||
93 | public string Reason | ||
94 | { | ||
95 | get { return _reason; } | ||
96 | |||
97 | set { _reason = value; } | ||
98 | } | ||
99 | private string _reason; | ||
100 | |||
101 | public long ContentLength | ||
102 | { | ||
103 | get { return _contentLength; } | ||
104 | |||
105 | set { _contentLength = value; } | ||
106 | } | ||
107 | private long _contentLength; | ||
108 | |||
109 | public string ContentType | ||
110 | { | ||
111 | get { return _contentType; } | ||
112 | |||
113 | set { _contentType = value; } | ||
114 | } | ||
115 | private string _contentType; | ||
116 | |||
117 | public bool HeadersSent | ||
118 | { | ||
119 | get { return _headersSent; } | ||
120 | } | ||
121 | private bool _headersSent; | ||
122 | |||
123 | public bool Sent | ||
124 | { | ||
125 | get { return _sent; } | ||
126 | } | ||
127 | private bool _sent; | ||
128 | |||
129 | public ResponseCookies Cookies | ||
130 | { | ||
131 | get { return _cookies; } | ||
132 | } | ||
133 | private ResponseCookies _cookies = null; | ||
134 | |||
135 | public TestHttpResponse() | ||
136 | { | ||
137 | _headersSent = false; | ||
138 | _sent = false; | ||
139 | } | ||
140 | |||
141 | public void AddHeader(string name, string value) {} | ||
142 | |||
143 | public void Send() | ||
144 | { | ||
145 | if (!_headersSent) SendHeaders(); | ||
146 | if (_sent) throw new InvalidOperationException("stuff already sent"); | ||
147 | _sent = true; | ||
148 | } | ||
149 | |||
150 | public void SendBody(byte[] buffer, int offset, int count) | ||
151 | { | ||
152 | if (!_headersSent) SendHeaders(); | ||
153 | _sent = true; | ||
154 | } | ||
155 | |||
156 | public void SendBody(byte[] buffer) | ||
157 | { | ||
158 | if (!_headersSent) SendHeaders(); | ||
159 | _sent = true; | ||
160 | } | ||
161 | |||
162 | public void SendHeaders() | ||
163 | { | ||
164 | if (_headersSent) throw new InvalidOperationException("headers already sent"); | ||
165 | _headersSent = true; | ||
166 | } | ||
167 | |||
168 | public void Redirect(Uri uri) {} | ||
169 | public void Redirect(string url) {} | ||
170 | } | ||
171 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index fc44358..c97a765 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs | |||
@@ -33,7 +33,7 @@ using OpenMetaverse; | |||
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Data; | 34 | using OpenSim.Data; |
35 | 35 | ||
36 | namespace OpenSim.Tests.Common.Mock | 36 | namespace OpenSim.Tests.Common |
37 | { | 37 | { |
38 | /// <summary> | 38 | /// <summary> |
39 | /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the | 39 | /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the |
@@ -185,7 +185,7 @@ namespace OpenSim.Tests.Common.Mock | |||
185 | 185 | ||
186 | public void addInventoryItem(InventoryItemBase item) | 186 | public void addInventoryItem(InventoryItemBase item) |
187 | { | 187 | { |
188 | // InventoryFolderBase folder = m_folders[item.Folder]; | 188 | InventoryFolderBase folder = m_folders[item.Folder]; |
189 | 189 | ||
190 | // m_log.DebugFormat( | 190 | // m_log.DebugFormat( |
191 | // "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); | 191 | // "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs index 27b9e5b..26887c9 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs +++ b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs | |||
@@ -32,8 +32,9 @@ using System.Net.Sockets; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse.Packets; | 33 | using OpenMetaverse.Packets; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.ClientStack.LindenUDP; | ||
35 | 36 | ||
36 | namespace OpenSim.Region.ClientStack.LindenUDP.Tests | 37 | namespace OpenSim.Tests.Common |
37 | { | 38 | { |
38 | /// <summary> | 39 | /// <summary> |
39 | /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data. | 40 | /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data. |
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs index 4b4d52d..89ebcd5 100644 --- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs +++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs | |||
@@ -32,7 +32,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
32 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Region.CoreModules.World.Land; | 33 | using OpenSim.Region.CoreModules.World.Land; |
34 | 34 | ||
35 | namespace OpenSim.Tests.Common.Mock | 35 | namespace OpenSim.Tests.Common |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// Land channel for test purposes | 38 | /// Land channel for test purposes |
@@ -81,6 +81,11 @@ namespace OpenSim.Tests.Common.Mock | |||
81 | return obj; | 81 | return obj; |
82 | } | 82 | } |
83 | 83 | ||
84 | public ILandObject GetLandObject(Vector3 position) | ||
85 | { | ||
86 | return GetLandObject(position.X, position.Y); | ||
87 | } | ||
88 | |||
84 | public ILandObject GetLandObject(int x, int y) | 89 | public ILandObject GetLandObject(int x, int y) |
85 | { | 90 | { |
86 | return GetNoLand(); | 91 | return GetNoLand(); |
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs index e769d30..7b1d2b5 100644 --- a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs +++ b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs | |||
@@ -35,7 +35,7 @@ using System.Text; | |||
35 | using System.Web; | 35 | using System.Web; |
36 | using OpenSim.Framework.Servers.HttpServer; | 36 | using OpenSim.Framework.Servers.HttpServer; |
37 | 37 | ||
38 | namespace OpenSim.Tests.Common.Mock | 38 | namespace OpenSim.Tests.Common |
39 | { | 39 | { |
40 | public class TestOSHttpRequest : IOSHttpRequest | 40 | public class TestOSHttpRequest : IOSHttpRequest |
41 | { | 41 | { |
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs index e10fe82..2e17f1e 100644 --- a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs +++ b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs | |||
@@ -32,7 +32,7 @@ using System.Text; | |||
32 | using System.Web; | 32 | using System.Web; |
33 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
34 | 34 | ||
35 | namespace OpenSim.Tests.Common.Mock | 35 | namespace OpenSim.Tests.Common |
36 | { | 36 | { |
37 | public class TestOSHttpResponse : IOSHttpResponse | 37 | public class TestOSHttpResponse : IOSHttpResponse |
38 | { | 38 | { |
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs index d4b5648..1a93c9f 100644 --- a/OpenSim/Tests/Common/Mock/TestScene.cs +++ b/OpenSim/Tests/Common/Mock/TestScene.cs | |||
@@ -28,23 +28,24 @@ | |||
28 | using System; | 28 | using System; |
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
31 | using OpenSim.Framework.Communications; | 31 | |
32 | using OpenSim.Framework.Servers; | 32 | using OpenSim.Framework.Servers; |
33 | using OpenSim.Region.Framework; | 33 | using OpenSim.Region.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.PhysicsModules.SharedBase; | ||
37 | using OpenSim.Services.Interfaces; | ||
36 | 38 | ||
37 | namespace OpenSim.Tests.Common.Mock | 39 | namespace OpenSim.Tests.Common |
38 | { | 40 | { |
39 | public class TestScene : Scene | 41 | public class TestScene : Scene |
40 | { | 42 | { |
41 | public TestScene( | 43 | public TestScene( |
42 | RegionInfo regInfo, AgentCircuitManager authen, | 44 | RegionInfo regInfo, AgentCircuitManager authen, |
43 | SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, | 45 | ISimulationDataService simDataService, IEstateDataService estateDataService, |
44 | bool dumpAssetsToFile, | ||
45 | IConfigSource config, string simulatorVersion) | 46 | IConfigSource config, string simulatorVersion) |
46 | : base(regInfo, authen, sceneGridService, simDataService, estateDataService, | 47 | : base(regInfo, authen, simDataService, estateDataService, |
47 | dumpAssetsToFile, config, simulatorVersion) | 48 | config, simulatorVersion) |
48 | { | 49 | { |
49 | } | 50 | } |
50 | 51 | ||
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs index ccbdf81..2b272e6 100644 --- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs | |||
@@ -35,7 +35,7 @@ using OpenSim.Framework; | |||
35 | using OpenSim.Data; | 35 | using OpenSim.Data; |
36 | using OpenSim.Data.Null; | 36 | using OpenSim.Data.Null; |
37 | 37 | ||
38 | namespace OpenSim.Tests.Common.Mock | 38 | namespace OpenSim.Tests.Common |
39 | { | 39 | { |
40 | public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData | 40 | public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData |
41 | { | 41 | { |
@@ -46,17 +46,33 @@ namespace OpenSim.Tests.Common.Mock | |||
46 | 46 | ||
47 | public XInventoryItem[] GetItems(string[] fields, string[] vals) | 47 | public XInventoryItem[] GetItems(string[] fields, string[] vals) |
48 | { | 48 | { |
49 | // Console.WriteLine( | ||
50 | // "Requesting items, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); | ||
51 | |||
49 | List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList()); | 52 | List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList()); |
50 | 53 | ||
51 | return origItems.Select(i => i.Clone()).ToArray(); | 54 | XInventoryItem[] items = origItems.Select(i => i.Clone()).ToArray(); |
55 | |||
56 | // Console.WriteLine("Found {0} items", items.Length); | ||
57 | // Array.ForEach(items, i => Console.WriteLine("Found item {0} {1}", i.inventoryName, i.inventoryID)); | ||
58 | |||
59 | return items; | ||
52 | } | 60 | } |
53 | 61 | ||
54 | public XInventoryFolder[] GetFolders(string[] fields, string[] vals) | 62 | public XInventoryFolder[] GetFolders(string[] fields, string[] vals) |
55 | { | 63 | { |
64 | // Console.WriteLine( | ||
65 | // "Requesting folders, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); | ||
66 | |||
56 | List<XInventoryFolder> origFolders | 67 | List<XInventoryFolder> origFolders |
57 | = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); | 68 | = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); |
58 | 69 | ||
59 | return origFolders.Select(f => f.Clone()).ToArray(); | 70 | XInventoryFolder[] folders = origFolders.Select(f => f.Clone()).ToArray(); |
71 | |||
72 | // Console.WriteLine("Found {0} folders", folders.Length); | ||
73 | // Array.ForEach(folders, f => Console.WriteLine("Found folder {0} {1}", f.folderName, f.folderID)); | ||
74 | |||
75 | return folders; | ||
60 | } | 76 | } |
61 | 77 | ||
62 | public bool StoreFolder(XInventoryFolder folder) | 78 | public bool StoreFolder(XInventoryFolder folder) |
@@ -72,7 +88,9 @@ namespace OpenSim.Tests.Common.Mock | |||
72 | { | 88 | { |
73 | m_allItems[item.inventoryID] = item.Clone(); | 89 | m_allItems[item.inventoryID] = item.Clone(); |
74 | 90 | ||
75 | // Console.WriteLine("Added item {0} {1}, creator {2}, owner {3}", item.inventoryName, item.inventoryID, item.creatorID, item.avatarID); | 91 | // Console.WriteLine( |
92 | // "Added item {0} {1}, folder {2}, creator {3}, owner {4}", | ||
93 | // item.inventoryName, item.inventoryID, item.parentFolderID, item.creatorID, item.avatarID); | ||
76 | 94 | ||
77 | return true; | 95 | return true; |
78 | } | 96 | } |
@@ -104,7 +122,30 @@ namespace OpenSim.Tests.Common.Mock | |||
104 | } | 122 | } |
105 | 123 | ||
106 | public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } | 124 | public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } |
107 | public bool MoveFolder(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 | |||
108 | public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } | 149 | public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } |
109 | public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } | 150 | public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } |
110 | } | 151 | } |