diff options
author | Justin Clarke Casey | 2009-01-05 18:00:53 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-01-05 18:00:53 +0000 |
commit | 0b07c9762b4c70b6d234b70fb9e591c770dc1bf1 (patch) | |
tree | 95435e1c5c8aece7224666cae400978b74fae931 | |
parent | * Extend stub to test the successful login of a user on the local login service (diff) | |
download | opensim-SC-0b07c9762b4c70b6d234b70fb9e591c770dc1bf1.zip opensim-SC-0b07c9762b4c70b6d234b70fb9e591c770dc1bf1.tar.gz opensim-SC-0b07c9762b4c70b6d234b70fb9e591c770dc1bf1.tar.bz2 opensim-SC-0b07c9762b4c70b6d234b70fb9e591c770dc1bf1.tar.xz |
* Simplify test code by always setting up mock 'in memory' user and inventory data plugins for every TestCommunicationsManager
* imo the gain in simplcity of test code outweighs the very small cost of setting up some stuff that some tests will never use
5 files changed, 42 insertions, 57 deletions
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 807afcc..44a28a2 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
52 | UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 52 | UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
53 | UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); | 53 | UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); |
54 | 54 | ||
55 | CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); | 55 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
56 | CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); | 56 | CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); |
57 | 57 | ||
58 | Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); | 58 | Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); |
@@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
68 | [Test] | 68 | [Test] |
69 | public void TestRequestInventoryForUser() | 69 | public void TestRequestInventoryForUser() |
70 | { | 70 | { |
71 | CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); | 71 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
72 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 72 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
73 | 73 | ||
74 | Assert.That(userInfo.HasReceivedInventory, Is.True); | 74 | Assert.That(userInfo.HasReceivedInventory, Is.True); |
@@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
80 | [Test] | 80 | [Test] |
81 | public void TestGetChildFolder() | 81 | public void TestGetChildFolder() |
82 | { | 82 | { |
83 | CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); | 83 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
84 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 84 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
85 | 85 | ||
86 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); | 86 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); |
@@ -96,12 +96,12 @@ namespace OpenSim.Framework.Communications.Tests | |||
96 | /// </summary> | 96 | /// </summary> |
97 | [Test] | 97 | [Test] |
98 | public void TestCreateFolder() | 98 | public void TestCreateFolder() |
99 | { | 99 | { |
100 | IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); | 100 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
101 | IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); | 101 | |
102 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
103 | IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; | ||
102 | 104 | ||
103 | CommunicationsManager commsManager | ||
104 | = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); | ||
105 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 105 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
106 | 106 | ||
107 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); | 107 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); |
@@ -129,11 +129,11 @@ namespace OpenSim.Framework.Communications.Tests | |||
129 | [Test] | 129 | [Test] |
130 | public void TestUpdateFolder() | 130 | public void TestUpdateFolder() |
131 | { | 131 | { |
132 | IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); | 132 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
133 | IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); | 133 | |
134 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
135 | IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; | ||
134 | 136 | ||
135 | CommunicationsManager commsManager | ||
136 | = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); | ||
137 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 137 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
138 | 138 | ||
139 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 139 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
@@ -188,11 +188,11 @@ namespace OpenSim.Framework.Communications.Tests | |||
188 | [Test] | 188 | [Test] |
189 | public void TestMoveFolder() | 189 | public void TestMoveFolder() |
190 | { | 190 | { |
191 | IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); | 191 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
192 | IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); | 192 | |
193 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
194 | IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; | ||
193 | 195 | ||
194 | CommunicationsManager commsManager | ||
195 | = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); | ||
196 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 196 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
197 | 197 | ||
198 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 198 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
@@ -226,11 +226,11 @@ namespace OpenSim.Framework.Communications.Tests | |||
226 | { | 226 | { |
227 | //log4net.Config.XmlConfigurator.Configure(); | 227 | //log4net.Config.XmlConfigurator.Configure(); |
228 | 228 | ||
229 | IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); | 229 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
230 | IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); | 230 | |
231 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
232 | IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; | ||
231 | 233 | ||
232 | CommunicationsManager commsManager | ||
233 | = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); | ||
234 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 234 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
235 | 235 | ||
236 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); | 236 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); |
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs index ea209fd..cf07ae5 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs | |||
@@ -37,33 +37,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
37 | /// Utility functions for carrying out user profile relate tests. | 37 | /// Utility functions for carrying out user profile relate tests. |
38 | /// </summary> | 38 | /// </summary> |
39 | public class UserProfileTestUtils | 39 | public class UserProfileTestUtils |
40 | { | 40 | { |
41 | /// <summary> | ||
42 | /// Set up standard services required for user tests. | ||
43 | /// </summary> | ||
44 | /// <returns>CommunicationsManager used to access these services</returns> | ||
45 | public static CommunicationsManager SetupServices() | ||
46 | { | ||
47 | return SetupServices(new TestUserDataPlugin(), new TestInventoryDataPlugin()); | ||
48 | } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Set up standard services required for user tests. | ||
52 | /// </summary> | ||
53 | /// <param name="userDataPlugin"></param> | ||
54 | /// <param name="inventoryDataPlugin"></param> | ||
55 | /// <returns>CommunicationsManager used to access these services</returns> | ||
56 | public static CommunicationsManager SetupServices( | ||
57 | IUserDataPlugin userDataPlugin, IInventoryDataPlugin inventoryDataPlugin) | ||
58 | { | ||
59 | CommunicationsManager commsManager = new TestCommunicationsManager(); | ||
60 | |||
61 | ((LocalUserServices)commsManager.UserService).AddPlugin(userDataPlugin); | ||
62 | ((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin); | ||
63 | |||
64 | return commsManager; | ||
65 | } | ||
66 | |||
67 | /// <summary> | 41 | /// <summary> |
68 | /// Create a test user with a standard inventory | 42 | /// Create a test user with a standard inventory |
69 | /// </summary> | 43 | /// </summary> |
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 51adba1..1e1fa73 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
50 | [Test] | 50 | [Test] |
51 | public void TestNormalLoginResponse() | 51 | public void TestNormalLoginResponse() |
52 | { | 52 | { |
53 | log4net.Config.XmlConfigurator.Configure(); | 53 | //log4net.Config.XmlConfigurator.Configure(); |
54 | 54 | ||
55 | string firstName = "Timmy"; | 55 | string firstName = "Timmy"; |
56 | string lastName = "Mallet"; | 56 | string lastName = "Mallet"; |
@@ -58,9 +58,6 @@ namespace OpenSim.Framework.Communications.Tests | |||
58 | CommunicationsManager commsManager | 58 | CommunicationsManager commsManager |
59 | = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); | 59 | = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); |
60 | 60 | ||
61 | ((LocalUserServices)commsManager.UserService).AddPlugin(new TestUserDataPlugin()); | ||
62 | ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); | ||
63 | |||
64 | commsManager.GridService.RegisterRegion( | 61 | commsManager.GridService.RegisterRegion( |
65 | new RegionInfo(42, 43, new IPEndPoint(IPAddress.Loopback, 9000), "localhost")); | 62 | new RegionInfo(42, 43, new IPEndPoint(IPAddress.Loopback, 9000), "localhost")); |
66 | commsManager.GridService.RegionLoginsEnabled = true; | 63 | commsManager.GridService.RegionLoginsEnabled = true; |
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs index e6648e1..e347e67 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs | |||
@@ -313,9 +313,6 @@ namespace OpenSim.Region.Environment.Scenes.Tests | |||
313 | TestScene scene = SceneTestUtils.SetupScene(); | 313 | TestScene scene = SceneTestUtils.SetupScene(); |
314 | SceneObjectPart part = SceneTestUtils.AddSceneObject(scene, myObjectName); | 314 | SceneObjectPart part = SceneTestUtils.AddSceneObject(scene, myObjectName); |
315 | 315 | ||
316 | ((LocalUserServices)scene.CommsManager.UserService).AddPlugin(new TestUserDataPlugin()); | ||
317 | ((LocalInventoryService)scene.CommsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); | ||
318 | |||
319 | Assert.That( | 316 | Assert.That( |
320 | scene.CommsManager.UserAdminService.AddUser( | 317 | scene.CommsManager.UserAdminService.AddUser( |
321 | "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), | 318 | "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), |
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs index 204ebd7..c234429 100644 --- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs +++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs | |||
@@ -35,6 +35,18 @@ namespace OpenSim.Tests.Common.Mock | |||
35 | { | 35 | { |
36 | public class TestCommunicationsManager : CommunicationsManager | 36 | public class TestCommunicationsManager : CommunicationsManager |
37 | { | 37 | { |
38 | public IUserDataPlugin UserDataPlugin | ||
39 | { | ||
40 | get { return m_userDataPlugin; } | ||
41 | } | ||
42 | private IUserDataPlugin m_userDataPlugin; | ||
43 | |||
44 | public IInventoryDataPlugin InventoryDataPlugin | ||
45 | { | ||
46 | get { return m_inventoryDataPlugin; } | ||
47 | } | ||
48 | private IInventoryDataPlugin m_inventoryDataPlugin; | ||
49 | |||
38 | public TestCommunicationsManager() | 50 | public TestCommunicationsManager() |
39 | : this(null) | 51 | : this(null) |
40 | { | 52 | { |
@@ -43,16 +55,21 @@ namespace OpenSim.Tests.Common.Mock | |||
43 | public TestCommunicationsManager(NetworkServersInfo serversInfo) | 55 | public TestCommunicationsManager(NetworkServersInfo serversInfo) |
44 | : base(serversInfo, null, null, false, null) | 56 | : base(serversInfo, null, null, false, null) |
45 | { | 57 | { |
58 | m_userDataPlugin = new TestUserDataPlugin(); | ||
59 | m_inventoryDataPlugin = new TestInventoryDataPlugin(); | ||
60 | |||
46 | LocalInventoryService lis = new LocalInventoryService(); | 61 | LocalInventoryService lis = new LocalInventoryService(); |
62 | lis.AddPlugin(m_inventoryDataPlugin); | ||
47 | m_interServiceInventoryService = lis; | 63 | m_interServiceInventoryService = lis; |
48 | AddInventoryService(lis); | 64 | AddInventoryService(lis); |
49 | 65 | ||
50 | LocalUserServices lus = new LocalUserServices(991, 992, lis); | 66 | LocalUserServices lus = new LocalUserServices(991, 992, lis); |
67 | lus.AddPlugin(m_userDataPlugin); | ||
51 | m_userService = lus; | 68 | m_userService = lus; |
52 | m_userAdminService = lus; | 69 | m_userAdminService = lus; |
53 | 70 | ||
54 | LocalBackEndServices gs = new LocalBackEndServices(); | 71 | LocalBackEndServices gs = new LocalBackEndServices(); |
55 | m_gridService = gs; | 72 | m_gridService = gs; |
56 | } | 73 | } |
57 | } | 74 | } |
58 | } | 75 | } |