aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Clients/Assets/AssetsClient.cs126
-rw-r--r--OpenSim/Tests/Clients/Grid/GridClient.cs205
-rw-r--r--OpenSim/Tests/Clients/Presence/OpenSim.Server.ini33
-rw-r--r--OpenSim/Tests/Clients/Presence/PresenceClient.cs115
-rw-r--r--OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini33
-rw-r--r--OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs144
-rw-r--r--OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs1
-rw-r--r--OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs95
-rw-r--r--OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs123
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs139
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs121
-rw-r--r--OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs2
-rw-r--r--OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs142
-rw-r--r--OpenSim/Tests/Common/Mock/BaseAssetRepository.cs11
-rw-r--r--OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs178
-rw-r--r--OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs29
-rw-r--r--OpenSim/Tests/Common/Mock/MockScriptEngine.cs272
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs179
-rw-r--r--OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs182
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpClientContext.cs110
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpRequest.cs174
-rw-r--r--OpenSim/Tests/Common/Mock/TestHttpResponse.cs171
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs4
-rw-r--r--OpenSim/Tests/Common/Mock/TestLLUDPServer.cs171
-rw-r--r--OpenSim/Tests/Common/Mock/TestLandChannel.cs7
-rw-r--r--OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs15
-rw-r--r--OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs51
-rw-r--r--OpenSim/Tests/Common/OpenSimTestCase.cs15
-rw-r--r--OpenSim/Tests/Common/TestHelpers.cs38
-rw-r--r--OpenSim/Tests/ConfigurationLoaderTest.cs4
-rw-r--r--OpenSim/Tests/Performance/NPCPerformanceTests.cs7
-rw-r--r--OpenSim/Tests/Performance/ObjectPerformanceTests.cs1
-rw-r--r--OpenSim/Tests/Performance/ScriptPerformanceTests.cs1
-rw-r--r--OpenSim/Tests/Robust/Clients/Grid/GridClient.cs133
-rw-r--r--OpenSim/Tests/Robust/Clients/Grid/GridForm.html (renamed from OpenSim/Tests/Clients/Grid/GridForm.html)0
-rw-r--r--OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs (renamed from OpenSim/Tests/Clients/InstantMessage/IMClient.cs)31
-rw-r--r--OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs206
-rw-r--r--OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs81
-rw-r--r--OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs86
-rw-r--r--OpenSim/Tests/Robust/Server/DemonServer.cs69
-rw-r--r--OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs3
44 files changed, 2727 insertions, 787 deletions
diff --git a/OpenSim/Tests/Clients/Assets/AssetsClient.cs b/OpenSim/Tests/Clients/Assets/AssetsClient.cs
new file mode 100644
index 0000000..e988d0e
--- /dev/null
+++ b/OpenSim/Tests/Clients/Assets/AssetsClient.cs
@@ -0,0 +1,126 @@
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.Net;
31using System.Text;
32using System.Reflection;
33using System.Threading;
34
35using OpenMetaverse;
36using log4net;
37using log4net.Appender;
38using log4net.Layout;
39
40using OpenSim.Framework;
41using OpenSim.Services.Interfaces;
42using OpenSim.Services.Connectors;
43
44namespace OpenSim.Tests.Clients.AssetsClient
45{
46 public class AssetsClient
47 {
48 private static readonly ILog m_log =
49 LogManager.GetLogger(
50 MethodBase.GetCurrentMethod().DeclaringType);
51
52 private static int m_MaxThreadID = 0;
53 private static readonly int NREQS = 150;
54 private static int m_NReceived = 0;
55
56 public static void Main(string[] args)
57 {
58 ConsoleAppender consoleAppender = new ConsoleAppender();
59 consoleAppender.Layout =
60 new PatternLayout("[%thread] - %message%newline");
61 log4net.Config.BasicConfigurator.Configure(consoleAppender);
62
63 string serverURI = "http://127.0.0.1:8003";
64 if (args.Length > 1)
65 serverURI = args[1];
66 int max1, max2;
67 ThreadPool.GetMaxThreads(out max1, out max2);
68 m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} max threads = {1} - {2}", serverURI, max1, max2);
69 ThreadPool.GetMinThreads(out max1, out max2);
70 m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} min threads = {1} - {2}", serverURI, max1, max2);
71
72 if (!ThreadPool.SetMinThreads(1, 1))
73 m_log.WarnFormat("[ASSET CLIENT]: Failed to set min threads");
74
75 if (!ThreadPool.SetMaxThreads(10, 3))
76 m_log.WarnFormat("[ASSET CLIENT]: Failed to set max threads");
77
78 ThreadPool.GetMaxThreads(out max1, out max2);
79 m_log.InfoFormat("[ASSET CLIENT]: Post set max threads = {1} - {2}", serverURI, max1, max2);
80 ThreadPool.GetMinThreads(out max1, out max2);
81 m_log.InfoFormat("[ASSET CLIENT]: Post set min threads = {1} - {2}", serverURI, max1, max2);
82
83 ServicePointManager.DefaultConnectionLimit = 12;
84
85 AssetServicesConnector m_Connector = new AssetServicesConnector(serverURI);
86 m_Connector.MaxAssetRequestConcurrency = 30;
87
88 for (int i = 0; i < NREQS; i++)
89 {
90 UUID uuid = UUID.Random();
91 m_Connector.Get(uuid.ToString(), null, ResponseReceived);
92 m_log.InfoFormat("[ASSET CLIENT]: [{0}] requested asset {1}", i, uuid);
93 }
94
95 for (int i = 0; i < 500; i++)
96 {
97 var x = i;
98 ThreadPool.QueueUserWorkItem(delegate
99 {
100 Dummy(x);
101 });
102 }
103
104 Thread.Sleep(30 * 1000);
105 m_log.InfoFormat("[ASSET CLIENT]: Received responses {0}", m_NReceived);
106 }
107
108 private static void ResponseReceived(string id, Object sender, AssetBase asset)
109 {
110 if (Thread.CurrentThread.ManagedThreadId > m_MaxThreadID)
111 m_MaxThreadID = Thread.CurrentThread.ManagedThreadId;
112 int max1, max2;
113 ThreadPool.GetAvailableThreads(out max1, out max2);
114 m_log.InfoFormat("[ASSET CLIENT]: Received asset {0} ({1}) ({2}-{3}) {4}", id, m_MaxThreadID, max1, max2, DateTime.Now.ToString("hh:mm:ss"));
115 m_NReceived++;
116 }
117
118 private static void Dummy(int i)
119 {
120 int max1, max2;
121 ThreadPool.GetAvailableThreads(out max1, out max2);
122 m_log.InfoFormat("[ASSET CLIENT]: ({0}) Hello! {1} - {2} {3}", i, max1, max2, DateTime.Now.ToString("hh:mm:ss"));
123 Thread.Sleep(2000);
124 }
125 }
126}
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs
deleted file mode 100644
index 8e33373..0000000
--- a/OpenSim/Tests/Clients/Grid/GridClient.cs
+++ /dev/null
@@ -1,205 +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.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 string msg = m_Connector.RegisterRegion(UUID.Zero, r1);
67 if (msg == String.Empty)
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 msg = m_Connector.RegisterRegion(UUID.Zero, r2);
74 if (msg == String.Empty)
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 msg = m_Connector.RegisterRegion(UUID.Zero, r3);
81 if (msg == String.Empty)
82 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
83 else
84 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
85
86
87 bool success;
88 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
89 success = m_Connector.DeregisterRegion(r3.RegionID);
90 if (success)
91 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
92 else
93 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
94 Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again");
95 msg = m_Connector.RegisterRegion(UUID.Zero, r3);
96 if (msg == String.Empty)
97 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
98 else
99 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
100
101 Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1");
102 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
103 if (regions == null)
104 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed");
105 else if (regions.Count > 0)
106 {
107 if (regions.Count != 1)
108 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
109 else
110 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
111 }
112 else
113 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
114
115
116 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)");
117 GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
118 if (region == null)
119 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
120 else
121 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
122
123 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)");
124 region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
125 if (region == null)
126 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
127 else
128 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
129
130 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)");
131 region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
132 if (region == null)
133 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
134 else
135 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
136
137 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)");
138 region = m_Connector.GetRegionByName(UUID.Zero, "Foo");
139 if (region == null)
140 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
141 else
142 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
143
144 Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)");
145 regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10);
146 if (regions == null)
147 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null");
148 else
149 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions");
150
151 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)");
152 regions = m_Connector.GetRegionRange(UUID.Zero,
153 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize,
154 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize);
155 if (regions == null)
156 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
157 else
158 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
159 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)");
160 regions = m_Connector.GetRegionRange(UUID.Zero,
161 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize,
162 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize);
163 if (regions == null)
164 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
165 else
166 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
167
168 Console.Write("Proceed to deregister? Press enter...");
169 Console.ReadLine();
170
171 // Deregister them all
172 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1");
173 success = m_Connector.DeregisterRegion(r1.RegionID);
174 if (success)
175 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1");
176 else
177 Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister");
178 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2");
179 success = m_Connector.DeregisterRegion(r2.RegionID);
180 if (success)
181 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2");
182 else
183 Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister");
184 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
185 success = m_Connector.DeregisterRegion(r3.RegionID);
186 if (success)
187 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
188 else
189 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
190
191 }
192
193 private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
194 {
195 GridRegion region = new GridRegion(xcell, ycell);
196 region.RegionName = name;
197 region.RegionID = UUID.Random();
198 region.ExternalHostName = "127.0.0.1";
199 region.HttpPort = 9000;
200 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);
201
202 return region;
203 }
204 }
205}
diff --git a/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini b/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini
deleted file mode 100644
index 8610c78..0000000
--- a/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini
+++ /dev/null
@@ -1,33 +0,0 @@
1; * Run a ROBUST server shell like this, from bin:
2; * $ OpenSim.Server.exe -inifile ../OpenSim/Tests/Clients/Presence/OpenSim.Server.ini
3; *
4; * Then run this client like this, from bin:
5; * $ OpenSim.Tests.Clients.PresenceClient.exe
6; *
7; *
8
9[Startup]
10ServiceConnectors = "OpenSim.Server.Handlers.dll:PresenceServiceConnector"
11
12; * This is common for all services, it's the network setup for the entire
13; * server instance
14; *
15[Network]
16port = 8003
17
18; * The following are for the remote console
19; * They have no effect for the local or basic console types
20; * Leave commented to diable logins to the console
21;ConsoleUser = Test
22;ConsolePass = secret
23
24; * As an example, the below configuration precisely mimicks the legacy
25; * asset server. It is read by the asset IN connector (defined above)
26; * and it then loads the OUT connector (a local database module). That,
27; * in turn, reads the asset loader and database connection information
28; *
29[PresenceService]
30 LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService"
31 StorageProvider = "OpenSim.Data.MySQL.dll"
32 ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;Old Guids=true;"
33
diff --git a/OpenSim/Tests/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Clients/Presence/PresenceClient.cs
deleted file mode 100644
index fd3905a..0000000
--- a/OpenSim/Tests/Clients/Presence/PresenceClient.cs
+++ /dev/null
@@ -1,115 +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.Text;
31using System.Reflection;
32
33using OpenMetaverse;
34using log4net;
35using log4net.Appender;
36using log4net.Layout;
37
38using OpenSim.Framework;
39using OpenSim.Services.Interfaces;
40using OpenSim.Services.Connectors;
41
42namespace OpenSim.Tests.Clients.PresenceClient
43{
44 public class PresenceClient
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 public static void Main(string[] args)
51 {
52 ConsoleAppender consoleAppender = new ConsoleAppender();
53 consoleAppender.Layout =
54 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
55 log4net.Config.BasicConfigurator.Configure(consoleAppender);
56
57 string serverURI = "http://127.0.0.1:8003";
58 PresenceServicesConnector m_Connector = new PresenceServicesConnector(serverURI);
59
60 UUID user1 = UUID.Random();
61 UUID session1 = UUID.Random();
62 UUID region1 = UUID.Random();
63
64 bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero);
65 if (success)
66 m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged in user {0} with session {1}", user1, session1);
67 else
68 m_log.InfoFormat("[PRESENCE CLIENT]: failed to login user {0}", user1);
69
70 System.Console.WriteLine("\n");
71
72 PresenceInfo pinfo = m_Connector.GetAgent(session1);
73 if (pinfo == null)
74 m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0}", user1);
75 else
76 m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={1}",
77 pinfo.UserID, pinfo.RegionID);
78
79 System.Console.WriteLine("\n");
80 success = m_Connector.ReportAgent(session1, region1);
81 if (success)
82 m_log.InfoFormat("[PRESENCE CLIENT]: Successfully reported session {0} in region {1}", user1, region1);
83 else
84 m_log.InfoFormat("[PRESENCE CLIENT]: failed to report session {0}", session1);
85 pinfo = m_Connector.GetAgent(session1);
86 if (pinfo == null)
87 m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for second time", user1);
88 else
89 m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={2}",
90 pinfo.UserID, pinfo.RegionID);
91
92 System.Console.WriteLine("\n");
93 success = m_Connector.LogoutAgent(session1);
94 if (success)
95 m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged out user {0}", user1);
96 else
97 m_log.InfoFormat("[PRESENCE CLIENT]: failed to logout user {0}", user1);
98 pinfo = m_Connector.GetAgent(session1);
99 if (pinfo == null)
100 m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for fourth time", user1);
101 else
102 m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={1}",
103 pinfo.UserID, pinfo.RegionID);
104
105 System.Console.WriteLine("\n");
106 success = m_Connector.ReportAgent(session1, UUID.Random());
107 if (success)
108 m_log.InfoFormat("[PRESENCE CLIENT]: Report agent succeeded, but this is wrong");
109 else
110 m_log.InfoFormat("[PRESENCE CLIENT]: failed to report agent, as it should because user is not logged in");
111
112 }
113
114 }
115}
diff --git a/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini b/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini
deleted file mode 100644
index 453e17e..0000000
--- a/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini
+++ /dev/null
@@ -1,33 +0,0 @@
1; * Run a ROBUST server shell like this, from bin:
2; * $ OpenSim.Server.exe -inifile ../OpenSim/Tests/Clients/Presence/OpenSim.Server.ini
3; *
4; * Then run this client like this, from bin:
5; * $ OpenSim.Tests.Clients.UserAccountClient.exe
6; *
7; *
8
9[Startup]
10ServiceConnectors = "OpenSim.Server.Handlers.dll:UserAccountServiceConnector"
11
12; * This is common for all services, it's the network setup for the entire
13; * server instance
14; *
15[Network]
16port = 8003
17
18; * The following are for the remote console
19; * They have no effect for the local or basic console types
20; * Leave commented to diable logins to the console
21;ConsoleUser = Test
22;ConsolePass = secret
23
24; * As an example, the below configuration precisely mimicks the legacy
25; * asset server. It is read by the asset IN connector (defined above)
26; * and it then loads the OUT connector (a local database module). That,
27; * in turn, reads the asset loader and database connection information
28; *
29[UserAccountService]
30 LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
31 StorageProvider = "OpenSim.Data.MySQL.dll"
32 ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;Old Guids=true;"
33
diff --git a/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs b/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs
deleted file mode 100644
index 1e0a35b..0000000
--- a/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs
+++ /dev/null
@@ -1,144 +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.Text;
31using System.Reflection;
32
33using OpenMetaverse;
34using log4net;
35using log4net.Appender;
36using log4net.Layout;
37
38using OpenSim.Framework;
39using OpenSim.Services.Interfaces;
40using OpenSim.Services.Connectors;
41
42namespace OpenSim.Tests.Clients.PresenceClient
43{
44 public class UserAccountsClient
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 public static void Main(string[] args)
51 {
52 ConsoleAppender consoleAppender = new ConsoleAppender();
53 consoleAppender.Layout =
54 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
55 log4net.Config.BasicConfigurator.Configure(consoleAppender);
56
57 string serverURI = "http://127.0.0.1:8003";
58 UserAccountServicesConnector m_Connector = new UserAccountServicesConnector(serverURI);
59
60 UUID user1 = UUID.Random();
61 string first = "Completely";
62 string last = "Clueless";
63 string email = "foo@bar.com";
64
65 //UserAccount account = new UserAccount(user1);
66 //account.ScopeID = UUID.Zero;
67 //account.FirstName = first;
68 //account.LastName = last;
69 //account.Email = email;
70 //account.ServiceURLs = new Dictionary<string, object>();
71 //account.ServiceURLs.Add("InventoryServerURI", "http://cnn.com");
72 //account.ServiceURLs.Add("AssetServerURI", "http://cnn.com");
73
74 //bool success = m_Connector.StoreUserAccount(account);
75 //if (success)
76 // m_log.InfoFormat("[USER CLIENT]: Successfully created account for user {0} {1}", account.FirstName, account.LastName);
77 //else
78 // m_log.InfoFormat("[USER CLIENT]: failed to create user {0} {1}", account.FirstName, account.LastName);
79
80 //System.Console.WriteLine("\n");
81
82 //account = m_Connector.GetUserAccount(UUID.Zero, user1);
83 //if (account == null)
84 // m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by UUID for {0}", user1);
85 //else
86 //{
87 // m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}",
88 // account.PrincipalID, account.FirstName, account.LastName, account.Email);
89 // foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
90 // m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value);
91 //}
92
93 //System.Console.WriteLine("\n");
94
95 UserAccount account = m_Connector.GetUserAccount(UUID.Zero, first, last);
96 if (account == null)
97 m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by name ");
98 else
99 {
100 m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}",
101 account.PrincipalID, account.FirstName, account.LastName, account.Email);
102 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
103 m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value);
104 }
105
106 System.Console.WriteLine("\n");
107 account = m_Connector.GetUserAccount(UUID.Zero, email);
108 if (account == null)
109 m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by email");
110 else
111 {
112 m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}",
113 account.PrincipalID, account.FirstName, account.LastName, account.Email);
114 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
115 m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value);
116 }
117
118 System.Console.WriteLine("\n");
119 account = m_Connector.GetUserAccount(UUID.Zero, user1);
120 if (account == null)
121 m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by UUID for {0}", user1);
122 else
123 {
124 m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}",
125 account.PrincipalID, account.FirstName, account.LastName, account.Email);
126 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
127 m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value);
128 }
129
130 System.Console.WriteLine("\n");
131 account = m_Connector.GetUserAccount(UUID.Zero, "DoesNot", "Exist");
132 if (account == null)
133 m_log.InfoFormat("[USER CLIENT]: Unable to retrieve account 'DoesNot Exist'");
134 else
135 {
136 m_log.InfoFormat("[USER CLIENT]: Account 'DoesNot Exist' retrieved correctly. REALLY??? userID={0}; FirstName={1}; LastName={2}; Email={3}",
137 account.PrincipalID, account.FirstName, account.LastName, account.Email);
138 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
139 m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value);
140 }
141 }
142
143 }
144}
diff --git a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs
index 49c99c5..82ecf9a 100644
--- a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs
@@ -32,7 +32,6 @@ using NUnit.Framework;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Servers; 33using OpenSim.Framework.Servers;
34using OpenSim.Framework.Servers.HttpServer; 34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Tests.Common.Mock;
36 35
37namespace OpenSim.Tests.Common 36namespace OpenSim.Tests.Common
38{ 37{
diff --git a/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs
new file mode 100644
index 0000000..33cd8a2
--- /dev/null
+++ b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs
@@ -0,0 +1,95 @@
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.Net;
30using Nini.Config;
31using OpenMetaverse;
32using OpenMetaverse.Packets;
33using OpenSim.Framework;
34using OpenSim.Region.ClientStack.LindenUDP;
35using OpenSim.Region.Framework.Scenes;
36
37namespace OpenSim.Tests.Common
38{
39 /// <summary>
40 /// This class adds full UDP client classes and associated scene presence to scene.
41 /// </summary>
42 /// <remarks>
43 /// This is used for testing client stack code. For testing other code, use SceneHelper methods instead since
44 /// they operate without the burden of setting up UDP structures which should be unnecessary for testing scene
45 /// code.
46 /// </remarks>
47 public static class ClientStackHelpers
48 {
49 public static ScenePresence AddChildClient(
50 Scene scene, LLUDPServer udpServer, UUID agentId, UUID sessionId, uint circuitCode)
51 {
52 IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
53
54 UseCircuitCodePacket uccp = new UseCircuitCodePacket();
55
56 UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
57 = new UseCircuitCodePacket.CircuitCodeBlock();
58 uccpCcBlock.Code = circuitCode;
59 uccpCcBlock.ID = agentId;
60 uccpCcBlock.SessionID = sessionId;
61 uccp.CircuitCode = uccpCcBlock;
62
63 byte[] uccpBytes = uccp.ToBytes();
64 UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length);
65 upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor.
66 Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length);
67
68 AgentCircuitData acd = new AgentCircuitData();
69 acd.AgentID = agentId;
70 acd.SessionID = sessionId;
71
72 scene.AuthenticateHandler.AddNewCircuit(circuitCode, acd);
73
74 udpServer.PacketReceived(upb);
75
76 return scene.GetScenePresence(agentId);
77 }
78
79 public static TestLLUDPServer AddUdpServer(Scene scene)
80 {
81 return AddUdpServer(scene, new IniConfigSource());
82 }
83
84 public static TestLLUDPServer AddUdpServer(Scene scene, IniConfigSource configSource)
85 {
86 uint port = 0;
87 AgentCircuitManager acm = scene.AuthenticateHandler;
88
89 TestLLUDPServer udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm);
90 udpServer.AddScene(scene);
91
92 return udpServer;
93 }
94 }
95} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
new file mode 100644
index 0000000..b215f1e
--- /dev/null
+++ b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
@@ -0,0 +1,123 @@
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.Reflection;
33using System.Text;
34using System.Threading;
35using log4net;
36using Nini.Config;
37using NUnit.Framework;
38using OpenMetaverse;
39using OpenSim.Framework;
40
41using OpenSim.Framework.Servers;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.CoreModules.Framework;
45using OpenSim.Tests.Common;
46
47namespace OpenSim.Tests.Common
48{
49 public static class EntityTransferHelpers
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 /// <summary>
54 /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
55 /// viewer to setup a connection with the destination region.
56 /// </summary>
57 /// <param name='tc'></param>
58 /// <param name='neighbourTcs'>
59 /// A list that will be populated with any TestClients set up in response to
60 /// being informed about a destination region.
61 /// </param>
62 public static void SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
63 TestClient tc, List<TestClient> neighbourTcs)
64 {
65 // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the
66 // event queue).
67
68 tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) =>
69 {
70 uint x, y;
71 Util.RegionHandleToRegionLoc(neighbourHandle, out x, out y);
72
73 m_log.DebugFormat(
74 "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}",
75 x, y, neighbourExternalEndPoint);
76
77 AgentCircuitData newAgent = tc.RequestClientInfo();
78
79 Scene neighbourScene;
80 SceneManager.Instance.TryGetScene(x, y, out neighbourScene);
81
82 TestClient neighbourTc = new TestClient(newAgent, neighbourScene);
83 neighbourTcs.Add(neighbourTc);
84 neighbourScene.AddNewAgent(neighbourTc, PresenceType.User);
85 };
86 }
87
88 /// <summary>
89 /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
90 /// viewer to setup a connection with the destination region.
91 /// </summary>
92 /// <param name='tc'></param>
93 /// <param name='neighbourTcs'>
94 /// A list that will be populated with any TestClients set up in response to
95 /// being informed about a destination region.
96 /// </param>
97 public static void SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
98 TestClient client, List<TestClient> destinationClients)
99 {
100 client.OnTestClientSendRegionTeleport
101 += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) =>
102 {
103 uint x, y;
104 Util.RegionHandleToRegionLoc(regionHandle, out x, out y);
105
106 m_log.DebugFormat(
107 "[TEST CLIENT]: Processing send region teleport for destination at {0},{1} at {2}",
108 x, y, regionExternalEndPoint);
109
110 AgentCircuitData newAgent = client.RequestClientInfo();
111
112 Scene destinationScene;
113 SceneManager.Instance.TryGetScene(x, y, out destinationScene);
114
115 TestClient destinationClient = new TestClient(newAgent, destinationScene);
116 destinationClients.Add(destinationClient);
117 destinationScene.AddNewAgent(destinationClient, PresenceType.User);
118
119 ThreadPool.UnsafeQueueUserWorkItem(o => destinationClient.CompleteMovement(), null);
120 };
121 }
122 }
123} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index ea3e348..df8b14c 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -30,12 +30,13 @@ using System.Net;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using Nini.Config; 31using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Data.Null;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Framework.Communications; 35
35using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
37using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.PhysicsModules.SharedBase;
39using OpenSim.Region.Framework; 40using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
@@ -47,8 +48,8 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
47using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; 48using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
48using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; 49using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
49using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; 50using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
51using OpenSim.Region.PhysicsModule.BasicPhysics;
50using OpenSim.Services.Interfaces; 52using OpenSim.Services.Interfaces;
51using OpenSim.Tests.Common.Mock;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion; 53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
53 54
54namespace OpenSim.Tests.Common 55namespace OpenSim.Tests.Common
@@ -63,9 +64,9 @@ namespace OpenSim.Tests.Common
63 /// </summary> 64 /// </summary>
64 public SceneManager SceneManager { get; private set; } 65 public SceneManager SceneManager { get; private set; }
65 66
67 public ISimulationDataService SimDataService { get; private set; }
68
66 private AgentCircuitManager m_acm = new AgentCircuitManager(); 69 private AgentCircuitManager m_acm = new AgentCircuitManager();
67 private ISimulationDataService m_simDataService
68 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
69 private IEstateDataService m_estateDataService = null; 70 private IEstateDataService m_estateDataService = null;
70 71
71 private LocalAssetServicesConnector m_assetService; 72 private LocalAssetServicesConnector m_assetService;
@@ -77,6 +78,8 @@ namespace OpenSim.Tests.Common
77 78
78 private CoreAssetCache m_cache; 79 private CoreAssetCache m_cache;
79 80
81 private PhysicsScene m_physicsScene;
82
80 public SceneHelpers() : this(null) {} 83 public SceneHelpers() : this(null) {}
81 84
82 public SceneHelpers(CoreAssetCache cache) 85 public SceneHelpers(CoreAssetCache cache)
@@ -96,6 +99,11 @@ namespace OpenSim.Tests.Common
96 m_presenceService.PostInitialise(); 99 m_presenceService.PostInitialise();
97 100
98 m_cache = cache; 101 m_cache = cache;
102
103 m_physicsScene = StartPhysicsScene();
104
105 SimDataService
106 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
99 } 107 }
100 108
101 /// <summary> 109 /// <summary>
@@ -115,6 +123,11 @@ namespace OpenSim.Tests.Common
115 return SetupScene(name, id, x, y, new IniConfigSource()); 123 return SetupScene(name, id, x, y, new IniConfigSource());
116 } 124 }
117 125
126 public TestScene SetupScene(string name, UUID id, uint x, uint y, IConfigSource configSource)
127 {
128 return SetupScene(name, id, x, y, Constants.RegionSize, Constants.RegionSize, configSource);
129 }
130
118 /// <summary> 131 /// <summary>
119 /// Set up a scene. 132 /// Set up a scene.
120 /// </summary> 133 /// </summary>
@@ -122,10 +135,12 @@ namespace OpenSim.Tests.Common
122 /// <param name="id">ID of the region</param> 135 /// <param name="id">ID of the region</param>
123 /// <param name="x">X co-ordinate of the region</param> 136 /// <param name="x">X co-ordinate of the region</param>
124 /// <param name="y">Y co-ordinate of the region</param> 137 /// <param name="y">Y co-ordinate of the region</param>
138 /// <param name="sizeX">X size of scene</param>
139 /// <param name="sizeY">Y size of scene</param>
125 /// <param name="configSource"></param> 140 /// <param name="configSource"></param>
126 /// <returns></returns> 141 /// <returns></returns>
127 public TestScene SetupScene( 142 public TestScene SetupScene(
128 string name, UUID id, uint x, uint y, IConfigSource configSource) 143 string name, UUID id, uint x, uint y, uint sizeX, uint sizeY, IConfigSource configSource)
129 { 144 {
130 Console.WriteLine("Setting up test scene {0}", name); 145 Console.WriteLine("Setting up test scene {0}", name);
131 146
@@ -135,16 +150,20 @@ namespace OpenSim.Tests.Common
135 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); 150 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
136 regInfo.RegionName = name; 151 regInfo.RegionName = name;
137 regInfo.RegionID = id; 152 regInfo.RegionID = id;
138 153 regInfo.RegionSizeX = sizeX;
139 SceneCommunicationService scs = new SceneCommunicationService(); 154 regInfo.RegionSizeY = sizeY;
140 155
141 TestScene testScene = new TestScene( 156 TestScene testScene = new TestScene(
142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, false, configSource, null); 157 regInfo, m_acm, SimDataService, m_estateDataService, configSource, null);
143 158
144 INonSharedRegionModule godsModule = new GodsModule(); 159 INonSharedRegionModule godsModule = new GodsModule();
145 godsModule.Initialise(new IniConfigSource()); 160 godsModule.Initialise(new IniConfigSource());
146 godsModule.AddRegion(testScene); 161 godsModule.AddRegion(testScene);
147 162
163 // Add scene to physics
164 ((INonSharedRegionModule)m_physicsScene).AddRegion(testScene);
165 ((INonSharedRegionModule)m_physicsScene).RegionLoaded(testScene);
166
148 // Add scene to services 167 // Add scene to services
149 m_assetService.AddRegion(testScene); 168 m_assetService.AddRegion(testScene);
150 169
@@ -182,12 +201,7 @@ namespace OpenSim.Tests.Common
182 testScene.SetModuleInterfaces(); 201 testScene.SetModuleInterfaces();
183 202
184 testScene.LandChannel = new TestLandChannel(testScene); 203 testScene.LandChannel = new TestLandChannel(testScene);
185 testScene.LoadWorldMap(); 204 testScene.LoadWorldMap();
186
187 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
188 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
189 testScene.PhysicsScene
190 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
191 205
192 testScene.RegionInfo.EstateSettings = new EstateSettings(); 206 testScene.RegionInfo.EstateSettings = new EstateSettings();
193 testScene.LoginsEnabled = true; 207 testScene.LoginsEnabled = true;
@@ -297,6 +311,11 @@ namespace OpenSim.Tests.Common
297 /// <param name="testScene"></param> 311 /// <param name="testScene"></param>
298 private static LocalPresenceServicesConnector StartPresenceService() 312 private static LocalPresenceServicesConnector StartPresenceService()
299 { 313 {
314 // Unfortunately, some services share data via statics, so we need to null every time to stop interference
315 // between tests.
316 // This is a massive non-obvious pita.
317 NullPresenceData.Instance = null;
318
300 IConfigSource config = new IniConfigSource(); 319 IConfigSource config = new IniConfigSource();
301 config.AddConfig("Modules"); 320 config.AddConfig("Modules");
302 config.AddConfig("PresenceService"); 321 config.AddConfig("PresenceService");
@@ -311,6 +330,19 @@ namespace OpenSim.Tests.Common
311 return presenceService; 330 return presenceService;
312 } 331 }
313 332
333 private static PhysicsScene StartPhysicsScene()
334 {
335 IConfigSource config = new IniConfigSource();
336 config.AddConfig("Startup");
337 config.Configs["Startup"].Set("physics", "basicphysics");
338
339 PhysicsScene pScene = new BasicScene();
340 INonSharedRegionModule mod = pScene as INonSharedRegionModule;
341 mod.Initialise(config);
342
343 return pScene;
344 }
345
314 /// <summary> 346 /// <summary>
315 /// Setup modules for a scene using their default settings. 347 /// Setup modules for a scene using their default settings.
316 /// </summary> 348 /// </summary>
@@ -447,9 +479,6 @@ namespace OpenSim.Tests.Common
447 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test 479 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
448 /// </summary> 480 /// </summary>
449 /// <remarks> 481 /// <remarks>
450 /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
451 /// and teleport doesn't take place.
452 ///
453 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will 482 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
454 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. 483 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
455 /// </remarks> 484 /// </remarks>
@@ -462,22 +491,6 @@ namespace OpenSim.Tests.Common
462 } 491 }
463 492
464 /// <summary> 493 /// <summary>
465 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
466 /// </summary>
467 /// <remarks>
468 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
469 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
470 /// </remarks>
471 /// <param name="scene"></param>
472 /// <param name="agentId"></param>
473 /// <param name="sceneManager"></param>
474 /// <returns></returns>
475 public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager)
476 {
477 return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
478 }
479
480 /// <summary>
481 /// Add a root agent. 494 /// Add a root agent.
482 /// </summary> 495 /// </summary>
483 /// <param name="scene"></param> 496 /// <param name="scene"></param>
@@ -508,7 +521,7 @@ namespace OpenSim.Tests.Common
508 /// <returns></returns> 521 /// <returns></returns>
509 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) 522 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
510 { 523 {
511 return AddScenePresence(scene, agentData, null); 524 return AddScenePresence(scene, new TestClient(agentData, scene), agentData);
512 } 525 }
513 526
514 /// <summary> 527 /// <summary>
@@ -528,9 +541,9 @@ namespace OpenSim.Tests.Common
528 /// </remarks> 541 /// </remarks>
529 /// <param name="scene"></param> 542 /// <param name="scene"></param>
530 /// <param name="agentData"></param> 543 /// <param name="agentData"></param>
531 /// <param name="sceneManager"></param>
532 /// <returns></returns> 544 /// <returns></returns>
533 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) 545 public static ScenePresence AddScenePresence(
546 Scene scene, IClientAPI client, AgentCircuitData agentData)
534 { 547 {
535 // We emulate the proper login sequence here by doing things in four stages 548 // We emulate the proper login sequence here by doing things in four stages
536 549
@@ -541,7 +554,7 @@ namespace OpenSim.Tests.Common
541 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); 554 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
542 555
543 // Stages 1 & 2 556 // Stages 1 & 2
544 ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin); 557 ScenePresence sp = IntroduceClientToScene(scene, client, agentData, TeleportFlags.ViaLogin);
545 558
546 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. 559 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
547 sp.CompleteMovement(sp.ControllingClient, true); 560 sp.CompleteMovement(sp.ControllingClient, true);
@@ -553,37 +566,37 @@ namespace OpenSim.Tests.Common
553 /// Introduce an agent into the scene by adding a new client. 566 /// Introduce an agent into the scene by adding a new client.
554 /// </summary> 567 /// </summary>
555 /// <returns>The scene presence added</returns> 568 /// <returns>The scene presence added</returns>
556 /// <param name='sceneManager'>
557 /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not
558 /// neighbours and where no teleporting takes place.
559 /// </param>
560 /// <param name='scene'></param> 569 /// <param name='scene'></param>
561 /// <param name='sceneManager></param> 570 /// <param name='testClient'></param>
562 /// <param name='agentData'></param> 571 /// <param name='agentData'></param>
563 /// <param name='tf'></param> 572 /// <param name='tf'></param>
564 private static ScenePresence IntroduceClientToScene( 573 private static ScenePresence IntroduceClientToScene(
565 Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf) 574 Scene scene, IClientAPI client, AgentCircuitData agentData, TeleportFlags tf)
566 { 575 {
567 string reason; 576 string reason;
568 577
569 // Stage 1: tell the scene to expect a new user connection 578 // Stage 1: tell the scene to expect a new user connection
570 if (!scene.NewUserConnection(agentData, (uint)tf, out reason)) 579 if (!scene.NewUserConnection(agentData, (uint)tf, null, out reason))
571 Console.WriteLine("NewUserConnection failed: " + reason); 580 Console.WriteLine("NewUserConnection failed: " + reason);
572 581
573 // Stage 2: add the new client as a child agent to the scene 582 // Stage 2: add the new client as a child agent to the scene
574 TestClient client = new TestClient(agentData, scene, sceneManager); 583 scene.AddNewAgent(client, PresenceType.User);
575 scene.AddNewClient(client, PresenceType.User);
576 584
577 return scene.GetScenePresence(agentData.AgentID); 585 return scene.GetScenePresence(client.AgentId);
578 } 586 }
579 587
580 public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) 588 public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId)
581 { 589 {
582 AgentCircuitData acd = GenerateAgentData(agentId); 590 return AddChildScenePresence(scene, GenerateAgentData(agentId));
591 }
592
593 public static ScenePresence AddChildScenePresence(Scene scene, AgentCircuitData acd)
594 {
583 acd.child = true; 595 acd.child = true;
584 596
585 // XXX: ViaLogin may not be correct for child agents 597 // XXX: ViaLogin may not be correct for child agents
586 return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin); 598 TestClient client = new TestClient(acd, scene);
599 return IntroduceClientToScene(scene, client, acd, TeleportFlags.ViaLogin);
587 } 600 }
588 601
589 /// <summary> 602 /// <summary>
@@ -610,6 +623,32 @@ namespace OpenSim.Tests.Common
610 //part.UpdatePrimFlags(false, false, true); 623 //part.UpdatePrimFlags(false, false, true);
611 //part.ObjectFlags |= (uint)PrimFlags.Phantom; 624 //part.ObjectFlags |= (uint)PrimFlags.Phantom;
612 625
626 scene.AddNewSceneObject(so, true);
627
628 return so;
629 }
630
631 /// <summary>
632 /// Add a test object
633 /// </summary>
634 /// <param name="scene"></param>
635 /// <param name="parts">
636 /// The number of parts that should be in the scene object
637 /// </param>
638 /// <param name="ownerId"></param>
639 /// <param name="partNamePrefix">
640 /// The prefix to be given to part names. This will be suffixed with "Part<part no>"
641 /// (e.g. mynamePart1 for the root part)
642 /// </param>
643 /// <param name="uuidTail">
644 /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
645 /// will be given to the root part, and incremented for each part thereafter.
646 /// </param>
647 /// <returns></returns>
648 public static SceneObjectGroup AddSceneObject(Scene scene, int parts, UUID ownerId, string partNamePrefix, int uuidTail)
649 {
650 SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail);
651
613 scene.AddNewSceneObject(so, false); 652 scene.AddNewSceneObject(so, false);
614 653
615 return so; 654 return so;
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
index 0a2b30a..3a3b33a 100644
--- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -43,21 +43,40 @@ namespace OpenSim.Tests.Common
43 /// <summary> 43 /// <summary>
44 /// Add a notecard item to the given part. 44 /// Add a notecard item to the given part.
45 /// </summary> 45 /// </summary>
46 /// <param name="scene"></param> 46 /// <param name="assetService"></param>
47 /// <param name="part"></param>
48 /// <param name="itemName"></param>
49 /// <param name="itemIDFrag">UUID or UUID stem</param>
50 /// <param name="assetIDFrag">UUID or UUID stem</param>
51 /// <param name="text">The tex to put in the notecard.</param>
52 /// <returns>The item that was added</returns>
53 public static TaskInventoryItem AddNotecard(
54 IAssetService assetService, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text)
55 {
56 return AddNotecard(
57 assetService, part, itemName, TestHelpers.ParseStem(itemIDStem), TestHelpers.ParseStem(assetIDStem), text);
58 }
59
60 /// <summary>
61 /// Add a notecard item to the given part.
62 /// </summary>
63 /// <param name="assetService"></param>
47 /// <param name="part"></param> 64 /// <param name="part"></param>
48 /// <param name="itemName"></param> 65 /// <param name="itemName"></param>
49 /// <param name="itemID"></param> 66 /// <param name="itemID"></param>
50 /// <param name="assetID"></param> 67 /// <param name="assetID"></param>
68 /// <param name="text">The tex to put in the notecard.</param>
51 /// <returns>The item that was added</returns> 69 /// <returns>The item that was added</returns>
52 public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID) 70 public static TaskInventoryItem AddNotecard(
71 IAssetService assetService, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text)
53 { 72 {
54 AssetNotecard nc = new AssetNotecard(); 73 AssetNotecard nc = new AssetNotecard();
55 nc.BodyText = "Hello World!"; 74 nc.BodyText = text;
56 nc.Encode(); 75 nc.Encode();
57 76
58 AssetBase ncAsset 77 AssetBase ncAsset
59 = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); 78 = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero);
60 scene.AssetService.Store(ncAsset); 79 assetService.Store(ncAsset);
61 80
62 TaskInventoryItem ncItem 81 TaskInventoryItem ncItem
63 = new TaskInventoryItem 82 = new TaskInventoryItem
@@ -75,44 +94,62 @@ namespace OpenSim.Tests.Common
75 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these 94 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
76 /// functions more than once in a test. 95 /// functions more than once in a test.
77 /// </remarks> 96 /// </remarks>
78 /// <param name="scene"></param> 97 /// <param name="assetService"></param>
79 /// <param name="part"></param> 98 /// <param name="part"></param>
80 /// <returns>The item that was added</returns> 99 /// <returns>The item that was added</returns>
81 public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) 100 public static TaskInventoryItem AddScript(IAssetService assetService, SceneObjectPart part)
82 { 101 {
83 return AddScript(scene, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }"); 102 return AddScript(assetService, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }");
84 } 103 }
85 104
86 /// <summary> 105 /// <summary>
87 /// Add a simple script to the given part. 106 /// Add a simple script to the given part.
88 /// </summary> 107 /// </summary>
89 /// <remarks> 108 /// <remarks>
90 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these 109 /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather
91 /// functions more than once in a test. 110 /// than a random component.
111 /// </remarks>
112 /// <param name="assetService"></param>
113 /// <param name="part"></param>
114 /// <param name="scriptName">Name of the script to add</param>
115 /// <param name="scriptSource">LSL script source</param>
116 /// <returns>The item that was added</returns>
117 public static TaskInventoryItem AddScript(
118 IAssetService assetService, SceneObjectPart part, string scriptName, string scriptSource)
119 {
120 return AddScript(assetService, part, UUID.Random(), UUID.Random(), scriptName, scriptSource);
121 }
122
123 /// <summary>
124 /// Add a simple script to the given part.
125 /// </summary>
126 /// <remarks>
127 /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather
128 /// than a random component.
92 /// </remarks> 129 /// </remarks>
93 /// <param name="scene"></param> 130 /// <param name="assetService"></param>
94 /// <param name="part"></param> 131 /// <param name="part"></param>
132 /// <param name="itemId">Item UUID for the script</param>
133 /// <param name="assetId">Asset UUID for the script</param>
95 /// <param name="scriptName">Name of the script to add</param> 134 /// <param name="scriptName">Name of the script to add</param>
96 /// <param name="scriptSource">LSL script source</param> 135 /// <param name="scriptSource">LSL script source</param>
97 /// <returns>The item that was added</returns> 136 /// <returns>The item that was added</returns>
98 public static TaskInventoryItem AddScript( 137 public static TaskInventoryItem AddScript(
99 Scene scene, SceneObjectPart part, string scriptName, string scriptSource) 138 IAssetService assetService, SceneObjectPart part, UUID itemId, UUID assetId, string scriptName, string scriptSource)
100 { 139 {
101 AssetScriptText ast = new AssetScriptText(); 140 AssetScriptText ast = new AssetScriptText();
102 ast.Source = scriptSource; 141 ast.Source = scriptSource;
103 ast.Encode(); 142 ast.Encode();
104 143
105 UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000");
106 UUID itemUuid = new UUID("00000000-0000-0000-1100-000000000000");
107 AssetBase asset 144 AssetBase asset
108 = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); 145 = AssetHelpers.CreateAsset(assetId, AssetType.LSLText, ast.AssetData, UUID.Zero);
109 scene.AssetService.Store(asset); 146 assetService.Store(asset);
110 TaskInventoryItem item 147 TaskInventoryItem item
111 = new TaskInventoryItem 148 = new TaskInventoryItem
112 { Name = scriptName, AssetID = assetUuid, ItemID = itemUuid, 149 { Name = scriptName, AssetID = assetId, ItemID = itemId,
113 Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; 150 Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL };
114 part.Inventory.AddInventoryItem(item, true); 151 part.Inventory.AddInventoryItem(item, true);
115 152
116 return item; 153 return item;
117 } 154 }
118 155
@@ -124,28 +161,50 @@ namespace OpenSim.Tests.Common
124 /// functions more than once in a test. 161 /// functions more than once in a test.
125 /// </remarks> 162 /// </remarks>
126 /// 163 ///
127 /// <param name="scene"></param> 164 /// <param name="assetService"></param>
128 /// <param name="sop"></param> 165 /// <param name="sop"></param>
129 /// <param name="itemName"></param> 166 /// <param name="itemName"></param>
130 /// <param name="id"></param> 167 /// <param name="itemId"></param>
131 /// <param name="userId"></param> 168 /// <param name="soToAdd"></param>
169 /// <param name="soAssetId"></param>
132 public static TaskInventoryItem AddSceneObject( 170 public static TaskInventoryItem AddSceneObject(
133 Scene scene, SceneObjectPart sop, string itemName, UUID id, UUID userId) 171 IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, SceneObjectGroup soToAdd, UUID soAssetId)
134 { 172 {
135 SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero); 173 AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(soAssetId, soToAdd);
136 AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); 174 assetService.Store(taskSceneObjectAsset);
137 scene.AssetService.Store(taskSceneObjectAsset);
138 TaskInventoryItem taskSceneObjectItem 175 TaskInventoryItem taskSceneObjectItem
139 = new TaskInventoryItem 176 = new TaskInventoryItem
140 { Name = itemName, 177 { Name = itemName,
141 AssetID = taskSceneObjectAsset.FullID, 178 AssetID = taskSceneObjectAsset.FullID,
142 ItemID = id, 179 ItemID = itemId,
143 OwnerID = userId, 180 OwnerID = soToAdd.OwnerID,
144 Type = (int)AssetType.Object, 181 Type = (int)AssetType.Object,
145 InvType = (int)InventoryType.Object }; 182 InvType = (int)InventoryType.Object };
146 sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); 183 sop.Inventory.AddInventoryItem(taskSceneObjectItem, true);
147 184
148 return taskSceneObjectItem; 185 return taskSceneObjectItem;
149 } 186 }
187
188 /// <summary>
189 /// Add a scene object item to the given part.
190 /// </summary>
191 /// <remarks>
192 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
193 /// functions more than once in a test.
194 /// </remarks>
195 ///
196 /// <param name="assetService"></param>
197 /// <param name="sop"></param>
198 /// <param name="itemName"></param>
199 /// <param name="id"></param>
200 /// <param name="userId"></param>
201 public static TaskInventoryItem AddSceneObject(
202 IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, UUID userId)
203 {
204 SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, userId);
205
206 return TaskInventoryHelpers.AddSceneObject(
207 assetService, sop, itemName, itemId, taskSceneObject, TestHelpers.ParseTail(0x10));
208 }
150 } 209 }
151} \ No newline at end of file 210} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
index 2fbebc4..c62b58e 100644
--- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
@@ -27,7 +27,7 @@
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Framework.Communications; 30
31using OpenSim.Region.Framework.Scenes; 31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Services.Interfaces; 32using OpenSim.Services.Interfaces;
33 33
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index 87d9410..5a36332 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -45,6 +45,9 @@ namespace OpenSim.Tests.Common
45 /// <summary> 45 /// <summary>
46 /// Add an existing scene object as an item in the user's inventory. 46 /// Add an existing scene object as an item in the user's inventory.
47 /// </summary> 47 /// </summary>
48 /// <remarks>
49 /// Will be added to the system Objects folder.
50 /// </remarks>
48 /// <param name='scene'></param> 51 /// <param name='scene'></param>
49 /// <param name='so'></param> 52 /// <param name='so'></param>
50 /// <param name='inventoryIdTail'></param> 53 /// <param name='inventoryIdTail'></param>
@@ -63,7 +66,29 @@ namespace OpenSim.Tests.Common
63 } 66 }
64 67
65 /// <summary> 68 /// <summary>
66 /// Creates a notecard in the objects folder and specify an item id. 69 /// Add an existing scene object as an item in the user's inventory at the given path.
70 /// </summary>
71 /// <param name='scene'></param>
72 /// <param name='so'></param>
73 /// <param name='inventoryIdTail'></param>
74 /// <param name='assetIdTail'></param>
75 /// <returns>The inventory item created.</returns>
76 public static InventoryItemBase AddInventoryItem(
77 Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail, string path)
78 {
79 return AddInventoryItem(
80 scene,
81 so.Name,
82 TestHelpers.ParseTail(inventoryIdTail),
83 InventoryType.Object,
84 AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
85 so.OwnerID,
86 path);
87 }
88
89 /// <summary>
90 /// Adds the given item to the existing system folder for its type (e.g. an object will go in the "Objects"
91 /// folder).
67 /// </summary> 92 /// </summary>
68 /// <param name="scene"></param> 93 /// <param name="scene"></param>
69 /// <param name="itemName"></param> 94 /// <param name="itemName"></param>
@@ -75,6 +100,25 @@ namespace OpenSim.Tests.Common
75 private static InventoryItemBase AddInventoryItem( 100 private static InventoryItemBase AddInventoryItem(
76 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId) 101 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
77 { 102 {
103 return AddInventoryItem(
104 scene, itemName, itemId, itemType, asset, userId,
105 scene.InventoryService.GetFolderForType(userId, (FolderType)asset.Type).Name);
106 }
107
108 /// <summary>
109 /// Adds the given item to an inventory folder
110 /// </summary>
111 /// <param name="scene"></param>
112 /// <param name="itemName"></param>
113 /// <param name="itemId"></param>
114 /// <param name="itemType"></param>
115 /// <param name="asset">The serialized asset for this item</param>
116 /// <param name="userId"></param>
117 /// <param name="path">Existing inventory path at which to add.</param>
118 /// <returns></returns>
119 private static InventoryItemBase AddInventoryItem(
120 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId, string path)
121 {
78 scene.AssetService.Store(asset); 122 scene.AssetService.Store(asset);
79 123
80 InventoryItemBase item = new InventoryItemBase(); 124 InventoryItemBase item = new InventoryItemBase();
@@ -85,7 +129,7 @@ namespace OpenSim.Tests.Common
85 item.AssetType = asset.Type; 129 item.AssetType = asset.Type;
86 item.InvType = (int)itemType; 130 item.InvType = (int)itemType;
87 131
88 InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type); 132 InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, path)[0];
89 133
90 item.Folder = folder.ID; 134 item.Folder = folder.ID;
91 scene.AddInventoryItem(item); 135 scene.AddInventoryItem(item);
@@ -156,58 +200,116 @@ namespace OpenSim.Tests.Common
156 /// <summary> 200 /// <summary>
157 /// Create inventory folders starting from the user's root folder. 201 /// Create inventory folders starting from the user's root folder.
158 /// </summary> 202 /// </summary>
159 ///
160 /// Ignores any existing folders with the same name
161 ///
162 /// <param name="inventoryService"></param> 203 /// <param name="inventoryService"></param>
163 /// <param name="userId"></param> 204 /// <param name="userId"></param>
164 /// <param name="path"> 205 /// <param name="path">
165 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER 206 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
166 /// </param> 207 /// </param>
208 /// <param name="useExistingFolders">
209 /// If true, then folders in the path which already the same name are
210 /// used. This applies to the terminal folder as well.
211 /// If false, then all folders in the path are created, even if there is already a folder at a particular
212 /// level with the same name.
213 /// </param>
167 /// <returns> 214 /// <returns>
168 /// The folder created. If the path contains multiple folders then the last one created is returned. 215 /// The folder created. If the path contains multiple folders then the last one created is returned.
169 /// Will return null if the root folder could not be found. 216 /// Will return null if the root folder could not be found.
170 /// </returns> 217 /// </returns>
171 public static InventoryFolderBase CreateInventoryFolder( 218 public static InventoryFolderBase CreateInventoryFolder(
172 IInventoryService inventoryService, UUID userId, string path) 219 IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders)
220 {
221 return CreateInventoryFolder(inventoryService, userId, UUID.Random(), path, useExistingFolders);
222 }
223
224 /// <summary>
225 /// Create inventory folders starting from the user's root folder.
226 /// </summary>
227 /// <param name="inventoryService"></param>
228 /// <param name="userId"></param>
229 /// <param name="folderId"></param>
230 /// <param name="path">
231 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
232 /// </param>
233 /// <param name="useExistingFolders">
234 /// If true, then folders in the path which already the same name are
235 /// used. This applies to the terminal folder as well.
236 /// If false, then all folders in the path are created, even if there is already a folder at a particular
237 /// level with the same name.
238 /// </param>
239 /// <returns>
240 /// The folder created. If the path contains multiple folders then the last one created is returned.
241 /// Will return null if the root folder could not be found.
242 /// </returns>
243 public static InventoryFolderBase CreateInventoryFolder(
244 IInventoryService inventoryService, UUID userId, UUID folderId, string path, bool useExistingFolders)
173 { 245 {
174 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); 246 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
175 247
176 if (null == rootFolder) 248 if (null == rootFolder)
177 return null; 249 return null;
178 250
179 return CreateInventoryFolder(inventoryService, rootFolder, path); 251 return CreateInventoryFolder(inventoryService, folderId, rootFolder, path, useExistingFolders);
180 } 252 }
181 253
182 /// <summary> 254 /// <summary>
183 /// Create inventory folders starting from a given parent folder 255 /// Create inventory folders starting from a given parent folder
184 /// </summary> 256 /// </summary>
185 /// 257 /// <remarks>
186 /// Ignores any existing folders with the same name 258 /// If any stem of the path names folders that already exist then these are not recreated. This includes the
187 /// 259 /// final folder.
260 /// TODO: May need to make it an option to create duplicate folders.
261 /// </remarks>
188 /// <param name="inventoryService"></param> 262 /// <param name="inventoryService"></param>
263 /// <param name="folderId">ID of the folder to create</param>
189 /// <param name="parentFolder"></param> 264 /// <param name="parentFolder"></param>
190 /// <param name="path"> 265 /// <param name="path">
191 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER 266 /// The folder to create.
267 /// </param>
268 /// <param name="useExistingFolders">
269 /// If true, then folders in the path which already the same name are
270 /// used. This applies to the terminal folder as well.
271 /// If false, then all folders in the path are created, even if there is already a folder at a particular
272 /// level with the same name.
192 /// </param> 273 /// </param>
193 /// <returns> 274 /// <returns>
194 /// The folder created. If the path contains multiple folders then the last one created is returned. 275 /// The folder created. If the path contains multiple folders then the last one created is returned.
195 /// </returns> 276 /// </returns>
196 public static InventoryFolderBase CreateInventoryFolder( 277 public static InventoryFolderBase CreateInventoryFolder(
197 IInventoryService inventoryService, InventoryFolderBase parentFolder, string path) 278 IInventoryService inventoryService, UUID folderId, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
198 { 279 {
199 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); 280 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
200 281
201 InventoryFolderBase newFolder 282 InventoryFolderBase folder = null;
202 = new InventoryFolderBase( 283
203 UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0); 284 if (useExistingFolders)
204 285 folder = InventoryArchiveUtils.FindFolderByPath(inventoryService, parentFolder, components[0]);
205 inventoryService.AddFolder(newFolder); 286
287 if (folder == null)
288 {
289// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name);
290
291 UUID folderIdForCreate;
292
293 if (components.Length > 1)
294 folderIdForCreate = UUID.Random();
295 else
296 folderIdForCreate = folderId;
297
298 folder
299 = new InventoryFolderBase(
300 folderIdForCreate, components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
301
302 inventoryService.AddFolder(folder);
303 }
304// else
305// {
306// Console.WriteLine("Found existing folder {0}", folder.Name);
307// }
206 308
207 if (components.Length > 1) 309 if (components.Length > 1)
208 return CreateInventoryFolder(inventoryService, newFolder, components[1]); 310 return CreateInventoryFolder(inventoryService, folderId, folder, components[1], useExistingFolders);
209 else 311 else
210 return newFolder; 312 return folder;
211 } 313 }
212 314
213 /// <summary> 315 /// <summary>
@@ -237,7 +339,7 @@ namespace OpenSim.Tests.Common
237 /// <returns>An empty list if no matching folders were found</returns> 339 /// <returns>An empty list if no matching folders were found</returns>
238 public static List<InventoryFolderBase> GetInventoryFolders(IInventoryService inventoryService, UUID userId, string path) 340 public static List<InventoryFolderBase> GetInventoryFolders(IInventoryService inventoryService, UUID userId, string path)
239 { 341 {
240 return InventoryArchiveUtils.FindFolderByPath(inventoryService, userId, path); 342 return InventoryArchiveUtils.FindFoldersByPath(inventoryService, userId, path);
241 } 343 }
242 344
243 /// <summary> 345 /// <summary>
diff --git a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs
index cfefd38..cb4fb80 100644
--- a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs
+++ b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs
@@ -25,11 +25,12 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
30using OpenSim.Framework; 31using OpenSim.Framework;
31 32
32namespace OpenSim.Tests.Common.Mock 33namespace OpenSim.Tests.Common
33{ 34{
34 public class BaseAssetRepository 35 public class BaseAssetRepository
35 { 36 {
@@ -37,7 +38,7 @@ namespace OpenSim.Tests.Common.Mock
37 38
38 public AssetBase FetchAsset(UUID uuid) 39 public AssetBase FetchAsset(UUID uuid)
39 { 40 {
40 if (ExistsAsset(uuid)) 41 if (AssetsExist(new[] { uuid })[0])
41 return Assets[uuid]; 42 return Assets[uuid];
42 else 43 else
43 return null; 44 return null;
@@ -53,9 +54,9 @@ namespace OpenSim.Tests.Common.Mock
53 CreateAsset(asset); 54 CreateAsset(asset);
54 } 55 }
55 56
56 public bool ExistsAsset(UUID uuid) 57 public bool[] AssetsExist(UUID[] uuids)
57 { 58 {
58 return Assets.ContainsKey(uuid); 59 return Array.ConvertAll(uuids, id => Assets.ContainsKey(id));
59 } 60 }
60 } 61 }
61} \ No newline at end of file 62} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
index 4a15cf2..dddf75d 100644
--- a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs
@@ -31,7 +31,7 @@ using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Data; 32using OpenSim.Data;
33 33
34namespace OpenSim.Tests.Common.Mock 34namespace OpenSim.Tests.Common
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the 37 /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the
diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
index 3035cea..7f530d0 100644
--- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
+++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
@@ -40,7 +40,7 @@ using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; 41using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
42 42
43namespace OpenSim.Tests.Common.Mock 43namespace OpenSim.Tests.Common
44{ 44{
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
46 public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector 46 public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector
@@ -138,33 +138,28 @@ namespace OpenSim.Tests.Common.Mock
138 { 138 {
139 } 139 }
140 140
141 private XGroup GetXGroup(UUID groupID, string name)
142 {
143 XGroup group = m_data.GetGroup(groupID);
144
145
146 if (group == null)
147 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID);
148
149 return group;
150 }
151
141 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) 152 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
142 { 153 {
143 m_log.DebugFormat( 154 m_log.DebugFormat(
144 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", 155 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}",
145 groupID, groupName); 156 groupID, groupName);
146 157
147 XGroup[] groups; 158 XGroup xg = GetXGroup(groupID, groupName);
148 string field, val;
149 159
150 if (groupID != UUID.Zero) 160 if (xg == null)
151 {
152 field = "groupID";
153 val = groupID.ToString();
154 }
155 else
156 {
157 field = "name";
158 val = groupName;
159 }
160
161 groups = m_data.GetGroups(field, val);
162
163 if (groups.Length == 0)
164 return null; 161 return null;
165 162
166 XGroup xg = groups[0];
167
168 GroupRecord gr = new GroupRecord() 163 GroupRecord gr = new GroupRecord()
169 { 164 {
170 GroupID = xg.groupID, 165 GroupID = xg.groupID,
@@ -196,8 +191,25 @@ namespace OpenSim.Tests.Common.Mock
196 { 191 {
197 } 192 }
198 193
199 public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) 194 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
200 { 195 {
196 m_log.DebugFormat(
197 "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}",
198 requestingAgentID, agentID, groupID, acceptNotices, listInProfile);
199
200 XGroup group = GetXGroup(groupID, null);
201
202 if (group == null)
203 return;
204
205 XGroupMember xgm = null;
206 if (!group.members.TryGetValue(agentID, out xgm))
207 return;
208
209 xgm.acceptNotices = acceptNotices;
210 xgm.listInProfile = listInProfile;
211
212 m_data.StoreGroup(group);
201 } 213 }
202 214
203 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) 215 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
@@ -213,8 +225,27 @@ namespace OpenSim.Tests.Common.Mock
213 { 225 {
214 } 226 }
215 227
216 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) 228 public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
217 { 229 {
230 m_log.DebugFormat(
231 "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}",
232 requestingAgentID, agentID, groupID, roleID);
233
234 XGroup group = GetXGroup(groupID, null);
235
236 if (group == null)
237 return;
238
239 XGroupMember groupMember = new XGroupMember()
240 {
241 agentID = agentID,
242 groupID = groupID,
243 roleID = roleID
244 };
245
246 group.members[agentID] = groupMember;
247
248 m_data.StoreGroup(group);
218 } 249 }
219 250
220 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) 251 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
@@ -259,9 +290,31 @@ namespace OpenSim.Tests.Common.Mock
259 return null; 290 return null;
260 } 291 }
261 292
262 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) 293 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID groupID)
263 { 294 {
264 return null; 295 m_log.DebugFormat(
296 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupMembers, requestingAgentID {0}, groupID {1}",
297 requestingAgentID, groupID);
298
299 List<GroupMembersData> groupMembers = new List<GroupMembersData>();
300
301 XGroup group = GetXGroup(groupID, null);
302
303 if (group == null)
304 return groupMembers;
305
306 foreach (XGroupMember xgm in group.members.Values)
307 {
308 GroupMembersData gmd = new GroupMembersData();
309 gmd.AgentID = xgm.agentID;
310 gmd.IsOwner = group.founderID == gmd.AgentID;
311 gmd.AcceptNotices = xgm.acceptNotices;
312 gmd.ListInProfile = xgm.listInProfile;
313
314 groupMembers.Add(gmd);
315 }
316
317 return groupMembers;
265 } 318 }
266 319
267 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) 320 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
@@ -269,18 +322,93 @@ namespace OpenSim.Tests.Common.Mock
269 return null; 322 return null;
270 } 323 }
271 324
272 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) 325 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID groupID)
273 { 326 {
274 return null; 327 XGroup group = GetXGroup(groupID, null);
328
329 if (group == null)
330 return null;
331
332 List<GroupNoticeData> notices = new List<GroupNoticeData>();
333
334 foreach (XGroupNotice notice in group.notices.Values)
335 {
336 GroupNoticeData gnd = new GroupNoticeData()
337 {
338 NoticeID = notice.noticeID,
339 Timestamp = notice.timestamp,
340 FromName = notice.fromName,
341 Subject = notice.subject,
342 HasAttachment = notice.hasAttachment,
343 AssetType = (byte)notice.assetType
344 };
345
346 notices.Add(gnd);
347 }
348
349 return notices;
275 } 350 }
276 351
277 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) 352 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
278 { 353 {
354 m_log.DebugFormat(
355 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupNotices, requestingAgentID {0}, noticeID {1}",
356 requestingAgentID, noticeID);
357
358 // Yes, not an efficient way to do it.
359 Dictionary<UUID, XGroup> groups = m_data.GetGroups();
360
361 foreach (XGroup group in groups.Values)
362 {
363 if (group.notices.ContainsKey(noticeID))
364 {
365 XGroupNotice n = group.notices[noticeID];
366
367 GroupNoticeInfo gni = new GroupNoticeInfo();
368 gni.GroupID = n.groupID;
369 gni.Message = n.message;
370 gni.BinaryBucket = n.binaryBucket;
371 gni.noticeData.NoticeID = n.noticeID;
372 gni.noticeData.Timestamp = n.timestamp;
373 gni.noticeData.FromName = n.fromName;
374 gni.noticeData.Subject = n.subject;
375 gni.noticeData.HasAttachment = n.hasAttachment;
376 gni.noticeData.AssetType = (byte)n.assetType;
377
378 return gni;
379 }
380 }
381
279 return null; 382 return null;
280 } 383 }
281 384
282 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) 385 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
283 { 386 {
387 m_log.DebugFormat(
388 "[MOCK GROUPS SERVICES CONNECTOR]: AddGroupNotice, requestingAgentID {0}, groupID {1}, noticeID {2}, fromName {3}, subject {4}, message {5}, binaryBucket.Length {6}",
389 requestingAgentID, groupID, noticeID, fromName, subject, message, binaryBucket.Length);
390
391 XGroup group = GetXGroup(groupID, null);
392
393 if (group == null)
394 return;
395
396 XGroupNotice groupNotice = new XGroupNotice()
397 {
398 groupID = groupID,
399 noticeID = noticeID,
400 fromName = fromName,
401 subject = subject,
402 message = message,
403 timestamp = (uint)Util.UnixTimeSinceEpoch(),
404 hasAttachment = false,
405 assetType = 0,
406 binaryBucket = binaryBucket
407 };
408
409 group.notices[noticeID] = groupNotice;
410
411 m_data.StoreGroup(group);
284 } 412 }
285 413
286 public void ResetAgentGroupChatSessions(UUID agentID) 414 public void ResetAgentGroupChatSessions(UUID agentID)
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
index ed29c39..5df8e04 100644
--- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
@@ -69,11 +69,21 @@ namespace OpenSim.Data.Null
69 m_store.StoreTerrain(terrain, regionID); 69 m_store.StoreTerrain(terrain, regionID);
70 } 70 }
71 71
72 public void StoreTerrain(TerrainData terrain, UUID regionID)
73 {
74 m_store.StoreTerrain(terrain, regionID);
75 }
76
72 public double[,] LoadTerrain(UUID regionID) 77 public double[,] LoadTerrain(UUID regionID)
73 { 78 {
74 return m_store.LoadTerrain(regionID); 79 return m_store.LoadTerrain(regionID);
75 } 80 }
76 81
82 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
83 {
84 return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
85 }
86
77 public void StoreLandObject(ILandObject Parcel) 87 public void StoreLandObject(ILandObject Parcel)
78 { 88 {
79 m_store.StoreLandObject(Parcel); 89 m_store.StoreLandObject(Parcel);
@@ -154,7 +164,7 @@ namespace OpenSim.Data.Null
154 protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>(); 164 protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>();
155 protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems 165 protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems
156 = new Dictionary<UUID, ICollection<TaskInventoryItem>>(); 166 = new Dictionary<UUID, ICollection<TaskInventoryItem>>();
157 protected Dictionary<UUID, double[,]> m_terrains = new Dictionary<UUID, double[,]>(); 167 protected Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
158 protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>(); 168 protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>();
159 169
160 public void Initialise(string dbfile) 170 public void Initialise(string dbfile)
@@ -299,12 +309,17 @@ namespace OpenSim.Data.Null
299 return new List<SceneObjectGroup>(objects.Values); 309 return new List<SceneObjectGroup>(objects.Values);
300 } 310 }
301 311
302 public void StoreTerrain(double[,] ter, UUID regionID) 312 public void StoreTerrain(TerrainData ter, UUID regionID)
303 { 313 {
304 m_terrains[regionID] = ter; 314 m_terrains[regionID] = ter;
305 } 315 }
306 316
307 public double[,] LoadTerrain(UUID regionID) 317 public void StoreTerrain(double[,] ter, UUID regionID)
318 {
319 m_terrains[regionID] = new HeightmapTerrainData(ter);
320 }
321
322 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
308 { 323 {
309 if (m_terrains.ContainsKey(regionID)) 324 if (m_terrains.ContainsKey(regionID))
310 return m_terrains[regionID]; 325 return m_terrains[regionID];
@@ -312,6 +327,14 @@ namespace OpenSim.Data.Null
312 return null; 327 return null;
313 } 328 }
314 329
330 public double[,] LoadTerrain(UUID regionID)
331 {
332 if (m_terrains.ContainsKey(regionID))
333 return m_terrains[regionID].GetDoubles();
334 else
335 return null;
336 }
337
315 public void RemoveLandObject(UUID globalID) 338 public void RemoveLandObject(UUID globalID)
316 { 339 {
317 if (m_landData.ContainsKey(globalID)) 340 if (m_landData.ContainsKey(globalID))
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
new file mode 100644
index 0000000..d7a144c
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
@@ -0,0 +1,272 @@
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;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.ScriptEngine.Interfaces;
38using OpenSim.Region.ScriptEngine.Shared;
39
40namespace OpenSim.Tests.Common
41{
42 public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
43 {
44 public IConfigSource ConfigSource { get; private set; }
45
46 public IConfig Config { get; private set; }
47
48 private Scene m_scene;
49
50 /// <summary>
51 /// Expose posted events to tests.
52 /// </summary>
53 public Dictionary<UUID, List<EventParams>> PostedEvents { get; private set; }
54
55 /// <summary>
56 /// A very primitive way of hooking text cose to a posed event.
57 /// </summary>
58 /// <remarks>
59 /// May be replaced with something that uses more original code in the future.
60 /// </remarks>
61 public event Action<UUID, EventParams> PostEventHook;
62
63 public void Initialise(IConfigSource source)
64 {
65 ConfigSource = source;
66
67 // Can set later on if required
68 Config = new IniConfig("MockScriptEngine", ConfigSource);
69
70 PostedEvents = new Dictionary<UUID, List<EventParams>>();
71 }
72
73 public void Close()
74 {
75 }
76
77 public void AddRegion(Scene scene)
78 {
79 m_scene = scene;
80
81 m_scene.StackModuleInterface<IScriptModule>(this);
82 }
83
84 public void RemoveRegion(Scene scene)
85 {
86 }
87
88 public void RegionLoaded(Scene scene)
89 {
90 }
91
92 public string Name { get { return "Mock Script Engine"; } }
93 public string ScriptEngineName { get { return Name; } }
94
95 public Type ReplaceableInterface { get { return null; } }
96
97#pragma warning disable 0067
98 public event ScriptRemoved OnScriptRemoved;
99 public event ObjectRemoved OnObjectRemoved;
100#pragma warning restore 0067
101
102 public string GetXMLState (UUID itemID)
103 {
104 throw new System.NotImplementedException ();
105 }
106
107 public bool SetXMLState(UUID itemID, string xml)
108 {
109 throw new System.NotImplementedException ();
110 }
111
112 public bool PostScriptEvent(UUID itemID, string name, object[] args)
113 {
114// Console.WriteLine("Posting event {0} for {1}", name, itemID);
115
116 return PostScriptEvent(itemID, new EventParams(name, args, null));
117 }
118
119 public bool PostScriptEvent(UUID itemID, EventParams evParams)
120 {
121 List<EventParams> eventsForItem;
122
123 if (!PostedEvents.ContainsKey(itemID))
124 {
125 eventsForItem = new List<EventParams>();
126 PostedEvents.Add(itemID, eventsForItem);
127 }
128 else
129 {
130 eventsForItem = PostedEvents[itemID];
131 }
132
133 eventsForItem.Add(evParams);
134
135 if (PostEventHook != null)
136 PostEventHook(itemID, evParams);
137
138 return true;
139 }
140
141 public bool PostObjectEvent(uint localID, EventParams evParams)
142 {
143 return PostObjectEvent(m_scene.GetSceneObjectPart(localID), evParams);
144 }
145
146 public bool PostObjectEvent(UUID itemID, string name, object[] args)
147 {
148 return PostObjectEvent(m_scene.GetSceneObjectPart(itemID), new EventParams(name, args, null));
149 }
150
151 private bool PostObjectEvent(SceneObjectPart part, EventParams evParams)
152 {
153 foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems(InventoryType.LSL))
154 PostScriptEvent(item.ItemID, evParams);
155
156 return true;
157 }
158
159 public void SuspendScript(UUID itemID)
160 {
161 throw new System.NotImplementedException ();
162 }
163
164 public void ResumeScript(UUID itemID)
165 {
166 throw new System.NotImplementedException ();
167 }
168
169 public ArrayList GetScriptErrors(UUID itemID)
170 {
171 throw new System.NotImplementedException ();
172 }
173
174 public bool HasScript(UUID itemID, out bool running)
175 {
176 throw new System.NotImplementedException ();
177 }
178
179 public bool GetScriptState(UUID itemID)
180 {
181 throw new System.NotImplementedException ();
182 }
183
184 public void SaveAllState()
185 {
186 throw new System.NotImplementedException ();
187 }
188
189 public void StartProcessing()
190 {
191 throw new System.NotImplementedException ();
192 }
193
194 public float GetScriptExecutionTime(List<UUID> itemIDs)
195 {
196 throw new System.NotImplementedException ();
197 }
198
199 public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
200 {
201 throw new System.NotImplementedException ();
202 }
203
204 public IScriptWorkItem QueueEventHandler(object parms)
205 {
206 throw new System.NotImplementedException ();
207 }
208
209 public DetectParams GetDetectParams(UUID item, int number)
210 {
211 throw new System.NotImplementedException ();
212 }
213
214 public void SetMinEventDelay(UUID itemID, double delay)
215 {
216 throw new System.NotImplementedException ();
217 }
218
219 public int GetStartParameter(UUID itemID)
220 {
221 throw new System.NotImplementedException ();
222 }
223
224 public void SetScriptState(UUID itemID, bool state)
225 {
226 throw new System.NotImplementedException ();
227 }
228
229 public void SetState(UUID itemID, string newState)
230 {
231 throw new System.NotImplementedException ();
232 }
233
234 public void ApiResetScript(UUID itemID)
235 {
236 throw new System.NotImplementedException ();
237 }
238
239 public void ResetScript (UUID itemID)
240 {
241 throw new System.NotImplementedException ();
242 }
243
244 public IScriptApi GetApi(UUID itemID, string name)
245 {
246 throw new System.NotImplementedException ();
247 }
248
249 public Scene World { get { return m_scene; } }
250
251 public IScriptModule ScriptModule { get { return this; } }
252
253 public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
254
255 public string ScriptClassName { get { throw new System.NotImplementedException (); } }
256
257 public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } }
258
259 public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
260
261 public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
262
263 public void ClearPostedEvents()
264 {
265 PostedEvents.Clear();
266 }
267
268 public void SleepScript(UUID itemID, int delay)
269 {
270 }
271 }
272}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index dde37ab..0e1bc8f 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -38,7 +38,7 @@ using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Framework.Client; 39using OpenSim.Framework.Client;
40 40
41namespace OpenSim.Tests.Common.Mock 41namespace OpenSim.Tests.Common
42{ 42{
43 public class TestClient : IClientAPI, IClientCore 43 public class TestClient : IClientAPI, IClientCore
44 { 44 {
@@ -46,12 +46,10 @@ namespace OpenSim.Tests.Common.Mock
46 46
47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); 47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
48 48
49 private TestClient TeleportSceneClient;
50
51 private Scene m_scene; 49 private Scene m_scene;
52 private SceneManager m_sceneManager;
53 50
54 // Properties so that we can get at received data for test purposes 51 // Properties so that we can get at received data for test purposes
52 public List<uint> ReceivedKills { get; private set; }
55 public List<UUID> ReceivedOfflineNotifications { get; private set; } 53 public List<UUID> ReceivedOfflineNotifications { get; private set; }
56 public List<UUID> ReceivedOnlineNotifications { get; private set; } 54 public List<UUID> ReceivedOnlineNotifications { get; private set; }
57 public List<UUID> ReceivedFriendshipTerminations { get; private set; } 55 public List<UUID> ReceivedFriendshipTerminations { get; private set; }
@@ -60,6 +58,27 @@ namespace OpenSim.Tests.Common.Mock
60 public List<ImagePacketPacket> SentImagePacketPackets { get; private set; } 58 public List<ImagePacketPacket> SentImagePacketPackets { get; private set; }
61 public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; } 59 public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; }
62 60
61 // Test client specific events - for use by tests to implement some IClientAPI behaviour.
62 public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion;
63 public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour;
64 public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport;
65
66 public event Action<ISceneEntity, PrimUpdateFlags> OnReceivedEntityUpdate;
67
68 public event OnReceivedChatMessageDelegate OnReceivedChatMessage;
69 public event Action<GridInstantMessage> OnReceivedInstantMessage;
70
71 public event Action<UUID> OnReceivedSendRebakeAvatarTextures;
72
73 public delegate void TestClientOnSendRegionTeleportDelegate(
74 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
75 uint locationID, uint flags, string capsURL);
76
77 public delegate void OnReceivedChatMessageDelegate(
78 string message, byte type, Vector3 fromPos, string fromName,
79 UUID fromAgentID, UUID ownerID, byte source, byte audible);
80
81
63// disable warning: public events, part of the public API 82// disable warning: public events, part of the public API
64#pragma warning disable 67 83#pragma warning disable 67
65 84
@@ -103,6 +122,7 @@ namespace OpenSim.Tests.Common.Mock
103 public event Action<IClientAPI, bool> OnCompleteMovementToRegion; 122 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
104 public event UpdateAgent OnPreAgentUpdate; 123 public event UpdateAgent OnPreAgentUpdate;
105 public event UpdateAgent OnAgentUpdate; 124 public event UpdateAgent OnAgentUpdate;
125 public event UpdateAgent OnAgentCameraUpdate;
106 public event AgentRequestSit OnAgentRequestSit; 126 public event AgentRequestSit OnAgentRequestSit;
107 public event AgentSit OnAgentSit; 127 public event AgentSit OnAgentSit;
108 public event AvatarPickerRequest OnAvatarPickerRequest; 128 public event AvatarPickerRequest OnAvatarPickerRequest;
@@ -193,6 +213,7 @@ namespace OpenSim.Tests.Common.Mock
193 public event EstateCovenantRequest OnEstateCovenantRequest; 213 public event EstateCovenantRequest OnEstateCovenantRequest;
194 public event EstateChangeInfo OnEstateChangeInfo; 214 public event EstateChangeInfo OnEstateChangeInfo;
195 public event EstateManageTelehub OnEstateManageTelehub; 215 public event EstateManageTelehub OnEstateManageTelehub;
216 public event CachedTextureRequest OnCachedTextureRequest;
196 217
197 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; 218 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
198 219
@@ -430,33 +451,21 @@ namespace OpenSim.Tests.Common.Mock
430 /// <summary> 451 /// <summary>
431 /// Constructor 452 /// Constructor
432 /// </summary> 453 /// </summary>
433 /// <remarks>
434 /// Can be used for a test where there is only one region or where there are multiple regions that are not
435 /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a
436 /// scene manager should be used.
437 /// </remarks>
438 /// <param name="agentData"></param>
439 /// <param name="scene"></param>
440 public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {}
441
442 /// <summary>
443 /// Constructor
444 /// </summary>
445 /// <param name="agentData"></param> 454 /// <param name="agentData"></param>
446 /// <param name="scene"></param> 455 /// <param name="scene"></param>
447 /// <param name="sceneManager"></param> 456 /// <param name="sceneManager"></param>
448 public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager) 457 public TestClient(AgentCircuitData agentData, Scene scene)
449 { 458 {
450 m_agentId = agentData.AgentID; 459 m_agentId = agentData.AgentID;
451 m_firstName = agentData.firstname; 460 m_firstName = agentData.firstname;
452 m_lastName = agentData.lastname; 461 m_lastName = agentData.lastname;
453 m_circuitCode = agentData.circuitcode; 462 m_circuitCode = agentData.circuitcode;
454 m_scene = scene; 463 m_scene = scene;
455 m_sceneManager = sceneManager;
456 SessionId = agentData.SessionID; 464 SessionId = agentData.SessionID;
457 SecureSessionId = agentData.SecureSessionID; 465 SecureSessionId = agentData.SecureSessionID;
458 CapsSeedUrl = agentData.CapsPath; 466 CapsSeedUrl = agentData.CapsPath;
459 467
468 ReceivedKills = new List<uint>();
460 ReceivedOfflineNotifications = new List<UUID>(); 469 ReceivedOfflineNotifications = new List<UUID>();
461 ReceivedOnlineNotifications = new List<UUID>(); 470 ReceivedOnlineNotifications = new List<UUID>();
462 ReceivedFriendshipTerminations = new List<UUID>(); 471 ReceivedFriendshipTerminations = new List<UUID>();
@@ -467,6 +476,34 @@ namespace OpenSim.Tests.Common.Mock
467 } 476 }
468 477
469 /// <summary> 478 /// <summary>
479 /// Trigger chat coming from this connection.
480 /// </summary>
481 /// <param name="channel"></param>
482 /// <param name="type"></param>
483 /// <param name="message"></param>
484 public bool Chat(int channel, ChatTypeEnum type, string message)
485 {
486 ChatMessage handlerChatFromClient = OnChatFromClient;
487
488 if (handlerChatFromClient != null)
489 {
490 OSChatMessage args = new OSChatMessage();
491 args.Channel = channel;
492 args.From = Name;
493 args.Message = message;
494 args.Type = type;
495
496 args.Scene = Scene;
497 args.Sender = this;
498 args.SenderUUID = AgentId;
499
500 handlerChatFromClient(this, args);
501 }
502
503 return true;
504 }
505
506 /// <summary>
470 /// Attempt a teleport to the given region. 507 /// Attempt a teleport to the given region.
471 /// </summary> 508 /// </summary>
472 /// <param name="regionHandle"></param> 509 /// <param name="regionHandle"></param>
@@ -479,7 +516,20 @@ namespace OpenSim.Tests.Common.Mock
479 516
480 public void CompleteMovement() 517 public void CompleteMovement()
481 { 518 {
482 OnCompleteMovementToRegion(this, true); 519 if (OnCompleteMovementToRegion != null)
520 OnCompleteMovementToRegion(this, true);
521 }
522
523 /// <summary>
524 /// Emulate sending an IM from the viewer to the simulator.
525 /// </summary>
526 /// <param name='im'></param>
527 public void HandleImprovedInstantMessage(GridInstantMessage im)
528 {
529 ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
530
531 if (handlerInstantMessage != null)
532 handlerInstantMessage(this, im);
483 } 533 }
484 534
485 public virtual void ActivateGesture(UUID assetId, UUID gestureId) 535 public virtual void ActivateGesture(UUID assetId, UUID gestureId)
@@ -494,6 +544,11 @@ namespace OpenSim.Tests.Common.Mock
494 { 544 {
495 } 545 }
496 546
547 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
548 {
549
550 }
551
497 public virtual void Kick(string message) 552 public virtual void Kick(string message)
498 { 553 {
499 } 554 }
@@ -508,22 +563,22 @@ namespace OpenSim.Tests.Common.Mock
508 563
509 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) 564 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
510 { 565 {
511
512 } 566 }
513 567
514 public virtual void SendKillObject(ulong regionHandle, List<uint> localID) 568 public virtual void SendKillObject(List<uint> localID)
515 { 569 {
570 ReceivedKills.AddRange(localID);
516 } 571 }
517 572
518 public virtual void SetChildAgentThrottle(byte[] throttle) 573 public virtual void SetChildAgentThrottle(byte[] throttle)
519 { 574 {
520 } 575 }
576
521 public byte[] GetThrottlesPacked(float multiplier) 577 public byte[] GetThrottlesPacked(float multiplier)
522 { 578 {
523 return new byte[0]; 579 return new byte[0];
524 } 580 }
525 581
526
527 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) 582 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
528 { 583 {
529 } 584 }
@@ -532,19 +587,23 @@ namespace OpenSim.Tests.Common.Mock
532 string message, byte type, Vector3 fromPos, string fromName, 587 string message, byte type, Vector3 fromPos, string fromName,
533 UUID fromAgentID, UUID ownerID, byte source, byte audible) 588 UUID fromAgentID, UUID ownerID, byte source, byte audible)
534 { 589 {
590// Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId);
591 if (OnReceivedChatMessage != null)
592 OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible);
535 } 593 }
536 594
537 public void SendInstantMessage(GridInstantMessage im) 595 public void SendInstantMessage(GridInstantMessage im)
538 { 596 {
539 597 if (OnReceivedInstantMessage != null)
598 OnReceivedInstantMessage(im);
540 } 599 }
541 600
542 public void SendGenericMessage(string method, List<string> message) 601 public void SendGenericMessage(string method, UUID invoice, List<string> message)
543 { 602 {
544 603
545 } 604 }
546 605
547 public void SendGenericMessage(string method, List<byte[]> message) 606 public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
548 { 607 {
549 608
550 } 609 }
@@ -566,13 +625,15 @@ namespace OpenSim.Tests.Common.Mock
566 625
567 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 626 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
568 { 627 {
628 if (OnReceivedMoveAgentIntoRegion != null)
629 OnReceivedMoveAgentIntoRegion(regInfo, pos, look);
569 } 630 }
570 631
571 public virtual AgentCircuitData RequestClientInfo() 632 public virtual AgentCircuitData RequestClientInfo()
572 { 633 {
573 AgentCircuitData agentData = new AgentCircuitData(); 634 AgentCircuitData agentData = new AgentCircuitData();
574 agentData.AgentID = AgentId; 635 agentData.AgentID = AgentId;
575 agentData.SessionID = UUID.Zero; 636 agentData.SessionID = SessionId;
576 agentData.SecureSessionID = UUID.Zero; 637 agentData.SecureSessionID = UUID.Zero;
577 agentData.circuitcode = m_circuitCode; 638 agentData.circuitcode = m_circuitCode;
578 agentData.child = false; 639 agentData.child = false;
@@ -591,46 +652,29 @@ namespace OpenSim.Tests.Common.Mock
591 652
592 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) 653 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
593 { 654 {
594 m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); 655 if (OnTestClientInformClientOfNeighbour != null)
595 656 OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint);
596 // In response to this message, we are going to make a teleport to the scene we've previous been told
597 // about by test code (this needs to be improved).
598 AgentCircuitData newAgent = RequestClientInfo();
599
600 // Stage 2: add the new client as a child agent to the scene
601 uint x, y;
602 Utils.LongToUInts(neighbourHandle, out x, out y);
603 x /= Constants.RegionSize;
604 y /= Constants.RegionSize;
605
606 Scene neighbourScene;
607 m_sceneManager.TryGetScene(x, y, out neighbourScene);
608
609 TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager);
610 neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User);
611 } 657 }
612 658
613 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, 659 public virtual void SendRegionTeleport(
614 uint locationID, uint flags, string capsURL) 660 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
661 uint locationID, uint flags, string capsURL)
615 { 662 {
616 m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport"); 663 m_log.DebugFormat(
664 "[TEST CLIENT]: Received SendRegionTeleport for {0} {1} on {2}", m_firstName, m_lastName, m_scene.Name);
617 665
618 CapsSeedUrl = capsURL; 666 CapsSeedUrl = capsURL;
619 667
620 // We don't do this here so that the source region can complete processing first in a single-threaded 668 if (OnTestClientSendRegionTeleport != null)
621 // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport 669 OnTestClientSendRegionTeleport(
622 // CompleteTeleportClientSide(); 670 regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
623 }
624
625 public void CompleteTeleportClientSide()
626 {
627 TeleportSceneClient.CompleteMovement();
628 //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false);
629 } 671 }
630 672
631 public virtual void SendTeleportFailed(string reason) 673 public virtual void SendTeleportFailed(string reason)
632 { 674 {
633 m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); 675 m_log.DebugFormat(
676 "[TEST CLIENT]: Teleport failed for {0} {1} on {2} with reason {3}",
677 m_firstName, m_lastName, m_scene.Name, reason);
634 } 678 }
635 679
636 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, 680 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,
@@ -660,7 +704,7 @@ namespace OpenSim.Tests.Common.Mock
660 { 704 {
661 } 705 }
662 706
663 public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance) 707 public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
664 { 708 {
665 } 709 }
666 710
@@ -682,6 +726,8 @@ namespace OpenSim.Tests.Common.Mock
682 726
683 public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 727 public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
684 { 728 {
729 if (OnReceivedEntityUpdate != null)
730 OnReceivedEntityUpdate(entity, updateFlags);
685 } 731 }
686 732
687 public void ReprioritizeUpdates() 733 public void ReprioritizeUpdates()
@@ -786,11 +832,6 @@ namespace OpenSim.Tests.Common.Mock
786 { 832 {
787 OnRegionHandShakeReply(this); 833 OnRegionHandShakeReply(this);
788 } 834 }
789
790 if (OnCompleteMovementToRegion != null)
791 {
792 OnCompleteMovementToRegion(this, true);
793 }
794 } 835 }
795 836
796 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 837 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
@@ -884,11 +925,6 @@ namespace OpenSim.Tests.Common.Mock
884 925
885 } 926 }
886 927
887 public bool AddMoney(int debit)
888 {
889 return false;
890 }
891
892 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) 928 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
893 { 929 {
894 } 930 }
@@ -1235,6 +1271,8 @@ namespace OpenSim.Tests.Common.Mock
1235 1271
1236 public void SendRebakeAvatarTextures(UUID textureID) 1272 public void SendRebakeAvatarTextures(UUID textureID)
1237 { 1273 {
1274 if (OnReceivedSendRebakeAvatarTextures != null)
1275 OnReceivedSendRebakeAvatarTextures(textureID);
1238 } 1276 }
1239 1277
1240 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) 1278 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
@@ -1269,12 +1307,17 @@ namespace OpenSim.Tests.Common.Mock
1269 { 1307 {
1270 } 1308 }
1271 1309
1272 public void StopFlying(ISceneEntity presence) 1310 public void SendAgentTerseUpdate(ISceneEntity presence)
1273 { 1311 {
1274 } 1312 }
1275 1313
1276 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) 1314 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
1277 { 1315 {
1278 } 1316 }
1317
1318 public void SendPartPhysicsProprieties(ISceneEntity entity)
1319 {
1320 }
1321
1279 } 1322 }
1280} 1323}
diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
new file mode 100644
index 0000000..f2bae58
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
@@ -0,0 +1,182 @@
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;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Threading;
34using log4net;
35using Nini.Config;
36using Mono.Addins;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers;
41using OpenSim.Region.ClientStack.Linden;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44
45namespace OpenSim.Tests.Common
46{
47 public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule
48 {
49 public class Event
50 {
51 public string Name { get; set; }
52 public object[] Args { get; set; }
53
54 public Event(string name, object[] args)
55 {
56 name = Name;
57 args = Args;
58 }
59 }
60
61 public Dictionary<UUID, List<Event>> Events { get; set; }
62
63 public void Initialise(IConfigSource source) {}
64
65 public void Close() {}
66
67 public void AddRegion(Scene scene)
68 {
69 Events = new Dictionary<UUID, List<Event>>();
70 scene.RegisterModuleInterface<IEventQueue>(this);
71 }
72
73 public void RemoveRegion (Scene scene) {}
74
75 public void RegionLoaded (Scene scene) {}
76
77 public string Name { get { return "TestEventQueueGetModule"; } }
78
79 public Type ReplaceableInterface { get { return null; } }
80
81 private void AddEvent(UUID avatarID, string name, params object[] args)
82 {
83 Console.WriteLine("Adding event {0} for {1}", name, avatarID);
84
85 List<Event> avEvents;
86
87 if (!Events.ContainsKey(avatarID))
88 {
89 avEvents = new List<Event>();
90 Events[avatarID] = avEvents;
91 }
92 else
93 {
94 avEvents = Events[avatarID];
95 }
96
97 avEvents.Add(new Event(name, args));
98 }
99
100 public void ClearEvents()
101 {
102 if (Events != null)
103 Events.Clear();
104 }
105
106 public bool Enqueue(OSD o, UUID avatarID)
107 {
108 AddEvent(avatarID, "Enqueue", o);
109 return true;
110 }
111
112 public void DisableSimulator(ulong handle, UUID avatarID)
113 {
114 AddEvent(avatarID, "DisableSimulator", handle);
115 }
116
117 public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
118 {
119 AddEvent(avatarID, "EnableSimulator", handle);
120 }
121
122 public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath,
123 ulong regionHandle, int regionSizeX, int regionSizeY)
124 {
125 AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
126 }
127
128 public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
129 uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY)
130 {
131 AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
132 }
133
134 public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint,
135 string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
136 {
137 AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
138 }
139
140 public void ChatterboxInvitation(
141 UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
142 byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
143 UUID transactionID, bool fromGroup, byte[] binaryBucket)
144 {
145 AddEvent(
146 toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
147 timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
148 }
149
150 public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute)
151 {
152 AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute);
153 }
154
155 public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
156 {
157 AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
158 }
159
160 public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID)
161 {
162 AddEvent(avatarID, "GroupMembership", groupUpdate);
163 }
164
165 public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono)
166 {
167 Console.WriteLine("ONE");
168 throw new System.NotImplementedException ();
169 }
170
171 public OSD BuildEvent(string eventName, OSD eventBody)
172 {
173 Console.WriteLine("TWO");
174 throw new System.NotImplementedException ();
175 }
176
177 public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
178 {
179 AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
180 }
181 }
182} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs b/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs
new file mode 100644
index 0000000..5a55b09
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs
@@ -0,0 +1,110 @@
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.Net.Sockets;
33using System.Text;
34using HttpServer;
35using OpenSim.Framework;
36
37namespace OpenSim.Tests.Common
38{
39 public class TestHttpClientContext: IHttpClientContext
40 {
41 /// <summary>
42 /// Bodies of responses from the server.
43 /// </summary>
44 public string ResponseBody
45 {
46 get { return Encoding.UTF8.GetString(m_responseStream.ToArray()); }
47 }
48
49 public Byte[] ResponseBodyBytes
50 {
51 get{ return m_responseStream.ToArray(); }
52 }
53
54 private MemoryStream m_responseStream = new MemoryStream();
55
56 public bool IsSecured { get; set; }
57
58 public bool Secured
59 {
60 get { return IsSecured; }
61 set { IsSecured = value; }
62 }
63
64 public TestHttpClientContext(bool secured)
65 {
66 Secured = secured;
67 }
68
69 public void Disconnect(SocketError error)
70 {
71// Console.WriteLine("TestHttpClientContext.Disconnect Received disconnect with status {0}", error);
72 }
73
74 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body) {Console.WriteLine("x");}
75 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) {Console.WriteLine("xx");}
76 public void Respond(string body) { Console.WriteLine("xxx");}
77
78 public void Send(byte[] buffer)
79 {
80 // Getting header data here
81// Console.WriteLine("xxxx: Got {0}", Encoding.UTF8.GetString(buffer));
82 }
83
84 public void Send(byte[] buffer, int offset, int size)
85 {
86// Util.PrintCallStack();
87//
88// Console.WriteLine(
89// "TestHttpClientContext.Send(byte[], int, int) got offset={0}, size={1}, buffer={2}",
90// offset, size, Encoding.UTF8.GetString(buffer));
91
92 m_responseStream.Write(buffer, offset, size);
93 }
94
95 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {Console.WriteLine("xxxxxx");}
96 public void Close() { }
97 public bool EndWhenDone { get { return false;} set { return;}}
98
99 public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing()
100 {
101 return new HTTPNetworkContext();
102 }
103
104 public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { };
105 /// <summary>
106 /// A request have been received in the context.
107 /// </summary>
108 public event EventHandler<RequestEventArgs> RequestReceived = delegate { };
109 }
110} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs
new file mode 100644
index 0000000..b868895
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs
@@ -0,0 +1,174 @@
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.Specialized;
30using System.IO;
31using HttpServer;
32using HttpServer.FormDecoders;
33
34namespace OpenSim.Tests.Common
35{
36 public class TestHttpRequest: IHttpRequest
37 {
38 private string _uriPath;
39 public bool BodyIsComplete
40 {
41 get { return true; }
42 }
43 public string[] AcceptTypes
44 {
45 get {return _acceptTypes; }
46 }
47 private string[] _acceptTypes;
48 public Stream Body
49 {
50 get { return _body; }
51 set { _body = value;}
52 }
53 private Stream _body;
54 public ConnectionType Connection
55 {
56 get { return _connection; }
57 set { _connection = value; }
58 }
59 private ConnectionType _connection;
60 public int ContentLength
61 {
62 get { return _contentLength; }
63 set { _contentLength = value; }
64 }
65 private int _contentLength;
66 public NameValueCollection Headers
67 {
68 get { return _headers; }
69 }
70 private NameValueCollection _headers = new NameValueCollection();
71
72 public string HttpVersion { get; set; }
73
74 public string Method
75 {
76 get { return _method; }
77 set { _method = value; }
78 }
79 private string _method = null;
80 public HttpInput QueryString
81 {
82 get { return _queryString; }
83 }
84 private HttpInput _queryString = null;
85 public Uri Uri
86 {
87 get { return _uri; }
88 set { _uri = value; }
89 }
90 private Uri _uri = null;
91 public string[] UriParts
92 {
93 get { return _uri.Segments; }
94 }
95 public HttpParam Param
96 {
97 get { return null; }
98 }
99 public HttpForm Form
100 {
101 get { return null; }
102 }
103 public bool IsAjax
104 {
105 get { return false; }
106 }
107 public RequestCookies Cookies
108 {
109 get { return null; }
110 }
111
112 public TestHttpRequest()
113 {
114 HttpVersion = "HTTP/1.1";
115 }
116
117 public TestHttpRequest(string contentEncoding, string contentType, string userAgent,
118 string remoteAddr, string remotePort, string[] acceptTypes,
119 ConnectionType connectionType, int contentLength, Uri uri) : base()
120 {
121 _headers["content-encoding"] = contentEncoding;
122 _headers["content-type"] = contentType;
123 _headers["user-agent"] = userAgent;
124 _headers["remote_addr"] = remoteAddr;
125 _headers["remote_port"] = remotePort;
126
127 _acceptTypes = acceptTypes;
128 _connection = connectionType;
129 _contentLength = contentLength;
130 _uri = uri;
131 }
132
133 public void DecodeBody(FormDecoderProvider providers) {}
134 public void SetCookies(RequestCookies cookies) {}
135 public void AddHeader(string name, string value)
136 {
137 _headers.Add(name, value);
138 }
139 public int AddToBody(byte[] bytes, int offset, int length)
140 {
141 return 0;
142 }
143 public void Clear() {}
144
145 public object Clone()
146 {
147 TestHttpRequest clone = new TestHttpRequest();
148 clone._acceptTypes = _acceptTypes;
149 clone._connection = _connection;
150 clone._contentLength = _contentLength;
151 clone._uri = _uri;
152 clone._headers = new NameValueCollection(_headers);
153
154 return clone;
155 }
156 public IHttpResponse CreateResponse(IHttpClientContext context)
157 {
158 return new HttpResponse(context, this);
159 }
160 /// <summary>
161 /// Path and query (will be merged with the host header) and put in Uri
162 /// </summary>
163 /// <see cref="Uri"/>
164 public string UriPath
165 {
166 get { return _uriPath; }
167 set
168 {
169 _uriPath = value;
170
171 }
172 }
173 }
174} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs
new file mode 100644
index 0000000..ff47c10
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs
@@ -0,0 +1,171 @@
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.IO;
30using System.Net;
31using System.Text;
32using HttpServer;
33
34namespace OpenSim.Tests.Common
35{
36 public class TestHttpResponse: IHttpResponse
37 {
38 public Stream Body
39 {
40 get { return _body; }
41
42 set { _body = value; }
43 }
44 private Stream _body;
45
46 public string ProtocolVersion
47 {
48 get { return _protocolVersion; }
49 set { _protocolVersion = value; }
50 }
51 private string _protocolVersion;
52
53 public bool Chunked
54 {
55 get { return _chunked; }
56
57 set { _chunked = value; }
58 }
59 private bool _chunked;
60
61 public ConnectionType Connection
62 {
63 get { return _connection; }
64
65 set { _connection = value; }
66 }
67 private ConnectionType _connection;
68
69 public Encoding Encoding
70 {
71 get { return _encoding; }
72
73 set { _encoding = value; }
74 }
75 private Encoding _encoding;
76
77 public int KeepAlive
78 {
79 get { return _keepAlive; }
80
81 set { _keepAlive = value; }
82 }
83 private int _keepAlive;
84
85 public HttpStatusCode Status
86 {
87 get { return _status; }
88
89 set { _status = value; }
90 }
91 private HttpStatusCode _status;
92
93 public string Reason
94 {
95 get { return _reason; }
96
97 set { _reason = value; }
98 }
99 private string _reason;
100
101 public long ContentLength
102 {
103 get { return _contentLength; }
104
105 set { _contentLength = value; }
106 }
107 private long _contentLength;
108
109 public string ContentType
110 {
111 get { return _contentType; }
112
113 set { _contentType = value; }
114 }
115 private string _contentType;
116
117 public bool HeadersSent
118 {
119 get { return _headersSent; }
120 }
121 private bool _headersSent;
122
123 public bool Sent
124 {
125 get { return _sent; }
126 }
127 private bool _sent;
128
129 public ResponseCookies Cookies
130 {
131 get { return _cookies; }
132 }
133 private ResponseCookies _cookies = null;
134
135 public TestHttpResponse()
136 {
137 _headersSent = false;
138 _sent = false;
139 }
140
141 public void AddHeader(string name, string value) {}
142
143 public void Send()
144 {
145 if (!_headersSent) SendHeaders();
146 if (_sent) throw new InvalidOperationException("stuff already sent");
147 _sent = true;
148 }
149
150 public void SendBody(byte[] buffer, int offset, int count)
151 {
152 if (!_headersSent) SendHeaders();
153 _sent = true;
154 }
155
156 public void SendBody(byte[] buffer)
157 {
158 if (!_headersSent) SendHeaders();
159 _sent = true;
160 }
161
162 public void SendHeaders()
163 {
164 if (_headersSent) throw new InvalidOperationException("headers already sent");
165 _headersSent = true;
166 }
167
168 public void Redirect(Uri uri) {}
169 public void Redirect(string url) {}
170 }
171} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
index fc44358..c97a765 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
@@ -33,7 +33,7 @@ using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Data; 34using OpenSim.Data;
35 35
36namespace OpenSim.Tests.Common.Mock 36namespace OpenSim.Tests.Common
37{ 37{
38 /// <summary> 38 /// <summary>
39 /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the 39 /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the
@@ -185,7 +185,7 @@ namespace OpenSim.Tests.Common.Mock
185 185
186 public void addInventoryItem(InventoryItemBase item) 186 public void addInventoryItem(InventoryItemBase item)
187 { 187 {
188// InventoryFolderBase folder = m_folders[item.Folder]; 188 InventoryFolderBase folder = m_folders[item.Folder];
189 189
190// m_log.DebugFormat( 190// m_log.DebugFormat(
191// "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); 191// "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID);
diff --git a/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs
new file mode 100644
index 0000000..26887c9
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs
@@ -0,0 +1,171 @@
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.Net;
31using System.Net.Sockets;
32using Nini.Config;
33using OpenMetaverse.Packets;
34using OpenSim.Framework;
35using OpenSim.Region.ClientStack.LindenUDP;
36
37namespace OpenSim.Tests.Common
38{
39 /// <summary>
40 /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data.
41 /// </summary>
42 public class TestLLUDPServer : LLUDPServer
43 {
44 public List<Packet> PacketsSent { get; private set; }
45
46 public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
47 : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager)
48 {
49 PacketsSent = new List<Packet>();
50 }
51
52 public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
53 {
54 PacketsSent.Add(ack);
55 }
56
57 public override void SendPacket(
58 LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
59 {
60 PacketsSent.Add(packet);
61 }
62
63 public void ClientOutgoingPacketHandler(IClientAPI client, bool resendUnacked, bool sendAcks, bool sendPing)
64 {
65 m_resendUnacked = resendUnacked;
66 m_sendAcks = sendAcks;
67 m_sendPing = sendPing;
68
69 ClientOutgoingPacketHandler(client);
70 }
71
72//// /// <summary>
73//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
74//// /// </summary>
75//// protected Queue<ChunkSenderTuple> m_chunksToLoad = new Queue<ChunkSenderTuple>();
76//
77//// protected override void BeginReceive()
78//// {
79//// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
80//// {
81//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
82//// reusedEpSender = tuple.Sender;
83//// throw new SocketException();
84//// }
85//// }
86//
87//// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
88//// {
89//// numBytes = 0;
90////
91//// //m_log.Debug("Queue size " + m_chunksToLoad.Count);
92////
93//// if (m_chunksToLoad.Count <= 0)
94//// return false;
95////
96//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
97//// RecvBuffer = tuple.Data;
98//// numBytes = tuple.Data.Length;
99//// epSender = tuple.Sender;
100////
101//// return true;
102//// }
103//
104//// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
105//// {
106//// // Don't do anything just yet
107//// }
108//
109// /// <summary>
110// /// Signal that this chunk should throw an exception on Socket.BeginReceive()
111// /// </summary>
112// /// <param name="epSender"></param>
113// public void LoadReceiveWithBeginException(EndPoint epSender)
114// {
115// ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
116// tuple.BeginReceiveException = true;
117// m_chunksToLoad.Enqueue(tuple);
118// }
119//
120// /// <summary>
121// /// Load some data to be received by the LLUDPServer on the next receive call
122// /// </summary>
123// /// <param name="data"></param>
124// /// <param name="epSender"></param>
125// public void LoadReceive(byte[] data, EndPoint epSender)
126// {
127// m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
128// }
129//
130// /// <summary>
131// /// Load a packet to be received by the LLUDPServer on the next receive call
132// /// </summary>
133// /// <param name="packet"></param>
134// public void LoadReceive(Packet packet, EndPoint epSender)
135// {
136// LoadReceive(packet.ToBytes(), epSender);
137// }
138//
139// /// <summary>
140// /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
141// /// </summary>
142// /// <param name="result"></param>
143// public void ReceiveData(IAsyncResult result)
144// {
145// // Doesn't work the same way anymore
146//// while (m_chunksToLoad.Count > 0)
147//// OnReceivedData(result);
148// }
149 }
150
151 /// <summary>
152 /// Record the data and sender tuple
153 /// </summary>
154 public class ChunkSenderTuple
155 {
156 public byte[] Data;
157 public EndPoint Sender;
158 public bool BeginReceiveException;
159
160 public ChunkSenderTuple(byte[] data, EndPoint sender)
161 {
162 Data = data;
163 Sender = sender;
164 }
165
166 public ChunkSenderTuple(EndPoint sender)
167 {
168 Sender = sender;
169 }
170 }
171}
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
index 4b4d52d..89ebcd5 100644
--- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs
+++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs
@@ -32,7 +32,7 @@ using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes; 32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.CoreModules.World.Land; 33using OpenSim.Region.CoreModules.World.Land;
34 34
35namespace OpenSim.Tests.Common.Mock 35namespace OpenSim.Tests.Common
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// Land channel for test purposes 38 /// Land channel for test purposes
@@ -81,6 +81,11 @@ namespace OpenSim.Tests.Common.Mock
81 return obj; 81 return obj;
82 } 82 }
83 83
84 public ILandObject GetLandObject(Vector3 position)
85 {
86 return GetLandObject(position.X, position.Y);
87 }
88
84 public ILandObject GetLandObject(int x, int y) 89 public ILandObject GetLandObject(int x, int y)
85 { 90 {
86 return GetNoLand(); 91 return GetNoLand();
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs
index e769d30..7b1d2b5 100644
--- a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs
+++ b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs
@@ -35,7 +35,7 @@ using System.Text;
35using System.Web; 35using System.Web;
36using OpenSim.Framework.Servers.HttpServer; 36using OpenSim.Framework.Servers.HttpServer;
37 37
38namespace OpenSim.Tests.Common.Mock 38namespace OpenSim.Tests.Common
39{ 39{
40 public class TestOSHttpRequest : IOSHttpRequest 40 public class TestOSHttpRequest : IOSHttpRequest
41 { 41 {
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs
index e10fe82..2e17f1e 100644
--- a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs
+++ b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs
@@ -32,7 +32,7 @@ using System.Text;
32using System.Web; 32using System.Web;
33using OpenSim.Framework.Servers.HttpServer; 33using OpenSim.Framework.Servers.HttpServer;
34 34
35namespace OpenSim.Tests.Common.Mock 35namespace OpenSim.Tests.Common
36{ 36{
37 public class TestOSHttpResponse : IOSHttpResponse 37 public class TestOSHttpResponse : IOSHttpResponse
38 { 38 {
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index d4b5648..1a93c9f 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -28,23 +28,24 @@
28using System; 28using System;
29using Nini.Config; 29using Nini.Config;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Framework.Communications; 31
32using OpenSim.Framework.Servers; 32using OpenSim.Framework.Servers;
33using OpenSim.Region.Framework; 33using OpenSim.Region.Framework;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.PhysicsModules.SharedBase;
37using OpenSim.Services.Interfaces;
36 38
37namespace OpenSim.Tests.Common.Mock 39namespace OpenSim.Tests.Common
38{ 40{
39 public class TestScene : Scene 41 public class TestScene : Scene
40 { 42 {
41 public TestScene( 43 public TestScene(
42 RegionInfo regInfo, AgentCircuitManager authen, 44 RegionInfo regInfo, AgentCircuitManager authen,
43 SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, 45 ISimulationDataService simDataService, IEstateDataService estateDataService,
44 bool dumpAssetsToFile,
45 IConfigSource config, string simulatorVersion) 46 IConfigSource config, string simulatorVersion)
46 : base(regInfo, authen, sceneGridService, simDataService, estateDataService, 47 : base(regInfo, authen, simDataService, estateDataService,
47 dumpAssetsToFile, config, simulatorVersion) 48 config, simulatorVersion)
48 { 49 {
49 } 50 }
50 51
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
index ccbdf81..2b272e6 100644
--- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
@@ -35,7 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Data; 35using OpenSim.Data;
36using OpenSim.Data.Null; 36using OpenSim.Data.Null;
37 37
38namespace OpenSim.Tests.Common.Mock 38namespace OpenSim.Tests.Common
39{ 39{
40 public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData 40 public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData
41 { 41 {
@@ -46,17 +46,33 @@ namespace OpenSim.Tests.Common.Mock
46 46
47 public XInventoryItem[] GetItems(string[] fields, string[] vals) 47 public XInventoryItem[] GetItems(string[] fields, string[] vals)
48 { 48 {
49// Console.WriteLine(
50// "Requesting items, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals));
51
49 List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList()); 52 List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList());
50 53
51 return origItems.Select(i => i.Clone()).ToArray(); 54 XInventoryItem[] items = origItems.Select(i => i.Clone()).ToArray();
55
56// Console.WriteLine("Found {0} items", items.Length);
57// Array.ForEach(items, i => Console.WriteLine("Found item {0} {1}", i.inventoryName, i.inventoryID));
58
59 return items;
52 } 60 }
53 61
54 public XInventoryFolder[] GetFolders(string[] fields, string[] vals) 62 public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
55 { 63 {
64// Console.WriteLine(
65// "Requesting folders, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals));
66
56 List<XInventoryFolder> origFolders 67 List<XInventoryFolder> origFolders
57 = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); 68 = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList());
58 69
59 return origFolders.Select(f => f.Clone()).ToArray(); 70 XInventoryFolder[] folders = origFolders.Select(f => f.Clone()).ToArray();
71
72// Console.WriteLine("Found {0} folders", folders.Length);
73// Array.ForEach(folders, f => Console.WriteLine("Found folder {0} {1}", f.folderName, f.folderID));
74
75 return folders;
60 } 76 }
61 77
62 public bool StoreFolder(XInventoryFolder folder) 78 public bool StoreFolder(XInventoryFolder folder)
@@ -72,7 +88,9 @@ namespace OpenSim.Tests.Common.Mock
72 { 88 {
73 m_allItems[item.inventoryID] = item.Clone(); 89 m_allItems[item.inventoryID] = item.Clone();
74 90
75// Console.WriteLine("Added item {0} {1}, creator {2}, owner {3}", item.inventoryName, item.inventoryID, item.creatorID, item.avatarID); 91// Console.WriteLine(
92// "Added item {0} {1}, folder {2}, creator {3}, owner {4}",
93// item.inventoryName, item.inventoryID, item.parentFolderID, item.creatorID, item.avatarID);
76 94
77 return true; 95 return true;
78 } 96 }
@@ -104,7 +122,30 @@ namespace OpenSim.Tests.Common.Mock
104 } 122 }
105 123
106 public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } 124 public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); }
107 public bool MoveFolder(string id, string newParent) { throw new NotImplementedException(); } 125
126 public bool MoveFolder(string id, string newParent)
127 {
128 // Don't use GetFolders() here - it takes a clone!
129 XInventoryFolder folder = m_allFolders[new UUID(id)];
130
131 if (folder == null)
132 return false;
133
134 folder.parentFolderID = new UUID(newParent);
135
136// XInventoryFolder[] newParentFolders
137// = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() });
138
139// Console.WriteLine(
140// "Moved folder {0} {1}, to {2} {3}",
141// folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID);
142
143 // TODO: Really need to implement folder version incrementing, though this should be common code anyway,
144 // not reimplemented in each db plugin.
145
146 return true;
147 }
148
108 public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } 149 public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); }
109 public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } 150 public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); }
110 } 151 }
diff --git a/OpenSim/Tests/Common/OpenSimTestCase.cs b/OpenSim/Tests/Common/OpenSimTestCase.cs
index 8c40923..9fea348 100644
--- a/OpenSim/Tests/Common/OpenSimTestCase.cs
+++ b/OpenSim/Tests/Common/OpenSimTestCase.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenSim.Framework;
31using OpenSim.Framework.Servers;
30 32
31namespace OpenSim.Tests.Common 33namespace OpenSim.Tests.Common
32{ 34{
@@ -36,11 +38,18 @@ namespace OpenSim.Tests.Common
36 [SetUp] 38 [SetUp]
37 public virtual void SetUp() 39 public virtual void SetUp()
38 { 40 {
39// TestHelpers.InMethod(); 41 //TestHelpers.InMethod();
40 // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests 42 // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests
41 // to have logging on if it failed with an exception. 43 // to have logging on if it failed with an exception.
42 TestHelpers.DisableLogging(); 44 TestHelpers.DisableLogging();
45
46 // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
47 // variables and the VM is not restarted between tests.
48 if (MainServer.Instance != null)
49 {
50 MainServer.RemoveHttpServer(MainServer.Instance.Port);
51// MainServer.Instance = null;
52 }
43 } 53 }
44 } 54 }
45} 55} \ No newline at end of file
46
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs
index 57da802..6bf23f8 100644
--- a/OpenSim/Tests/Common/TestHelpers.cs
+++ b/OpenSim/Tests/Common/TestHelpers.cs
@@ -114,6 +114,25 @@ namespace OpenSim.Tests.Common
114 } 114 }
115 115
116 /// <summary> 116 /// <summary>
117 /// Parse a UUID stem into a full UUID.
118 /// </summary>
119 /// <remarks>
120 /// The fragment will come at the start of the UUID. The rest will be 0s
121 /// </remarks>
122 /// <returns></returns>
123 /// <param name='frag'>
124 /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain
125 /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is
126 /// given as the 'fragment'.
127 /// </param>
128 public static UUID ParseStem(string stem)
129 {
130 string rawUuid = stem.PadRight(32, '0');
131
132 return UUID.Parse(rawUuid);
133 }
134
135 /// <summary>
117 /// Parse tail section into full UUID. 136 /// Parse tail section into full UUID.
118 /// </summary> 137 /// </summary>
119 /// <param name="tail"></param> 138 /// <param name="tail"></param>
@@ -122,5 +141,24 @@ namespace OpenSim.Tests.Common
122 { 141 {
123 return new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", tail)); 142 return new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", tail));
124 } 143 }
144
145 /// <summary>
146 /// Parse a UUID tail section into a full UUID.
147 /// </summary>
148 /// <remarks>
149 /// The fragment will come at the end of the UUID. The rest will be 0s
150 /// </remarks>
151 /// <returns></returns>
152 /// <param name='frag'>
153 /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain
154 /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is
155 /// given as the 'fragment'.
156 /// </param>
157 public static UUID ParseTail(string stem)
158 {
159 string rawUuid = stem.PadLeft(32, '0');
160
161 return UUID.Parse(rawUuid);
162 }
125 } 163 }
126} 164}
diff --git a/OpenSim/Tests/ConfigurationLoaderTest.cs b/OpenSim/Tests/ConfigurationLoaderTest.cs
index e5186ae..a409a13 100644
--- a/OpenSim/Tests/ConfigurationLoaderTest.cs
+++ b/OpenSim/Tests/ConfigurationLoaderTest.cs
@@ -45,8 +45,10 @@ namespace OpenSim.Tests
45 /// Set up a test directory. 45 /// Set up a test directory.
46 /// </summary> 46 /// </summary>
47 [SetUp] 47 [SetUp]
48 public void SetUp() 48 public override void SetUp()
49 { 49 {
50 base.SetUp();
51
50 m_basePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); 52 m_basePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
51 string path = Path.Combine(m_basePath, m_testSubdirectory); 53 string path = Path.Combine(m_basePath, m_testSubdirectory);
52 Directory.CreateDirectory(path); 54 Directory.CreateDirectory(path);
diff --git a/OpenSim/Tests/Performance/NPCPerformanceTests.cs b/OpenSim/Tests/Performance/NPCPerformanceTests.cs
index 2026a88..ca6ae42 100644
--- a/OpenSim/Tests/Performance/NPCPerformanceTests.cs
+++ b/OpenSim/Tests/Performance/NPCPerformanceTests.cs
@@ -34,7 +34,7 @@ using Nini.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications; 37
38using OpenSim.Region.CoreModules.Avatar.Attachments; 38using OpenSim.Region.CoreModules.Avatar.Attachments;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory; 39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.CoreModules.Framework.InventoryAccess; 40using OpenSim.Region.CoreModules.Framework.InventoryAccess;
@@ -45,7 +45,6 @@ using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.OptionalModules.World.NPC; 45using OpenSim.Region.OptionalModules.World.NPC;
46using OpenSim.Services.AvatarService; 46using OpenSim.Services.AvatarService;
47using OpenSim.Tests.Common; 47using OpenSim.Tests.Common;
48using OpenSim.Tests.Common.Mock;
49 48
50namespace OpenSim.Tests.Performance 49namespace OpenSim.Tests.Performance
51{ 50{
@@ -144,6 +143,7 @@ namespace OpenSim.Tests.Performance
144 // ScenePresence.SendInitialData() to reset our entire appearance. 143 // ScenePresence.SendInitialData() to reset our entire appearance.
145 scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); 144 scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
146 145
146/*
147 afm.SetAppearance(sp, originalTe, null); 147 afm.SetAppearance(sp, originalTe, null);
148 148
149 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 149 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
@@ -185,6 +185,7 @@ namespace OpenSim.Tests.Performance
185 endGcMemory / 1024 / 1024, 185 endGcMemory / 1024 / 1024,
186 startGcMemory / 1024 / 1024, 186 startGcMemory / 1024 / 1024,
187 (endGcMemory - startGcMemory) / 1024 / 1024); 187 (endGcMemory - startGcMemory) / 1024 / 1024);
188*/
188 } 189 }
189 } 190 }
190} \ No newline at end of file 191}
diff --git a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
index 656a971..9dad423 100644
--- a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
+++ b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
@@ -34,7 +34,6 @@ using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Tests.Common; 36using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38 37
39namespace OpenSim.Tests.Performance 38namespace OpenSim.Tests.Performance
40{ 39{
diff --git a/OpenSim/Tests/Performance/ScriptPerformanceTests.cs b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
index 4064edc..028f4b0 100644
--- a/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
+++ b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
@@ -40,7 +40,6 @@ using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.ScriptEngine.XEngine; 41using OpenSim.Region.ScriptEngine.XEngine;
42using OpenSim.Tests.Common; 42using OpenSim.Tests.Common;
43using OpenSim.Tests.Common.Mock;
44 43
45namespace OpenSim.Tests.Performance 44namespace OpenSim.Tests.Performance
46{ 45{
diff --git a/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs
new file mode 100644
index 0000000..671aca7
--- /dev/null
+++ b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs
@@ -0,0 +1,133 @@
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 NUnit.Framework;
35
36using OpenSim.Framework;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Services.Connectors;
40
41namespace Robust.Tests
42{
43 [TestFixture]
44 public class GridClient
45 {
46// private static readonly ILog m_log =
47// LogManager.GetLogger(
48// MethodBase.GetCurrentMethod().DeclaringType);
49
50 [Test]
51 public void Grid_001()
52 {
53 GridServicesConnector m_Connector = new GridServicesConnector(DemonServer.Address);
54
55 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
56 GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000);
57 GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
58
59 string msg = m_Connector.RegisterRegion(UUID.Zero, r1);
60 Assert.AreEqual(msg, string.Empty, "Region 1 failed to register");
61
62 msg = m_Connector.RegisterRegion(UUID.Zero, r2);
63 Assert.AreEqual(msg, string.Empty, "Region 2 failed to register");
64
65 msg = m_Connector.RegisterRegion(UUID.Zero, r3);
66 Assert.AreEqual(msg, string.Empty, "Region 3 failed to register");
67
68 bool success;
69 success = m_Connector.DeregisterRegion(r3.RegionID);
70 Assert.AreEqual(success, true, "Region 3 failed to deregister");
71
72 msg = m_Connector.RegisterRegion(UUID.Zero, r3);
73 Assert.AreEqual(msg, string.Empty, "Region 3 failed to re-register");
74
75 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
76 Assert.AreNotEqual(regions, null, "GetNeighbours of region 1 failed");
77 Assert.AreEqual(regions.Count, 1, "Region 1 should have 1 neighbor");
78 Assert.AreEqual(regions[0].RegionName, "Test Region 2", "Region 1 has the wrong neighbor");
79
80 GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
81 Assert.AreNotEqual(region, null, "GetRegionByUUID for region 2 failed");
82 Assert.AreEqual(region.RegionName, "Test Region 2", "GetRegionByUUID of region 2 returned wrong region");
83
84 region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
85 Assert.AreEqual(region, null, "Region with randon id should not exist");
86
87 region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
88 Assert.AreNotEqual(region, null, "GetRegionByUUID for region 3 failed");
89 Assert.AreEqual(region.RegionName, "Test Region 3", "GetRegionByUUID of region 3 returned wrong region");
90
91 region = m_Connector.GetRegionByName(UUID.Zero, "Foo");
92 Assert.AreEqual(region, null, "Region Foo should not exist");
93
94 regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10);
95 Assert.AreNotEqual(regions, null, "GetRegionsByName failed");
96 Assert.AreEqual(regions.Count, 3, "GetRegionsByName should return 3");
97
98 regions = m_Connector.GetRegionRange(UUID.Zero,
99 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002),
100 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) );
101 Assert.AreNotEqual(regions, null, "GetRegionRange failed");
102 Assert.AreEqual(regions.Count, 2, "GetRegionRange should return 2");
103
104 regions = m_Connector.GetRegionRange(UUID.Zero,
105 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950),
106 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) );
107 Assert.AreNotEqual(regions, null, "GetRegionRange (bis) failed");
108 Assert.AreEqual(regions.Count, 0, "GetRegionRange (bis) should return 0");
109
110 // Deregister them all
111 success = m_Connector.DeregisterRegion(r1.RegionID);
112 Assert.AreEqual(success, true, "Region 1 failed to deregister");
113
114 success = m_Connector.DeregisterRegion(r2.RegionID);
115 Assert.AreEqual(success, true, "Region 2 failed to deregister");
116
117 success = m_Connector.DeregisterRegion(r3.RegionID);
118 Assert.AreEqual(success, true, "Region 3 failed to deregister");
119 }
120
121 private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
122 {
123 GridRegion region = new GridRegion(xcell, ycell);
124 region.RegionName = name;
125 region.RegionID = UUID.Random();
126 region.ExternalHostName = "127.0.0.1";
127 region.HttpPort = 9000;
128 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);
129
130 return region;
131 }
132 }
133}
diff --git a/OpenSim/Tests/Clients/Grid/GridForm.html b/OpenSim/Tests/Robust/Clients/Grid/GridForm.html
index 252920f..252920f 100644
--- a/OpenSim/Tests/Clients/Grid/GridForm.html
+++ b/OpenSim/Tests/Robust/Clients/Grid/GridForm.html
diff --git a/OpenSim/Tests/Clients/InstantMessage/IMClient.cs b/OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs
index e7304a2..8f312eb 100644
--- a/OpenSim/Tests/Clients/InstantMessage/IMClient.cs
+++ b/OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs
@@ -28,47 +28,30 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using System.Reflection;
32 31
33using OpenMetaverse; 32using OpenMetaverse;
34using log4net; 33using NUnit.Framework;
35using log4net.Appender;
36using log4net.Layout;
37 34
38using OpenSim.Framework; 35using OpenSim.Framework;
39using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
40using OpenSim.Services.Connectors.InstantMessage; 37using OpenSim.Services.Connectors.InstantMessage;
41 38
42namespace OpenSim.Tests.Clients.InstantMessage 39namespace Robust.Tests
43{ 40{
41 [TestFixture]
44 public class IMClient 42 public class IMClient
45 { 43 {
46 private static readonly ILog m_log = 44 [Test]
47 LogManager.GetLogger( 45 public void HGIM_001()
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 public static void Main(string[] args)
51 { 46 {
52 ConsoleAppender consoleAppender = new ConsoleAppender();
53 consoleAppender.Layout =
54 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
55 log4net.Config.BasicConfigurator.Configure(consoleAppender);
56
57 string serverURI = "http://127.0.0.1:8002";
58 GridInstantMessage im = new GridInstantMessage(); 47 GridInstantMessage im = new GridInstantMessage();
59 im.fromAgentID = new Guid(); 48 im.fromAgentID = new Guid();
60 im.toAgentID = new Guid(); 49 im.toAgentID = new Guid();
61 im.message = "Hello"; 50 im.message = "Hello";
62 im.imSessionID = new Guid(); 51 im.imSessionID = new Guid();
63 52
64 bool success = InstantMessageServiceConnector.SendInstantMessage(serverURI, im); 53 bool success = InstantMessageServiceConnector.SendInstantMessage(DemonServer.Address, im);
65 54 Assert.IsFalse(success, "Sending of IM succeeded, but it should have failed");
66 if (success)
67 m_log.InfoFormat("[IM CLIENT]: Successfully IMed {0}", serverURI);
68 else
69 m_log.InfoFormat("[IM CLIENT]: failed to IM {0}", serverURI);
70
71 System.Console.WriteLine("\n");
72 } 55 }
73 56
74 } 57 }
diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs
new file mode 100644
index 0000000..0280b73
--- /dev/null
+++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs
@@ -0,0 +1,206 @@
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 NUnit.Framework;
35
36using OpenSim.Framework;
37using OpenSim.Services.Interfaces;
38using OpenSim.Services.Connectors;
39
40using OpenSim.Tests.Common;
41
42namespace Robust.Tests
43{
44 [TestFixture]
45 public class InventoryClient
46 {
47// private static readonly ILog m_log =
48// LogManager.GetLogger(
49// MethodBase.GetCurrentMethod().DeclaringType);
50
51 private UUID m_userID = new UUID("00000000-0000-0000-0000-333333333333");
52 private UUID m_rootFolderID;
53 private UUID m_notecardsFolder;
54 private UUID m_objectsFolder;
55
56 [Test]
57 public void Inventory_001_CreateInventory()
58 {
59 TestHelpers.InMethod();
60 XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address);
61
62 // Create an inventory that looks like this:
63 //
64 // /My Inventory
65 // <other system folders>
66 // /Objects
67 // Some Object
68 // /Notecards
69 // Notecard 1
70 // Notecard 2
71 // /Test Folder
72 // Link to notecard -> /Notecards/Notecard 2
73 // Link to Objects folder -> /Objects
74
75 bool success = m_Connector.CreateUserInventory(m_userID);
76 Assert.IsTrue(success, "Failed to create user inventory");
77
78 m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID;
79 Assert.AreNotEqual(m_rootFolderID, UUID.Zero, "Root folder ID must not be UUID.Zero");
80
81 InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, FolderType.Object);
82 Assert.IsNotNull(of, "Failed to retrieve Objects folder");
83 m_objectsFolder = of.ID;
84 Assert.AreNotEqual(m_objectsFolder, UUID.Zero, "Objects folder ID must not be UUID.Zero");
85
86 // Add an object
87 InventoryItemBase item = new InventoryItemBase(new UUID("b0000000-0000-0000-0000-00000000000b"), m_userID);
88 item.AssetID = UUID.Random();
89 item.AssetType = (int)AssetType.Object;
90 item.Folder = m_objectsFolder;
91 item.Name = "Some Object";
92 item.Description = string.Empty;
93 success = m_Connector.AddItem(item);
94 Assert.IsTrue(success, "Failed to add object to inventory");
95
96 InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, FolderType.Notecard);
97 Assert.IsNotNull(of, "Failed to retrieve Notecards folder");
98 m_notecardsFolder = ncf.ID;
99 Assert.AreNotEqual(m_notecardsFolder, UUID.Zero, "Notecards folder ID must not be UUID.Zero");
100 m_notecardsFolder = ncf.ID;
101
102 // Add a notecard
103 item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID);
104 item.AssetID = UUID.Random();
105 item.AssetType = (int)AssetType.Notecard;
106 item.Folder = m_notecardsFolder;
107 item.Name = "Test Notecard 1";
108 item.Description = string.Empty;
109 success = m_Connector.AddItem(item);
110 Assert.IsTrue(success, "Failed to add Notecard 1 to inventory");
111 // Add another notecard
112 item.ID = new UUID("20000000-0000-0000-0000-000000000002");
113 item.AssetID = new UUID("a0000000-0000-0000-0000-00000000000a");
114 item.Name = "Test Notecard 2";
115 item.Description = string.Empty;
116 success = m_Connector.AddItem(item);
117 Assert.IsTrue(success, "Failed to add Notecard 2 to inventory");
118
119 // Add a folder
120 InventoryFolderBase folder = new InventoryFolderBase(new UUID("f0000000-0000-0000-0000-00000000000f"), "Test Folder", m_userID, m_rootFolderID);
121 folder.Type = (int)FolderType.None;
122 success = m_Connector.AddFolder(folder);
123 Assert.IsTrue(success, "Failed to add Test Folder to inventory");
124
125 // Add a link to notecard 2 in Test Folder
126 item.AssetID = item.ID; // use item ID of notecard 2
127 item.ID = new UUID("40000000-0000-0000-0000-000000000004");
128 item.AssetType = (int)AssetType.Link;
129 item.Folder = folder.ID;
130 item.Name = "Link to notecard";
131 item.Description = string.Empty;
132 success = m_Connector.AddItem(item);
133 Assert.IsTrue(success, "Failed to add link to notecard to inventory");
134
135 // Add a link to the Objects folder in Test Folder
136 item.AssetID = m_Connector.GetFolderForType(m_userID, FolderType.Object).ID; // use item ID of Objects folder
137 item.ID = new UUID("50000000-0000-0000-0000-000000000005");
138 item.AssetType = (int)AssetType.LinkFolder;
139 item.Folder = folder.ID;
140 item.Name = "Link to Objects folder";
141 item.Description = string.Empty;
142 success = m_Connector.AddItem(item);
143 Assert.IsTrue(success, "Failed to add link to objects folder to inventory");
144
145 InventoryCollection coll = m_Connector.GetFolderContent(m_userID, m_rootFolderID);
146 Assert.IsNotNull(coll, "Failed to retrieve contents of root folder");
147 Assert.Greater(coll.Folders.Count, 0, "Root folder does not have any subfolders");
148
149 coll = m_Connector.GetFolderContent(m_userID, folder.ID);
150 Assert.IsNotNull(coll, "Failed to retrieve contents of Test Folder");
151 Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside");
152
153 }
154
155 [Test]
156 public void Inventory_002_MultipleItemsRequest()
157 {
158 TestHelpers.InMethod();
159 XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address);
160
161 // Prefetch Notecard 1, will be cached from here on
162 InventoryItemBase item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID);
163 item = m_Connector.GetItem(item);
164 Assert.NotNull(item, "Failed to get Notecard 1");
165 Assert.AreEqual("Test Notecard 1", item.Name, "Wrong name for Notecard 1");
166
167 UUID[] uuids = new UUID[2];
168 uuids[0] = item.ID;
169 uuids[1] = new UUID("20000000-0000-0000-0000-000000000002");
170
171 InventoryItemBase[] items = m_Connector.GetMultipleItems(m_userID, uuids);
172 Assert.NotNull(items, "Failed to get multiple items");
173 Assert.IsTrue(items.Length == 2, "Requested 2 items, but didn't receive 2 items");
174
175 // Now they should both be cached
176 items = m_Connector.GetMultipleItems(m_userID, uuids);
177 Assert.NotNull(items, "(Repeat) Failed to get multiple items");
178 Assert.IsTrue(items.Length == 2, "(Repeat) Requested 2 items, but didn't receive 2 items");
179
180 // This item doesn't exist, but [0] does, and it's cached.
181 uuids[1] = new UUID("bb000000-0000-0000-0000-0000000000bb");
182 // Fetching should return 2 items, but [1] should be null
183 items = m_Connector.GetMultipleItems(m_userID, uuids);
184 Assert.NotNull(items, "(Three times) Failed to get multiple items");
185 Assert.IsTrue(items.Length == 2, "(Three times) Requested 2 items, but didn't receive 2 items");
186 Assert.AreEqual("Test Notecard 1", items[0].Name, "(Three times) Wrong name for Notecard 1");
187 Assert.IsNull(items[1], "(Three times) Expecting 2nd item to be null");
188
189 // Now both don't exist
190 uuids[0] = new UUID("aa000000-0000-0000-0000-0000000000aa");
191 items = m_Connector.GetMultipleItems(m_userID, uuids);
192 Assert.Null(items[0], "Request to multiple non-existent items is supposed to return null [0]");
193 Assert.Null(items[1], "Request to multiple non-existent items is supposed to return null [1]");
194
195 // This item exists, and it's not cached
196 uuids[1] = new UUID("b0000000-0000-0000-0000-00000000000b");
197 // Fetching should return 2 items, but [0] should be null
198 items = m_Connector.GetMultipleItems(m_userID, uuids);
199 Assert.NotNull(items, "(Four times) Failed to get multiple items");
200 Assert.IsTrue(items.Length == 2, "(Four times) Requested 2 items, but didn't receive 2 items");
201 Assert.AreEqual("Some Object", items[1].Name, "(Four times) Wrong name for Some Object");
202 Assert.IsNull(items[0], "(Four times) Expecting 1st item to be null");
203
204 }
205 }
206}
diff --git a/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs
new file mode 100644
index 0000000..31c8ee9
--- /dev/null
+++ b/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs
@@ -0,0 +1,81 @@
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 NUnit.Framework;
35
36using OpenSim.Framework;
37using OpenSim.Services.Interfaces;
38using OpenSim.Services.Connectors;
39
40namespace Robust.Tests
41{
42 [TestFixture]
43 public class PresenceClient
44 {
45 [Test]
46 public void Presence_001()
47 {
48 PresenceServicesConnector m_Connector = new PresenceServicesConnector(DemonServer.Address);
49
50 UUID user1 = UUID.Random();
51 UUID session1 = UUID.Random();
52 UUID region1 = UUID.Random();
53
54 bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero);
55 Assert.AreEqual(success, true, "Failed to add user session");
56
57 PresenceInfo pinfo = m_Connector.GetAgent(session1);
58 Assert.AreNotEqual(pinfo, null, "Unable to retrieve session");
59 Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID");
60 Assert.AreNotEqual(pinfo.RegionID, region1, "Retrieved session is unexpectedly in region");
61
62 success = m_Connector.ReportAgent(session1, region1);
63 Assert.AreEqual(success, true, "Failed to report session in region 1");
64
65 pinfo = m_Connector.GetAgent(session1);
66 Assert.AreNotEqual(pinfo, null, "Unable to session presence");
67 Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID");
68 Assert.AreEqual(pinfo.RegionID, region1, "Retrieved session is not in expected region");
69
70 success = m_Connector.LogoutAgent(session1);
71 Assert.AreEqual(success, true, "Failed to remove session");
72
73 pinfo = m_Connector.GetAgent(session1);
74 Assert.AreEqual(pinfo, null, "Session is still there, even though it shouldn't");
75
76 success = m_Connector.ReportAgent(session1, UUID.Random());
77 Assert.AreEqual(success, false, "Remove non-existing session should fail");
78 }
79
80 }
81}
diff --git a/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs b/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs
new file mode 100644
index 0000000..3238dc9
--- /dev/null
+++ b/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs
@@ -0,0 +1,86 @@
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 NUnit.Framework;
35
36using OpenSim.Framework;
37using OpenSim.Services.Interfaces;
38using OpenSim.Services.Connectors;
39
40namespace Robust.Tests
41{
42 [TestFixture]
43 public class UserAccountsClient
44 {
45 [Test]
46 public void UserAccounts_001()
47 {
48 UserAccountServicesConnector m_Connector = new UserAccountServicesConnector(DemonServer.Address);
49
50 string first = "Completely";
51 string last = "Clueless";
52 string email = "foo@bar.com";
53
54 UserAccount account = m_Connector.CreateUser(first, last, "123", email, UUID.Zero);
55 Assert.IsNotNull(account, "Failed to create account " + first + " " + last);
56 UUID user1 = account.PrincipalID;
57
58 account = m_Connector.GetUserAccount(UUID.Zero, user1);
59 Assert.NotNull(account, "Failed to retrieve account for user id " + user1);
60 Assert.AreEqual(account.FirstName, first, "First name does not match");
61 Assert.AreEqual(account.LastName, last, "Last name does not match");
62
63 account = m_Connector.GetUserAccount(UUID.Zero, first, last);
64 Assert.IsNotNull(account, "Failed to retrieve account for user " + first + " " + last);
65 Assert.AreEqual(account.FirstName, first, "First name does not match (bis)");
66 Assert.AreEqual(account.LastName, last, "Last name does not match (bis)");
67
68 account.Email = "user@example.com";
69 bool success = m_Connector.StoreUserAccount(account);
70 Assert.IsTrue(success, "Failed to store existing account");
71
72 account = m_Connector.GetUserAccount(UUID.Zero, user1);
73 Assert.NotNull(account, "Failed to retrieve account for user id " + user1);
74 Assert.AreEqual(account.Email, "user@example.com", "Incorrect email");
75
76 account = new UserAccount(UUID.Zero, "DoesNot", "Exist", "xxx@xxx.com");
77 success = m_Connector.StoreUserAccount(account);
78 Assert.IsFalse(success, "Storing a non-existing account must fail");
79
80 account = m_Connector.GetUserAccount(UUID.Zero, "DoesNot", "Exist");
81 Assert.IsNull(account, "Account DoesNot Exist must not be there");
82
83 }
84
85 }
86}
diff --git a/OpenSim/Tests/Robust/Server/DemonServer.cs b/OpenSim/Tests/Robust/Server/DemonServer.cs
new file mode 100644
index 0000000..1e0797e
--- /dev/null
+++ b/OpenSim/Tests/Robust/Server/DemonServer.cs
@@ -0,0 +1,69 @@
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.Threading;
32
33using Nini.Config;
34using log4net;
35using NUnit.Framework;
36
37using OpenSim.Server;
38
39namespace Robust.Tests
40{
41 [SetUpFixture]
42 public class DemonServer : OpenSimServer
43 {
44 private Thread m_demon;
45
46 public static string Address = "http://localhost:8888";
47
48 [SetUp]
49 public void StartDemon()
50 {
51 if (File.Exists("Robust.Tests.log"))
52 File.Delete("Robust.Tests.log");
53
54 Console.WriteLine("**** Starting demon Robust server ****");
55 m_demon = new Thread( () => Main(new string[] {"-inifile=Robust.Tests.ini"}));
56 m_demon.Start();
57 // Give some time for the server to instantiate all services
58 Thread.Sleep(3000);
59 Console.WriteLine("**** Setup Finished ****");
60 }
61
62 [TearDown]
63 public void StopDemon()
64 {
65 Console.WriteLine("**** Killing demon Robust Server ****");
66 m_Server.Shutdown();
67 }
68 }
69}
diff --git a/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs b/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs
index 1f220c0..0ab407e 100644
--- a/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs
+++ b/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs
@@ -41,7 +41,6 @@ using OpenSim.Region.CoreModules.Scripting.VectorRender;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Scenes.Serialization; 42using OpenSim.Region.Framework.Scenes.Serialization;
43using OpenSim.Tests.Common; 43using OpenSim.Tests.Common;
44using OpenSim.Tests.Common.Mock;
45 44
46namespace OpenSim.Tests.Stress 45namespace OpenSim.Tests.Stress
47{ 46{
@@ -79,7 +78,7 @@ namespace OpenSim.Tests.Stress
79 Drawer d = new Drawer(this, i); 78 Drawer d = new Drawer(this, i);
80 drawers.Add(d); 79 drawers.Add(d);
81 Console.WriteLine("Starting drawer {0}", i); 80 Console.WriteLine("Starting drawer {0}", i);
82 Util.FireAndForget(o => d.Draw()); 81 Util.FireAndForget(o => d.Draw(), null, "VectorRenderModuleStressTests.TestConcurrentRepeatedDraw");
83 } 82 }
84 83
85 Thread.Sleep(10 * 60 * 1000); 84 Thread.Sleep(10 * 60 * 1000);