diff options
Diffstat (limited to 'OpenSim/Tests/Clients/Grid/GridClient.cs')
-rw-r--r-- | OpenSim/Tests/Clients/Grid/GridClient.cs | 205 |
1 files changed, 0 insertions, 205 deletions
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs deleted file mode 100644 index fed7a16..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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using log4net; | ||
35 | using log4net.Appender; | ||
36 | using log4net.Layout; | ||
37 | |||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | using OpenSim.Services.Connectors; | ||
42 | |||
43 | namespace 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 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002), | ||
154 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) ); | ||
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 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950), | ||
162 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) ); | ||
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 | } | ||