diff options
author | Diva Canto | 2009-09-23 20:35:16 -0700 |
---|---|---|
committer | Diva Canto | 2009-09-23 20:35:16 -0700 |
commit | 3c19bd5142479e468aa9841a2177ddd33b46f8f6 (patch) | |
tree | 6392a56c1a482a2a1a3267b470990f184aff33bd /OpenSim | |
parent | Changed IGridService to use the new GridRegion data structure instead of old ... (diff) | |
download | opensim-SC_OLD-3c19bd5142479e468aa9841a2177ddd33b46f8f6.zip opensim-SC_OLD-3c19bd5142479e468aa9841a2177ddd33b46f8f6.tar.gz opensim-SC_OLD-3c19bd5142479e468aa9841a2177ddd33b46f8f6.tar.bz2 opensim-SC_OLD-3c19bd5142479e468aa9841a2177ddd33b46f8f6.tar.xz |
Unit tests for the grid service. Yey!
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | 122 |
1 files changed, 122 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..8d44249 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -0,0 +1,122 @@ | |||
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 | |||
82 | GridRegion r2 = new GridRegion(); | ||
83 | r2.RegionName = "Test Region 2"; | ||
84 | r2.RegionID = new UUID(2); | ||
85 | r2.RegionLocX = 1000 * (int)Constants.RegionSize + 1; | ||
86 | r2.RegionLocY = 1000 * (int)Constants.RegionSize; | ||
87 | r2.ExternalHostName = "127.0.0.1"; | ||
88 | r2.HttpPort = 9002; | ||
89 | r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | ||
90 | |||
91 | GridRegion r3 = new GridRegion(); | ||
92 | r3.RegionName = "Test Region 3"; | ||
93 | r3.RegionID = new UUID(3); | ||
94 | r3.RegionLocX = 1000 * (int)Constants.RegionSize + 5; | ||
95 | r3.RegionLocY = 1000 * (int)Constants.RegionSize; | ||
96 | r3.ExternalHostName = "127.0.0.1"; | ||
97 | r3.HttpPort = 9003; | ||
98 | r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | ||
99 | |||
100 | m_LocalConnector.RegisterRegion(UUID.Zero, r1); | ||
101 | GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test"); | ||
102 | Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); | ||
103 | Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); | ||
104 | |||
105 | result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); | ||
106 | Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); | ||
107 | Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); | ||
108 | |||
109 | result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); | ||
110 | Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); | ||
111 | Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); | ||
112 | |||
113 | m_LocalConnector.RegisterRegion(UUID.Zero, r2); | ||
114 | m_LocalConnector.RegisterRegion(UUID.Zero, r3); | ||
115 | |||
116 | List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1)); | ||
117 | Assert.IsNotNull(results, "Retrieved neighbours list is null"); | ||
118 | Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected"); | ||
119 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2))); | ||
120 | } | ||
121 | } | ||
122 | } | ||