KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > test > TxnTestSuite


1 /*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002-2005
5 * Sleepycat Software. All rights reserved.
6 *
7 * $Id: TxnTestSuite.java,v 1.8 2005/01/28 17:43:07 mark Exp $
8 */

9
10 package com.sleepycat.je.test;
11
12 import java.util.Enumeration;
13
14 import junit.framework.TestSuite;
15
16 import com.sleepycat.je.EnvironmentConfig;
17 import com.sleepycat.je.util.TestUtils;
18
19 /**
20  * Runs a set of test cases for each type of transaction.
21  * The test case class must extend TxnTestCase.
22  */

23 public class TxnTestSuite extends TestSuite {
24
25     /**
26      * For running all three types of transactions: Null, Auto, User
27      */

28     public TxnTestSuite(Class testCaseClass, EnvironmentConfig envConfig) {
29
30         this(testCaseClass, envConfig, null);
31     }
32
33     /**
34      * For specifying the desirged txn types. If txnTypes is null,
35      * all three types are run.
36      */

37     public TxnTestSuite(Class testCaseClass,
38                         EnvironmentConfig envConfig,
39                         String[] txnTypes) {
40         if (txnTypes == null) {
41             txnTypes = new String[] { TxnTestCase.TXN_NULL,
42                                       TxnTestCase.TXN_USER,
43                                       TxnTestCase.TXN_AUTO };
44         }
45         if (envConfig == null) {
46             envConfig = TestUtils.initEnvConfig();
47             envConfig.setAllowCreate(true);
48             envConfig.setTxnNoSync(Boolean.getBoolean(TestUtils.NO_SYNC));
49         }
50         for (int i = 0; i < txnTypes.length; i += 1) {
51             TestSuite suite = new TestSuite(testCaseClass);
52             Enumeration e = suite.tests();
53             while (e.hasMoreElements()) {
54                 TxnTestCase test = (TxnTestCase) e.nextElement();
55                 test.txnInit(envConfig, txnTypes[i]);
56                 addTest(test);
57             }
58         }
59     }
60 }
61
Popular Tags