aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Tests/EstateTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/Tests/EstateTests.cs')
-rw-r--r--OpenSim/Data/Tests/EstateTests.cs540
1 files changed, 540 insertions, 0 deletions
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs
new file mode 100644
index 0000000..7f13925
--- /dev/null
+++ b/OpenSim/Data/Tests/EstateTests.cs
@@ -0,0 +1,540 @@
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
28using System;
29using log4net.Config;
30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces;
35using System.Text;
36using log4net;
37using System.Reflection;
38using System.Data.Common;
39
40
41// DBMS-specific:
42using MySql.Data.MySqlClient;
43using OpenSim.Data.MySQL;
44
45using System.Data.SqlClient;
46using OpenSim.Data.MSSQL;
47
48using Mono.Data.Sqlite;
49using OpenSim.Data.SQLite;
50
51
52namespace OpenSim.Data.Tests
53{
54 [TestFixture(typeof(MySqlConnection), typeof(MySQLEstateStore), Description = "Estate store tests (MySQL)")]
55 [TestFixture(typeof(SqlConnection), typeof(MSSQLEstateStore), Description = "Estate store tests (MS SQL Server)")]
56 [TestFixture(typeof(SqliteConnection), typeof(SQLiteEstateStore), Description = "Estate store tests (SQLite)")]
57
58 public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore>
59 where TConn : DbConnection, new()
60 where TEstateStore : class, IEstateDataStore, new()
61 {
62 public IEstateDataStore db;
63
64 public static UUID REGION_ID = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed7");
65
66 public static UUID USER_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed1");
67 public static UUID USER_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed2");
68
69 public static UUID MANAGER_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed3");
70 public static UUID MANAGER_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed4");
71
72 public static UUID GROUP_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed5");
73 public static UUID GROUP_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed6");
74
75 protected override void InitService(object service)
76 {
77 db = (IEstateDataStore)service;
78 db.Initialise(m_connStr);
79 ClearDB();
80 }
81
82 private void ClearDB()
83 {
84 // if a new table is added, it has to be dropped here
85 ExecuteSql("delete from migrations where name='EstateStore';");
86
87 DropTables(
88 "prims",
89 "primshapes",
90 "primitems",
91 "terrain",
92 "land",
93 "landaccesslist",
94 "regionban",
95 "regionsettings",
96 "estate_managers",
97 "estate_groups",
98 "estate_users",
99 "estateban",
100 "estate_settings",
101 "estate_map"
102 );
103 }
104
105 #region 0Tests
106
107 [Test]
108 public void T010_EstateSettingsSimpleStorage_MinimumParameterSet()
109 {
110 EstateSettingsSimpleStorage(
111 REGION_ID,
112 DataTestUtil.STRING_MIN,
113 DataTestUtil.UNSIGNED_INTEGER_MIN,
114 DataTestUtil.FLOAT_MIN,
115 DataTestUtil.INTEGER_MIN,
116 DataTestUtil.INTEGER_MIN,
117 DataTestUtil.INTEGER_MIN,
118 DataTestUtil.BOOLEAN_MIN,
119 DataTestUtil.BOOLEAN_MIN,
120 DataTestUtil.DOUBLE_MIN,
121 DataTestUtil.BOOLEAN_MIN,
122 DataTestUtil.BOOLEAN_MIN,
123 DataTestUtil.BOOLEAN_MIN,
124 DataTestUtil.BOOLEAN_MIN,
125 DataTestUtil.BOOLEAN_MIN,
126 DataTestUtil.BOOLEAN_MIN,
127 DataTestUtil.BOOLEAN_MIN,
128 DataTestUtil.BOOLEAN_MIN,
129 DataTestUtil.BOOLEAN_MIN,
130 DataTestUtil.BOOLEAN_MIN,
131 DataTestUtil.BOOLEAN_MIN,
132 DataTestUtil.BOOLEAN_MIN,
133 DataTestUtil.STRING_MIN,
134 DataTestUtil.UUID_MIN
135 );
136 }
137
138 [Test]
139 public void T011_EstateSettingsSimpleStorage_MaximumParameterSet()
140 {
141 EstateSettingsSimpleStorage(
142 REGION_ID,
143 DataTestUtil.STRING_MAX(64),
144 DataTestUtil.UNSIGNED_INTEGER_MAX,
145 DataTestUtil.FLOAT_MAX,
146 DataTestUtil.INTEGER_MAX,
147 DataTestUtil.INTEGER_MAX,
148 DataTestUtil.INTEGER_MAX,
149 DataTestUtil.BOOLEAN_MAX,
150 DataTestUtil.BOOLEAN_MAX,
151 DataTestUtil.DOUBLE_MAX,
152 DataTestUtil.BOOLEAN_MAX,
153 DataTestUtil.BOOLEAN_MAX,
154 DataTestUtil.BOOLEAN_MAX,
155 DataTestUtil.BOOLEAN_MAX,
156 DataTestUtil.BOOLEAN_MAX,
157 DataTestUtil.BOOLEAN_MAX,
158 DataTestUtil.BOOLEAN_MAX,
159 DataTestUtil.BOOLEAN_MAX,
160 DataTestUtil.BOOLEAN_MAX,
161 DataTestUtil.BOOLEAN_MAX,
162 DataTestUtil.BOOLEAN_MAX,
163 DataTestUtil.BOOLEAN_MAX,
164 DataTestUtil.STRING_MAX(255),
165 DataTestUtil.UUID_MAX
166 );
167 }
168
169 [Test]
170 public void T012_EstateSettingsSimpleStorage_AccurateParameterSet()
171 {
172 EstateSettingsSimpleStorage(
173 REGION_ID,
174 DataTestUtil.STRING_MAX(1),
175 DataTestUtil.UNSIGNED_INTEGER_MIN,
176 DataTestUtil.FLOAT_ACCURATE,
177 DataTestUtil.INTEGER_MIN,
178 DataTestUtil.INTEGER_MIN,
179 DataTestUtil.INTEGER_MIN,
180 DataTestUtil.BOOLEAN_MIN,
181 DataTestUtil.BOOLEAN_MIN,
182 DataTestUtil.DOUBLE_ACCURATE,
183 DataTestUtil.BOOLEAN_MIN,
184 DataTestUtil.BOOLEAN_MIN,
185 DataTestUtil.BOOLEAN_MIN,
186 DataTestUtil.BOOLEAN_MIN,
187 DataTestUtil.BOOLEAN_MIN,
188 DataTestUtil.BOOLEAN_MIN,
189 DataTestUtil.BOOLEAN_MIN,
190 DataTestUtil.BOOLEAN_MIN,
191 DataTestUtil.BOOLEAN_MIN,
192 DataTestUtil.BOOLEAN_MIN,
193 DataTestUtil.BOOLEAN_MIN,
194 DataTestUtil.BOOLEAN_MIN,
195 DataTestUtil.STRING_MAX(1),
196 DataTestUtil.UUID_MIN
197 );
198 }
199
200 [Test]
201 public void T012_EstateSettingsRandomStorage()
202 {
203 // Letting estate store generate rows to database for us
204 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
205 new PropertyScrambler<EstateSettings>()
206 .DontScramble(x=>x.EstateID)
207 .Scramble(originalSettings);
208
209 // Saving settings.
210 db.StoreEstateSettings(originalSettings);
211
212 // Loading settings to another instance variable.
213 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
214
215 // Checking that loaded values are correct.
216 Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
217 }
218
219 [Test]
220 public void T020_EstateSettingsManagerList()
221 {
222 // Letting estate store generate rows to database for us
223 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
224
225 originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
226
227 // Saving settings.
228 db.StoreEstateSettings(originalSettings);
229
230 // Loading settings to another instance variable.
231 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
232
233 Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
234 Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
235 Assert.AreEqual(MANAGER_ID_2, loadedSettings.EstateManagers[1]);
236 }
237
238 [Test]
239 public void T021_EstateSettingsUserList()
240 {
241 // Letting estate store generate rows to database for us
242 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
243
244 originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
245
246 // Saving settings.
247 db.StoreEstateSettings(originalSettings);
248
249 // Loading settings to another instance variable.
250 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
251
252 Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
253 Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
254 Assert.AreEqual(USER_ID_2, loadedSettings.EstateAccess[1]);
255 }
256
257 [Test]
258 public void T022_EstateSettingsGroupList()
259 {
260 // Letting estate store generate rows to database for us
261 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
262
263 originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
264
265 // Saving settings.
266 db.StoreEstateSettings(originalSettings);
267
268 // Loading settings to another instance variable.
269 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
270
271 Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
272 Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
273 Assert.AreEqual(GROUP_ID_2, loadedSettings.EstateGroups[1]);
274 }
275
276 [Test]
277 public void T022_EstateSettingsBanList()
278 {
279 // Letting estate store generate rows to database for us
280 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
281
282 EstateBan estateBan1 = new EstateBan();
283 estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
284
285 EstateBan estateBan2 = new EstateBan();
286 estateBan2.BannedUserID = DataTestUtil.UUID_MAX;
287
288 originalSettings.EstateBans = new EstateBan[] { estateBan1, estateBan2 };
289
290 // Saving settings.
291 db.StoreEstateSettings(originalSettings);
292
293 // Loading settings to another instance variable.
294 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
295
296 Assert.AreEqual(2, loadedSettings.EstateBans.Length);
297 Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
298
299 Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].BannedUserID);
300
301 }
302
303 #endregion
304
305 #region Parametrizable Test Implementations
306
307 private void EstateSettingsSimpleStorage(
308 UUID regionId,
309 string estateName,
310 uint parentEstateID,
311 float billableFactor,
312 int pricePerMeter,
313 int redirectGridX,
314 int redirectGridY,
315 bool useGlobalTime,
316 bool fixedSun,
317 double sunPosition,
318 bool allowVoice,
319 bool allowDirectTeleport,
320 bool resetHomeOnTeleport,
321 bool denyAnonymous,
322 bool denyIdentified,
323 bool denyTransacted,
324 bool denyMinors,
325 bool abuseEmailToEstateOwner,
326 bool blockDwell,
327 bool estateSkipScripts,
328 bool taxFree,
329 bool publicAccess,
330 string abuseEmail,
331 UUID estateOwner
332 )
333 {
334
335 // Letting estate store generate rows to database for us
336 EstateSettings originalSettings = db.LoadEstateSettings(regionId, true);
337
338 SetEstateSettings(
339 originalSettings,
340 estateName,
341 parentEstateID,
342 billableFactor,
343 pricePerMeter,
344 redirectGridX,
345 redirectGridY,
346 useGlobalTime,
347 fixedSun,
348 sunPosition,
349 allowVoice,
350 allowDirectTeleport,
351 resetHomeOnTeleport,
352 denyAnonymous,
353 denyIdentified,
354 denyTransacted,
355 denyMinors,
356 abuseEmailToEstateOwner,
357 blockDwell,
358 estateSkipScripts,
359 taxFree,
360 publicAccess,
361 abuseEmail,
362 estateOwner
363 );
364
365 originalSettings.EstateName = estateName;
366 originalSettings.ParentEstateID = parentEstateID;
367 originalSettings.BillableFactor = billableFactor;
368 originalSettings.PricePerMeter = pricePerMeter;
369 originalSettings.RedirectGridX = redirectGridX;
370 originalSettings.RedirectGridY = redirectGridY;
371 originalSettings.UseGlobalTime = useGlobalTime;
372 originalSettings.FixedSun = fixedSun;
373 originalSettings.SunPosition = sunPosition;
374 originalSettings.AllowVoice = allowVoice;
375 originalSettings.AllowDirectTeleport = allowDirectTeleport;
376 originalSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
377 originalSettings.DenyAnonymous = denyAnonymous;
378 originalSettings.DenyIdentified = denyIdentified;
379 originalSettings.DenyTransacted = denyTransacted;
380 originalSettings.DenyMinors = denyMinors;
381 originalSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
382 originalSettings.BlockDwell = blockDwell;
383 originalSettings.EstateSkipScripts = estateSkipScripts;
384 originalSettings.TaxFree = taxFree;
385 originalSettings.PublicAccess = publicAccess;
386 originalSettings.AbuseEmail = abuseEmail;
387 originalSettings.EstateOwner = estateOwner;
388
389 // Saving settings.
390 db.StoreEstateSettings(originalSettings);
391
392 // Loading settings to another instance variable.
393 EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true);
394
395 // Checking that loaded values are correct.
396 ValidateEstateSettings(
397 loadedSettings,
398 estateName,
399 parentEstateID,
400 billableFactor,
401 pricePerMeter,
402 redirectGridX,
403 redirectGridY,
404 useGlobalTime,
405 fixedSun,
406 sunPosition,
407 allowVoice,
408 allowDirectTeleport,
409 resetHomeOnTeleport,
410 denyAnonymous,
411 denyIdentified,
412 denyTransacted,
413 denyMinors,
414 abuseEmailToEstateOwner,
415 blockDwell,
416 estateSkipScripts,
417 taxFree,
418 publicAccess,
419 abuseEmail,
420 estateOwner
421 );
422
423 }
424
425 #endregion
426
427 #region EstateSetting Initialization and Validation Methods
428
429 private void SetEstateSettings(
430 EstateSettings estateSettings,
431 string estateName,
432 uint parentEstateID,
433 float billableFactor,
434 int pricePerMeter,
435 int redirectGridX,
436 int redirectGridY,
437 bool useGlobalTime,
438 bool fixedSun,
439 double sunPosition,
440 bool allowVoice,
441 bool allowDirectTeleport,
442 bool resetHomeOnTeleport,
443 bool denyAnonymous,
444 bool denyIdentified,
445 bool denyTransacted,
446 bool denyMinors,
447 bool abuseEmailToEstateOwner,
448 bool blockDwell,
449 bool estateSkipScripts,
450 bool taxFree,
451 bool publicAccess,
452 string abuseEmail,
453 UUID estateOwner
454 )
455 {
456 estateSettings.EstateName = estateName;
457 estateSettings.ParentEstateID = parentEstateID;
458 estateSettings.BillableFactor = billableFactor;
459 estateSettings.PricePerMeter = pricePerMeter;
460 estateSettings.RedirectGridX = redirectGridX;
461 estateSettings.RedirectGridY = redirectGridY;
462 estateSettings.UseGlobalTime = useGlobalTime;
463 estateSettings.FixedSun = fixedSun;
464 estateSettings.SunPosition = sunPosition;
465 estateSettings.AllowVoice = allowVoice;
466 estateSettings.AllowDirectTeleport = allowDirectTeleport;
467 estateSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
468 estateSettings.DenyAnonymous = denyAnonymous;
469 estateSettings.DenyIdentified = denyIdentified;
470 estateSettings.DenyTransacted = denyTransacted;
471 estateSettings.DenyMinors = denyMinors;
472 estateSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
473 estateSettings.BlockDwell = blockDwell;
474 estateSettings.EstateSkipScripts = estateSkipScripts;
475 estateSettings.TaxFree = taxFree;
476 estateSettings.PublicAccess = publicAccess;
477 estateSettings.AbuseEmail = abuseEmail;
478 estateSettings.EstateOwner = estateOwner;
479 }
480
481 private void ValidateEstateSettings(
482 EstateSettings estateSettings,
483 string estateName,
484 uint parentEstateID,
485 float billableFactor,
486 int pricePerMeter,
487 int redirectGridX,
488 int redirectGridY,
489 bool useGlobalTime,
490 bool fixedSun,
491 double sunPosition,
492 bool allowVoice,
493 bool allowDirectTeleport,
494 bool resetHomeOnTeleport,
495 bool denyAnonymous,
496 bool denyIdentified,
497 bool denyTransacted,
498 bool denyMinors,
499 bool abuseEmailToEstateOwner,
500 bool blockDwell,
501 bool estateSkipScripts,
502 bool taxFree,
503 bool publicAccess,
504 string abuseEmail,
505 UUID estateOwner
506 )
507 {
508 Assert.AreEqual(estateName, estateSettings.EstateName);
509 Assert.AreEqual(parentEstateID, estateSettings.ParentEstateID);
510
511 DataTestUtil.AssertFloatEqualsWithTolerance(billableFactor, estateSettings.BillableFactor);
512
513 Assert.AreEqual(pricePerMeter, estateSettings.PricePerMeter);
514 Assert.AreEqual(redirectGridX, estateSettings.RedirectGridX);
515 Assert.AreEqual(redirectGridY, estateSettings.RedirectGridY);
516 Assert.AreEqual(useGlobalTime, estateSettings.UseGlobalTime);
517 Assert.AreEqual(fixedSun, estateSettings.FixedSun);
518
519 DataTestUtil.AssertDoubleEqualsWithTolerance(sunPosition, estateSettings.SunPosition);
520
521 Assert.AreEqual(allowVoice, estateSettings.AllowVoice);
522 Assert.AreEqual(allowDirectTeleport, estateSettings.AllowDirectTeleport);
523 Assert.AreEqual(resetHomeOnTeleport, estateSettings.ResetHomeOnTeleport);
524 Assert.AreEqual(denyAnonymous, estateSettings.DenyAnonymous);
525 Assert.AreEqual(denyIdentified, estateSettings.DenyIdentified);
526 Assert.AreEqual(denyTransacted, estateSettings.DenyTransacted);
527 Assert.AreEqual(denyMinors, estateSettings.DenyMinors);
528 Assert.AreEqual(abuseEmailToEstateOwner, estateSettings.AbuseEmailToEstateOwner);
529 Assert.AreEqual(blockDwell, estateSettings.BlockDwell);
530 Assert.AreEqual(estateSkipScripts, estateSettings.EstateSkipScripts);
531 Assert.AreEqual(taxFree, estateSettings.TaxFree);
532 Assert.AreEqual(publicAccess, estateSettings.PublicAccess);
533 Assert.AreEqual(abuseEmail, estateSettings.AbuseEmail);
534 Assert.AreEqual(estateOwner, estateSettings.EstateOwner);
535 }
536
537 #endregion
538
539 }
540}