aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Clients/Grid
diff options
context:
space:
mode:
authorDiva Canto2009-09-24 13:33:58 -0700
committerDiva Canto2009-09-24 13:33:58 -0700
commitdd3d52ae1faefbca85e2fe8d8cea67f7db4005ac (patch)
tree659b977f1ab6b7fd5def36fe8c967953dc1edeb5 /OpenSim/Tests/Clients/Grid
parentMerge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-dd3d52ae1faefbca85e2fe8d8cea67f7db4005ac.zip
opensim-SC_OLD-dd3d52ae1faefbca85e2fe8d8cea67f7db4005ac.tar.gz
opensim-SC_OLD-dd3d52ae1faefbca85e2fe8d8cea67f7db4005ac.tar.bz2
opensim-SC_OLD-dd3d52ae1faefbca85e2fe8d8cea67f7db4005ac.tar.xz
Added test GridClient, which allowed me to remove a few bugs out of the new code.
Diffstat (limited to 'OpenSim/Tests/Clients/Grid')
-rw-r--r--OpenSim/Tests/Clients/Grid/GridClient.cs102
1 files changed, 102 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..0b84f9b
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridClient.cs
@@ -0,0 +1,102 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Reflection;
5
6using OpenMetaverse;
7using log4net;
8using log4net.Appender;
9using log4net.Layout;
10
11using OpenSim.Framework;
12using OpenSim.Services.Interfaces;
13using GridRegion = OpenSim.Services.Interfaces.GridRegion;
14using OpenSim.Services.Connectors;
15
16namespace OpenSim.Tests.Clients.GridClient
17{
18 public class GridClient
19 {
20 private static readonly ILog m_log =
21 LogManager.GetLogger(
22 MethodBase.GetCurrentMethod().DeclaringType);
23
24 public static void Main(string[] args)
25 {
26 ConsoleAppender consoleAppender = new ConsoleAppender();
27 consoleAppender.Layout =
28 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
29 log4net.Config.BasicConfigurator.Configure(consoleAppender);
30
31 string serverURI = "http://127.0.0.1:8002";
32 GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
33
34 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
35 GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000);
36 GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
37
38 Console.WriteLine("[GRID CLIENT]: Registering region 1");
39 bool success = m_Connector.RegisterRegion(UUID.Zero, r1);
40 if (success)
41 Console.WriteLine("[GRID CLIENT]: Successfully registered region 1");
42 else
43 Console.WriteLine("[GRID CLIENT]: region 1 failed to register");
44
45 Console.WriteLine("[GRID CLIENT]: Registering region 2");
46 success = m_Connector.RegisterRegion(UUID.Zero, r2);
47 if (success)
48 Console.WriteLine("[GRID CLIENT]: Successfully registered region 2");
49 else
50 Console.WriteLine("[GRID CLIENT]: region 2 failed to register");
51
52 Console.WriteLine("[GRID CLIENT]: Registering region 3");
53 success = m_Connector.RegisterRegion(UUID.Zero, r3);
54 if (success)
55 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
56 else
57 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
58
59
60 Console.WriteLine("[GRID CLIENT]: Deregistering region 3");
61 success = m_Connector.DeregisterRegion(r3.RegionID);
62 if (success)
63 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
64 else
65 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
66 Console.WriteLine("[GRID CLIENT]: Registering region 3 again");
67 success = m_Connector.RegisterRegion(UUID.Zero, r3);
68 if (success)
69 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
70 else
71 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
72
73 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1");
74 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
75 if (regions == null)
76 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed");
77 else if (regions.Count > 0)
78 {
79 if (regions.Count != 1)
80 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
81 else
82 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
83 }
84 else
85 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
86
87
88 }
89
90 private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
91 {
92 GridRegion region = new GridRegion(xcell, ycell);
93 region.RegionName = name;
94 region.RegionID = UUID.Random();
95 region.ExternalHostName = "127.0.0.1";
96 region.HttpPort = 9000;
97 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
98
99 return region;
100 }
101 }
102}