diff options
author | John Hurliman | 2010-02-22 14:10:19 -0800 |
---|---|---|
committer | John Hurliman | 2010-02-22 14:10:19 -0800 |
commit | 71c6559a91a58d93588dcdd8c74b5fce0c1a3780 (patch) | |
tree | cca5b1ea88ad4b29156767afdd77e37ec072c8a7 /OpenSim/Data/SQLite/SQLiteUserAccountData.cs | |
parent | * Adds CreatorID to asset metadata. This is just the plumbing to support Crea... (diff) | |
parent | Merge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/open... (diff) | |
download | opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.zip opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.gz opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.bz2 opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.xz |
Merge branch 'presence-refactor' of ssh://opensimulator.org/var/git/opensim into presence-refactor
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserAccountData.cs (renamed from OpenSim/Data/MySQL/Tests/MySQLUserTest.cs) | 82 |
1 files changed, 39 insertions, 43 deletions
diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs index cf8139a..50e8c23 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs | |||
@@ -26,60 +26,56 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using NUnit.Framework; | 29 | using System.Collections; |
30 | using OpenSim.Data.Tests; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using System.Data; |
32 | using System.Reflection; | 32 | using OpenMetaverse; |
33 | using OpenSim.Tests.Common; | 33 | using OpenSim.Framework; |
34 | using Mono.Data.SqliteClient; | ||
34 | 35 | ||
35 | namespace OpenSim.Data.MySQL.Tests | 36 | namespace OpenSim.Data.SQLite |
36 | { | 37 | { |
37 | [TestFixture, DatabaseTest] | 38 | public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData |
38 | public class MySQLUserTest : BasicUserTest | ||
39 | { | 39 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | public SQLiteUserAccountData(string connectionString, string realm) |
41 | public string file; | 41 | : base(connectionString, realm, "UserAccount") |
42 | public MySQLManager database; | ||
43 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; | ||
44 | |||
45 | [TestFixtureSetUp] | ||
46 | public void Init() | ||
47 | { | 42 | { |
48 | SuperInit(); | ||
49 | // If we manage to connect to the database with the user | ||
50 | // and password above it is our test database, and run | ||
51 | // these tests. If anything goes wrong, ignore these | ||
52 | // tests. | ||
53 | try | ||
54 | { | ||
55 | database = new MySQLManager(connect); | ||
56 | db = new MySQLUserData(); | ||
57 | db.Initialise(connect); | ||
58 | } | ||
59 | catch (Exception e) | ||
60 | { | ||
61 | m_log.Error("Exception {0}", e); | ||
62 | Assert.Ignore(); | ||
63 | } | ||
64 | } | 43 | } |
65 | 44 | ||
66 | [TestFixtureTearDown] | 45 | public UserAccountData[] GetUsers(UUID scopeID, string query) |
67 | public void Cleanup() | ||
68 | { | 46 | { |
69 | if (db != null) | 47 | string[] words = query.Split(new char[] {' '}); |
48 | |||
49 | for (int i = 0 ; i < words.Length ; i++) | ||
70 | { | 50 | { |
71 | db.Dispose(); | 51 | if (words[i].Length < 3) |
52 | { | ||
53 | if (i != words.Length - 1) | ||
54 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); | ||
55 | Array.Resize(ref words, words.Length - 1); | ||
56 | } | ||
72 | } | 57 | } |
73 | // if a new table is added, it has to be dropped here | 58 | |
74 | if (database != null) | 59 | if (words.Length == 0) |
60 | return new UserAccountData[0]; | ||
61 | |||
62 | if (words.Length > 2) | ||
63 | return new UserAccountData[0]; | ||
64 | |||
65 | SqliteCommand cmd = new SqliteCommand(); | ||
66 | |||
67 | if (words.Length == 1) | ||
75 | { | 68 | { |
76 | database.ExecuteSql("drop table migrations"); | 69 | cmd.CommandText = String.Format("select * from {0} where ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", |
77 | database.ExecuteSql("drop table users"); | 70 | m_Realm, scopeID.ToString(), words[0]); |
78 | database.ExecuteSql("drop table userfriends"); | ||
79 | database.ExecuteSql("drop table agents"); | ||
80 | database.ExecuteSql("drop table avatarappearance"); | ||
81 | database.ExecuteSql("drop table avatarattachments"); | ||
82 | } | 71 | } |
72 | else | ||
73 | { | ||
74 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", | ||
75 | m_Realm, scopeID.ToString(), words[0], words[1]); | ||
76 | } | ||
77 | |||
78 | return DoQuery(cmd); | ||
83 | } | 79 | } |
84 | } | 80 | } |
85 | } | 81 | } |