aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs196
1 files changed, 196 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
new file mode 100644
index 0000000..4765a86
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -0,0 +1,196 @@
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.Reflection;
30using Nini.Config;
31using NUnit.Framework;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
37using OpenSim.Tests.Common;
38using OpenSim.Tests.Common.Mock;
39using System.Threading;
40
41namespace OpenSim.Region.Framework.Scenes.Tests
42{
43 /// <summary>
44 /// Teleport tests in a standalone OpenSim
45 /// </summary>
46 [TestFixture]
47 public class ScenePresenceTeleportTests
48 {
49 /// <summary>
50 /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common.
51 /// </summary>
52 /// Does not yet do what is says on the tin.
53 /// Commenting for now
54 //[Test, LongRunning]
55 public void TestSimpleNotNeighboursTeleport()
56 {
57 TestHelpers.InMethod();
58 ThreadRunResults results = new ThreadRunResults();
59 results.Result = false;
60 results.Message = "Test did not run";
61 TestRunning testClass = new TestRunning(results);
62
63 Thread testThread = new Thread(testClass.run);
64
65 try
66 {
67 // Seems kind of redundant to start a thread and then join it, however.. We need to protect against
68 // A thread abort exception in the simulator code.
69 testThread.Start();
70 testThread.Join();
71 }
72 catch (ThreadAbortException)
73 {
74
75 }
76 Assert.That(testClass.results.Result, Is.EqualTo(true), testClass.results.Message);
77 // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
78 }
79
80 [TearDown]
81 public void TearDown()
82 {
83 try
84 {
85 if (MainServer.Instance != null) MainServer.Instance.Stop();
86 }
87 catch (NullReferenceException)
88 { }
89 }
90
91 }
92
93 public class ThreadRunResults
94 {
95 public bool Result = false;
96 public string Message = string.Empty;
97 }
98
99 public class TestRunning
100 {
101 public ThreadRunResults results;
102 public TestRunning(ThreadRunResults t)
103 {
104 results = t;
105 }
106 public void run(object o)
107 {
108
109 //results.Result = true;
110 log4net.Config.XmlConfigurator.Configure();
111
112 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100");
113 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200");
114
115 // shared module
116 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
117
118
119 Scene sceneB = SceneHelpers.SetupScene("sceneB", sceneBId, 1010, 1010);
120 SceneHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
121 sceneB.RegisterRegionWithGrid();
122
123 Scene sceneA = SceneHelpers.SetupScene("sceneA", sceneAId, 1000, 1000);
124 SceneHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
125 sceneA.RegisterRegionWithGrid();
126
127 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041");
128 TestClient client = SceneHelpers.AddClient(sceneA, agentId);
129
130 ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>();
131
132 results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl);
133
134 if (!results.Result)
135 {
136 results.Message = "Incorrect caps object path set up in sceneA";
137 return;
138 }
139
140 /*
141 Assert.That(
142 sceneACapsModule.GetCapsPath(agentId),
143 Is.EqualTo(client.CapsSeedUrl),
144 "Incorrect caps object path set up in sceneA");
145 */
146 // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used.
147
148
149 client.TeleportTargetScene = sceneB;
150 client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40));
151
152 results.Result = (sceneB.GetScenePresence(agentId) != null);
153 if (!results.Result)
154 {
155 results.Message = "Client does not have an agent in sceneB";
156 return;
157 }
158
159 //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB");
160
161 //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA");
162
163 results.Result = (sceneA.GetScenePresence(agentId) == null);
164 if (!results.Result)
165 {
166 results.Message = "Client still had an agent in sceneA";
167 return;
168 }
169
170 ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>();
171
172
173 results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort +
174 "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl);
175 if (!results.Result)
176 {
177 results.Message = "Incorrect caps object path set up in sceneB";
178 return;
179 }
180
181 // Temporary assertion - caps url construction should at least be doable through a method.
182 /*
183 Assert.That(
184 "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/",
185 Is.EqualTo(client.CapsSeedUrl),
186 "Incorrect caps object path set up in sceneB");
187 */
188 // This assertion will currently fail since we don't remove the caps paths when no longer needed
189 //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path");
190
191 // TODO: Check that more of everything is as it should be
192
193 // TODO: test what happens if we try to teleport to a region that doesn't exist
194 }
195 }
196}