diff options
Diffstat (limited to 'OpenSim/Data/Tests/RegionTests.cs')
-rw-r--r-- | OpenSim/Data/Tests/RegionTests.cs | 161 |
1 files changed, 84 insertions, 77 deletions
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs index 8d4249a..4f81594 100644 --- a/OpenSim/Data/Tests/RegionTests.cs +++ b/OpenSim/Data/Tests/RegionTests.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Tests.Common; | |||
39 | using log4net; | 39 | using log4net; |
40 | using System.Reflection; | 40 | using System.Reflection; |
41 | using System.Data.Common; | 41 | using System.Data.Common; |
42 | using System.Threading; | ||
42 | 43 | ||
43 | // DBMS-specific: | 44 | // DBMS-specific: |
44 | using MySql.Data.MySqlClient; | 45 | using MySql.Data.MySqlClient; |
@@ -82,7 +83,7 @@ namespace OpenSim.Data.Tests | |||
82 | public UUID item3 = UUID.Random(); | 83 | public UUID item3 = UUID.Random(); |
83 | 84 | ||
84 | public static Random random = new Random(); | 85 | public static Random random = new Random(); |
85 | 86 | ||
86 | public string itemname1 = "item1"; | 87 | public string itemname1 = "item1"; |
87 | 88 | ||
88 | public uint localID = 1; | 89 | public uint localID = 1; |
@@ -110,10 +111,10 @@ namespace OpenSim.Data.Tests | |||
110 | 111 | ||
111 | private void ClearDB() | 112 | private void ClearDB() |
112 | { | 113 | { |
113 | string[] reg_tables = new string[] { | 114 | string[] reg_tables = new string[] { |
114 | "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings" | 115 | "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings" |
115 | }; | 116 | }; |
116 | 117 | ||
117 | if (m_rebuildDB) | 118 | if (m_rebuildDB) |
118 | { | 119 | { |
119 | DropTables(reg_tables); | 120 | DropTables(reg_tables); |
@@ -144,7 +145,7 @@ namespace OpenSim.Data.Tests | |||
144 | public void T001_LoadEmpty() | 145 | public void T001_LoadEmpty() |
145 | { | 146 | { |
146 | TestHelpers.InMethod(); | 147 | TestHelpers.InMethod(); |
147 | 148 | ||
148 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | 149 | List<SceneObjectGroup> objs = db.LoadObjects(region1); |
149 | List<SceneObjectGroup> objs3 = db.LoadObjects(region3); | 150 | List<SceneObjectGroup> objs3 = db.LoadObjects(region3); |
150 | List<LandData> land = db.LoadLandObjects(region1); | 151 | List<LandData> land = db.LoadLandObjects(region1); |
@@ -153,21 +154,21 @@ namespace OpenSim.Data.Tests | |||
153 | Assert.That(objs3.Count, Is.EqualTo(0), "Assert.That(objs3.Count, Is.EqualTo(0))"); | 154 | Assert.That(objs3.Count, Is.EqualTo(0), "Assert.That(objs3.Count, Is.EqualTo(0))"); |
154 | Assert.That(land.Count, Is.EqualTo(0), "Assert.That(land.Count, Is.EqualTo(0))"); | 155 | Assert.That(land.Count, Is.EqualTo(0), "Assert.That(land.Count, Is.EqualTo(0))"); |
155 | } | 156 | } |
156 | 157 | ||
157 | // SOG round trips | 158 | // SOG round trips |
158 | // * store objects, make sure they save | 159 | // * store objects, make sure they save |
159 | // * update | 160 | // * update |
160 | 161 | ||
161 | [Test] | 162 | [Test] |
162 | public void T010_StoreSimpleObject() | 163 | public void T010_StoreSimpleObject() |
163 | { | 164 | { |
164 | TestHelpers.InMethod(); | 165 | TestHelpers.InMethod(); |
165 | 166 | ||
166 | SceneObjectGroup sog = NewSOG("object1", prim1, region1); | 167 | SceneObjectGroup sog = NewSOG("object1", prim1, region1); |
167 | SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); | 168 | SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); |
168 | 169 | ||
169 | // in case the objects don't store | 170 | // in case the objects don't store |
170 | try | 171 | try |
171 | { | 172 | { |
172 | db.StoreObject(sog, region1); | 173 | db.StoreObject(sog, region1); |
173 | } | 174 | } |
@@ -176,8 +177,8 @@ namespace OpenSim.Data.Tests | |||
176 | m_log.Error(e.ToString()); | 177 | m_log.Error(e.ToString()); |
177 | Assert.Fail(); | 178 | Assert.Fail(); |
178 | } | 179 | } |
179 | 180 | ||
180 | try | 181 | try |
181 | { | 182 | { |
182 | db.StoreObject(sog2, region1); | 183 | db.StoreObject(sog2, region1); |
183 | } | 184 | } |
@@ -189,15 +190,15 @@ namespace OpenSim.Data.Tests | |||
189 | 190 | ||
190 | // This tests the ADO.NET driver | 191 | // This tests the ADO.NET driver |
191 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | 192 | List<SceneObjectGroup> objs = db.LoadObjects(region1); |
192 | 193 | ||
193 | Assert.That(objs.Count, Is.EqualTo(2), "Assert.That(objs.Count, Is.EqualTo(2))"); | 194 | Assert.That(objs.Count, Is.EqualTo(2), "Assert.That(objs.Count, Is.EqualTo(2))"); |
194 | } | 195 | } |
195 | 196 | ||
196 | [Test] | 197 | [Test] |
197 | public void T011_ObjectNames() | 198 | public void T011_ObjectNames() |
198 | { | 199 | { |
199 | TestHelpers.InMethod(); | 200 | TestHelpers.InMethod(); |
200 | 201 | ||
201 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | 202 | List<SceneObjectGroup> objs = db.LoadObjects(region1); |
202 | foreach (SceneObjectGroup sog in objs) | 203 | foreach (SceneObjectGroup sog in objs) |
203 | { | 204 | { |
@@ -206,12 +207,12 @@ namespace OpenSim.Data.Tests | |||
206 | Assert.That(p.Name, Is.EqualTo(p.Description), "Assert.That(p.Name, Is.EqualTo(p.Description))"); | 207 | Assert.That(p.Name, Is.EqualTo(p.Description), "Assert.That(p.Name, Is.EqualTo(p.Description))"); |
207 | } | 208 | } |
208 | } | 209 | } |
209 | 210 | ||
210 | [Test] | 211 | [Test] |
211 | public void T012_SceneParts() | 212 | public void T012_SceneParts() |
212 | { | 213 | { |
213 | TestHelpers.InMethod(); | 214 | TestHelpers.InMethod(); |
214 | 215 | ||
215 | UUID tmp0 = UUID.Random(); | 216 | UUID tmp0 = UUID.Random(); |
216 | UUID tmp1 = UUID.Random(); | 217 | UUID tmp1 = UUID.Random(); |
217 | UUID tmp2 = UUID.Random(); | 218 | UUID tmp2 = UUID.Random(); |
@@ -224,10 +225,10 @@ namespace OpenSim.Data.Tests | |||
224 | sog.AddPart(p1); | 225 | sog.AddPart(p1); |
225 | sog.AddPart(p2); | 226 | sog.AddPart(p2); |
226 | sog.AddPart(p3); | 227 | sog.AddPart(p3); |
227 | 228 | ||
228 | SceneObjectPart[] parts = sog.Parts; | 229 | SceneObjectPart[] parts = sog.Parts; |
229 | Assert.That(parts.Length,Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); | 230 | Assert.That(parts.Length,Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); |
230 | 231 | ||
231 | db.StoreObject(sog, newregion); | 232 | db.StoreObject(sog, newregion); |
232 | List<SceneObjectGroup> sogs = db.LoadObjects(newregion); | 233 | List<SceneObjectGroup> sogs = db.LoadObjects(newregion); |
233 | Assert.That(sogs.Count,Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); | 234 | Assert.That(sogs.Count,Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); |
@@ -235,18 +236,18 @@ namespace OpenSim.Data.Tests | |||
235 | 236 | ||
236 | SceneObjectPart[] newparts = newsog.Parts; | 237 | SceneObjectPart[] newparts = newsog.Parts; |
237 | Assert.That(newparts.Length,Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); | 238 | Assert.That(newparts.Length,Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); |
238 | 239 | ||
239 | Assert.That(newsog.ContainsPart(tmp0), "Assert.That(newsog.ContainsPart(tmp0))"); | 240 | Assert.That(newsog.ContainsPart(tmp0), "Assert.That(newsog.ContainsPart(tmp0))"); |
240 | Assert.That(newsog.ContainsPart(tmp1), "Assert.That(newsog.ContainsPart(tmp1))"); | 241 | Assert.That(newsog.ContainsPart(tmp1), "Assert.That(newsog.ContainsPart(tmp1))"); |
241 | Assert.That(newsog.ContainsPart(tmp2), "Assert.That(newsog.ContainsPart(tmp2))"); | 242 | Assert.That(newsog.ContainsPart(tmp2), "Assert.That(newsog.ContainsPart(tmp2))"); |
242 | Assert.That(newsog.ContainsPart(tmp3), "Assert.That(newsog.ContainsPart(tmp3))"); | 243 | Assert.That(newsog.ContainsPart(tmp3), "Assert.That(newsog.ContainsPart(tmp3))"); |
243 | } | 244 | } |
244 | 245 | ||
245 | [Test] | 246 | [Test] |
246 | public void T013_DatabasePersistency() | 247 | public void T013_DatabasePersistency() |
247 | { | 248 | { |
248 | TestHelpers.InMethod(); | 249 | TestHelpers.InMethod(); |
249 | 250 | ||
250 | // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data | 251 | // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data |
251 | // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored | 252 | // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored |
252 | // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. | 253 | // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. |
@@ -259,7 +260,7 @@ namespace OpenSim.Data.Tests | |||
259 | uint localid = localID+1; | 260 | uint localid = localID+1; |
260 | localID = localID + 1; | 261 | localID = localID + 1; |
261 | string name = "Adam West"; | 262 | string name = "Adam West"; |
262 | byte material = (byte) random.Next(127); | 263 | byte material = (byte) random.Next((int)SOPMaterialData.MaxMaterial); |
263 | ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); | 264 | ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); |
264 | int pin = random.Next(); | 265 | int pin = random.Next(); |
265 | Byte[] partsys = new byte[8]; | 266 | Byte[] partsys = new byte[8]; |
@@ -297,7 +298,7 @@ namespace OpenSim.Data.Tests | |||
297 | 298 | ||
298 | SceneObjectPart sop = new SceneObjectPart(); | 299 | SceneObjectPart sop = new SceneObjectPart(); |
299 | SceneObjectGroup sog = new SceneObjectGroup(sop); | 300 | SceneObjectGroup sog = new SceneObjectGroup(sop); |
300 | 301 | ||
301 | sop.RegionHandle = regionh; | 302 | sop.RegionHandle = regionh; |
302 | sop.UUID = uuid; | 303 | sop.UUID = uuid; |
303 | sop.LocalId = localid; | 304 | sop.LocalId = localid; |
@@ -359,10 +360,10 @@ namespace OpenSim.Data.Tests | |||
359 | Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))"); | 360 | Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))"); |
360 | Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))"); | 361 | Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))"); |
361 | Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))"); | 362 | Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))"); |
362 | 363 | ||
363 | // This is necessary or object will not be inserted in DB | 364 | // This is necessary or object will not be inserted in DB |
364 | sop.Flags = PrimFlags.None; | 365 | sop.Flags = PrimFlags.None; |
365 | 366 | ||
366 | // Inserts group in DB | 367 | // Inserts group in DB |
367 | db.StoreObject(sog,region3); | 368 | db.StoreObject(sog,region3); |
368 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); | 369 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); |
@@ -371,7 +372,7 @@ namespace OpenSim.Data.Tests | |||
371 | db.StoreObject(sog,region3); | 372 | db.StoreObject(sog,region3); |
372 | sogs = db.LoadObjects(region3); | 373 | sogs = db.LoadObjects(region3); |
373 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); | 374 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); |
374 | 375 | ||
375 | 376 | ||
376 | // Tests if the parameters were inserted correctly | 377 | // Tests if the parameters were inserted correctly |
377 | SceneObjectPart p = sogs[0].RootPart; | 378 | SceneObjectPart p = sogs[0].RootPart; |
@@ -413,12 +414,12 @@ namespace OpenSim.Data.Tests | |||
413 | Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))"); | 414 | Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))"); |
414 | Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))"); | 415 | Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))"); |
415 | } | 416 | } |
416 | 417 | ||
417 | [Test] | 418 | [Test] |
418 | public void T014_UpdateObject() | 419 | public void T014_UpdateObject() |
419 | { | 420 | { |
420 | TestHelpers.InMethod(); | 421 | TestHelpers.InMethod(); |
421 | 422 | ||
422 | string text1 = "object1 text"; | 423 | string text1 = "object1 text"; |
423 | SceneObjectGroup sog = FindSOG("object1", region1); | 424 | SceneObjectGroup sog = FindSOG("object1", region1); |
424 | sog.RootPart.Text = text1; | 425 | sog.RootPart.Text = text1; |
@@ -433,7 +434,7 @@ namespace OpenSim.Data.Tests | |||
433 | TaskInventoryDictionary dic = new TaskInventoryDictionary(); | 434 | TaskInventoryDictionary dic = new TaskInventoryDictionary(); |
434 | localID = localID + 1; | 435 | localID = localID + 1; |
435 | string name = "West Adam"; | 436 | string name = "West Adam"; |
436 | byte material = (byte) random.Next(127); | 437 | byte material = (byte) random.Next((int)SOPMaterialData.MaxMaterial); |
437 | ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); | 438 | ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); |
438 | int pin = random.Next(); | 439 | int pin = random.Next(); |
439 | Byte[] partsys = new byte[8]; | 440 | Byte[] partsys = new byte[8]; |
@@ -458,7 +459,7 @@ namespace OpenSim.Data.Tests | |||
458 | PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); | 459 | PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); |
459 | pbshap = PrimitiveBaseShape.Default; | 460 | pbshap = PrimitiveBaseShape.Default; |
460 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); | 461 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); |
461 | 462 | ||
462 | // Updates the region with new values | 463 | // Updates the region with new values |
463 | SceneObjectGroup sog2 = FindSOG("Adam West", region3); | 464 | SceneObjectGroup sog2 = FindSOG("Adam West", region3); |
464 | Assert.That(sog2,Is.Not.Null); | 465 | Assert.That(sog2,Is.Not.Null); |
@@ -487,11 +488,11 @@ namespace OpenSim.Data.Tests | |||
487 | sog2.RootPart.LinkNum = linknum; | 488 | sog2.RootPart.LinkNum = linknum; |
488 | sog2.RootPart.ClickAction = clickaction; | 489 | sog2.RootPart.ClickAction = clickaction; |
489 | sog2.RootPart.Scale = scale; | 490 | sog2.RootPart.Scale = scale; |
490 | 491 | ||
491 | db.StoreObject(sog2, region3); | 492 | db.StoreObject(sog2, region3); |
492 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); | 493 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); |
493 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); | 494 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); |
494 | 495 | ||
495 | SceneObjectGroup retsog = FindSOG("West Adam", region3); | 496 | SceneObjectGroup retsog = FindSOG("West Adam", region3); |
496 | Assert.That(retsog,Is.Not.Null); | 497 | Assert.That(retsog,Is.Not.Null); |
497 | SceneObjectPart p = retsog.RootPart; | 498 | SceneObjectPart p = retsog.RootPart; |
@@ -518,7 +519,7 @@ namespace OpenSim.Data.Tests | |||
518 | Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); | 519 | Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); |
519 | Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); | 520 | Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); |
520 | } | 521 | } |
521 | 522 | ||
522 | /// <summary> | 523 | /// <summary> |
523 | /// Test storage and retrieval of a scene object with a large number of parts. | 524 | /// Test storage and retrieval of a scene object with a large number of parts. |
524 | /// </summary> | 525 | /// </summary> |
@@ -526,12 +527,12 @@ namespace OpenSim.Data.Tests | |||
526 | public void T015_LargeSceneObjects() | 527 | public void T015_LargeSceneObjects() |
527 | { | 528 | { |
528 | TestHelpers.InMethod(); | 529 | TestHelpers.InMethod(); |
529 | 530 | ||
530 | UUID id = UUID.Random(); | 531 | UUID id = UUID.Random(); |
531 | Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); | 532 | Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); |
532 | SceneObjectGroup sog = NewSOG("Test SOG", id, region4); | 533 | SceneObjectGroup sog = NewSOG("Test SOG", id, region4); |
533 | mydic.Add(sog.RootPart.UUID,sog.RootPart); | 534 | mydic.Add(sog.RootPart.UUID,sog.RootPart); |
534 | for (int i = 0; i < 30; i++) | 535 | for (int i = 0; i < 30; i++) |
535 | { | 536 | { |
536 | UUID tmp = UUID.Random(); | 537 | UUID tmp = UUID.Random(); |
537 | SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); | 538 | SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); |
@@ -541,20 +542,20 @@ namespace OpenSim.Data.Tests | |||
541 | Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); | 542 | Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); |
542 | Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); | 543 | Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); |
543 | Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); | 544 | Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); |
544 | 545 | ||
545 | sop.GroupPosition = groupos; | 546 | sop.GroupPosition = groupos; |
546 | sop.RotationOffset = rotoff; | 547 | sop.RotationOffset = rotoff; |
547 | sop.OffsetPosition = offset; | 548 | sop.OffsetPosition = offset; |
548 | sop.Velocity = velocity; | 549 | sop.Velocity = velocity; |
549 | sop.AngularVelocity = angvelo; | 550 | sop.AngularVelocity = angvelo; |
550 | sop.Acceleration = accel; | 551 | sop.Acceleration = accel; |
551 | 552 | ||
552 | mydic.Add(tmp,sop); | 553 | mydic.Add(tmp,sop); |
553 | sog.AddPart(sop); | 554 | sog.AddPart(sop); |
554 | } | 555 | } |
555 | 556 | ||
556 | db.StoreObject(sog, region4); | 557 | db.StoreObject(sog, region4); |
557 | 558 | ||
558 | SceneObjectGroup retsog = FindSOG("Test SOG", region4); | 559 | SceneObjectGroup retsog = FindSOG("Test SOG", region4); |
559 | SceneObjectPart[] parts = retsog.Parts; | 560 | SceneObjectPart[] parts = retsog.Parts; |
560 | for (int i = 0; i < 30; i++) | 561 | for (int i = 0; i < 30; i++) |
@@ -573,7 +574,7 @@ namespace OpenSim.Data.Tests | |||
573 | public void T016_RandomSogWithSceneParts() | 574 | public void T016_RandomSogWithSceneParts() |
574 | { | 575 | { |
575 | TestHelpers.InMethod(); | 576 | TestHelpers.InMethod(); |
576 | 577 | ||
577 | PropertyScrambler<SceneObjectPart> scrambler = | 578 | PropertyScrambler<SceneObjectPart> scrambler = |
578 | new PropertyScrambler<SceneObjectPart>() | 579 | new PropertyScrambler<SceneObjectPart>() |
579 | .DontScramble(x => x.UUID); | 580 | .DontScramble(x => x.UUID); |
@@ -633,22 +634,22 @@ namespace OpenSim.Data.Tests | |||
633 | SceneObjectGroup sog = FindSOG(name, region1); | 634 | SceneObjectGroup sog = FindSOG(name, region1); |
634 | if (sog == null) | 635 | if (sog == null) |
635 | { | 636 | { |
636 | sog = NewSOG(name, prim1, region1); | 637 | sog = NewSOG(name, prim1, region1); |
637 | db.StoreObject(sog, region1); | 638 | db.StoreObject(sog, region1); |
638 | } | 639 | } |
639 | return sog; | 640 | return sog; |
640 | } | 641 | } |
641 | 642 | ||
642 | // NOTE: it is a bad practice to rely on some of the previous tests having been run before. | 643 | // NOTE: it is a bad practice to rely on some of the previous tests having been run before. |
643 | // If the tests are run manually, one at a time, each starts with full class init (DB cleared). | 644 | // If the tests are run manually, one at a time, each starts with full class init (DB cleared). |
644 | // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order. | 645 | // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order. |
645 | // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*! | 646 | // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*! |
646 | 647 | ||
647 | [Test] | 648 | [Test] |
648 | public void T020_PrimInventoryEmpty() | 649 | public void T020_PrimInventoryEmpty() |
649 | { | 650 | { |
650 | TestHelpers.InMethod(); | 651 | TestHelpers.InMethod(); |
651 | 652 | ||
652 | SceneObjectGroup sog = GetMySOG("object1"); | 653 | SceneObjectGroup sog = GetMySOG("object1"); |
653 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | 654 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); |
654 | Assert.That(t, Is.Null); | 655 | Assert.That(t, Is.Null); |
@@ -672,14 +673,14 @@ namespace OpenSim.Data.Tests | |||
672 | public void T021_PrimInventoryBasic() | 673 | public void T021_PrimInventoryBasic() |
673 | { | 674 | { |
674 | TestHelpers.InMethod(); | 675 | TestHelpers.InMethod(); |
675 | 676 | ||
676 | SceneObjectGroup sog = GetMySOG("object1"); | 677 | SceneObjectGroup sog = GetMySOG("object1"); |
677 | InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); | 678 | InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); |
678 | 679 | ||
679 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True); | 680 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True); |
680 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | 681 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); |
681 | Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | 682 | Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); |
682 | 683 | ||
683 | StoreInventory(sog); | 684 | StoreInventory(sog); |
684 | 685 | ||
685 | SceneObjectGroup sog1 = FindSOG("object1", region1); | 686 | SceneObjectGroup sog1 = FindSOG("object1", region1); |
@@ -707,12 +708,12 @@ namespace OpenSim.Data.Tests | |||
707 | t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | 708 | t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); |
708 | Assert.That(t, Is.Null); | 709 | Assert.That(t, Is.Null); |
709 | } | 710 | } |
710 | 711 | ||
711 | [Test] | 712 | [Test] |
712 | public void T025_PrimInventoryPersistency() | 713 | public void T025_PrimInventoryPersistency() |
713 | { | 714 | { |
714 | TestHelpers.InMethod(); | 715 | TestHelpers.InMethod(); |
715 | 716 | ||
716 | InventoryItemBase i = new InventoryItemBase(); | 717 | InventoryItemBase i = new InventoryItemBase(); |
717 | UUID id = UUID.Random(); | 718 | UUID id = UUID.Random(); |
718 | i.ID = id; | 719 | i.ID = id; |
@@ -751,11 +752,11 @@ namespace OpenSim.Data.Tests | |||
751 | i.Flags = flags; | 752 | i.Flags = flags; |
752 | int creationd = random.Next(); | 753 | int creationd = random.Next(); |
753 | i.CreationDate = creationd; | 754 | i.CreationDate = creationd; |
754 | 755 | ||
755 | SceneObjectGroup sog = GetMySOG("object1"); | 756 | SceneObjectGroup sog = GetMySOG("object1"); |
756 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True); | 757 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True); |
757 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); | 758 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); |
758 | 759 | ||
759 | Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))"); | 760 | Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))"); |
760 | Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))"); | 761 | Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))"); |
761 | Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))"); | 762 | Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))"); |
@@ -779,13 +780,13 @@ namespace OpenSim.Data.Tests | |||
779 | Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))"); | 780 | Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))"); |
780 | Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))"); | 781 | Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))"); |
781 | } | 782 | } |
782 | 783 | ||
783 | [Test] | 784 | [Test] |
784 | [ExpectedException(typeof(ArgumentException))] | 785 | [ExpectedException(typeof(ArgumentException))] |
785 | public void T026_PrimInventoryMany() | 786 | public void T026_PrimInventoryMany() |
786 | { | 787 | { |
787 | TestHelpers.InMethod(); | 788 | TestHelpers.InMethod(); |
788 | 789 | ||
789 | UUID i1,i2,i3,i4; | 790 | UUID i1,i2,i3,i4; |
790 | i1 = UUID.Random(); | 791 | i1 = UUID.Random(); |
791 | i2 = UUID.Random(); | 792 | i2 = UUID.Random(); |
@@ -795,14 +796,14 @@ namespace OpenSim.Data.Tests | |||
795 | InventoryItemBase ib2 = NewItem(i2, zero, zero, RandomName(), zero); | 796 | InventoryItemBase ib2 = NewItem(i2, zero, zero, RandomName(), zero); |
796 | InventoryItemBase ib3 = NewItem(i3, zero, zero, RandomName(), zero); | 797 | InventoryItemBase ib3 = NewItem(i3, zero, zero, RandomName(), zero); |
797 | InventoryItemBase ib4 = NewItem(i4, zero, zero, RandomName(), zero); | 798 | InventoryItemBase ib4 = NewItem(i4, zero, zero, RandomName(), zero); |
798 | 799 | ||
799 | SceneObjectGroup sog = FindSOG("object1", region1); | 800 | SceneObjectGroup sog = FindSOG("object1", region1); |
800 | 801 | ||
801 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib1, zero), Is.True); | 802 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib1, zero), Is.True); |
802 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib2, zero), Is.True); | 803 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib2, zero), Is.True); |
803 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib3, zero), Is.True); | 804 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib3, zero), Is.True); |
804 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib4, zero), Is.True); | 805 | Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib4, zero), Is.True); |
805 | 806 | ||
806 | TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1); | 807 | TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1); |
807 | Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))"); | 808 | Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))"); |
808 | TaskInventoryItem t2 = sog.GetInventoryItem(sog.RootPart.LocalId, i2); | 809 | TaskInventoryItem t2 = sog.GetInventoryItem(sog.RootPart.LocalId, i2); |
@@ -817,7 +818,7 @@ namespace OpenSim.Data.Tests | |||
817 | public void T052_RemoveObject() | 818 | public void T052_RemoveObject() |
818 | { | 819 | { |
819 | TestHelpers.InMethod(); | 820 | TestHelpers.InMethod(); |
820 | 821 | ||
821 | db.RemoveObject(prim1, region1); | 822 | db.RemoveObject(prim1, region1); |
822 | SceneObjectGroup sog = FindSOG("object1", region1); | 823 | SceneObjectGroup sog = FindSOG("object1", region1); |
823 | Assert.That(sog, Is.Null); | 824 | Assert.That(sog, Is.Null); |
@@ -827,7 +828,7 @@ namespace OpenSim.Data.Tests | |||
827 | public void T100_DefaultRegionInfo() | 828 | public void T100_DefaultRegionInfo() |
828 | { | 829 | { |
829 | TestHelpers.InMethod(); | 830 | TestHelpers.InMethod(); |
830 | 831 | ||
831 | RegionSettings r1 = db.LoadRegionSettings(region1); | 832 | RegionSettings r1 = db.LoadRegionSettings(region1); |
832 | Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); | 833 | Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); |
833 | 834 | ||
@@ -839,7 +840,7 @@ namespace OpenSim.Data.Tests | |||
839 | public void T101_UpdateRegionInfo() | 840 | public void T101_UpdateRegionInfo() |
840 | { | 841 | { |
841 | TestHelpers.InMethod(); | 842 | TestHelpers.InMethod(); |
842 | 843 | ||
843 | int agentlimit = random.Next(); | 844 | int agentlimit = random.Next(); |
844 | double objectbonus = random.Next(); | 845 | double objectbonus = random.Next(); |
845 | int maturity = random.Next(); | 846 | int maturity = random.Next(); |
@@ -899,9 +900,9 @@ namespace OpenSim.Data.Tests | |||
899 | r1.FixedSun = true; | 900 | r1.FixedSun = true; |
900 | r1.SunPosition = sunpos; | 901 | r1.SunPosition = sunpos; |
901 | r1.Covenant = cov; | 902 | r1.Covenant = cov; |
902 | 903 | ||
903 | db.StoreRegionSettings(r1); | 904 | db.StoreRegionSettings(r1); |
904 | 905 | ||
905 | RegionSettings r1a = db.LoadRegionSettings(region1); | 906 | RegionSettings r1a = db.LoadRegionSettings(region1); |
906 | Assert.That(r1a.RegionUUID, Is.EqualTo(region1), "Assert.That(r1a.RegionUUID, Is.EqualTo(region1))"); | 907 | Assert.That(r1a.RegionUUID, Is.EqualTo(region1), "Assert.That(r1a.RegionUUID, Is.EqualTo(region1))"); |
907 | Assert.That(r1a.BlockTerraform,Is.True); | 908 | Assert.That(r1a.BlockTerraform,Is.True); |
@@ -938,14 +939,14 @@ namespace OpenSim.Data.Tests | |||
938 | //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); | 939 | //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); |
939 | Assert.That(r1a.FixedSun,Is.True); | 940 | Assert.That(r1a.FixedSun,Is.True); |
940 | Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); | 941 | Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); |
941 | Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); | 942 | Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); |
942 | } | 943 | } |
943 | 944 | ||
944 | [Test] | 945 | [Test] |
945 | public void T300_NoTerrain() | 946 | public void T300_NoTerrain() |
946 | { | 947 | { |
947 | TestHelpers.InMethod(); | 948 | TestHelpers.InMethod(); |
948 | 949 | ||
949 | Assert.That(db.LoadTerrain(zero), Is.Null); | 950 | Assert.That(db.LoadTerrain(zero), Is.Null); |
950 | Assert.That(db.LoadTerrain(region1), Is.Null); | 951 | Assert.That(db.LoadTerrain(region1), Is.Null); |
951 | Assert.That(db.LoadTerrain(region2), Is.Null); | 952 | Assert.That(db.LoadTerrain(region2), Is.Null); |
@@ -956,10 +957,13 @@ namespace OpenSim.Data.Tests | |||
956 | public void T301_CreateTerrain() | 957 | public void T301_CreateTerrain() |
957 | { | 958 | { |
958 | TestHelpers.InMethod(); | 959 | TestHelpers.InMethod(); |
959 | 960 | ||
960 | double[,] t1 = GenTerrain(height1); | 961 | double[,] t1 = GenTerrain(height1); |
961 | db.StoreTerrain(t1, region1); | 962 | db.StoreTerrain(t1, region1); |
962 | 963 | ||
964 | // store terrain is async | ||
965 | Thread.Sleep(1000); | ||
966 | |||
963 | Assert.That(db.LoadTerrain(zero), Is.Null); | 967 | Assert.That(db.LoadTerrain(zero), Is.Null); |
964 | Assert.That(db.LoadTerrain(region1), Is.Not.Null); | 968 | Assert.That(db.LoadTerrain(region1), Is.Not.Null); |
965 | Assert.That(db.LoadTerrain(region2), Is.Null); | 969 | Assert.That(db.LoadTerrain(region2), Is.Null); |
@@ -970,7 +974,7 @@ namespace OpenSim.Data.Tests | |||
970 | public void T302_FetchTerrain() | 974 | public void T302_FetchTerrain() |
971 | { | 975 | { |
972 | TestHelpers.InMethod(); | 976 | TestHelpers.InMethod(); |
973 | 977 | ||
974 | double[,] baseterrain1 = GenTerrain(height1); | 978 | double[,] baseterrain1 = GenTerrain(height1); |
975 | double[,] baseterrain2 = GenTerrain(height2); | 979 | double[,] baseterrain2 = GenTerrain(height2); |
976 | double[,] t1 = db.LoadTerrain(region1); | 980 | double[,] t1 = db.LoadTerrain(region1); |
@@ -982,11 +986,14 @@ namespace OpenSim.Data.Tests | |||
982 | public void T303_UpdateTerrain() | 986 | public void T303_UpdateTerrain() |
983 | { | 987 | { |
984 | TestHelpers.InMethod(); | 988 | TestHelpers.InMethod(); |
985 | 989 | ||
986 | double[,] baseterrain1 = GenTerrain(height1); | 990 | double[,] baseterrain1 = GenTerrain(height1); |
987 | double[,] baseterrain2 = GenTerrain(height2); | 991 | double[,] baseterrain2 = GenTerrain(height2); |
988 | db.StoreTerrain(baseterrain2, region1); | 992 | db.StoreTerrain(baseterrain2, region1); |
989 | 993 | ||
994 | // store terrain is async | ||
995 | Thread.Sleep(1000); | ||
996 | |||
990 | double[,] t1 = db.LoadTerrain(region1); | 997 | double[,] t1 = db.LoadTerrain(region1); |
991 | Assert.That(CompareTerrain(t1, baseterrain1), Is.False); | 998 | Assert.That(CompareTerrain(t1, baseterrain1), Is.False); |
992 | Assert.That(CompareTerrain(t1, baseterrain2), Is.True); | 999 | Assert.That(CompareTerrain(t1, baseterrain2), Is.True); |
@@ -996,7 +1003,7 @@ namespace OpenSim.Data.Tests | |||
996 | public void T400_EmptyLand() | 1003 | public void T400_EmptyLand() |
997 | { | 1004 | { |
998 | TestHelpers.InMethod(); | 1005 | TestHelpers.InMethod(); |
999 | 1006 | ||
1000 | Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); | 1007 | Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); |
1001 | Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); | 1008 | Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); |
1002 | Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); | 1009 | Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); |
@@ -1018,15 +1025,15 @@ namespace OpenSim.Data.Tests | |||
1018 | for (int x = 0; x < Constants.RegionSize; x++) | 1025 | for (int x = 0; x < Constants.RegionSize; x++) |
1019 | for (int y = 0; y < Constants.RegionSize; y++) | 1026 | for (int y = 0; y < Constants.RegionSize; y++) |
1020 | terret[x,y] = value; | 1027 | terret[x,y] = value; |
1021 | 1028 | ||
1022 | return terret; | 1029 | return terret; |
1023 | } | 1030 | } |
1024 | 1031 | ||
1025 | private bool CompareTerrain(double[,] one, double[,] two) | 1032 | private bool CompareTerrain(double[,] one, double[,] two) |
1026 | { | 1033 | { |
1027 | for (int x = 0; x < Constants.RegionSize; x++) | 1034 | for (int x = 0; x < Constants.RegionSize; x++) |
1028 | for (int y = 0; y < Constants.RegionSize; y++) | 1035 | for (int y = 0; y < Constants.RegionSize; y++) |
1029 | if (one[x,y] != two[x,y]) | 1036 | if (one[x,y] != two[x,y]) |
1030 | return false; | 1037 | return false; |
1031 | 1038 | ||
1032 | return true; | 1039 | return true; |
@@ -1046,12 +1053,12 @@ namespace OpenSim.Data.Tests | |||
1046 | // common failure case is people adding new fields that aren't | 1053 | // common failure case is people adding new fields that aren't |
1047 | // initialized, but have non-null db constraints. We should | 1054 | // initialized, but have non-null db constraints. We should |
1048 | // honestly be passing more and more null things in here. | 1055 | // honestly be passing more and more null things in here. |
1049 | // | 1056 | // |
1050 | // Please note that in Sqlite.BuildPrim there is a commented out inline version | 1057 | // Please note that in Sqlite.BuildPrim there is a commented out inline version |
1051 | // of this so you can debug and step through the build process and check the fields | 1058 | // of this so you can debug and step through the build process and check the fields |
1052 | // | 1059 | // |
1053 | // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart | 1060 | // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart |
1054 | // causes the application to crash at the database layer because of null values | 1061 | // causes the application to crash at the database layer because of null values |
1055 | // in NOT NULL fields | 1062 | // in NOT NULL fields |
1056 | // | 1063 | // |
1057 | private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId) | 1064 | private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId) |
@@ -1075,7 +1082,7 @@ namespace OpenSim.Data.Tests | |||
1075 | 1082 | ||
1076 | return sog; | 1083 | return sog; |
1077 | } | 1084 | } |
1078 | 1085 | ||
1079 | private SceneObjectPart NewSOP(string name, UUID uuid) | 1086 | private SceneObjectPart NewSOP(string name, UUID uuid) |
1080 | { | 1087 | { |
1081 | SceneObjectPart sop = new SceneObjectPart(); | 1088 | SceneObjectPart sop = new SceneObjectPart(); |
@@ -1089,7 +1096,7 @@ namespace OpenSim.Data.Tests | |||
1089 | return sop; | 1096 | return sop; |
1090 | } | 1097 | } |
1091 | 1098 | ||
1092 | // These are copied from the Inventory Item tests | 1099 | // These are copied from the Inventory Item tests |
1093 | 1100 | ||
1094 | private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) | 1101 | private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) |
1095 | { | 1102 | { |
@@ -1107,7 +1114,7 @@ namespace OpenSim.Data.Tests | |||
1107 | private static string RandomName() | 1114 | private static string RandomName() |
1108 | { | 1115 | { |
1109 | StringBuilder name = new StringBuilder(); | 1116 | StringBuilder name = new StringBuilder(); |
1110 | int size = random.Next(5,12); | 1117 | int size = random.Next(5,12); |
1111 | char ch ; | 1118 | char ch ; |
1112 | for (int i=0; i<size; i++) | 1119 | for (int i=0; i<size; i++) |
1113 | { | 1120 | { |