diff options
author | AlexRa | 2010-05-23 12:46:33 +0300 |
---|---|---|
committer | AlexRa | 2010-05-23 12:46:33 +0300 |
commit | 57f4729eeaa377f74681bd3d0bbb999680c72441 (patch) | |
tree | 59b5a90b3e62bdf5de186d5f3905ef83725047b5 /OpenSim/Data/Tests | |
parent | Removed (unused?) empty SQL files from MSSQL resource dir (diff) | |
download | opensim-SC_OLD-57f4729eeaa377f74681bd3d0bbb999680c72441.zip opensim-SC_OLD-57f4729eeaa377f74681bd3d0bbb999680c72441.tar.gz opensim-SC_OLD-57f4729eeaa377f74681bd3d0bbb999680c72441.tar.bz2 opensim-SC_OLD-57f4729eeaa377f74681bd3d0bbb999680c72441.tar.xz |
Ensured that tests are skipped for wrong conn string, also m_log chng
The base test class now tries to connect to DB, ignores all tests in the
class if unable to.
Also m_log changed to instance field (which in this case shouldn't cause
any problems), to avoid having to define it separately in each derived
class. Here I touched things that I don't understand well (using log4net),
so please review this commit.
Diffstat (limited to 'OpenSim/Data/Tests')
-rw-r--r-- | OpenSim/Data/Tests/BasicDataServiceTest.cs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs index 4c7cf28..c261126 100644 --- a/OpenSim/Data/Tests/BasicDataServiceTest.cs +++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs | |||
@@ -27,7 +27,10 @@ namespace OpenSim.Data.Tests | |||
27 | private string m_file; | 27 | private string m_file; |
28 | 28 | ||
29 | // TODO: Is this in the right place here? | 29 | // TODO: Is this in the right place here? |
30 | protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 30 | // Later: apparently it's not, but does it matter here? |
31 | // protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
32 | |||
33 | protected ILog m_log; // doesn't matter here that it's not static, init to correct type in instance .ctor | ||
31 | 34 | ||
32 | public BasicDataServiceTest() | 35 | public BasicDataServiceTest() |
33 | : this("") | 36 | : this("") |
@@ -38,6 +41,7 @@ namespace OpenSim.Data.Tests | |||
38 | { | 41 | { |
39 | m_connStr = !String.IsNullOrEmpty(conn) ? conn : DefaultTestConns.Get(typeof(TConn)); | 42 | m_connStr = !String.IsNullOrEmpty(conn) ? conn : DefaultTestConns.Get(typeof(TConn)); |
40 | 43 | ||
44 | m_log = LogManager.GetLogger(this.GetType()); | ||
41 | OpenSim.Tests.Common.TestLogging.LogToConsole(); // TODO: Is that right? | 45 | OpenSim.Tests.Common.TestLogging.LogToConsole(); // TODO: Is that right? |
42 | } | 46 | } |
43 | 47 | ||
@@ -72,10 +76,27 @@ namespace OpenSim.Data.Tests | |||
72 | if (String.IsNullOrEmpty(m_connStr)) | 76 | if (String.IsNullOrEmpty(m_connStr)) |
73 | { | 77 | { |
74 | string msg = String.Format("Connection string for {0} is not defined, ignoring tests", typeof(TConn).Name); | 78 | string msg = String.Format("Connection string for {0} is not defined, ignoring tests", typeof(TConn).Name); |
75 | m_log.Error(msg); | 79 | m_log.Warn(msg); |
76 | Assert.Ignore(msg); | 80 | Assert.Ignore(msg); |
77 | } | 81 | } |
78 | 82 | ||
83 | // Try the connection, ignore tests if Open() fails | ||
84 | using (TConn conn = new TConn()) | ||
85 | { | ||
86 | conn.ConnectionString = m_connStr; | ||
87 | try | ||
88 | { | ||
89 | conn.Open(); | ||
90 | conn.Close(); | ||
91 | } | ||
92 | catch | ||
93 | { | ||
94 | string msg = String.Format("{0} is unable to connect to the database, ignoring tests", typeof(TConn).Name); | ||
95 | m_log.Warn(msg); | ||
96 | Assert.Ignore(msg); | ||
97 | } | ||
98 | } | ||
99 | |||
79 | // If we manage to connect to the database with the user | 100 | // If we manage to connect to the database with the user |
80 | // and password above it is our test database, and run | 101 | // and password above it is our test database, and run |
81 | // these tests. If anything goes wrong, ignore these | 102 | // these tests. If anything goes wrong, ignore these |