aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs99
-rw-r--r--OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs65
-rw-r--r--OpenSim/Data/Tests/BasicEstateTest.cs154
3 files changed, 318 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs
new file mode 100644
index 0000000..17e71e1
--- /dev/null
+++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs
@@ -0,0 +1,99 @@
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.IO;
30using System.Collections.Generic;
31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenSim.Framework;
34using OpenSim.Data.Tests;
35using OpenSim.Data.MySQL;
36using OpenSim.Region.Framework.Scenes;
37using OpenMetaverse;
38
39namespace OpenSim.Data.MySQL.Tests
40{
41 [TestFixture]
42 public class MySQLEstateTest : BasicEstateTest
43 {
44 public string file;
45 public MySQLManager database;
46 public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
47
48 [TestFixtureSetUp]
49 public void Init()
50 {
51 SuperInit();
52 // If we manage to connect to the database with the user
53 // and password above it is our test database, and run
54 // these tests. If anything goes wrong, ignore these
55 // tests.
56 try
57 {
58 database = new MySQLManager(connect);
59 regionDb = new MySQLDataStore();
60 regionDb.Initialise(connect);
61 db = new MySQLEstateStore();
62 db.Initialise(connect);
63 }
64 catch (Exception e)
65 {
66 System.Console.WriteLine("Exception {0}", e);
67 Assert.Ignore();
68 }
69 }
70
71 [TestFixtureTearDown]
72 public void Cleanup()
73 {
74 if (regionDb != null)
75 {
76 regionDb.Dispose();
77 }
78 // if a new table is added, it has to be dropped here
79 if (database != null)
80 {
81 database.ExecuteSql("drop table migrations");
82 database.ExecuteSql("drop table prims");
83 database.ExecuteSql("drop table primshapes");
84 database.ExecuteSql("drop table primitems");
85 database.ExecuteSql("drop table terrain");
86 database.ExecuteSql("drop table land");
87 database.ExecuteSql("drop table landaccesslist");
88 database.ExecuteSql("drop table regionban");
89 database.ExecuteSql("drop table regionsettings");
90 database.ExecuteSql("drop table estate_managers");
91 database.ExecuteSql("drop table estate_groups");
92 database.ExecuteSql("drop table estate_users");
93 database.ExecuteSql("drop table estateban");
94 database.ExecuteSql("drop table estate_settings");
95 database.ExecuteSql("drop table estate_map");
96 }
97 }
98 }
99}
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs
new file mode 100644
index 0000000..8f27b65
--- /dev/null
+++ b/OpenSim/Data/SQLite/Tests/SQLiteEstateTest.cs
@@ -0,0 +1,65 @@
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.IO;
30using System.Collections.Generic;
31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenSim.Framework;
34using OpenSim.Data.Tests;
35using OpenSim.Data.SQLite;
36using OpenSim.Region.Framework.Scenes;
37using OpenMetaverse;
38
39namespace OpenSim.Data.SQLite.Tests
40{
41 [TestFixture]
42 public class SQLiteEstateTest : BasicEstateTest
43 {
44 public string file = "regiontest.db";
45 public string connect;
46
47 [TestFixtureSetUp]
48 public void Init()
49 {
50 SuperInit();
51 file = Path.GetTempFileName() + ".db";
52 connect = "URI=file:" + file + ",version=3";
53 db = new SQLiteEstateStore();
54 db.Initialise(connect);
55 regionDb = new SQLiteRegionData();
56 regionDb.Initialise(connect);
57 }
58
59 [TestFixtureTearDown]
60 public void Cleanup()
61 {
62 regionDb.Dispose();
63 }
64 }
65}
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs
new file mode 100644
index 0000000..ef15150
--- /dev/null
+++ b/OpenSim/Data/Tests/BasicEstateTest.cs
@@ -0,0 +1,154 @@
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.Drawing;
31using System.Text;
32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenSim.Framework;
35using OpenSim.Data;
36using OpenMetaverse;
37using OpenSim.Region.Framework.Interfaces;
38
39namespace OpenSim.Data.Tests
40{
41 public class BasicEstateTest
42 {
43 public IEstateDataStore db;
44 public IRegionDataStore regionDb;
45 public UUID prim1;
46 public static Random random;
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 prim1 = UUID.Random();
59 random = new Random();
60
61 }
62
63 [Test]
64 public void T010_StoreEstateSettings()
65 {
66 // Initializing field values. Avoid randomness. For checking ranges use different parameter sets
67 // for mix and max values. If you use random values the tests are not _repeatable_.
68 string estateName = "test-estate";
69 uint parentEstateID = 2;
70 float billableFactor = 3;
71 int priceMeter = 4;
72 int redirectGridX = 5;
73 int redirectGridY = 6;
74 bool useGlobalTime = true;
75 bool fixedSun = true;
76 double sunPosition = 7;
77 bool allowVoice = true;
78 bool allowDirectTeleport = true;
79 bool denyAnonymous = true;
80 bool denyIdentified = true;
81 bool denyTransacted = true;
82 bool abuseEmailtoEstateOwner = true;
83 bool blockDwell = true;
84 bool estateskipScripts = true;
85 bool taxFree = true;
86 bool publicAccess = true;
87 string abuseMail = "test-email@nowhere.com";
88 UUID estateOwner = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed7");
89 bool denyMinors = (random.NextDouble() > 0.5)? true : false;
90
91 // Lets choose random region ID
92 UUID regionId = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed7");
93
94 // Letting estate store generate rows to database for us
95 EstateSettings es = db.LoadEstateSettings(regionId);
96
97 // Setting field values to the on demand create settings object.
98 es.EstateName = estateName;
99 es.ParentEstateID = parentEstateID;
100 es.BillableFactor = billableFactor;
101 es.PricePerMeter = priceMeter;
102 es.RedirectGridX = redirectGridX;
103 es.RedirectGridY = redirectGridY;
104 es.UseGlobalTime = useGlobalTime;
105 es.FixedSun = fixedSun;
106 es.SunPosition = sunPosition;
107 es.AllowVoice = allowVoice;
108 es.AllowDirectTeleport = allowDirectTeleport;
109 es.DenyAnonymous = denyAnonymous;
110 es.DenyIdentified = denyIdentified;
111 es.DenyTransacted = denyTransacted;
112 es.AbuseEmailToEstateOwner = abuseEmailtoEstateOwner;
113 es.BlockDwell = blockDwell;
114 es.EstateSkipScripts = estateskipScripts;
115 es.TaxFree = taxFree;
116 es.PublicAccess = publicAccess;
117 es.AbuseEmail = abuseMail;
118 es.EstateOwner = estateOwner;
119 es.DenyMinors = denyMinors;
120
121 // Saving settings.
122 db.StoreEstateSettings(es);
123
124 // Loading settings to another instance variable.
125 EstateSettings nes = db.LoadEstateSettings(regionId);
126
127 // Checking that loaded values are correct.
128 Assert.That(estateName, Is.EqualTo(nes.EstateName));
129 Assert.That(parentEstateID, Is.EqualTo(nes.ParentEstateID));
130 Assert.That(billableFactor, Is.EqualTo(nes.BillableFactor));
131 Assert.That(priceMeter, Is.EqualTo(nes.PricePerMeter));
132 Assert.That(redirectGridX, Is.EqualTo(nes.RedirectGridX));
133 Assert.That(redirectGridY, Is.EqualTo(nes.RedirectGridY));
134 Assert.That(useGlobalTime, Is.EqualTo(nes.UseGlobalTime));
135 Assert.That(fixedSun, Is.EqualTo(nes.FixedSun));
136 Assert.That(sunPosition, Is.EqualTo(nes.SunPosition));
137 Assert.That(allowVoice, Is.EqualTo(nes.AllowVoice));
138 Assert.That(allowDirectTeleport, Is.EqualTo(nes.AllowDirectTeleport));
139 Assert.That(denyAnonymous, Is.EqualTo(nes.DenyAnonymous));
140 Assert.That(denyIdentified, Is.EqualTo(nes.DenyIdentified));
141 Assert.That(denyTransacted, Is.EqualTo(nes.DenyTransacted));
142 Assert.That(abuseEmailtoEstateOwner, Is.EqualTo(nes.AbuseEmailToEstateOwner));
143 Assert.That(blockDwell, Is.EqualTo(nes.BlockDwell));
144 Assert.That(estateskipScripts, Is.EqualTo(nes.EstateSkipScripts));
145 Assert.That(taxFree, Is.EqualTo(nes.TaxFree));
146 Assert.That(publicAccess, Is.EqualTo(nes.PublicAccess));
147 Assert.That(abuseMail, Is.EqualTo(nes.AbuseEmail));
148 Assert.That(estateOwner, Is.EqualTo(nes.EstateOwner));
149 Assert.That(denyMinors, Is.EqualTo(nes.DenyMinors));
150
151 }
152
153 }
154}