aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Common/Mock/TestAssetService.cs9
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryService.cs133
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs129
-rw-r--r--OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs42
4 files changed, 275 insertions, 38 deletions
diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/TestAssetService.cs
index d35e3ed..5f1184b 100644
--- a/OpenSim/Tests/Common/Mock/TestAssetService.cs
+++ b/OpenSim/Tests/Common/Mock/TestAssetService.cs
@@ -31,13 +31,18 @@ using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Data; 32using OpenSim.Data;
33using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
34using Nini.Config;
34 35
35namespace OpenSim.Tests.Common.Mock 36namespace OpenSim.Tests.Common.Mock
36{ 37{
37 public class TestAssetService : IAssetService 38 public class TestAssetService : IAssetService
38 { 39 {
39 private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); 40 private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>();
40 41
42 public TestAssetService(IConfigSource config)
43 {
44 }
45
41 public AssetBase Get(string id) 46 public AssetBase Get(string id)
42 { 47 {
43 return Assets[ id ]; 48 return Assets[ id ];
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/TestInventoryService.cs
new file mode 100644
index 0000000..cf1a3a9
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestInventoryService.cs
@@ -0,0 +1,133 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework;
5using OpenMetaverse;
6using OpenSim.Services.Interfaces;
7using Nini.Config;
8
9namespace OpenSim.Tests.Common.Mock
10{
11 public class TestInventoryService : IInventoryService
12 {
13 public TestInventoryService()
14 {
15 }
16
17 public TestInventoryService(IConfigSource config)
18 {
19 }
20
21 /// <summary>
22 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
23 /// </summary>
24 /// <param name="userId"></param>
25 /// <returns></returns>
26 public bool CreateUserInventory(UUID userId)
27 {
28 return false;
29 }
30
31 /// <summary>
32 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
33 /// </summary>
34 /// <param name="userId"></param>
35 /// <returns></returns>
36 public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
37 {
38 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
39 InventoryFolderBase folder = new InventoryFolderBase();
40 folder.ID = UUID.Random();
41 folder.Owner = userId;
42 folders.Add(folder);
43 return folders;
44 }
45
46 /// <summary>
47 /// Returns a list of all the active gestures in a user's inventory.
48 /// </summary>
49 /// <param name="userId">
50 /// The <see cref="UUID"/> of the user
51 /// </param>
52 /// <returns>
53 /// A flat list of the gesture items.
54 /// </returns>
55 public List<InventoryItemBase> GetActiveGestures(UUID userId)
56 {
57 return null;
58 }
59
60 public InventoryCollection GetUserInventory(UUID userID)
61 {
62 return null;
63 }
64
65 public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback)
66 {
67 }
68
69 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
70 {
71 return null;
72 }
73
74 public bool AddFolder(InventoryFolderBase folder)
75 {
76 return false;
77 }
78
79 public bool UpdateFolder(InventoryFolderBase folder)
80 {
81 return false;
82 }
83
84 public bool MoveFolder(InventoryFolderBase folder)
85 {
86 return false;
87 }
88
89 public bool PurgeFolder(InventoryFolderBase folder)
90 {
91 return false;
92 }
93
94 public bool AddItem(InventoryItemBase item)
95 {
96 return false;
97 }
98
99 public bool UpdateItem(InventoryItemBase item)
100 {
101 return false;
102 }
103
104 public bool DeleteItem(InventoryItemBase item)
105 {
106 return false;
107 }
108
109 public InventoryItemBase QueryItem(InventoryItemBase item)
110 {
111 return null;
112 }
113
114 public InventoryFolderBase QueryFolder(InventoryFolderBase folder)
115 {
116 return null;
117 }
118
119 public bool HasInventoryForUser(UUID userID)
120 {
121 return false;
122 }
123
124 public InventoryFolderBase RequestRootFolder(UUID userID)
125 {
126 InventoryFolderBase root = new InventoryFolderBase();
127 root.ID = UUID.Random();
128 root.Owner = userID;
129 root.ParentID = UUID.Zero;
130 return root;
131 }
132 }
133}
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index c11691f..b1b32cc 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -54,6 +54,12 @@ namespace OpenSim.Tests.Common.Setup
54 /// </summary> 54 /// </summary>
55 public class SceneSetupHelpers 55 public class SceneSetupHelpers
56 { 56 {
57 // These static variables in order to allow regions to be linked by shared modules and same
58 // CommunicationsManager.
59 private static ISharedRegionModule m_assetService = null;
60 private static ISharedRegionModule m_inventoryService = null;
61 private static TestCommunicationsManager commsManager = null;
62
57 /// <summary> 63 /// <summary>
58 /// Set up a test scene 64 /// Set up a test scene
59 /// </summary> 65 /// </summary>
@@ -63,21 +69,33 @@ namespace OpenSim.Tests.Common.Setup
63 /// <returns></returns> 69 /// <returns></returns>
64 public static TestScene SetupScene() 70 public static TestScene SetupScene()
65 { 71 {
66 return SetupScene(true); 72 return SetupScene("");
67 } 73 }
68 74
69 /// <summary> 75 /// <summary>
70 /// Set up a test scene 76 /// Set up a test scene
71 /// </summary> 77 /// </summary>
72 /// 78 ///
73 /// <param name="startServices">Start associated service threads for the scene</param> 79 /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
74 /// <returns></returns> 80 /// <returns></returns>
75 public static TestScene SetupScene(bool startServices) 81 public static TestScene SetupScene(String realServices)
76 { 82 {
77 return SetupScene( 83 return SetupScene(
78 "Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager(), startServices); 84 "Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager(), realServices);
85 }
86
87 /// <summary>
88 /// Set up a test scene
89 /// </summary>
90 ///
91 /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
92 /// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
93 /// <returns></returns>
94 public static TestScene SetupScene(TestCommunicationsManager cm, String realServices)
95 {
96 return SetupScene(
97 "Unit test region", UUID.Random(), 1000, 1000, cm, "");
79 } 98 }
80
81 /// <summary> 99 /// <summary>
82 /// Set up a test scene 100 /// Set up a test scene
83 /// </summary> 101 /// </summary>
@@ -89,28 +107,40 @@ namespace OpenSim.Tests.Common.Setup
89 /// <returns></returns> 107 /// <returns></returns>
90 public static TestScene SetupScene(string name, UUID id, uint x, uint y, TestCommunicationsManager cm) 108 public static TestScene SetupScene(string name, UUID id, uint x, uint y, TestCommunicationsManager cm)
91 { 109 {
92 return SetupScene(name, id, x, y, cm, true); 110 return SetupScene(name, id, x, y, cm, "");
93 } 111 }
94 112
95 /// <summary> 113 /// <summary>
96 /// Set up a test scene 114 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
115 /// or a different, to get a brand new scene with new shared region modules.
97 /// </summary> 116 /// </summary>
98 /// <param name="name">Name of the region</param> 117 /// <param name="name">Name of the region</param>
99 /// <param name="id">ID of the region</param> 118 /// <param name="id">ID of the region</param>
100 /// <param name="x">X co-ordinate of the region</param> 119 /// <param name="x">X co-ordinate of the region</param>
101 /// <param name="y">Y co-ordinate of the region</param> 120 /// <param name="y">Y co-ordinate of the region</param>
102 /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> 121 /// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
103 /// <param name="startServices">Start associated threads for the services used by the scene</param> 122 /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
104 /// <returns></returns> 123 /// <returns></returns>
105 public static TestScene SetupScene( 124 public static TestScene SetupScene(
106 string name, UUID id, uint x, uint y, TestCommunicationsManager cm, bool startServices) 125 string name, UUID id, uint x, uint y, TestCommunicationsManager cm, String realServices)
107 { 126 {
127 bool newScene= false;
128
108 Console.WriteLine("Setting up test scene {0}", name); 129 Console.WriteLine("Setting up test scene {0}", name);
130
131 // If cm is the same as our last commsManager used, this means the tester wants to link
132 // regions. In this case, don't use the sameshared region modules and dont initialize them again.
133 // Also, no need to start another MainServer and MainConsole instance.
134 if (cm == null || cm != commsManager)
135 {
136 System.Console.WriteLine("Starting a brand new scene");
137 newScene = true;
138 MainConsole.Instance = new LocalConsole("TEST PROMPT");
139 MainServer.Instance = new BaseHttpServer(980);
140 commsManager = cm;
141 }
109 142
110 // We must set up a console otherwise setup of some modules may fail 143 // We must set up a console otherwise setup of some modules may fail
111 MainConsole.Instance = new LocalConsole("TEST PROMPT");
112
113 MainServer.Instance = new BaseHttpServer(980);
114 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); 144 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
115 regInfo.RegionName = name; 145 regInfo.RegionName = name;
116 regInfo.RegionID = id; 146 regInfo.RegionID = id;
@@ -132,44 +162,83 @@ namespace OpenSim.Tests.Common.Setup
132 IRegionModule godsModule = new GodsModule(); 162 IRegionModule godsModule = new GodsModule();
133 godsModule.Initialise(testScene, new IniConfigSource()); 163 godsModule.Initialise(testScene, new IniConfigSource());
134 testScene.AddModule(godsModule.Name, godsModule); 164 testScene.AddModule(godsModule.Name, godsModule);
165 realServices = realServices.ToLower();
166 IniConfigSource config = new IniConfigSource();
167
168 // If we have a brand new scene, need to initialize shared region modules
169 if ((m_assetService == null && m_inventoryService == null) || newScene)
170 {
171 if (realServices.Contains("asset"))
172 StartAssetService(testScene, true);
173 else
174 StartAssetService(testScene, false);
175 if (realServices.Contains("inventory"))
176 StartInventoryService(testScene, true);
177 else
178 StartInventoryService(testScene, false);
179 }
180 // If not, make sure the shared module gets references to this new scene
181 else
182 {
183 m_assetService.AddRegion(testScene);
184 m_assetService.RegionLoaded(testScene);
185 m_inventoryService.AddRegion(testScene);
186 m_inventoryService.RegionLoaded(testScene);
187 }
188 m_inventoryService.PostInitialise();
189 m_assetService.PostInitialise();
190
191 testScene.CommsManager.UserService.SetInventoryService(testScene.InventoryService);
192
193 testScene.SetModuleInterfaces();
135 194
195 testScene.LandChannel = new TestLandChannel();
196 testScene.LoadWorldMap();
197
198 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
199 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
200 testScene.PhysicsScene
201 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test");
202
203 return testScene;
204 }
205
206 private static void StartAssetService(Scene testScene, bool real)
207 {
136 ISharedRegionModule assetService = new LocalAssetServicesConnector(); 208 ISharedRegionModule assetService = new LocalAssetServicesConnector();
137 IniConfigSource config = new IniConfigSource(); 209 IniConfigSource config = new IniConfigSource();
138 config.AddConfig("Modules"); 210 config.AddConfig("Modules");
139 config.AddConfig("AssetService"); 211 config.AddConfig("AssetService");
140 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); 212 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
141 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); 213 if (real)
214 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
215 else
216 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestAssetService");
142 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 217 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
143 assetService.Initialise(config); 218 assetService.Initialise(config);
144 assetService.AddRegion(testScene); 219 assetService.AddRegion(testScene);
145 assetService.RegionLoaded(testScene); 220 assetService.RegionLoaded(testScene);
146 testScene.AddRegionModule(assetService.Name, assetService); 221 testScene.AddRegionModule(assetService.Name, assetService);
147 assetService.PostInitialise(); 222 m_assetService = assetService;
223 }
148 224
225 private static void StartInventoryService(Scene testScene, bool real)
226 {
149 ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); 227 ISharedRegionModule inventoryService = new LocalInventoryServicesConnector();
150 config = new IniConfigSource(); 228 IniConfigSource config = new IniConfigSource();
151 config.AddConfig("Modules"); 229 config.AddConfig("Modules");
152 config.AddConfig("InventoryService"); 230 config.AddConfig("InventoryService");
153 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); 231 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
154 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); 232 if (real)
233 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
234 else
235 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestInventoryService");
155 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 236 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
156 inventoryService.Initialise(config); 237 inventoryService.Initialise(config);
157 inventoryService.AddRegion(testScene); 238 inventoryService.AddRegion(testScene);
158 inventoryService.RegionLoaded(testScene); 239 inventoryService.RegionLoaded(testScene);
159 testScene.AddRegionModule(inventoryService.Name, inventoryService); 240 testScene.AddRegionModule(inventoryService.Name, inventoryService);
160 inventoryService.PostInitialise(); 241 m_inventoryService = inventoryService;
161
162 testScene.SetModuleInterfaces();
163
164 testScene.LandChannel = new TestLandChannel();
165 testScene.LoadWorldMap();
166
167 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
168 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
169 testScene.PhysicsScene
170 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test");
171
172 return testScene;
173 } 242 }
174 243
175 /// <summary> 244 /// <summary>
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
index fc41166..f146a15 100644
--- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
@@ -41,28 +41,58 @@ namespace OpenSim.Tests.Common.Setup
41 /// Create a test user with a standard inventory 41 /// Create a test user with a standard inventory
42 /// </summary> 42 /// </summary>
43 /// <param name="commsManager"></param> 43 /// <param name="commsManager"></param>
44 /// <param name="callback">
45 /// Callback to invoke when inventory has been loaded. This is required because
46 /// loading may be asynchronous, even on standalone
47 /// </param>
44 /// <returns></returns> 48 /// <returns></returns>
45 public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager) 49 public static CachedUserInfo CreateUserWithInventory(
50 CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
46 { 51 {
47 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); 52 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
48 return CreateUserWithInventory(commsManager, userId); 53 return CreateUserWithInventory(commsManager, userId, callback);
49 } 54 }
50 55
51 /// <summary> 56 /// <summary>
52 /// Create a test user with a standard inventory 57 /// Create a test user with a standard inventory
53 /// </summary> 58 /// </summary>
54 /// <param name="commsManager"></param> 59 /// <param name="commsManager"></param>
55 /// <param name="userId">Explicit user id to use for user creation</param> 60 /// <param name="userId">User ID</param>
61 /// <param name="callback">
62 /// Callback to invoke when inventory has been loaded. This is required because
63 /// loading may be asynchronous, even on standalone
64 /// </param>
56 /// <returns></returns> 65 /// <returns></returns>
57 public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId) 66 public static CachedUserInfo CreateUserWithInventory(
67 CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
68 {
69 return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
70 }
71
72 /// <summary>
73 /// Create a test user with a standard inventory
74 /// </summary>
75 /// <param name="commsManager"></param>
76 /// <param name="firstName">First name of user</param>
77 /// <param name="lastName">Last name of user</param>
78 /// <param name="userId">User ID</param>
79 /// <param name="callback">
80 /// Callback to invoke when inventory has been loaded. This is required because
81 /// loading may be asynchronous, even on standalone
82 /// </param>
83 /// <returns></returns>
84 public static CachedUserInfo CreateUserWithInventory(
85 CommunicationsManager commsManager, string firstName, string lastName,
86 UUID userId, OnInventoryReceivedDelegate callback)
58 { 87 {
59 LocalUserServices lus = (LocalUserServices)commsManager.UserService; 88 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
60 lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); 89 lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
61 90
62 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); 91 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
92 userInfo.OnInventoryReceived += callback;
63 userInfo.FetchInventory(); 93 userInfo.FetchInventory();
64 94
65 return userInfo; 95 return userInfo;
66 } 96 }
67 } 97 }
68} 98}