summaryrefslogtreecommitdiff
path: root/test/java/compat/src/com/sleepycat/collections/test/TransactionTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/java/compat/src/com/sleepycat/collections/test/TransactionTest.java')
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TransactionTest.java75
1 files changed, 32 insertions, 43 deletions
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TransactionTest.java b/test/java/compat/src/com/sleepycat/collections/test/TransactionTest.java
index 1244174e..c091c403 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TransactionTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TransactionTest.java
@@ -1,12 +1,19 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2002, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
package com.sleepycat.collections.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Iterator;
@@ -14,9 +21,9 @@ import java.util.List;
import java.util.SortedSet;
import java.util.concurrent.atomic.AtomicInteger;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import com.sleepycat.collections.CurrentTransaction;
import com.sleepycat.collections.StoredCollections;
@@ -41,49 +48,18 @@ import com.sleepycat.db.Transaction;
import com.sleepycat.db.TransactionConfig;
import com.sleepycat.util.RuntimeExceptionWrapper;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
* @author Mark Hayes
*/
-public class TransactionTest extends TestCase {
+public class TransactionTest extends TestBase {
private static final Long ONE = new Long(1);
private static final Long TWO = new Long(2);
private static final Long THREE = new Long(3);
- /**
- * Runs a command line collection test.
- * @see #usage
- */
- public static void main(String[] args) {
- if (args.length == 1 &&
- (args[0].equals("-h") || args[0].equals("-help"))) {
- usage();
- } else {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
- }
-
- private static void usage() {
-
- System.out.println(
- "Usage: java com.sleepycat.collections.test.TransactionTest"
- + " [-h | -help]\n");
- System.exit(2);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(TransactionTest.class);
- return suite;
- }
private Environment env;
private CurrentTransaction currentTxn;
@@ -91,16 +67,16 @@ public class TransactionTest extends TestCase {
private StoredSortedMap map;
private TestStore testStore = TestStore.BTREE_UNIQ;
- public TransactionTest(String name) {
+ public TransactionTest() {
- super(name);
+ customName = "TransactionTest";
}
- @Override
+ @Before
public void setUp()
throws Exception {
- SharedTestUtils.printTestName(SharedTestUtils.qualifiedTestName(this));
+ super.setUp();
env = TestEnv.TXN.open("TransactionTests");
currentTxn = CurrentTransaction.getInstance(env);
store = testStore.open(env, dbName(0));
@@ -108,7 +84,7 @@ public class TransactionTest extends TestCase {
testStore.getValueBinding(), true);
}
- @Override
+ @After
public void tearDown() {
try {
@@ -132,9 +108,10 @@ public class TransactionTest extends TestCase {
private String dbName(int i) {
- return "txn-test-" + getName() + '-' + i;
+ return "txn-test-" + i;
}
+ @Test
public void testGetters()
throws Exception {
@@ -191,6 +168,7 @@ public class TransactionTest extends TestCase {
assertTrue(!isReadCommitted(map.entrySet()));
}
+ @Test
public void testTransactional()
throws Exception {
@@ -232,6 +210,7 @@ public class TransactionTest extends TestCase {
db.close();
}
+ @Test
public void testExceptions()
throws Exception {
@@ -246,6 +225,7 @@ public class TransactionTest extends TestCase {
} catch (IllegalStateException expected) {}
}
+ @Test
public void testNested()
throws Exception {
@@ -317,12 +297,14 @@ public class TransactionTest extends TestCase {
assertEquals(ONE, map.get(ONE));
}
+ @Test
public void testRunnerCommit()
throws Exception {
commitTest(false);
}
+ @Test
public void testExplicitCommit()
throws Exception {
@@ -373,12 +355,14 @@ public class TransactionTest extends TestCase {
assertNull(currentTxn.getTransaction());
}
+ @Test
public void testRunnerAbort()
throws Exception {
abortTest(false);
}
+ @Test
public void testExplicitAbort()
throws Exception {
@@ -436,6 +420,7 @@ public class TransactionTest extends TestCase {
assertNull(currentTxn.getTransaction());
}
+ @Test
public void testReadCommittedCollection()
throws Exception {
@@ -484,6 +469,7 @@ public class TransactionTest extends TestCase {
storedContainer.getCursorConfig().getReadCommitted();
}
+ @Test
public void testReadCommittedTransaction()
throws Exception {
@@ -524,6 +510,7 @@ public class TransactionTest extends TestCase {
assertNull(currentTxn.getTransaction());
}
+ @Test
public void testReadUncommittedCollection()
throws Exception {
@@ -569,6 +556,7 @@ public class TransactionTest extends TestCase {
storedContainer.getCursorConfig().getReadUncommitted();
}
+ @Test
public void testReadUncommittedTransaction()
throws Exception {
@@ -596,6 +584,7 @@ public class TransactionTest extends TestCase {
* This test only succeeds intermittently, probably due to its reliance
* on the GC call.
*/
+ @Test
public void testCurrentTransactionGC()
throws Exception {