diff options
Merge branch 'master' into diva-textures
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs new file mode 100644 index 0000000..2ca90f8 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -0,0 +1,141 @@ | |||
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.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using Nini.Config; | ||
39 | |||
40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
43 | using OpenSim.Tests.Common; | ||
44 | using OpenSim.Tests.Common.Setup; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | ||
47 | { | ||
48 | [TestFixture] | ||
49 | public class GridConnectorsTests | ||
50 | { | ||
51 | LocalGridServicesConnector m_LocalConnector; | ||
52 | private void SetUp() | ||
53 | { | ||
54 | IConfigSource config = new IniConfigSource(); | ||
55 | config.AddConfig("Modules"); | ||
56 | config.AddConfig("GridService"); | ||
57 | config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); | ||
58 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); | ||
59 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); | ||
60 | |||
61 | m_LocalConnector = new LocalGridServicesConnector(config); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Test saving a V0.2 OpenSim Region Archive. | ||
66 | /// </summary> | ||
67 | [Test] | ||
68 | public void TestRegisterRegionV0_2() | ||
69 | { | ||
70 | SetUp(); | ||
71 | |||
72 | // Create 3 regions | ||
73 | GridRegion r1 = new GridRegion(); | ||
74 | r1.RegionName = "Test Region 1"; | ||
75 | r1.RegionID = new UUID(1); | ||
76 | r1.RegionLocX = 1000 * (int)Constants.RegionSize; | ||
77 | r1.RegionLocY = 1000 * (int)Constants.RegionSize; | ||
78 | r1.ExternalHostName = "127.0.0.1"; | ||
79 | r1.HttpPort = 9001; | ||
80 | r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | ||
81 | Scene s = new Scene(new RegionInfo()); | ||
82 | s.RegionInfo.RegionID = r1.RegionID; | ||
83 | m_LocalConnector.AddRegion(s); | ||
84 | |||
85 | |||
86 | GridRegion r2 = new GridRegion(); | ||
87 | r2.RegionName = "Test Region 2"; | ||
88 | r2.RegionID = new UUID(2); | ||
89 | r2.RegionLocX = 1001 * (int)Constants.RegionSize; | ||
90 | r2.RegionLocY = 1000 * (int)Constants.RegionSize; | ||
91 | r2.ExternalHostName = "127.0.0.1"; | ||
92 | r2.HttpPort = 9002; | ||
93 | r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | ||
94 | s = new Scene(new RegionInfo()); | ||
95 | s.RegionInfo.RegionID = r1.RegionID; | ||
96 | m_LocalConnector.AddRegion(s); | ||
97 | |||
98 | GridRegion r3 = new GridRegion(); | ||
99 | r3.RegionName = "Test Region 3"; | ||
100 | r3.RegionID = new UUID(3); | ||
101 | r3.RegionLocX = 1005 * (int)Constants.RegionSize; | ||
102 | r3.RegionLocY = 1000 * (int)Constants.RegionSize; | ||
103 | r3.ExternalHostName = "127.0.0.1"; | ||
104 | r3.HttpPort = 9003; | ||
105 | r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | ||
106 | s = new Scene(new RegionInfo()); | ||
107 | s.RegionInfo.RegionID = r1.RegionID; | ||
108 | m_LocalConnector.AddRegion(s); | ||
109 | |||
110 | m_LocalConnector.RegisterRegion(UUID.Zero, r1); | ||
111 | GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test"); | ||
112 | Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); | ||
113 | Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); | ||
114 | |||
115 | result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); | ||
116 | Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); | ||
117 | Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); | ||
118 | |||
119 | result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); | ||
120 | Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); | ||
121 | Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); | ||
122 | |||
123 | m_LocalConnector.RegisterRegion(UUID.Zero, r2); | ||
124 | m_LocalConnector.RegisterRegion(UUID.Zero, r3); | ||
125 | |||
126 | List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1)); | ||
127 | Assert.IsNotNull(results, "Retrieved neighbours list is null"); | ||
128 | Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected"); | ||
129 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match"); | ||
130 | |||
131 | results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10); | ||
132 | Assert.IsNotNull(results, "Retrieved GetRegionsByName list is null"); | ||
133 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected"); | ||
134 | |||
135 | results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize, | ||
136 | 900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize); | ||
137 | Assert.IsNotNull(results, "Retrieved GetRegionRange list is null"); | ||
138 | Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); | ||
139 | } | ||
140 | } | ||
141 | } | ||