aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Tests/RegionTests.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/Tests/RegionTests.cs99
1 files changed, 58 insertions, 41 deletions
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index 23d498d..44cf1ab 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -31,11 +31,11 @@ using System.Drawing;
31using System.Text; 31using System.Text;
32using log4net.Config; 32using log4net.Config;
33using NUnit.Framework; 33using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 34using OpenMetaverse;
36using OpenSim.Framework; 35using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common;
39using log4net; 39using log4net;
40using System.Reflection; 40using System.Reflection;
41using System.Data.Common; 41using System.Data.Common;
@@ -52,14 +52,6 @@ using OpenSim.Data.SQLite;
52 52
53namespace OpenSim.Data.Tests 53namespace OpenSim.Data.Tests
54{ 54{
55#if NUNIT25
56
57 [TestFixture(typeof(SqliteConnection), typeof(SQLiteRegionData), Description = "Region store tests (SQLite)")]
58 [TestFixture(typeof(MySqlConnection), typeof(MySqlRegionData), Description = "Region store tests (MySQL)")]
59 [TestFixture(typeof(SqlConnection), typeof(MSSQLRegionData), Description = "Region store tests (MS SQL Server)")]
60
61#else
62
63 [TestFixture(Description = "Region store tests (SQLite)")] 55 [TestFixture(Description = "Region store tests (SQLite)")]
64 public class SQLiteRegionTests : RegionTests<SqliteConnection, SQLiteSimulationData> 56 public class SQLiteRegionTests : RegionTests<SqliteConnection, SQLiteSimulationData>
65 { 57 {
@@ -75,8 +67,6 @@ namespace OpenSim.Data.Tests
75 { 67 {
76 } 68 }
77 69
78#endif
79
80 public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore> 70 public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore>
81 where TConn : DbConnection, new() 71 where TConn : DbConnection, new()
82 where TRegStore : class, ISimulationDataStore, new() 72 where TRegStore : class, ISimulationDataStore, new()
@@ -131,15 +121,18 @@ namespace OpenSim.Data.Tests
131 string[] reg_tables = new string[] { 121 string[] reg_tables = new string[] {
132 "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings" 122 "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings"
133 }; 123 };
124
134 if (m_rebuildDB) 125 if (m_rebuildDB)
135 { 126 {
136 DropTables(reg_tables); 127 DropTables(reg_tables);
137 ResetMigrations("RegionStore"); 128 ResetMigrations("RegionStore");
138 }else 129 }
130 else
131 {
139 ClearTables(reg_tables); 132 ClearTables(reg_tables);
133 }
140 } 134 }
141 135
142
143 // Test Plan 136 // Test Plan
144 // Prims 137 // Prims
145 // - empty test - 001 138 // - empty test - 001
@@ -158,6 +151,8 @@ namespace OpenSim.Data.Tests
158 [Test] 151 [Test]
159 public void T001_LoadEmpty() 152 public void T001_LoadEmpty()
160 { 153 {
154 TestHelper.InMethod();
155
161 List<SceneObjectGroup> objs = db.LoadObjects(region1); 156 List<SceneObjectGroup> objs = db.LoadObjects(region1);
162 List<SceneObjectGroup> objs3 = db.LoadObjects(region3); 157 List<SceneObjectGroup> objs3 = db.LoadObjects(region3);
163 List<LandData> land = db.LoadLandObjects(region1); 158 List<LandData> land = db.LoadLandObjects(region1);
@@ -174,6 +169,8 @@ namespace OpenSim.Data.Tests
174 [Test] 169 [Test]
175 public void T010_StoreSimpleObject() 170 public void T010_StoreSimpleObject()
176 { 171 {
172 TestHelper.InMethod();
173
177 SceneObjectGroup sog = NewSOG("object1", prim1, region1); 174 SceneObjectGroup sog = NewSOG("object1", prim1, region1);
178 SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); 175 SceneObjectGroup sog2 = NewSOG("object2", prim2, region1);
179 176
@@ -207,6 +204,8 @@ namespace OpenSim.Data.Tests
207 [Test] 204 [Test]
208 public void T011_ObjectNames() 205 public void T011_ObjectNames()
209 { 206 {
207 TestHelper.InMethod();
208
210 List<SceneObjectGroup> objs = db.LoadObjects(region1); 209 List<SceneObjectGroup> objs = db.LoadObjects(region1);
211 foreach (SceneObjectGroup sog in objs) 210 foreach (SceneObjectGroup sog in objs)
212 { 211 {
@@ -219,6 +218,8 @@ namespace OpenSim.Data.Tests
219 [Test] 218 [Test]
220 public void T012_SceneParts() 219 public void T012_SceneParts()
221 { 220 {
221 TestHelper.InMethod();
222
222 UUID tmp0 = UUID.Random(); 223 UUID tmp0 = UUID.Random();
223 UUID tmp1 = UUID.Random(); 224 UUID tmp1 = UUID.Random();
224 UUID tmp2 = UUID.Random(); 225 UUID tmp2 = UUID.Random();
@@ -252,6 +253,8 @@ namespace OpenSim.Data.Tests
252 [Test] 253 [Test]
253 public void T013_DatabasePersistency() 254 public void T013_DatabasePersistency()
254 { 255 {
256 TestHelper.InMethod();
257
255 // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data 258 // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data
256 // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored 259 // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored
257 // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. 260 // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently.
@@ -427,6 +430,8 @@ namespace OpenSim.Data.Tests
427 [Test] 430 [Test]
428 public void T014_UpdateObject() 431 public void T014_UpdateObject()
429 { 432 {
433 TestHelper.InMethod();
434
430 string text1 = "object1 text"; 435 string text1 = "object1 text";
431 SceneObjectGroup sog = FindSOG("object1", region1); 436 SceneObjectGroup sog = FindSOG("object1", region1);
432 sog.RootPart.Text = text1; 437 sog.RootPart.Text = text1;
@@ -528,15 +533,20 @@ namespace OpenSim.Data.Tests
528 Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); 533 Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
529 Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); 534 Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))");
530 } 535 }
531 536
537 /// <summary>
538 /// Test storage and retrieval of a scene object with a large number of parts.
539 /// </summary>
532 [Test] 540 [Test]
533 public void T015_LargeSceneObjects() 541 public void T015_LargeSceneObjects()
534 { 542 {
543 TestHelper.InMethod();
544
535 UUID id = UUID.Random(); 545 UUID id = UUID.Random();
536 Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); 546 Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>();
537 SceneObjectGroup sog = NewSOG("Test SOG", id, region4); 547 SceneObjectGroup sog = NewSOG("Test SOG", id, region4);
538 mydic.Add(sog.RootPart.UUID,sog.RootPart); 548 mydic.Add(sog.RootPart.UUID,sog.RootPart);
539 for (int i=0;i<30;i++) 549 for (int i = 0; i < 30; i++)
540 { 550 {
541 UUID tmp = UUID.Random(); 551 UUID tmp = UUID.Random();
542 SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); 552 SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp);
@@ -555,13 +565,14 @@ namespace OpenSim.Data.Tests
555 sop.Acceleration = accel; 565 sop.Acceleration = accel;
556 566
557 mydic.Add(tmp,sop); 567 mydic.Add(tmp,sop);
558 sog.AddPart(sop); 568 sog.AddPart(sop);
559 db.StoreObject(sog, region4);
560 } 569 }
561 570
571 db.StoreObject(sog, region4);
572
562 SceneObjectGroup retsog = FindSOG("Test SOG", region4); 573 SceneObjectGroup retsog = FindSOG("Test SOG", region4);
563 SceneObjectPart[] parts = retsog.Parts; 574 SceneObjectPart[] parts = retsog.Parts;
564 for (int i=0;i<30;i++) 575 for (int i = 0; i < 30; i++)
565 { 576 {
566 SceneObjectPart cursop = mydic[parts[i].UUID]; 577 SceneObjectPart cursop = mydic[parts[i].UUID];
567 Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))"); 578 Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))");
@@ -576,6 +587,8 @@ namespace OpenSim.Data.Tests
576 //[Test] 587 //[Test]
577 public void T016_RandomSogWithSceneParts() 588 public void T016_RandomSogWithSceneParts()
578 { 589 {
590 TestHelper.InMethod();
591
579 PropertyScrambler<SceneObjectPart> scrambler = 592 PropertyScrambler<SceneObjectPart> scrambler =
580 new PropertyScrambler<SceneObjectPart>() 593 new PropertyScrambler<SceneObjectPart>()
581 .DontScramble(x => x.UUID); 594 .DontScramble(x => x.UUID);
@@ -642,15 +655,16 @@ namespace OpenSim.Data.Tests
642 return sog; 655 return sog;
643 } 656 }
644 657
645
646 // NOTE: it is a bad practice to rely on some of the previous tests having been run before. 658 // NOTE: it is a bad practice to rely on some of the previous tests having been run before.
647 // If the tests are run manually, one at a time, each starts with full class init (DB cleared). 659 // If the tests are run manually, one at a time, each starts with full class init (DB cleared).
648 // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order. 660 // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order.
649 // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*! 661 // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*!
650 662
651 [Test] 663 [Test]
652 public void T020_PrimInventoryEmpty() 664 public void T020_PrimInventoryEmpty()
653 { 665 {
666 TestHelper.InMethod();
667
654 SceneObjectGroup sog = GetMySOG("object1"); 668 SceneObjectGroup sog = GetMySOG("object1");
655 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); 669 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
656 Assert.That(t, Is.Null); 670 Assert.That(t, Is.Null);
@@ -670,10 +684,11 @@ namespace OpenSim.Data.Tests
670 db.StorePrimInventory(sog.RootPart.UUID, list); 684 db.StorePrimInventory(sog.RootPart.UUID, list);
671 } 685 }
672 686
673
674 [Test] 687 [Test]
675 public void T021_PrimInventoryBasic() 688 public void T021_PrimInventoryBasic()
676 { 689 {
690 TestHelper.InMethod();
691
677 SceneObjectGroup sog = GetMySOG("object1"); 692 SceneObjectGroup sog = GetMySOG("object1");
678 InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); 693 InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
679 694
@@ -701,20 +716,19 @@ namespace OpenSim.Data.Tests
701 Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))"); 716 Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
702 717
703 // Removing inventory 718 // Removing inventory
704
705 List<TaskInventoryItem> list = new List<TaskInventoryItem>(); 719 List<TaskInventoryItem> list = new List<TaskInventoryItem>();
706 db.StorePrimInventory(prim1, list); 720 db.StorePrimInventory(prim1, list);
707 721
708 sog = FindSOG("object1", region1); 722 sog = FindSOG("object1", region1);
709 t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); 723 t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
710 Assert.That(t, Is.Null); 724 Assert.That(t, Is.Null);
711
712 } 725 }
713
714 726
715 [Test] 727 [Test]
716 public void T025_PrimInventoryPersistency() 728 public void T025_PrimInventoryPersistency()
717 { 729 {
730 TestHelper.InMethod();
731
718 InventoryItemBase i = new InventoryItemBase(); 732 InventoryItemBase i = new InventoryItemBase();
719 UUID id = UUID.Random(); 733 UUID id = UUID.Random();
720 i.ID = id; 734 i.ID = id;
@@ -786,6 +800,8 @@ namespace OpenSim.Data.Tests
786 [ExpectedException(typeof(ArgumentException))] 800 [ExpectedException(typeof(ArgumentException))]
787 public void T026_PrimInventoryMany() 801 public void T026_PrimInventoryMany()
788 { 802 {
803 TestHelper.InMethod();
804
789 UUID i1,i2,i3,i4; 805 UUID i1,i2,i3,i4;
790 i1 = UUID.Random(); 806 i1 = UUID.Random();
791 i2 = UUID.Random(); 807 i2 = UUID.Random();
@@ -816,15 +832,18 @@ namespace OpenSim.Data.Tests
816 [Test] 832 [Test]
817 public void T052_RemoveObject() 833 public void T052_RemoveObject()
818 { 834 {
835 TestHelper.InMethod();
836
819 db.RemoveObject(prim1, region1); 837 db.RemoveObject(prim1, region1);
820 SceneObjectGroup sog = FindSOG("object1", region1); 838 SceneObjectGroup sog = FindSOG("object1", region1);
821 Assert.That(sog, Is.Null); 839 Assert.That(sog, Is.Null);
822 } 840 }
823 841
824
825 [Test] 842 [Test]
826 public void T100_DefaultRegionInfo() 843 public void T100_DefaultRegionInfo()
827 { 844 {
845 TestHelper.InMethod();
846
828 RegionSettings r1 = db.LoadRegionSettings(region1); 847 RegionSettings r1 = db.LoadRegionSettings(region1);
829 Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); 848 Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))");
830 849
@@ -835,6 +854,8 @@ namespace OpenSim.Data.Tests
835 [Test] 854 [Test]
836 public void T101_UpdateRegionInfo() 855 public void T101_UpdateRegionInfo()
837 { 856 {
857 TestHelper.InMethod();
858
838 int agentlimit = random.Next(); 859 int agentlimit = random.Next();
839 double objectbonus = random.Next(); 860 double objectbonus = random.Next();
840 int maturity = random.Next(); 861 int maturity = random.Next();
@@ -933,13 +954,14 @@ namespace OpenSim.Data.Tests
933 //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); 954 //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))");
934 Assert.That(r1a.FixedSun,Is.True); 955 Assert.That(r1a.FixedSun,Is.True);
935 Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); 956 Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))");
936 Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); 957 Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))");
937
938 } 958 }
939 959
940 [Test] 960 [Test]
941 public void T300_NoTerrain() 961 public void T300_NoTerrain()
942 { 962 {
963 TestHelper.InMethod();
964
943 Assert.That(db.LoadTerrain(zero), Is.Null); 965 Assert.That(db.LoadTerrain(zero), Is.Null);
944 Assert.That(db.LoadTerrain(region1), Is.Null); 966 Assert.That(db.LoadTerrain(region1), Is.Null);
945 Assert.That(db.LoadTerrain(region2), Is.Null); 967 Assert.That(db.LoadTerrain(region2), Is.Null);
@@ -949,6 +971,8 @@ namespace OpenSim.Data.Tests
949 [Test] 971 [Test]
950 public void T301_CreateTerrain() 972 public void T301_CreateTerrain()
951 { 973 {
974 TestHelper.InMethod();
975
952 double[,] t1 = GenTerrain(height1); 976 double[,] t1 = GenTerrain(height1);
953 db.StoreTerrain(t1, region1); 977 db.StoreTerrain(t1, region1);
954 978
@@ -961,6 +985,8 @@ namespace OpenSim.Data.Tests
961 [Test] 985 [Test]
962 public void T302_FetchTerrain() 986 public void T302_FetchTerrain()
963 { 987 {
988 TestHelper.InMethod();
989
964 double[,] baseterrain1 = GenTerrain(height1); 990 double[,] baseterrain1 = GenTerrain(height1);
965 double[,] baseterrain2 = GenTerrain(height2); 991 double[,] baseterrain2 = GenTerrain(height2);
966 double[,] t1 = db.LoadTerrain(region1); 992 double[,] t1 = db.LoadTerrain(region1);
@@ -971,6 +997,8 @@ namespace OpenSim.Data.Tests
971 [Test] 997 [Test]
972 public void T303_UpdateTerrain() 998 public void T303_UpdateTerrain()
973 { 999 {
1000 TestHelper.InMethod();
1001
974 double[,] baseterrain1 = GenTerrain(height1); 1002 double[,] baseterrain1 = GenTerrain(height1);
975 double[,] baseterrain2 = GenTerrain(height2); 1003 double[,] baseterrain2 = GenTerrain(height2);
976 db.StoreTerrain(baseterrain2, region1); 1004 db.StoreTerrain(baseterrain2, region1);
@@ -983,6 +1011,8 @@ namespace OpenSim.Data.Tests
983 [Test] 1011 [Test]
984 public void T400_EmptyLand() 1012 public void T400_EmptyLand()
985 { 1013 {
1014 TestHelper.InMethod();
1015
986 Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); 1016 Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))");
987 Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); 1017 Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))");
988 Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); 1018 Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))");
@@ -1018,25 +1048,12 @@ namespace OpenSim.Data.Tests
1018 return true; 1048 return true;
1019 } 1049 }
1020 1050
1021
1022 private SceneObjectGroup FindSOG(string name, UUID r) 1051 private SceneObjectGroup FindSOG(string name, UUID r)
1023 { 1052 {
1024 List<SceneObjectGroup> objs = db.LoadObjects(r); 1053 List<SceneObjectGroup> objs = db.LoadObjects(r);
1025 foreach (SceneObjectGroup sog in objs) 1054 foreach (SceneObjectGroup sog in objs)
1026 { 1055 if (sog.Name == name)
1027 SceneObjectPart p = sog.RootPart;
1028 if (p.Name == name) {
1029 RegionInfo regionInfo = new RegionInfo();
1030 regionInfo.RegionID = r;
1031 regionInfo.RegionLocX = 0;
1032 regionInfo.RegionLocY = 0;
1033
1034 Scene scene = new Scene(regionInfo);
1035 sog.SetScene(scene);
1036
1037 return sog; 1056 return sog;
1038 }
1039 }
1040 1057
1041 return null; 1058 return null;
1042 } 1059 }