aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Clients
diff options
context:
space:
mode:
authorMelanie2009-10-02 08:23:38 +0100
committerMelanie2009-10-02 08:23:38 +0100
commit31d8cec0f8cd47ff445edc7771e5e73825a57927 (patch)
treea2d60604317739fa530502c40ffc71bab2a5c494 /OpenSim/Tests/Clients
parentRestore the missing image handling to the image manager. The missing (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-31d8cec0f8cd47ff445edc7771e5e73825a57927.zip
opensim-SC-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.gz
opensim-SC-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.bz2
opensim-SC-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.xz
Merge branch 'master' into diva-textures
Diffstat (limited to 'OpenSim/Tests/Clients')
-rw-r--r--OpenSim/Tests/Clients/Grid/GridClient.cs204
-rw-r--r--OpenSim/Tests/Clients/Grid/GridForm.html11
2 files changed, 215 insertions, 0 deletions
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs
new file mode 100644
index 0000000..8798c5e
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridClient.cs
@@ -0,0 +1,204 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using System.Reflection;
32
33using OpenMetaverse;
34using log4net;
35using log4net.Appender;
36using log4net.Layout;
37
38using OpenSim.Framework;
39using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Connectors;
42
43namespace OpenSim.Tests.Clients.GridClient
44{
45 public class GridClient
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 public static void Main(string[] args)
52 {
53 ConsoleAppender consoleAppender = new ConsoleAppender();
54 consoleAppender.Layout =
55 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
56 log4net.Config.BasicConfigurator.Configure(consoleAppender);
57
58 string serverURI = "http://127.0.0.1:8001";
59 GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
60
61 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
62 GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000);
63 GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
64
65 Console.WriteLine("[GRID CLIENT]: *** Registering region 1");
66 bool success = m_Connector.RegisterRegion(UUID.Zero, r1);
67 if (success)
68 Console.WriteLine("[GRID CLIENT]: Successfully registered region 1");
69 else
70 Console.WriteLine("[GRID CLIENT]: region 1 failed to register");
71
72 Console.WriteLine("[GRID CLIENT]: *** Registering region 2");
73 success = m_Connector.RegisterRegion(UUID.Zero, r2);
74 if (success)
75 Console.WriteLine("[GRID CLIENT]: Successfully registered region 2");
76 else
77 Console.WriteLine("[GRID CLIENT]: region 2 failed to register");
78
79 Console.WriteLine("[GRID CLIENT]: *** Registering region 3");
80 success = m_Connector.RegisterRegion(UUID.Zero, r3);
81 if (success)
82 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
83 else
84 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
85
86
87 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
88 success = m_Connector.DeregisterRegion(r3.RegionID);
89 if (success)
90 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
91 else
92 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
93 Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again");
94 success = m_Connector.RegisterRegion(UUID.Zero, r3);
95 if (success)
96 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
97 else
98 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
99
100 Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1");
101 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
102 if (regions == null)
103 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed");
104 else if (regions.Count > 0)
105 {
106 if (regions.Count != 1)
107 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
108 else
109 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
110 }
111 else
112 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
113
114
115 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)");
116 GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
117 if (region == null)
118 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
119 else
120 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
121
122 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)");
123 region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
124 if (region == null)
125 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
126 else
127 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
128
129 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)");
130 region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
131 if (region == null)
132 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
133 else
134 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
135
136 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)");
137 region = m_Connector.GetRegionByName(UUID.Zero, "Foo");
138 if (region == null)
139 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
140 else
141 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
142
143 Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)");
144 regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10);
145 if (regions == null)
146 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null");
147 else
148 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions");
149
150 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)");
151 regions = m_Connector.GetRegionRange(UUID.Zero,
152 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize,
153 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize);
154 if (regions == null)
155 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
156 else
157 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
158 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)");
159 regions = m_Connector.GetRegionRange(UUID.Zero,
160 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize,
161 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize);
162 if (regions == null)
163 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
164 else
165 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
166
167 Console.Write("Proceed to deregister? Press enter...");
168 Console.ReadLine();
169
170 // Deregister them all
171 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1");
172 success = m_Connector.DeregisterRegion(r1.RegionID);
173 if (success)
174 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1");
175 else
176 Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister");
177 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2");
178 success = m_Connector.DeregisterRegion(r2.RegionID);
179 if (success)
180 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2");
181 else
182 Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister");
183 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
184 success = m_Connector.DeregisterRegion(r3.RegionID);
185 if (success)
186 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
187 else
188 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
189
190 }
191
192 private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
193 {
194 GridRegion region = new GridRegion(xcell, ycell);
195 region.RegionName = name;
196 region.RegionID = UUID.Random();
197 region.ExternalHostName = "127.0.0.1";
198 region.HttpPort = 9000;
199 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);
200
201 return region;
202 }
203 }
204}
diff --git a/OpenSim/Tests/Clients/Grid/GridForm.html b/OpenSim/Tests/Clients/Grid/GridForm.html
new file mode 100644
index 0000000..252920f
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridForm.html
@@ -0,0 +1,11 @@
1<html>
2
3<form name="input" action="http://127.0.0.1:8002/grid" method="post">
4xmin:<input type="text" name="XMIN" value="0">
5xmax:<input type="text" name="XMAX" value="0">
6ymin:<input type="text" name="YMIN" value="0">
7ymax:<input type="text" name="YMAX" value="0">
8<input type="hidden" name="METHOD" value="get_region_range">
9<input type="submit" value="Submit" />
10</form>
11</html>