aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
authorKittoFlora2009-11-15 22:20:51 +0100
committerKittoFlora2009-11-15 22:20:51 +0100
commitba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee (patch)
treee218f290178d98e63aa8ab6aef46c1715195c32e /OpenSim/Tests
parentMerge branch 'master' into vehicles (diff)
parentMake GroupRootUpdate be a terse update. This method is not used by opensim (i... (diff)
downloadopensim-SC-ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee.zip
opensim-SC-ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee.tar.gz
opensim-SC-ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee.tar.bz2
opensim-SC-ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to '')
-rw-r--r--OpenSim/Tests/Common/Mock/MockAssetService.cs (renamed from OpenSim/Tests/Common/Mock/TestAssetService.cs)21
-rw-r--r--OpenSim/Tests/Common/Mock/MockInventoryService.cs (renamed from OpenSim/Tests/Common/Mock/TestInventoryService.cs)6
-rw-r--r--OpenSim/Tests/Common/Mock/MockUserService.cs123
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs2
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs64
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs4
-rw-r--r--OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs24
-rw-r--r--OpenSim/Tests/Common/TestHelper.cs1
8 files changed, 234 insertions, 11 deletions
diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/MockAssetService.cs
index 317ec06..cb38043 100644
--- a/OpenSim/Tests/Common/Mock/TestAssetService.cs
+++ b/OpenSim/Tests/Common/Mock/MockAssetService.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
30using OpenMetaverse; 32using OpenMetaverse;
31using OpenSim.Framework; 33using OpenSim.Framework;
32using OpenSim.Data; 34using OpenSim.Data;
@@ -35,16 +37,25 @@ using Nini.Config;
35 37
36namespace OpenSim.Tests.Common.Mock 38namespace OpenSim.Tests.Common.Mock
37{ 39{
38 public class TestAssetService : IAssetService 40 public class MockAssetService : IAssetService
39 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
40 private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); 44 private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>();
41 45
42 public TestAssetService(IConfigSource config) 46 public MockAssetService() {}
43 { 47
44 } 48 /// <summary>
49 /// This constructor is required if the asset service is being created reflectively (which is the case in some
50 /// tests).
51 /// </summary>
52 /// <param name="config"></param>
53 public MockAssetService(IConfigSource config) {}
45 54
46 public AssetBase Get(string id) 55 public AssetBase Get(string id)
47 { 56 {
57 m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id);
58
48 AssetBase asset; 59 AssetBase asset;
49 if (Assets.ContainsKey(id)) 60 if (Assets.ContainsKey(id))
50 asset = Assets[id]; 61 asset = Assets[id];
@@ -73,6 +84,8 @@ namespace OpenSim.Tests.Common.Mock
73 84
74 public string Store(AssetBase asset) 85 public string Store(AssetBase asset)
75 { 86 {
87 m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID);
88
76 Assets[asset.ID] = asset; 89 Assets[asset.ID] = asset;
77 90
78 return asset.ID; 91 return asset.ID;
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/MockInventoryService.cs
index 5a0ee7c..1ea4bc1 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryService.cs
+++ b/OpenSim/Tests/Common/Mock/MockInventoryService.cs
@@ -35,13 +35,13 @@ using Nini.Config;
35 35
36namespace OpenSim.Tests.Common.Mock 36namespace OpenSim.Tests.Common.Mock
37{ 37{
38 public class TestInventoryService : IInventoryService 38 public class MockInventoryService : IInventoryService
39 { 39 {
40 public TestInventoryService() 40 public MockInventoryService()
41 { 41 {
42 } 42 }
43 43
44 public TestInventoryService(IConfigSource config) 44 public MockInventoryService(IConfigSource config)
45 { 45 {
46 } 46 }
47 47
diff --git a/OpenSim/Tests/Common/Mock/MockUserService.cs b/OpenSim/Tests/Common/Mock/MockUserService.cs
new file mode 100644
index 0000000..1e27fb7
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockUserService.cs
@@ -0,0 +1,123 @@
1
2using System;
3using System.Collections.Generic;
4using OpenMetaverse;
5using OpenSim.Framework;
6using OpenSim.Framework.Communications;
7using OpenSim.Framework.Communications.Cache;
8using OpenSim.Services.Interfaces;
9
10namespace OpenSim.Tests.Common
11{
12 public class MockUserService : IUserService
13 {
14 public void AddTemporaryUserProfile(UserProfileData userProfile)
15 {
16 throw new NotImplementedException();
17 }
18
19 public UserProfileData GetUserProfile(string firstName, string lastName)
20 {
21 throw new NotImplementedException();
22 }
23
24 public UserProfileData GetUserProfile(UUID userId)
25 {
26 throw new NotImplementedException();
27 }
28
29 public UserProfileData GetUserProfile(Uri uri)
30 {
31 UserProfileData userProfile = new UserProfileData();
32
33// userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret));
34
35 return userProfile;
36 }
37
38 public Uri GetUserUri(UserProfileData userProfile)
39 {
40 throw new NotImplementedException();
41 }
42
43 public UserAgentData GetAgentByUUID(UUID userId)
44 {
45 throw new NotImplementedException();
46 }
47
48 public void ClearUserAgent(UUID avatarID)
49 {
50 throw new NotImplementedException();
51 }
52
53 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID QueryID, string Query)
54 {
55 throw new NotImplementedException();
56 }
57
58 public UserProfileData SetupMasterUser(string firstName, string lastName)
59 {
60 throw new NotImplementedException();
61 }
62
63 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
64 {
65 throw new NotImplementedException();
66 }
67
68 public UserProfileData SetupMasterUser(UUID userId)
69 {
70 throw new NotImplementedException();
71 }
72
73 public bool UpdateUserProfile(UserProfileData data)
74 {
75 throw new NotImplementedException();
76 }
77
78 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
79 {
80 throw new NotImplementedException();
81 }
82
83 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
84 {
85 throw new NotImplementedException();
86 }
87
88 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
89 {
90 throw new NotImplementedException();
91 }
92
93 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
94 {
95 throw new NotImplementedException();
96 }
97
98 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
99 {
100 throw new NotImplementedException();
101 }
102
103 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
104 {
105 throw new NotImplementedException();
106 }
107
108 public bool VerifySession(UUID userID, UUID sessionID)
109 {
110 return true;
111 }
112
113 public void SetInventoryService(IInventoryService inv)
114 {
115 throw new NotImplementedException();
116 }
117
118 public virtual bool AuthenticateUserByPassword(UUID userID, string password)
119 {
120 throw new NotImplementedException();
121 }
122 }
123}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 0f642b9..27025d9 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -191,6 +191,7 @@ namespace OpenSim.Tests.Common.Mock
191 public event FriendActionDelegate OnApproveFriendRequest; 191 public event FriendActionDelegate OnApproveFriendRequest;
192 public event FriendActionDelegate OnDenyFriendRequest; 192 public event FriendActionDelegate OnDenyFriendRequest;
193 public event FriendshipTermination OnTerminateFriendship; 193 public event FriendshipTermination OnTerminateFriendship;
194 public event GrantUserFriendRights OnGrantUserRights;
194 195
195 public event EconomyDataRequest OnEconomyDataRequest; 196 public event EconomyDataRequest OnEconomyDataRequest;
196 public event MoneyBalanceRequest OnMoneyBalanceRequest; 197 public event MoneyBalanceRequest OnMoneyBalanceRequest;
@@ -631,6 +632,7 @@ namespace OpenSim.Tests.Common.Mock
631 public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, 632 public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID,
632 List<InventoryItemBase> items, 633 List<InventoryItemBase> items,
633 List<InventoryFolderBase> folders, 634 List<InventoryFolderBase> folders,
635 int version,
634 bool fetchFolders, 636 bool fetchFolders,
635 bool fetchItems) 637 bool fetchItems)
636 { 638 {
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
new file mode 100644
index 0000000..df69cd9
--- /dev/null
+++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
@@ -0,0 +1,64 @@
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.Text;
29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Region.Framework.Scenes.Serialization;
33
34namespace OpenSim.Tests.Common
35{
36 public class AssetHelpers
37 {
38 /// <summary>
39 /// Create an asset from the given data
40 /// </summary>
41 /// <param name="assetUuid"></param>
42 /// <param name="data"></param>
43 /// <returns></returns>
44 public static AssetBase CreateAsset(UUID assetUuid, string data)
45 {
46 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)AssetType.Object);
47 asset.Data = Encoding.ASCII.GetBytes(data);
48 return asset;
49 }
50
51 /// <summary>
52 /// Create an asset from the given scene object
53 /// </summary>
54 /// <param name="assetUuid"></param>
55 /// <param name="sog"></param>
56 /// <returns></returns>
57 public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog)
58 {
59 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)AssetType.Object);
60 asset.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog));
61 return asset;
62 }
63 }
64}
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index eab5422..8b18d07 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -219,7 +219,7 @@ namespace OpenSim.Tests.Common.Setup
219 if (real) 219 if (real)
220 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); 220 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
221 else 221 else
222 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestAssetService"); 222 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockAssetService");
223 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 223 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
224 assetService.Initialise(config); 224 assetService.Initialise(config);
225 assetService.AddRegion(testScene); 225 assetService.AddRegion(testScene);
@@ -238,7 +238,7 @@ namespace OpenSim.Tests.Common.Setup
238 if (real) 238 if (real)
239 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); 239 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
240 else 240 else
241 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestInventoryService"); 241 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockInventoryService");
242 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 242 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
243 inventoryService.Initialise(config); 243 inventoryService.Initialise(config);
244 inventoryService.AddRegion(testScene); 244 inventoryService.AddRegion(testScene);
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
index 3ca44a1..1b06a46 100644
--- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
@@ -85,14 +85,34 @@ namespace OpenSim.Tests.Common.Setup
85 CommunicationsManager commsManager, string firstName, string lastName, 85 CommunicationsManager commsManager, string firstName, string lastName,
86 UUID userId, OnInventoryReceivedDelegate callback) 86 UUID userId, OnInventoryReceivedDelegate callback)
87 { 87 {
88 return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback);
89 }
90
91 /// <summary>
92 /// Create a test user with a standard inventory
93 /// </summary>
94 /// <param name="commsManager"></param>
95 /// <param name="firstName">First name of user</param>
96 /// <param name="lastName">Last name of user</param>
97 /// <param name="password">Password</param>
98 /// <param name="userId">User ID</param>
99 /// <param name="callback">
100 /// Callback to invoke when inventory has been loaded. This is required because
101 /// loading may be asynchronous, even on standalone
102 /// </param>
103 /// <returns></returns>
104 public static CachedUserInfo CreateUserWithInventory(
105 CommunicationsManager commsManager, string firstName, string lastName, string password,
106 UUID userId, OnInventoryReceivedDelegate callback)
107 {
88 LocalUserServices lus = (LocalUserServices)commsManager.UserService; 108 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
89 lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); 109 lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId);
90 110
91 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); 111 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
92 userInfo.OnInventoryReceived += callback; 112 userInfo.OnInventoryReceived += callback;
93 userInfo.FetchInventory(); 113 userInfo.FetchInventory();
94 114
95 return userInfo; 115 return userInfo;
96 } 116 }
97 } 117 }
98} 118}
diff --git a/OpenSim/Tests/Common/TestHelper.cs b/OpenSim/Tests/Common/TestHelper.cs
index 4abf2e3..9d53063 100644
--- a/OpenSim/Tests/Common/TestHelper.cs
+++ b/OpenSim/Tests/Common/TestHelper.cs
@@ -54,6 +54,7 @@ namespace OpenSim.Tests.Common
54 public static void InMethod() 54 public static void InMethod()
55 { 55 {
56 StackTrace stackTrace = new StackTrace(); 56 StackTrace stackTrace = new StackTrace();
57 Console.WriteLine();
57 Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); 58 Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name);
58 } 59 }
59 } 60 }