aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Setup
diff options
context:
space:
mode:
authorJohn Hurliman2009-09-30 15:28:23 -0700
committerJohn Hurliman2009-09-30 15:28:23 -0700
commitacfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009 (patch)
tree305349e1bd0a5849fd7f96483e24d5e07b24b8f4 /OpenSim/Tests/Common/Setup
parent* Adding Scale to EntityBase * Fixing the incorrect initialization of EntityB... (diff)
parentFormatting cleanup. (diff)
downloadopensim-SC-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.zip
opensim-SC-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.gz
opensim-SC-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.bz2
opensim-SC-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Tests/Common/Setup')
-rw-r--r--OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs12
-rw-r--r--OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs122
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs29
-rw-r--r--OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs8
-rw-r--r--OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs14
5 files changed, 41 insertions, 144 deletions
diff --git a/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
index e858371..eaf8b39 100644
--- a/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
+++ b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
@@ -72,15 +72,5 @@ namespace OpenSim.Tests.Common.Setup
72 72
73 public static byte[] EmptyByteArray = new byte[] {}; 73 public static byte[] EmptyByteArray = new byte[] {};
74 74
75 public static void BaseTestHandleNoParams(BaseGetAssetStreamHandler handler, string assetsPath)
76 {
77 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath, null, null, null), "Failed on empty params.");
78 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/", null, null, null), "Failed on single slash.");
79 }
80
81 public static void BaseTestHandleMalformedGuid(BaseGetAssetStreamHandler handler, string assetsPath)
82 {
83 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/badGuid", null, null, null), "Failed on bad guid.");
84 }
85 } 75 }
86} \ No newline at end of file 76}
diff --git a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs
deleted file mode 100644
index ffa7283..0000000
--- a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Text;
33using System.Xml;
34using System.Xml.Serialization;
35using NUnit.Framework;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Server.Base;
41using OpenSim.Tests.Common.Mock;
42
43namespace OpenSim.Tests.Common.Setup
44{
45 public class GetAssetStreamHandlerTestHelpers
46 {
47 private const string EXPECTED_CONTENT_TYPE = "application/x-metaverse-callingcard";
48
49 public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
50 {
51 byte[] expected = BaseGetAssetStreamHandler.GetXml(asset);
52
53 byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response);
54
55 Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash.");
56 Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash.");
57 // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
58
59 actual = handler.Handle("/assets/" + asset.ID + "/", null, null, response);
60 Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with trailing slash.");
61 Assert.AreEqual(expected, actual, "Failed on fetching xml with trailing slash.");
62 // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
63
64 actual = handler.Handle("/assets/" + asset.ID + "/badData", null, null, response);
65 Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with bad trailing data.");
66 Assert.AreEqual(expected, actual, "Failed on fetching xml with bad trailing trailing slash.");
67 // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
68 }
69
70 public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
71 {
72 Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash.");
73 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
74 Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");
75
76 Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash.");
77 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
78 Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
79 }
80
81 public static void BaseFetchExistingAssetMetaDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
82 {
83 XmlSerializer xs = new XmlSerializer(typeof(AssetMetadata));
84
85 byte[] expected = ServerUtils.SerializeResult(xs, asset.Metadata);
86
87 Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata", null, null, response), "Failed on fetching data without trailing slash.");
88 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
89 Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");
90
91 Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata/", null, null, response), "Failed on fetching data with trailing slash.");
92 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
93 Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
94 }
95
96 public static AssetBase CreateCommonTestResources(out OSHttpResponse response)
97 {
98 AssetBase asset = CreateTestAsset();
99 response = new TestOSHttpResponse();
100 return asset;
101 }
102
103 public static AssetBase CreateTestAsset()
104 {
105 byte[] expected = new byte[] { 1,2,3 };
106 AssetBase asset = new AssetBase();
107 asset.ID = Guid.NewGuid().ToString();
108 asset.Data = expected;
109 asset.Type = 2;
110
111 return asset;
112 }
113
114 public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler, OSHttpResponse response)
115 {
116 Assert.AreEqual(
117 BaseRequestHandlerTestHelper.EmptyByteArray,
118 handler.Handle("/assets/" + Guid.NewGuid(), null, null, response), "Failed on bad guid.");
119 Assert.AreEqual((int)HttpStatusCode.NotFound, response.StatusCode, "Response code wrong in BaseFetchMissingAsset");
120 }
121 }
122}
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index 0d8baad..53f24d9 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -44,6 +44,7 @@ using OpenSim.Region.CoreModules.Agent.Capabilities;
44using OpenSim.Region.CoreModules.Avatar.Gods; 44using OpenSim.Region.CoreModules.Avatar.Gods;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; 45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset;
46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; 46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
47using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
47using OpenSim.Services.Interfaces; 48using OpenSim.Services.Interfaces;
48using OpenSim.Tests.Common.Mock; 49using OpenSim.Tests.Common.Mock;
49 50
@@ -58,6 +59,7 @@ namespace OpenSim.Tests.Common.Setup
58 // CommunicationsManager. 59 // CommunicationsManager.
59 private static ISharedRegionModule m_assetService = null; 60 private static ISharedRegionModule m_assetService = null;
60 private static ISharedRegionModule m_inventoryService = null; 61 private static ISharedRegionModule m_inventoryService = null;
62 private static ISharedRegionModule m_gridService = null;
61 private static TestCommunicationsManager commsManager = null; 63 private static TestCommunicationsManager commsManager = null;
62 64
63 /// <summary> 65 /// <summary>
@@ -110,6 +112,7 @@ namespace OpenSim.Tests.Common.Setup
110 return SetupScene(name, id, x, y, cm, ""); 112 return SetupScene(name, id, x, y, cm, "");
111 } 113 }
112 114
115
113 /// <summary> 116 /// <summary>
114 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions 117 /// 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. 118 /// or a different, to get a brand new scene with new shared region modules.
@@ -176,6 +179,9 @@ namespace OpenSim.Tests.Common.Setup
176 StartInventoryService(testScene, true); 179 StartInventoryService(testScene, true);
177 else 180 else
178 StartInventoryService(testScene, false); 181 StartInventoryService(testScene, false);
182 if (realServices.Contains("grid"))
183 StartGridService(testScene, true);
184
179 } 185 }
180 // If not, make sure the shared module gets references to this new scene 186 // If not, make sure the shared module gets references to this new scene
181 else 187 else
@@ -241,6 +247,29 @@ namespace OpenSim.Tests.Common.Setup
241 m_inventoryService = inventoryService; 247 m_inventoryService = inventoryService;
242 } 248 }
243 249
250 private static void StartGridService(Scene testScene, bool real)
251 {
252 IConfigSource config = new IniConfigSource();
253 config.AddConfig("Modules");
254 config.AddConfig("GridService");
255 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
256 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
257 if (real)
258 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
259 if (m_gridService == null)
260 {
261 ISharedRegionModule gridService = new LocalGridServicesConnector();
262 gridService.Initialise(config);
263 m_gridService = gridService;
264 }
265 //else
266 // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService");
267 m_gridService.AddRegion(testScene);
268 m_gridService.RegionLoaded(testScene);
269 //testScene.AddRegionModule(m_gridService.Name, m_gridService);
270 }
271
272
244 /// <summary> 273 /// <summary>
245 /// Setup modules for a scene using their default settings. 274 /// Setup modules for a scene using their default settings.
246 /// </summary> 275 /// </summary>
diff --git a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
index 3528072..7e0c567 100644
--- a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
@@ -31,10 +31,10 @@ using OpenSim.Framework;
31using OpenSim.Services.Interfaces; 31using OpenSim.Services.Interfaces;
32 32
33namespace OpenSim.Tests.Common 33namespace OpenSim.Tests.Common
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// Utility functions for carrying out user inventory related tests. 36 /// Utility functions for carrying out user inventory related tests.
37 /// </summary> 37 /// </summary>
38 public static class UserInventoryTestUtils 38 public static class UserInventoryTestUtils
39 { 39 {
40 public static readonly string PATH_DELIMITER = "/"; 40 public static readonly string PATH_DELIMITER = "/";
@@ -78,7 +78,7 @@ namespace OpenSim.Tests.Common
78 /// </param> 78 /// </param>
79 /// <returns> 79 /// <returns>
80 /// The folder created. If the path contains multiple folders then the last one created is returned. 80 /// The folder created. If the path contains multiple folders then the last one created is returned.
81 /// </returns> 81 /// </returns>
82 public static InventoryFolderBase CreateInventoryFolder( 82 public static InventoryFolderBase CreateInventoryFolder(
83 IInventoryService inventoryService, InventoryFolderBase parentFolder, string path) 83 IInventoryService inventoryService, InventoryFolderBase parentFolder, string path)
84 { 84 {
@@ -91,7 +91,7 @@ namespace OpenSim.Tests.Common
91 if (components.Length > 1) 91 if (components.Length > 1)
92 return CreateInventoryFolder(inventoryService, newFolder, components[1]); 92 return CreateInventoryFolder(inventoryService, newFolder, components[1]);
93 else 93 else
94 return newFolder; 94 return newFolder;
95 } 95 }
96 } 96 }
97} \ No newline at end of file 97} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
index 4ad9926..3ca44a1 100644
--- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
@@ -31,12 +31,12 @@ using OpenSim.Framework.Communications.Cache;
31using OpenSim.Region.Communications.Local; 31using OpenSim.Region.Communications.Local;
32 32
33namespace OpenSim.Tests.Common.Setup 33namespace OpenSim.Tests.Common.Setup
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// Utility functions for carrying out user profile related tests. 36 /// Utility functions for carrying out user profile related tests.
37 /// </summary> 37 /// </summary>
38 public static class UserProfileTestUtils 38 public static class UserProfileTestUtils
39 { 39 {
40 /// <summary> 40 /// <summary>
41 /// Create a test user with a standard inventory 41 /// Create a test user with a standard inventory
42 /// </summary> 42 /// </summary>
@@ -51,7 +51,7 @@ namespace OpenSim.Tests.Common.Setup
51 { 51 {
52 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); 52 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
53 return CreateUserWithInventory(commsManager, userId, callback); 53 return CreateUserWithInventory(commsManager, userId, callback);
54 } 54 }
55 55
56 /// <summary> 56 /// <summary>
57 /// Create a test user with a standard inventory 57 /// Create a test user with a standard inventory
@@ -65,7 +65,7 @@ namespace OpenSim.Tests.Common.Setup
65 /// <returns></returns> 65 /// <returns></returns>
66 public static CachedUserInfo CreateUserWithInventory( 66 public static CachedUserInfo CreateUserWithInventory(
67 CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) 67 CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
68 { 68 {
69 return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); 69 return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
70 } 70 }
71 71
@@ -84,8 +84,8 @@ namespace OpenSim.Tests.Common.Setup
84 public static CachedUserInfo CreateUserWithInventory( 84 public static CachedUserInfo CreateUserWithInventory(
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 LocalUserServices lus = (LocalUserServices)commsManager.UserService; 88 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
89 lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); 89 lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
90 90
91 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); 91 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
@@ -93,6 +93,6 @@ namespace OpenSim.Tests.Common.Setup
93 userInfo.FetchInventory(); 93 userInfo.FetchInventory();
94 94
95 return userInfo; 95 return userInfo;
96 } 96 }
97 } 97 }
98} 98}