aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
authorMelanie2009-10-02 08:23:38 +0100
committerMelanie2009-10-02 08:23:38 +0100
commit31d8cec0f8cd47ff445edc7771e5e73825a57927 (patch)
treea2d60604317739fa530502c40ffc71bab2a5c494 /OpenSim/Tests
parentRestore the missing image handling to the image manager. The missing (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.zip
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.gz
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.bz2
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.xz
Merge branch 'master' into diva-textures
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Clients/Grid/GridClient.cs204
-rw-r--r--OpenSim/Tests/Clients/Grid/GridForm.html11
-rw-r--r--OpenSim/Tests/Common/LongRunningAttribute.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs4
-rw-r--r--OpenSim/Tests/Common/Mock/TestAssetService.cs4
-rw-r--r--OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs4
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs6
-rw-r--r--OpenSim/Tests/Common/Mock/TestLandChannel.cs4
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs6
-rw-r--r--OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs76
-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
13 files changed, 345 insertions, 27 deletions
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs
new file mode 100644
index 0000000..8798c5e
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridClient.cs
@@ -0,0 +1,204 @@
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.Text;
31using System.Reflection;
32
33using OpenMetaverse;
34using log4net;
35using log4net.Appender;
36using log4net.Layout;
37
38using OpenSim.Framework;
39using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Connectors;
42
43namespace OpenSim.Tests.Clients.GridClient
44{
45 public class GridClient
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 public static void Main(string[] args)
52 {
53 ConsoleAppender consoleAppender = new ConsoleAppender();
54 consoleAppender.Layout =
55 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
56 log4net.Config.BasicConfigurator.Configure(consoleAppender);
57
58 string serverURI = "http://127.0.0.1:8001";
59 GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
60
61 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
62 GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000);
63 GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
64
65 Console.WriteLine("[GRID CLIENT]: *** Registering region 1");
66 bool success = m_Connector.RegisterRegion(UUID.Zero, r1);
67 if (success)
68 Console.WriteLine("[GRID CLIENT]: Successfully registered region 1");
69 else
70 Console.WriteLine("[GRID CLIENT]: region 1 failed to register");
71
72 Console.WriteLine("[GRID CLIENT]: *** Registering region 2");
73 success = m_Connector.RegisterRegion(UUID.Zero, r2);
74 if (success)
75 Console.WriteLine("[GRID CLIENT]: Successfully registered region 2");
76 else
77 Console.WriteLine("[GRID CLIENT]: region 2 failed to register");
78
79 Console.WriteLine("[GRID CLIENT]: *** Registering region 3");
80 success = m_Connector.RegisterRegion(UUID.Zero, r3);
81 if (success)
82 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
83 else
84 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
85
86
87 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
88 success = m_Connector.DeregisterRegion(r3.RegionID);
89 if (success)
90 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
91 else
92 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
93 Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again");
94 success = m_Connector.RegisterRegion(UUID.Zero, r3);
95 if (success)
96 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
97 else
98 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
99
100 Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1");
101 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
102 if (regions == null)
103 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed");
104 else if (regions.Count > 0)
105 {
106 if (regions.Count != 1)
107 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
108 else
109 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
110 }
111 else
112 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
113
114
115 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)");
116 GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
117 if (region == null)
118 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
119 else
120 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
121
122 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)");
123 region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
124 if (region == null)
125 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
126 else
127 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
128
129 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)");
130 region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
131 if (region == null)
132 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
133 else
134 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
135
136 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)");
137 region = m_Connector.GetRegionByName(UUID.Zero, "Foo");
138 if (region == null)
139 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
140 else
141 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
142
143 Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)");
144 regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10);
145 if (regions == null)
146 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null");
147 else
148 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions");
149
150 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)");
151 regions = m_Connector.GetRegionRange(UUID.Zero,
152 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize,
153 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize);
154 if (regions == null)
155 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
156 else
157 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
158 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)");
159 regions = m_Connector.GetRegionRange(UUID.Zero,
160 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize,
161 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize);
162 if (regions == null)
163 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
164 else
165 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
166
167 Console.Write("Proceed to deregister? Press enter...");
168 Console.ReadLine();
169
170 // Deregister them all
171 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1");
172 success = m_Connector.DeregisterRegion(r1.RegionID);
173 if (success)
174 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1");
175 else
176 Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister");
177 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2");
178 success = m_Connector.DeregisterRegion(r2.RegionID);
179 if (success)
180 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2");
181 else
182 Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister");
183 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
184 success = m_Connector.DeregisterRegion(r3.RegionID);
185 if (success)
186 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
187 else
188 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
189
190 }
191
192 private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
193 {
194 GridRegion region = new GridRegion(xcell, ycell);
195 region.RegionName = name;
196 region.RegionID = UUID.Random();
197 region.ExternalHostName = "127.0.0.1";
198 region.HttpPort = 9000;
199 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);
200
201 return region;
202 }
203 }
204}
diff --git a/OpenSim/Tests/Clients/Grid/GridForm.html b/OpenSim/Tests/Clients/Grid/GridForm.html
new file mode 100644
index 0000000..252920f
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridForm.html
@@ -0,0 +1,11 @@
1<html>
2
3<form name="input" action="http://127.0.0.1:8002/grid" method="post">
4xmin:<input type="text" name="XMIN" value="0">
5xmax:<input type="text" name="XMAX" value="0">
6ymin:<input type="text" name="YMIN" value="0">
7ymax:<input type="text" name="YMAX" value="0">
8<input type="hidden" name="METHOD" value="get_region_range">
9<input type="submit" value="Submit" />
10</form>
11</html>
diff --git a/OpenSim/Tests/Common/LongRunningAttribute.cs b/OpenSim/Tests/Common/LongRunningAttribute.cs
index 37cbbcd..9831ea8 100644
--- a/OpenSim/Tests/Common/LongRunningAttribute.cs
+++ b/OpenSim/Tests/Common/LongRunningAttribute.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Tests.Common
43 } 43 }
44 44
45 protected LongRunningAttribute(string category) : base(category) 45 protected LongRunningAttribute(string category) : base(category)
46 { 46 {
47 } 47 }
48 } 48 }
49} 49}
diff --git a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
index 3981fe9..20ea18f 100644
--- a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Tests.Common.Mock
39 /// tests are single threaded. 39 /// tests are single threaded.
40 /// </summary> 40 /// </summary>
41 public class TestAssetDataPlugin : BaseAssetRepository, IAssetDataPlugin 41 public class TestAssetDataPlugin : BaseAssetRepository, IAssetDataPlugin
42 { 42 {
43 public string Version { get { return "0"; } } 43 public string Version { get { return "0"; } }
44 public string Name { get { return "TestAssetDataPlugin"; } } 44 public string Name { get { return "TestAssetDataPlugin"; } }
45 45
@@ -59,6 +59,6 @@ namespace OpenSim.Tests.Common.Mock
59 assets.Add(asset); 59 assets.Add(asset);
60 } 60 }
61 61
62 public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); } 62 public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); }
63 } 63 }
64} \ No newline at end of file 64} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/TestAssetService.cs
index 81f123a..317ec06 100644
--- a/OpenSim/Tests/Common/Mock/TestAssetService.cs
+++ b/OpenSim/Tests/Common/Mock/TestAssetService.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Tests.Common.Mock
49 if (Assets.ContainsKey(id)) 49 if (Assets.ContainsKey(id))
50 asset = Assets[id]; 50 asset = Assets[id];
51 else 51 else
52 asset = null; 52 asset = null;
53 53
54 return asset; 54 return asset;
55 } 55 }
@@ -65,7 +65,7 @@ namespace OpenSim.Tests.Common.Mock
65 } 65 }
66 66
67 public bool Get(string id, object sender, AssetRetrieved handler) 67 public bool Get(string id, object sender, AssetRetrieved handler)
68 { 68 {
69 handler(id, sender, Get(id)); 69 handler(id, sender, Get(id));
70 70
71 return true; 71 return true;
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
index 4313c96..013462e 100644
--- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
+++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Tests.Common.Mock
56 56
57 public TestCommunicationsManager(NetworkServersInfo serversInfo) 57 public TestCommunicationsManager(NetworkServersInfo serversInfo)
58 : base(serversInfo, null) 58 : base(serversInfo, null)
59 { 59 {
60 60
61 LocalUserServices lus = new LocalUserServices(991, 992, this); 61 LocalUserServices lus = new LocalUserServices(991, 992, this);
62 lus.AddPlugin(new TemporaryUserProfilePlugin()); 62 lus.AddPlugin(new TemporaryUserProfilePlugin());
@@ -65,8 +65,6 @@ namespace OpenSim.Tests.Common.Mock
65 m_userService = lus; 65 m_userService = lus;
66 m_userAdminService = lus; 66 m_userAdminService = lus;
67 67
68 LocalBackEndServices gs = new LocalBackEndServices();
69 m_gridService = gs;
70 } 68 }
71 } 69 }
72} 70}
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
index daef38b..0c7ebca 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Tests.Common.Mock
52 //// <value> 52 //// <value>
53 /// Inventory items 53 /// Inventory items
54 /// </value> 54 /// </value>
55 private Dictionary<UUID, InventoryItemBase> m_items = new Dictionary<UUID, InventoryItemBase>(); 55 private Dictionary<UUID, InventoryItemBase> m_items = new Dictionary<UUID, InventoryItemBase>();
56 56
57 /// <value> 57 /// <value>
58 /// User root folders 58 /// User root folders
@@ -120,7 +120,7 @@ namespace OpenSim.Tests.Common.Mock
120 } 120 }
121 121
122 return folders; 122 return folders;
123 } 123 }
124 124
125 public InventoryFolderBase getInventoryFolder(UUID folderId) 125 public InventoryFolderBase getInventoryFolder(UUID folderId)
126 { 126 {
@@ -191,7 +191,7 @@ namespace OpenSim.Tests.Common.Mock
191 public InventoryItemBase queryInventoryItem(UUID item) 191 public InventoryItemBase queryInventoryItem(UUID item)
192 { 192 {
193 return null; 193 return null;
194 } 194 }
195 195
196 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) { return null; } 196 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) { return null; }
197 } 197 }
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
index f7eda68..01b5203 100644
--- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs
+++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
@@ -31,7 +31,7 @@ using OpenSim.Framework;
31using OpenSim.Region.Framework.Interfaces; 31using OpenSim.Region.Framework.Interfaces;
32 32
33namespace OpenSim.Tests.Common.Mock 33namespace OpenSim.Tests.Common.Mock
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// Land channel for test purposes 36 /// Land channel for test purposes
37 /// </summary> 37 /// </summary>
@@ -40,7 +40,7 @@ namespace OpenSim.Tests.Common.Mock
40 public List<ILandObject> ParcelsNearPoint(Vector3 position) { return null; } 40 public List<ILandObject> ParcelsNearPoint(Vector3 position) { return null; }
41 public List<ILandObject> AllParcels() { return null; } 41 public List<ILandObject> AllParcels() { return null; }
42 public ILandObject GetLandObject(int x, int y) { return null; } 42 public ILandObject GetLandObject(int x, int y) { return null; }
43 public ILandObject GetLandObject(int localID) { return null; } 43 public ILandObject GetLandObject(int localID) { return null; }
44 public ILandObject GetLandObject(float x, float y) { return null; } 44 public ILandObject GetLandObject(float x, float y) { return null; }
45 public bool IsLandPrimCountTainted() { return false; } 45 public bool IsLandPrimCountTainted() { return false; }
46 public bool IsForcefulBansAllowed() { return false; } 46 public bool IsForcefulBansAllowed() { return false; }
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index 3fc22ba..22cfa2c 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -35,9 +35,9 @@ using OpenSim.Region.Framework;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36 36
37namespace OpenSim.Tests.Common.Mock 37namespace OpenSim.Tests.Common.Mock
38{ 38{
39 public class TestScene : Scene 39 public class TestScene : Scene
40 { 40 {
41 public TestScene( 41 public TestScene(
42 RegionInfo regInfo, AgentCircuitManager authen, 42 RegionInfo regInfo, AgentCircuitManager authen,
43 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, StorageManager storeManager, 43 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, StorageManager storeManager,
@@ -60,7 +60,7 @@ namespace OpenSim.Tests.Common.Mock
60 { 60 {
61 reason = String.Empty; 61 reason = String.Empty;
62 return true; 62 return true;
63 } 63 }
64 64
65 public AsyncSceneObjectGroupDeleter SceneObjectGroupDeleter 65 public AsyncSceneObjectGroupDeleter SceneObjectGroupDeleter
66 { 66 {
diff --git a/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
new file mode 100644
index 0000000..eaf8b39
--- /dev/null
+++ b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
@@ -0,0 +1,76 @@
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.Text;
31using NUnit.Framework;
32using OpenSim.Framework;
33using OpenSim.Framework.Servers;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Tests.Common.Mock;
36
37namespace OpenSim.Tests.Common.Setup
38{
39 public class BaseRequestHandlerTestHelper
40 {
41 private static string[] m_emptyStringArray = new string[] { };
42
43 public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath)
44 {
45 Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path.");
46 Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path.");
47 Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url.");
48 Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl.");
49
50 Assert.AreEqual(String.Empty, handler.GetParam(assetsPath));
51 Assert.AreEqual("/", handler.GetParam(assetsPath + "/"));
52 Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a"));
53 Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/"));
54 Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d"));
55 Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/"));
56 }
57
58 public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath)
59 {
60 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null.");
61 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path.");
62 Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url.");
63
64 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params.");
65 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash.");
66
67 Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment.");
68 Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash.");
69 Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment.");
70 Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash.");
71 }
72
73 public static byte[] EmptyByteArray = new byte[] {};
74
75 }
76}
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}