aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/Tests')
-rw-r--r--OpenSim/Data/Tests/BasicGridTest.cs265
1 files changed, 265 insertions, 0 deletions
diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs
new file mode 100644
index 0000000..b9cf4cf
--- /dev/null
+++ b/OpenSim/Data/Tests/BasicGridTest.cs
@@ -0,0 +1,265 @@
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 OpenSim 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 NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenSim.Data;
34using OpenSim.Framework;
35using OpenSim.Region.Environment.Scenes;
36using OpenMetaverse;
37
38namespace OpenSim.Data.Tests
39{
40 public class BasicGridTest
41 {
42 public GridDataBase db;
43 public UUID region1, region2, region3;
44 public UUID zero = UUID.Zero;
45 public static Random random;
46
47
48 public void SuperInit()
49 {
50 try
51 {
52 log4net.Config.XmlConfigurator.Configure();
53 }
54 catch (Exception)
55 {
56 // I don't care, just leave log4net off
57 }
58 region1 = UUID.Random();
59 region2 = UUID.Random();
60 region3 = UUID.Random();
61 random = new Random();
62 }
63
64 [Test]
65 public void T001_LoadEmpty()
66 {
67 Assert.That(db.GetProfileByUUID(region1),Is.Null);
68 Assert.That(db.GetProfileByUUID(region2),Is.Null);
69 Assert.That(db.GetProfileByUUID(region3),Is.Null);
70 Assert.That(db.GetProfileByUUID(zero),Is.Null);
71 }
72
73 [Test]
74 public void T999_StillNull()
75 {
76 Assert.That(db.GetProfileByUUID(zero),Is.Null);
77 }
78
79 [Test]
80 public void T010_SimpleAddRetrieveProfile()
81 {
82 RegionProfileData reg = new RegionProfileData();
83 reg.Uuid = region1;
84 reg.RegionName = "My new Region";
85 reg.RegionHandle = (ulong) random.Next();
86 reg.RegionLocX = 1000;
87 reg.RegionLocY = 1000;
88 reg.RegionLocZ = 0;
89
90 db.AddProfile(reg);
91
92 RegionProfileData retreg = db.GetProfileByUUID(region1);
93
94 Assert.That(retreg.RegionName, Is.EqualTo("My new Region"));
95 Assert.That(retreg.Uuid, Is.EqualTo(region1));
96 }
97
98 [Test]
99 public void T011_AddRetrieveCompleteTest()
100 {
101 string regionname = "|<Goth@m Ci1y>|";
102 ulong regionhandle = (ulong) random.Next();
103 uint regionlocx = (uint) random.Next();
104 uint regionlocy = (uint) random.Next();
105 uint regionlocz = (uint) random.Next();
106 string regionsendkey = RandomName();
107 string regionrecvkey = RandomName();
108 string regionsecret = RandomName();
109 bool regiononline = false;
110 string serverip = RandomName();
111 uint serverport = (uint) random.Next();
112 string serveruri = RandomName();
113 uint serverhttpport = (uint) random.Next();
114 uint serverremotingport = (uint) random.Next();
115 ulong northovrhandle = (ulong) random.Next();
116 ulong southovrhandle = (ulong) random.Next();
117 ulong eastovrhandle = (ulong) random.Next();
118 ulong westovrhandle = (ulong) random.Next();
119 string regiondatauri = RandomName();
120 string regionasseturi = RandomName();
121 string regionassetsendkey = RandomName();
122 string regionassetrcvkey = RandomName();
123 string regionuseruri = RandomName();
124 string regionusersendkey = RandomName();
125 string regionuserrcvkey = RandomName();
126 UUID regionmaptextureid = UUID.Random();
127 UUID owner_uuid = UUID.Random();
128 UUID originuuid = UUID.Random();
129
130
131 RegionProfileData reg = new RegionProfileData();
132 reg.Uuid = region2;
133 reg.RegionName = regionname;
134 reg.RegionHandle = regionhandle;
135 reg.RegionLocX = regionlocx;
136 reg.RegionLocY = regionlocy;
137 reg.RegionLocZ = regionlocz;
138 reg.RegionSendKey = regionsendkey;
139 reg.RegionRecvKey = regionrecvkey;
140 reg.RegionSecret = regionsecret;
141 reg.RegionOnline = regiononline;
142 reg.OriginUUID = originuuid;
143 reg.ServerIP = serverip;
144 reg.ServerPort = serverport;
145 reg.ServerURI = serveruri;
146 reg.ServerHttpPort = serverhttpport;
147 reg.ServerRemotingPort = serverremotingport;
148 reg.NorthOverrideHandle = northovrhandle;
149 reg.SouthOverrideHandle = southovrhandle;
150 reg.EastOverrideHandle = eastovrhandle;
151 reg.WestOverrideHandle = westovrhandle;
152 reg.RegionDataURI = regiondatauri;
153 reg.RegionAssetURI = regionasseturi;
154 reg.RegionAssetSendKey = regionassetsendkey;
155 reg.RegionAssetRecvKey = regionassetrcvkey;
156 reg.RegionUserURI = regionuseruri;
157 reg.RegionUserSendKey = regionusersendkey;
158 reg.RegionUserRecvKey = regionuserrcvkey;
159 reg.RegionMapTextureID = regionmaptextureid;
160 reg.Owner_uuid = owner_uuid;
161 reg.OriginUUID = originuuid;
162
163 db.AddProfile(reg);
164
165 RegionProfileData retreg = db.GetProfileByUUID(region2);
166
167 Assert.That(retreg.RegionName, Is.EqualTo(regionname));
168 Assert.That(retreg.Uuid, Is.EqualTo(region2));
169 Assert.That(retreg.RegionHandle, Is.EqualTo(regionhandle));
170 Assert.That(retreg.RegionLocX, Is.EqualTo(regionlocx));
171 Assert.That(retreg.RegionLocY, Is.EqualTo(regionlocy));
172 Assert.That(retreg.RegionLocZ, Is.EqualTo(regionlocz));
173 Assert.That(retreg.RegionSendKey, Is.EqualTo(regionsendkey));
174 Assert.That(retreg.RegionRecvKey, Is.EqualTo(regionrecvkey));
175 Assert.That(retreg.RegionSecret, Is.EqualTo(regionsecret));
176 Assert.That(retreg.RegionOnline, Is.EqualTo(regiononline));
177 Assert.That(retreg.OriginUUID, Is.EqualTo(originuuid));
178 Assert.That(retreg.ServerIP, Is.EqualTo(serverip));
179 Assert.That(retreg.ServerPort, Is.EqualTo(serverport));
180 Assert.That(retreg.ServerURI, Is.EqualTo(serveruri));
181 Assert.That(retreg.ServerHttpPort, Is.EqualTo(serverhttpport));
182 Assert.That(retreg.ServerRemotingPort, Is.EqualTo(serverremotingport));
183 Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(northovrhandle));
184 Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(southovrhandle));
185 Assert.That(retreg.EastOverrideHandle, Is.EqualTo(eastovrhandle));
186 Assert.That(retreg.WestOverrideHandle, Is.EqualTo(westovrhandle));
187 Assert.That(retreg.RegionDataURI, Is.EqualTo(regiondatauri));
188 Assert.That(retreg.RegionAssetURI, Is.EqualTo(regionasseturi));
189 Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(regionassetsendkey));
190 Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(regionassetrcvkey));
191 Assert.That(retreg.RegionUserURI, Is.EqualTo(regionuseruri));
192 Assert.That(retreg.RegionUserSendKey, Is.EqualTo(regionusersendkey));
193 Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(regionuserrcvkey));
194 Assert.That(retreg.RegionMapTextureID, Is.EqualTo(regionmaptextureid));
195 Assert.That(retreg.Owner_uuid, Is.EqualTo(owner_uuid));
196 Assert.That(retreg.OriginUUID, Is.EqualTo(originuuid));
197
198 retreg = db.GetProfileByHandle(regionhandle);
199 Assert.That(retreg.Uuid, Is.EqualTo(region2));
200
201 retreg = db.GetProfileByString(regionname);
202 Assert.That(retreg.Uuid, Is.EqualTo(region2));
203
204 RegionProfileData[] retregs = db.GetProfilesInRange(regionlocx,regionlocy,regionlocx,regionlocy);
205 Assert.That(retregs[0].Uuid, Is.EqualTo(region2));
206 }
207
208 [Test]
209 public void T012_DeleteProfile()
210 {
211 db.DeleteProfile(region1.ToString());
212 RegionProfileData retreg = db.GetProfileByUUID(region1);
213 Assert.That(retreg,Is.Null);
214 }
215
216 [Test]
217 public void T013_UpdateProfile()
218 {
219 RegionProfileData retreg = db.GetProfileByUUID(region2);
220 retreg.regionName = "Gotham City";
221
222 db.UpdateProfile(retreg);
223
224 retreg = db.GetProfileByUUID(region2);
225 Assert.That(retreg.RegionName, Is.EqualTo("Gotham City"));
226 }
227
228 [Test]
229 public void T014_RegionList()
230 {
231 RegionProfileData retreg = db.GetProfileByUUID(region2);
232 retreg.RegionName = "Gotham Town";
233 retreg.Uuid = region1;
234
235 db.AddProfile(retreg);
236
237 retreg = db.GetProfileByUUID(region2);
238 retreg.RegionName = "Gothan Town";
239 retreg.Uuid = region3;
240
241 db.AddProfile(retreg);
242
243 List<RegionProfileData> listreg = db.GetRegionsByName("Gotham",10);
244
245 Assert.That(listreg.Count,Is.EqualTo(2));
246 Assert.That(listreg[0].Uuid,Is.Not.EqualTo(listreg[1].Uuid));
247 Assert.That(listreg[0].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2));
248 Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2));
249 }
250
251 [Test]
252 public static string RandomName()
253 {
254 StringBuilder name = new StringBuilder();
255 int size = random.Next(5,12);
256 char ch ;
257 for (int i=0; i<size; i++)
258 {
259 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
260 name.Append(ch);
261 }
262 return name.ToString();
263 }
264 }
265}