01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.
06: //
07: // $Id: OzoneTestCase.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $
08:
09: package org.ozoneDB.test;
10:
11: import org.ozoneDB.*;
12: import org.ozoneDB.DxLib.*;
13: import junit.framework.*;
14:
15: import org.apache.log4j.Category;
16:
17: /**
18: * Base class for the Ozone based TestCase. The following is an
19: * example of writting OzoneTestCase.
20: *
21: * <pre>
22: * packge com.foo;
23: *
24: * import junit.framework.*;
25: * import org.ozoneDB.test.OzoneTestCase;
26: * import org.ozoneDB.test.simple.*;
27: *
28: * package FooTestCase extends OzoneTestCase {
29: * public static Test suite() {
30: * TestSuite suite = new TestSuite();
31: * suite.addTestSuite(FooTestCase.class);
32: * return suite;
33: * }
34: *
35: * public void testCreate() {
36: * // db() provide the access to database setup by TestRunner
37: * Auto auto = (Auto)db().createObject(AutoImpl.class.getName());
38: * assertNotNull(auto);
39: * // Test away!!!
40: * }
41: * }
42: *</pre>
43: *
44: * @author <a href="http://www.softwarebuero.de/">SMB</a>
45: * @author <a href="mailto:david@d11e.com">David Li</a>
46: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:31 $ */
47: public abstract class OzoneTestCase extends TestCase {
48:
49: /**
50: * log4j logger
51: */
52: private static Category fLog = Category
53: .getInstance(OzoneTestCase.class);
54:
55: /**
56: * the database to be used for testing
57: */
58: private ExternalDatabase db;
59:
60: /**
61: * Constructor.
62: */
63: protected OzoneTestCase(String name) {
64: super (name);
65: }
66:
67: /**
68: * Return the database set up by OzoneTestRunner
69: * @return a instance of ExternalDatabase
70: */
71: public ExternalDatabase db() {
72: return db;
73: }
74:
75: /**
76: * Set the database for this TestCase. This is typically used by
77: * the OzoneTestRunner. However, you can also use it in the
78: * setUp() method to connect to different database than the one
79: * specified by the OzoneTestRunner.
80: *
81: * @param db the database to be used for the TestCase
82: */
83: public void setDB(ExternalDatabase db) {
84: this .db = db;
85: fLog.debug("setDB(): set new database" + db);
86: }
87: }
|