aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/Tests/AssetTests.cs62
-rw-r--r--OpenSim/Data/Tests/BasicAssetTest.cs166
-rw-r--r--OpenSim/Data/Tests/EstateTests.cs26
-rw-r--r--OpenSim/Data/Tests/InventoryTests.cs29
-rw-r--r--OpenSim/Data/Tests/RegionTests.cs27
5 files changed, 137 insertions, 173 deletions
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
index acd5449..d228c1f 100644
--- a/OpenSim/Data/Tests/AssetTests.cs
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -35,6 +35,10 @@ using OpenSim.Framework;
35using System.Data.Common; 35using System.Data.Common;
36using log4net; 36using log4net;
37 37
38#if !NUNIT25
39using NUnit.Framework.SyntaxHelpers;
40#endif
41
38// DBMS-specific: 42// DBMS-specific:
39using MySql.Data.MySqlClient; 43using MySql.Data.MySqlClient;
40using OpenSim.Data.MySQL; 44using OpenSim.Data.MySQL;
@@ -47,25 +51,46 @@ using OpenSim.Data.SQLite;
47 51
48namespace OpenSim.Data.Tests 52namespace OpenSim.Data.Tests
49{ 53{
54
55#if NUNIT25
56
50 [TestFixture(typeof(MySqlConnection), typeof(MySQLAssetData), Description="Basic Asset store tests (MySQL)")] 57 [TestFixture(typeof(MySqlConnection), typeof(MySQLAssetData), Description="Basic Asset store tests (MySQL)")]
51 [TestFixture(typeof(SqlConnection), typeof(MSSQLAssetData), Description = "Basic Asset store tests (MS SQL Server)")] 58 [TestFixture(typeof(SqlConnection), typeof(MSSQLAssetData), Description = "Basic Asset store tests (MS SQL Server)")]
52 [TestFixture(typeof(SqliteConnection), typeof(SQLiteAssetData), Description = "Basic Asset store tests (SQLite)")] 59 [TestFixture(typeof(SqliteConnection), typeof(SQLiteAssetData), Description = "Basic Asset store tests (SQLite)")]
53 60
61#else
62
63 [TestFixture(Description = "Region store tests (SQLite)")]
64 public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData>
65 {
66 }
67
68 [TestFixture(Description = "Region store tests (MySQL)")]
69 public class MySqlAssetTests : AssetTests<MySqlConnection, MySQLAssetData>
70 {
71 }
72
73 [TestFixture(Description = "Region store tests (MS SQL Server)")]
74 public class MSSQLAssetTests : AssetTests<SqlConnection, MSSQLAssetData>
75 {
76 }
77
78#endif
79
80
54 public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData> 81 public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData>
55 where TConn : DbConnection, new() 82 where TConn : DbConnection, new()
56 where TAssetData : AssetDataBase, new() 83 where TAssetData : AssetDataBase, new()
57 { 84 {
58 TAssetData m_db; 85 TAssetData m_db;
59 86
60 const bool COMPARE_CREATOR = false;
61
62 public UUID uuid1 = UUID.Random(); 87 public UUID uuid1 = UUID.Random();
63 public UUID uuid2 = UUID.Random(); 88 public UUID uuid2 = UUID.Random();
64 public UUID uuid3 = UUID.Random(); 89 public UUID uuid3 = UUID.Random();
65 90
66 public UUID critter1 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; 91 public string critter1 = UUID.Random().ToString();
67 public UUID critter2 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; 92 public string critter2 = UUID.Random().ToString();
68 public UUID critter3 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; 93 public string critter3 = UUID.Random().ToString();
69 94
70 public byte[] data1 = new byte[100]; 95 public byte[] data1 = new byte[100];
71 96
@@ -157,5 +182,32 @@ namespace OpenSim.Data.Tests
157 Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID)); 182 Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
158 } 183 }
159 } 184 }
185
186 [Test]
187 public void T020_CheckForWeirdCreatorID()
188 {
189 // It is expected that eventually the CreatorID might be an arbitrary string (an URI)
190 // rather than a valid UUID (?). This test is to make sure that the database layer does not
191 // attempt to convert CreatorID to GUID, but just passes it both ways as a string.
192 AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1);
193 AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!");
194 AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, "");
195 a1.Data = data1;
196 a2.Data = data1;
197 a3.Data = data1;
198
199 m_db.StoreAsset(a1);
200 m_db.StoreAsset(a2);
201 m_db.StoreAsset(a3);
202
203 AssetBase a1a = m_db.GetAsset(uuid1);
204 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
205
206 AssetBase a2a = m_db.GetAsset(uuid2);
207 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
208
209 AssetBase a3a = m_db.GetAsset(uuid3);
210 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
211 }
160 } 212 }
161} 213}
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs
deleted file mode 100644
index 71d6314..0000000
--- a/OpenSim/Data/Tests/BasicAssetTest.cs
+++ /dev/null
@@ -1,166 +0,0 @@
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 System.Collections.Generic;
30using log4net.Config;
31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse;
34using OpenSim.Framework;
35using log4net;
36
37namespace OpenSim.Data.Tests
38{
39 public class BasicAssetTest
40 {
41 public IAssetDataPlugin db;
42 public UUID uuid1;
43 public UUID uuid2;
44 public UUID uuid3;
45 public string critter1 = UUID.Random().ToString();
46 public string critter2 = UUID.Random().ToString();
47 public string critter3 = UUID.Random().ToString();
48 public byte[] asset1;
49 PropertyScrambler<AssetBase> scrambler;
50
51 public void SuperInit()
52 {
53 OpenSim.Tests.Common.TestLogging.LogToConsole();
54
55 uuid1 = UUID.Random();
56 uuid2 = UUID.Random();
57 uuid3 = UUID.Random();
58 asset1 = new byte[100];
59 asset1.Initialize();
60
61
62 scrambler = new PropertyScrambler<AssetBase>()
63 .DontScramble(x => x.ID)
64 .DontScramble(x => x.FullID)
65 .DontScramble(x => x.Metadata.ID)
66 .DontScramble(x => x.Metadata.Type)
67 .DontScramble(x => x.Metadata.CreatorID)
68 .DontScramble(x => x.Metadata.ContentType)
69 .DontScramble(x => x.Metadata.FullID);
70 }
71
72 [Test]
73 public void T001_LoadEmpty()
74 {
75 Assert.That(db.ExistsAsset(uuid1), Is.False);
76 Assert.That(db.ExistsAsset(uuid2), Is.False);
77 Assert.That(db.ExistsAsset(uuid3), Is.False);
78 }
79
80 [Test]
81 public void T010_StoreSimpleAsset()
82 {
83 AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1);
84 AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2);
85 AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3);
86 a1.Data = asset1;
87 a2.Data = asset1;
88 a3.Data = asset1;
89
90 scrambler.Scramble(a1);
91 scrambler.Scramble(a2);
92 scrambler.Scramble(a3);
93
94 db.StoreAsset(a1);
95 db.StoreAsset(a2);
96 db.StoreAsset(a3);
97
98 AssetBase a1a = db.GetAsset(uuid1);
99 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
100
101 AssetBase a2a = db.GetAsset(uuid2);
102 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
103
104 AssetBase a3a = db.GetAsset(uuid3);
105 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
106
107 scrambler.Scramble(a1a);
108 scrambler.Scramble(a2a);
109 scrambler.Scramble(a3a);
110
111 db.StoreAsset(a1a);
112 db.StoreAsset(a2a);
113 db.StoreAsset(a3a);
114
115 AssetBase a1b = db.GetAsset(uuid1);
116 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
117
118 AssetBase a2b = db.GetAsset(uuid2);
119 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
120
121 AssetBase a3b = db.GetAsset(uuid3);
122 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
123
124 Assert.That(db.ExistsAsset(uuid1), Is.True);
125 Assert.That(db.ExistsAsset(uuid2), Is.True);
126 Assert.That(db.ExistsAsset(uuid3), Is.True);
127
128 List<AssetMetadata> metadatas = db.FetchAssetMetadataSet(0, 1000);
129
130 AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1);
131 Assert.That(metadata.Name, Is.EqualTo(a1b.Name));
132 Assert.That(metadata.Description, Is.EqualTo(a1b.Description));
133 Assert.That(metadata.Type, Is.EqualTo(a1b.Type));
134 Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary));
135 Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
136 }
137
138
139 [Test]
140 public void T020_CheckForWeirdCreatorID()
141 {
142 // It is expected that eventually the CreatorID might be an arbitrary string (an URI)
143 // rather than a valid UUID (?). This test is to make sure that the database layer does not
144 // attempt to convert CreatorID to GUID, but just passes it both ways as a string.
145 AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1);
146 AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!");
147 AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, "");
148 a1.Data = asset1;
149 a2.Data = asset1;
150 a3.Data = asset1;
151
152 db.StoreAsset(a1);
153 db.StoreAsset(a2);
154 db.StoreAsset(a3);
155
156 AssetBase a1a = db.GetAsset(uuid1);
157 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
158
159 AssetBase a2a = db.GetAsset(uuid2);
160 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
161
162 AssetBase a3a = db.GetAsset(uuid3);
163 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
164 }
165 }
166}
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs
index 4893cc7..2da010d 100644
--- a/OpenSim/Data/Tests/EstateTests.cs
+++ b/OpenSim/Data/Tests/EstateTests.cs
@@ -37,6 +37,10 @@ using log4net;
37using System.Reflection; 37using System.Reflection;
38using System.Data.Common; 38using System.Data.Common;
39 39
40#if !NUNIT25
41using NUnit.Framework.SyntaxHelpers;
42#endif
43
40 44
41// DBMS-specific: 45// DBMS-specific:
42using MySql.Data.MySqlClient; 46using MySql.Data.MySqlClient;
@@ -51,10 +55,32 @@ using OpenSim.Data.SQLite;
51 55
52namespace OpenSim.Data.Tests 56namespace OpenSim.Data.Tests
53{ 57{
58
59#if NUNIT25
60
54 [TestFixture(typeof(MySqlConnection), typeof(MySQLEstateStore), Description = "Estate store tests (MySQL)")] 61 [TestFixture(typeof(MySqlConnection), typeof(MySQLEstateStore), Description = "Estate store tests (MySQL)")]
55 [TestFixture(typeof(SqlConnection), typeof(MSSQLEstateStore), Description = "Estate store tests (MS SQL Server)")] 62 [TestFixture(typeof(SqlConnection), typeof(MSSQLEstateStore), Description = "Estate store tests (MS SQL Server)")]
56 [TestFixture(typeof(SqliteConnection), typeof(SQLiteEstateStore), Description = "Estate store tests (SQLite)")] 63 [TestFixture(typeof(SqliteConnection), typeof(SQLiteEstateStore), Description = "Estate store tests (SQLite)")]
57 64
65#else
66
67 [TestFixture(Description = "Estate store tests (SQLite)")]
68 public class SQLiteEstateTests : EstateTests<SqliteConnection, SQLiteEstateStore>
69 {
70 }
71
72 [TestFixture(Description = "Estate store tests (MySQL)")]
73 public class MySqlEstateTests : EstateTests<MySqlConnection, MySQLEstateStore>
74 {
75 }
76
77 [TestFixture(Description = "Estate store tests (MS SQL Server)")]
78 public class MSSQLEstateTests : EstateTests<SqlConnection, MSSQLEstateStore>
79 {
80 }
81
82#endif
83
58 public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore> 84 public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore>
59 where TConn : DbConnection, new() 85 where TConn : DbConnection, new()
60 where TEstateStore : class, IEstateDataStore, new() 86 where TEstateStore : class, IEstateDataStore, new()
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
index d5f3be4..93e1eba 100644
--- a/OpenSim/Data/Tests/InventoryTests.cs
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -25,6 +25,8 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28// #define NUNIT25
29
28using System; 30using System;
29using log4net.Config; 31using log4net.Config;
30using NUnit.Framework; 32using NUnit.Framework;
@@ -35,6 +37,10 @@ using log4net;
35using System.Reflection; 37using System.Reflection;
36using System.Data.Common; 38using System.Data.Common;
37 39
40#if !NUNIT25
41using NUnit.Framework.SyntaxHelpers;
42#endif
43
38// DBMS-specific: 44// DBMS-specific:
39using MySql.Data.MySqlClient; 45using MySql.Data.MySqlClient;
40using OpenSim.Data.MySQL; 46using OpenSim.Data.MySQL;
@@ -47,9 +53,29 @@ using OpenSim.Data.SQLite;
47 53
48namespace OpenSim.Data.Tests 54namespace OpenSim.Data.Tests
49{ 55{
56#if NUNIT25
57
58 [TestFixture(typeof(SqliteConnection), typeof(SQLiteInventoryStore), Description = "Inventory store tests (SQLite)")]
50 [TestFixture(typeof(MySqlConnection), typeof(MySQLInventoryData), Description = "Inventory store tests (MySQL)")] 59 [TestFixture(typeof(MySqlConnection), typeof(MySQLInventoryData), Description = "Inventory store tests (MySQL)")]
51 [TestFixture(typeof(SqlConnection), typeof(MSSQLInventoryData), Description = "Inventory store tests (MS SQL Server)")] 60 [TestFixture(typeof(SqlConnection), typeof(MSSQLInventoryData), Description = "Inventory store tests (MS SQL Server)")]
52 [TestFixture(typeof(SqliteConnection), typeof(SQLiteInventoryStore), Description = "Inventory store tests (SQLite)")] 61
62#else
63
64 [TestFixture(Description = "Inventory store tests (SQLite)")]
65 public class SQLiteInventoryTests : InventoryTests<SqliteConnection, SQLiteInventoryStore>
66 {
67 }
68
69 [TestFixture(Description = "Inventory store tests (MySQL)")]
70 public class MySqlInventoryTests : InventoryTests<MySqlConnection, MySQLInventoryData>
71 {
72 }
73
74 [TestFixture(Description = "Inventory store tests (MS SQL Server)")]
75 public class MSSQLInventoryTests : InventoryTests<SqlConnection, MSSQLInventoryData>
76 {
77 }
78#endif
53 79
54 public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore> 80 public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore>
55 where TConn : DbConnection, new() 81 where TConn : DbConnection, new()
@@ -85,6 +111,7 @@ namespace OpenSim.Data.Tests
85 { 111 {
86 name1 = "Root Folder for " + owner1.ToString(); 112 name1 = "Root Folder for " + owner1.ToString();
87 } 113 }
114 public InventoryTests() : this("") { }
88 115
89 protected override void InitService(object service) 116 protected override void InitService(object service)
90 { 117 {
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index f38dc4a..5ac2dd0 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -40,6 +40,10 @@ using log4net;
40using System.Reflection; 40using System.Reflection;
41using System.Data.Common; 41using System.Data.Common;
42 42
43#if !NUNIT25
44using NUnit.Framework.SyntaxHelpers;
45#endif
46
43// DBMS-specific: 47// DBMS-specific:
44using MySql.Data.MySqlClient; 48using MySql.Data.MySqlClient;
45using OpenSim.Data.MySQL; 49using OpenSim.Data.MySQL;
@@ -52,9 +56,30 @@ using OpenSim.Data.SQLite;
52 56
53namespace OpenSim.Data.Tests 57namespace OpenSim.Data.Tests
54{ 58{
59#if NUNIT25
60
61 [TestFixture(typeof(SqliteConnection), typeof(SQLiteRegionData), Description = "Region store tests (SQLite)")]
55 [TestFixture(typeof(MySqlConnection), typeof(MySqlRegionData), Description = "Region store tests (MySQL)")] 62 [TestFixture(typeof(MySqlConnection), typeof(MySqlRegionData), Description = "Region store tests (MySQL)")]
56 [TestFixture(typeof(SqlConnection), typeof(MSSQLRegionData), Description = "Region store tests (MS SQL Server)")] 63 [TestFixture(typeof(SqlConnection), typeof(MSSQLRegionData), Description = "Region store tests (MS SQL Server)")]
57 [TestFixture(typeof(SqliteConnection), typeof(SQLiteRegionData), Description = "Region store tests (SQLite)")] 64
65#else
66
67 [TestFixture(Description = "Region store tests (SQLite)")]
68 public class SQLiteRegionTests : RegionTests<SqliteConnection, SQLiteRegionData>
69 {
70 }
71
72 [TestFixture(Description = "Region store tests (MySQL)")]
73 public class MySqlRegionTests : RegionTests<MySqlConnection, MySQLDataStore>
74 {
75 }
76
77 [TestFixture(Description = "Region store tests (MS SQL Server)")]
78 public class MSSQLRegionTests : RegionTests<SqlConnection, MSSQLRegionDataStore>
79 {
80 }
81
82#endif
58 83
59 public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore> 84 public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore>
60 where TConn : DbConnection, new() 85 where TConn : DbConnection, new()