summaryrefslogtreecommitdiff
path: root/test/java/compat/src/com/sleepycat/collections
diff options
context:
space:
mode:
Diffstat (limited to 'test/java/compat/src/com/sleepycat/collections')
-rw-r--r--test/java/compat/src/com/sleepycat/collections/KeyRangeTest.java45
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/CollectionTest.java184
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/DbTestUtil.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/ForeignKeyTest.java70
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/IterDeadlockTest.java41
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/JoinTest.java45
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/NullTransactionRunner.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/NullValueTest.java42
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/SecondaryDeadlockTest.java41
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TestDataBinding.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TestEntity.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TestEntityBinding.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TestEnv.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TestKeyAssigner.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TestKeyCreator.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TestSR15721.java53
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TestStore.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/TransactionTest.java75
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/serial/CatalogCornerCaseTest.java42
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTest.java69
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTestInit.java74
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java.original2
-rw-r--r--test/java/compat/src/com/sleepycat/collections/test/serial/TupleSerialFactoryTest.java60
24 files changed, 359 insertions, 504 deletions
diff --git a/test/java/compat/src/com/sleepycat/collections/KeyRangeTest.java b/test/java/compat/src/com/sleepycat/collections/KeyRangeTest.java
index c02f6b75..b0af3432 100644
--- a/test/java/compat/src/com/sleepycat/collections/KeyRangeTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/KeyRangeTest.java
@@ -1,20 +1,23 @@
/*-
* 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;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
import java.io.File;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Comparator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Test;
import com.sleepycat.bind.ByteArrayBinding;
import com.sleepycat.compat.DbCompat;
@@ -28,11 +31,12 @@ import com.sleepycat.db.OperationStatus;
import com.sleepycat.util.keyrange.KeyRange;
import com.sleepycat.util.keyrange.KeyRangeException;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
/**
* @author Mark Hayes
*/
-public class KeyRangeTest extends TestCase {
+public class KeyRangeTest extends TestBase {
private static boolean VERBOSE = false;
@@ -58,32 +62,6 @@ public class KeyRangeTest extends TestCase {
private DataView view;
private DataCursor cursor;
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
-
- return new TestSuite(KeyRangeTest.class);
- }
-
- public KeyRangeTest(String name) {
-
- super(name);
- }
-
- @Override
- public void setUp() {
- SharedTestUtils.printTestName(SharedTestUtils.qualifiedTestName(this));
- }
-
private void openDb(Comparator<byte []> comparator)
throws Exception {
@@ -113,7 +91,7 @@ public class KeyRangeTest extends TestCase {
env = null;
}
- @Override
+ @After
public void tearDown() {
try {
if (store != null) {
@@ -136,12 +114,14 @@ public class KeyRangeTest extends TestCase {
cursor = null;
}
+ @Test
public void testScan() throws Exception {
openDb(null);
doScan(false);
closeDb();
}
+ @Test
public void testScanComparator() throws Exception {
openDb(new ReverseComparator());
doScan(true);
@@ -361,6 +341,7 @@ public class KeyRangeTest extends TestCase {
System.out.println();
}
+ @Test
public void testSubRanges() {
DatabaseEntry begin = new DatabaseEntry();
diff --git a/test/java/compat/src/com/sleepycat/collections/test/CollectionTest.java b/test/java/compat/src/com/sleepycat/collections/test/CollectionTest.java
index 5a3963d2..e7edc67a 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/CollectionTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/CollectionTest.java
@@ -1,16 +1,22 @@
/*-
* 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -22,9 +28,10 @@ import java.util.SortedMap;
import java.util.SortedSet;
import java.util.concurrent.ConcurrentMap;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.bind.EntityBinding;
import com.sleepycat.bind.EntryBinding;
@@ -50,12 +57,14 @@ import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.util.ExceptionUnwrapper;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
* @author Mark Hayes
*/
-public class CollectionTest extends TestCase {
+@RunWith(Parameterized.class)
+public class CollectionTest extends TestBase {
private static final int NONE = 0;
private static final int SUB = 1;
@@ -69,13 +78,13 @@ public class CollectionTest extends TestCase {
* test below the block size (6), at the block size (10), and above it (14
* and 22).
*/
- private static final int DEFAULT_MAX_KEY = 6;
+ protected static final int DEFAULT_MAX_KEY = 6;
private static final int[] MAX_KEYS = {6, 10, 14, 22};
private boolean testStoredIterator;
- private int maxKey; /* Must be a multiple of 2. */
- private int beginKey = 1;
- private int endKey;
+ private static int maxKey; /* Must be a multiple of 2. */
+ protected static int beginKey = 1;
+ private static int endKey;
private Environment env;
private Database store;
@@ -104,121 +113,49 @@ public class CollectionTest extends TestCase {
private StoredKeySet keySet;
private StoredValueSet valueSet;
- /**
- * 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(args));
- 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.CollectionTest\n" +
- " -h | -help\n" +
- " [testName]...\n" +
- " where testName has the format:\n" +
- " <env>-<store>-{entity|value}\n" +
- " <env> is:\n" +
- " bdb | cdb | txn\n" +
- " <store> is:\n" +
- " btree-uniq | btree-dup | btree-dupsort | btree-recnum |\n" +
- " hash-uniq | hash-dup | hash-dupsort |\n" +
- " queue | recno | recno-renum\n" +
- " For example: bdb-btree-uniq-entity\n" +
- " If no arguments are given then all tests are run.");
- System.exit(2);
- }
-
- public static Test suite() {
- return suite(null);
- }
-
- static Test suite(String[] args) {
- if (SharedTestUtils.runLongTests()) {
- TestSuite suite = new TestSuite();
-
- /* StoredIterator tests. */
- permuteTests(args, suite, true, DEFAULT_MAX_KEY);
-
- /* BlockIterator tests with different maxKey values. */
- for (int i = 0; i < MAX_KEYS.length; i += 1) {
- permuteTests(args, suite, false, MAX_KEYS[i]);
- }
-
- return suite;
- } else {
- return baseSuite(args);
- }
- }
-
- private static void permuteTests(String[] args,
- TestSuite suite,
- boolean storedIter,
- int maxKey) {
- TestSuite baseTests = baseSuite(args);
- Enumeration e = baseTests.tests();
- while (e.hasMoreElements()) {
- CollectionTest t = (CollectionTest) e.nextElement();
- t.setParams(storedIter, maxKey);
- suite.addTest(t);
- }
- }
-
- private static TestSuite baseSuite(String[] args) {
- TestSuite suite = new TestSuite();
+ @Parameters
+ public static List<Object[]> genParams() {
+ if (SharedTestUtils.runLongTests()){
+ List<Object[]> list = baseParams(true, DEFAULT_MAX_KEY);
+
+ for (int i : MAX_KEYS)
+ list.addAll(baseParams(false, i));
+
+ return list;
+ }
+ return baseParams(false, 6);
+ }
+
+ private static List<Object[]> baseParams(boolean storedIter,
+ int maximumKey){
+
+ List <Object[]> list = new ArrayList<Object[]>();
for (int i = 0; i < TestEnv.ALL.length; i += 1) {
for (int j = 0; j < TestStore.ALL.length; j += 1) {
for (int k = 0; k < 2; k += 1) {
boolean entityBinding = (k != 0);
-
- addTest(args, suite, new CollectionTest(
- TestEnv.ALL[i], TestStore.ALL[j],
- entityBinding, false));
-
+
+ list.add(new Object[] {TestEnv.ALL[i], TestStore.ALL[j],
+ entityBinding, false, storedIter, maximumKey});
+
if (TestEnv.ALL[i].isTxnMode()) {
- addTest(args, suite, new CollectionTest(
- TestEnv.ALL[i], TestStore.ALL[j],
- entityBinding, true));
+ list.add(new Object[]
+ {TestEnv.ALL[i], TestStore.ALL[j], entityBinding,
+ true, storedIter, maximumKey});
}
}
}
}
- return suite;
+
+ return list;
}
- private static void addTest(String[] args, TestSuite suite,
- CollectionTest test) {
-
- if (args == null || args.length == 0) {
- suite.addTest(test);
- } else {
- for (int t = 0; t < args.length; t += 1) {
- if (args[t].equals(test.testName)) {
- suite.addTest(test);
- break;
- }
- }
- }
- }
-
- public CollectionTest(TestEnv testEnv, TestStore testStore,
- boolean isEntityBinding, boolean isAutoCommit) {
-
- super(null);
+ public CollectionTest(TestEnv testEnv,
+ TestStore testStore,
+ boolean isEntityBinding,
+ boolean isAutoCommit,
+ boolean storedIter,
+ int maxKey) {
this.testEnv = testEnv;
this.testStore = testStore;
@@ -229,14 +166,15 @@ public class CollectionTest extends TestCase {
valueBinding = testStore.getValueBinding();
entityBinding = testStore.getEntityBinding();
- setParams(false, DEFAULT_MAX_KEY);
+ setParams(storedIter, maxKey);
+ customName = testName;
}
- private void setParams(boolean storedIter, int maxKey) {
+ private void setParams(boolean storedIter, int maximumKey) {
- this.testStoredIterator = storedIter;
- this.maxKey = maxKey;
- this.endKey = maxKey;
+ testStoredIterator = storedIter;
+ maxKey = maximumKey;
+ endKey = maximumKey;
testName = testEnv.getName() + '-' + testStore.getName() +
(isEntityBinding ? "-entity" : "-value") +
@@ -245,19 +183,13 @@ public class CollectionTest extends TestCase {
((maxKey != DEFAULT_MAX_KEY) ? ("-maxKey-" + maxKey) : "");
}
- @Override
- public void tearDown() {
- setName(testName);
- }
- @Override
+ @Test
public void runTest()
throws Exception {
- SharedTestUtils.printTestName(SharedTestUtils.qualifiedTestName(this));
try {
env = testEnv.open(testName);
-
// For testing auto-commit, use a normal (transactional) runner for
// all reading and for writing via an iterator, and a do-nothing
// runner for writing via collections; if auto-commit is tested,
diff --git a/test/java/compat/src/com/sleepycat/collections/test/DbTestUtil.java b/test/java/compat/src/com/sleepycat/collections/test/DbTestUtil.java
index de92d03f..69ba23d9 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/DbTestUtil.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/DbTestUtil.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
* $Id: DbTestUtil.java,v 0f73af5ae3da 2010/05/10 05:38:40 alexander $
*/
diff --git a/test/java/compat/src/com/sleepycat/collections/test/ForeignKeyTest.java b/test/java/compat/src/com/sleepycat/collections/test/ForeignKeyTest.java
index ef540994..60d196b6 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/ForeignKeyTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/ForeignKeyTest.java
@@ -1,17 +1,29 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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.util.ArrayList;
+import java.util.List;
import java.util.Map;
-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 org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.bind.serial.StoredClassCatalog;
import com.sleepycat.bind.serial.TupleSerialMarshalledKeyCreator;
@@ -29,12 +41,14 @@ import com.sleepycat.db.SecondaryDatabase;
import com.sleepycat.util.ExceptionUnwrapper;
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 ForeignKeyTest extends TestCase {
+@RunWith(Parameterized.class)
+public class ForeignKeyTest extends TestBase {
private static final ForeignKeyDeleteAction[] ACTIONS = {
ForeignKeyDeleteAction.ABORT,
@@ -47,29 +61,20 @@ public class ForeignKeyTest extends TestCase {
"CASCADE",
};
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- for (int i = 0; i < TestEnv.ALL.length; i += 1) {
- for (int j = 0; j < ACTIONS.length; j += 1) {
- suite.addTest(new ForeignKeyTest(TestEnv.ALL[i],
- ACTIONS[j],
- ACTION_LABELS[j]));
+ @Parameters
+ public static List<Object[]> genParams() {
+ List<Object[]> params = new ArrayList<Object[]>();
+ for (TestEnv testEnv : TestEnv.ALL) {
+ int i = 0;
+ for (ForeignKeyDeleteAction action : ACTIONS) {
+ params.add(new Object[]{testEnv, action, ACTION_LABELS[i]});
+ i ++;
}
}
- return suite;
+
+ return params;
}
-
+
private TestEnv testEnv;
private Environment env;
private StoredClassCatalog catalog;
@@ -87,23 +92,24 @@ public class ForeignKeyTest extends TestCase {
public ForeignKeyTest(TestEnv testEnv, ForeignKeyDeleteAction onDelete,
String onDeleteLabel) {
- super("ForeignKeyTest-" + testEnv.getName() + '-' + onDeleteLabel);
+ customName =
+ "ForeignKeyTest-" + testEnv.getName() + '-' + onDeleteLabel;
this.testEnv = testEnv;
this.onDelete = onDelete;
}
- @Override
+ @Before
public void setUp()
throws Exception {
- SharedTestUtils.printTestName(getName());
- env = testEnv.open(getName());
-
+ super.setUp();
+ SharedTestUtils.printTestName(customName);
+ env = testEnv.open(customName);
createDatabase();
}
- @Override
+ @After
public void tearDown() {
try {
@@ -144,7 +150,7 @@ public class ForeignKeyTest extends TestCase {
}
}
- @Override
+ @Test
public void runTest()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/IterDeadlockTest.java b/test/java/compat/src/com/sleepycat/collections/test/IterDeadlockTest.java
index 1a8dcc4d..9492ffe3 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/IterDeadlockTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/IterDeadlockTest.java
@@ -1,18 +1,22 @@
/*-
* 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.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Iterator;
import java.util.ListIterator;
-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.bind.ByteArrayBinding;
import com.sleepycat.collections.StoredIterator;
@@ -24,6 +28,7 @@ import com.sleepycat.db.Database;
import com.sleepycat.db.DatabaseConfig;
import com.sleepycat.db.Environment;
import com.sleepycat.db.DeadlockException;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
@@ -33,26 +38,10 @@ import com.sleepycat.util.test.TestEnv;
* the first element.
* @author Mark Hayes
*/
-public class IterDeadlockTest extends TestCase {
+public class IterDeadlockTest extends TestBase {
private static final byte[] ONE = { 1 };
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(IterDeadlockTest.class);
- return suite;
- }
-
private Environment env;
private Database store1;
private Database store2;
@@ -60,12 +49,7 @@ public class IterDeadlockTest extends TestCase {
private StoredSortedMap map2;
private final ByteArrayBinding binding = new ByteArrayBinding();
- public IterDeadlockTest(String name) {
-
- super(name);
- }
-
- @Override
+ @Before
public void setUp()
throws Exception {
@@ -76,7 +60,7 @@ public class IterDeadlockTest extends TestCase {
map2 = new StoredSortedMap(store2, binding, binding, true);
}
- @Override
+ @After
public void tearDown() {
if (store1 != null) {
@@ -119,6 +103,7 @@ public class IterDeadlockTest extends TestCase {
return DbCompat.testOpenDatabase(env, null, file, null, config);
}
+ @Test
public void testIterDeadlock()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/JoinTest.java b/test/java/compat/src/com/sleepycat/collections/test/JoinTest.java
index d2bf4152..9157a6cc 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/JoinTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/JoinTest.java
@@ -1,16 +1,24 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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.assertFalse;
+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 java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import com.sleepycat.bind.serial.StoredClassCatalog;
import com.sleepycat.bind.serial.test.MarshalledObject;
@@ -28,33 +36,19 @@ import com.sleepycat.db.Environment;
import com.sleepycat.db.SecondaryConfig;
import com.sleepycat.db.SecondaryDatabase;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
* @author Mark Hayes
*/
-public class JoinTest extends TestCase
+public class JoinTest extends TestBase
implements TransactionWorker {
private static final String MATCH_DATA = "d4"; // matches both keys = "yes"
private static final String MATCH_KEY = "k4"; // matches both keys = "yes"
private static final String[] VALUES = {"yes", "yes"};
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
- return new JoinTest();
- }
-
private Environment env;
private TransactionRunner runner;
private StoredClassCatalog catalog;
@@ -67,21 +61,20 @@ public class JoinTest extends TestCase
private StoredMap indexMap2;
public JoinTest() {
-
- super("JoinTest");
+ customName = "JoinTest";
}
- @Override
+ @Before
public void setUp()
throws Exception {
- SharedTestUtils.printTestName(getName());
- env = TestEnv.TXN.open(getName());
+ SharedTestUtils.printTestName(customName);
+ env = TestEnv.TXN.open(customName);
runner = new TransactionRunner(env);
createDatabase();
}
- @Override
+ @After
public void tearDown() {
try {
@@ -117,7 +110,7 @@ public class JoinTest extends TestCase
}
}
- @Override
+ @Test
public void runTest()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/NullTransactionRunner.java b/test/java/compat/src/com/sleepycat/collections/test/NullTransactionRunner.java
index 96d56dc6..20ce2e2a 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/NullTransactionRunner.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/NullTransactionRunner.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
*/
diff --git a/test/java/compat/src/com/sleepycat/collections/test/NullValueTest.java b/test/java/compat/src/com/sleepycat/collections/test/NullValueTest.java
index 238855c4..59929598 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/NullValueTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/NullValueTest.java
@@ -1,15 +1,21 @@
/*-
* 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.assertNull;
+import static org.junit.Assert.fail;
+
import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestCase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import com.sleepycat.bind.EntityBinding;
import com.sleepycat.bind.EntryBinding;
@@ -29,30 +35,16 @@ import com.sleepycat.db.DatabaseConfig;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
* Unit test for [#19085]. The collections API supports storing and retrieving
* null values, as long as the value binding supports null values.
*/
-public class NullValueTest extends TestCase
+public class NullValueTest extends TestBase
implements TransactionWorker {
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
- return new NullValueTest();
- }
-
private Environment env;
private ClassCatalog catalog;
private Database db;
@@ -60,20 +52,20 @@ public class NullValueTest extends TestCase
public NullValueTest() {
- super("NullValueTest");
+ customName = "NullValueTest";
}
- @Override
+ @Before
public void setUp()
throws Exception {
- SharedTestUtils.printTestName(getName());
- env = TestEnv.TXN.open(getName());
+ SharedTestUtils.printTestName(customName);
+ env = TestEnv.TXN.open(customName);
runner = new TransactionRunner(env);
open();
}
- @Override
+ @After
public void tearDown() {
if (catalog != null) {
try {
@@ -116,7 +108,7 @@ public class NullValueTest extends TestCase
db = DbCompat.testOpenDatabase(env, null, "test", null, dbConfig);
}
- @Override
+ @Test
public void runTest()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/SecondaryDeadlockTest.java b/test/java/compat/src/com/sleepycat/collections/test/SecondaryDeadlockTest.java
index 2b122a72..c3f54ea3 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/SecondaryDeadlockTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/SecondaryDeadlockTest.java
@@ -1,15 +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 junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import com.sleepycat.collections.StoredSortedMap;
import com.sleepycat.collections.TransactionRunner;
@@ -19,6 +23,7 @@ import com.sleepycat.db.Environment;
import com.sleepycat.db.DeadlockException;
import com.sleepycat.db.TransactionConfig;
import com.sleepycat.util.ExceptionUnwrapper;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
@@ -30,29 +35,13 @@ import com.sleepycat.util.test.TestEnv;
*
* @author Mark Hayes
*/
-public class SecondaryDeadlockTest extends TestCase {
+public class SecondaryDeadlockTest extends TestBase {
private static final Long N_ONE = new Long(1);
private static final Long N_101 = new Long(101);
private static final int N_ITERS = 20;
private static final int MAX_RETRIES = 1000;
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(SecondaryDeadlockTest.class);
- return suite;
- }
-
private Environment env;
private Database store;
private Database index;
@@ -60,15 +49,16 @@ public class SecondaryDeadlockTest extends TestCase {
private StoredSortedMap indexMap;
private Exception exception;
- public SecondaryDeadlockTest(String name) {
+ public SecondaryDeadlockTest() {
- super(name);
+ customName = "SecondaryDeadlockTest";
}
- @Override
+ @Before
public void setUp()
throws Exception {
+ super.setUp();
env = TestEnv.TXN.open("SecondaryDeadlockTest");
store = TestStore.BTREE_UNIQ.open(env, "store.db");
index = TestStore.BTREE_UNIQ.openIndex(store, "index.db");
@@ -82,7 +72,7 @@ public class SecondaryDeadlockTest extends TestCase {
true);
}
- @Override
+ @After
public void tearDown() {
if (index != null) {
@@ -114,6 +104,7 @@ public class SecondaryDeadlockTest extends TestCase {
indexMap = null;
}
+ @Test
public void testSecondaryDeadlock()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TestDataBinding.java b/test/java/compat/src/com/sleepycat/collections/test/TestDataBinding.java
index 76626ada..bbd4b006 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TestDataBinding.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TestDataBinding.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
*/
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TestEntity.java b/test/java/compat/src/com/sleepycat/collections/test/TestEntity.java
index a1a53b46..29d4cde9 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TestEntity.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TestEntity.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
*/
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TestEntityBinding.java b/test/java/compat/src/com/sleepycat/collections/test/TestEntityBinding.java
index 791ac276..e5b78d43 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TestEntityBinding.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TestEntityBinding.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
*/
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TestEnv.java b/test/java/compat/src/com/sleepycat/collections/test/TestEnv.java
index 72345325..76f59ce1 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TestEnv.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TestEnv.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
* $Id: TestEnv.java,v 0f73af5ae3da 2010/05/10 05:38:40 alexander $
*/
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TestKeyAssigner.java b/test/java/compat/src/com/sleepycat/collections/test/TestKeyAssigner.java
index dddd19ba..7f19e871 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TestKeyAssigner.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TestKeyAssigner.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
*/
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TestKeyCreator.java b/test/java/compat/src/com/sleepycat/collections/test/TestKeyCreator.java
index 867622ad..15347b64 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TestKeyCreator.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TestKeyCreator.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
*/
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TestSR15721.java b/test/java/compat/src/com/sleepycat/collections/test/TestSR15721.java
index 8caf58c1..0fd7c433 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TestSR15721.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TestSR15721.java
@@ -1,62 +1,34 @@
/*-
* 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 junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import com.sleepycat.collections.CurrentTransaction;
import com.sleepycat.db.Environment;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
* @author Chao Huang
*/
-public class TestSR15721 extends TestCase {
-
- /**
- * 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.TestSR15721"
- + " [-h | -help]\n");
- System.exit(2);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(TestSR15721.class);
- return suite;
- }
+public class TestSR15721 extends TestBase {
private Environment env;
private CurrentTransaction currentTxn;
- @Override
+ @Before
public void setUp()
throws Exception {
@@ -64,7 +36,7 @@ public class TestSR15721 extends TestCase {
currentTxn = CurrentTransaction.getInstance(env);
}
- @Override
+ @After
public void tearDown() {
try {
if (env != null) {
@@ -83,6 +55,7 @@ public class TestSR15721 extends TestCase {
* Tests that the CurrentTransaction instance doesn't indeed allow GC to
* reclaim while attached environment is open. [#15721]
*/
+ @Test
public void testSR15721Fix()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/TestStore.java b/test/java/compat/src/com/sleepycat/collections/test/TestStore.java
index 265ec886..54f9ffd8 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/TestStore.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/TestStore.java
@@ -1,7 +1,7 @@
/*-
* 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.
*
*/
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 {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/serial/CatalogCornerCaseTest.java b/test/java/compat/src/com/sleepycat/collections/test/serial/CatalogCornerCaseTest.java
index e620371b..d8d8b296 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/serial/CatalogCornerCaseTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/serial/CatalogCornerCaseTest.java
@@ -1,14 +1,16 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
package com.sleepycat.collections.test.serial;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import com.sleepycat.bind.serial.StoredClassCatalog;
import com.sleepycat.compat.DbCompat;
@@ -16,44 +18,31 @@ import com.sleepycat.db.Database;
import com.sleepycat.db.DatabaseConfig;
import com.sleepycat.db.Environment;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
* @author Mark Hayes
*/
-public class CatalogCornerCaseTest extends TestCase {
-
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
- return new TestSuite(CatalogCornerCaseTest.class);
- }
+public class CatalogCornerCaseTest extends TestBase {
private Environment env;
- public CatalogCornerCaseTest(String name) {
+ public CatalogCornerCaseTest() {
- super(name);
+ customName = "CatalogCornerCaseTest";
}
- @Override
+ @Before
public void setUp()
throws Exception {
- SharedTestUtils.printTestName(getName());
- env = TestEnv.BDB.open(getName());
+ super.setUp();
+ SharedTestUtils.printTestName(customName);
+ env = TestEnv.BDB.open(customName);
}
- @Override
+ @After
public void tearDown() {
try {
@@ -68,6 +57,7 @@ public class CatalogCornerCaseTest extends TestCase {
}
}
+ @Test
public void testReadOnlyEmptyCatalog()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTest.java b/test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTest.java
index b9fd4750..9e7954bc 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTest.java
@@ -1,17 +1,27 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
package com.sleepycat.collections.test.serial;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
import java.io.ObjectStreamClass;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
-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 org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.bind.serial.SerialBinding;
import com.sleepycat.bind.serial.StoredClassCatalog;
@@ -23,6 +33,7 @@ import com.sleepycat.db.Database;
import com.sleepycat.db.DatabaseConfig;
import com.sleepycat.db.Environment;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
@@ -34,29 +45,20 @@ import com.sleepycat.util.test.TestEnv;
*
* @author Mark Hayes
*/
-public class StoredClassCatalogTest extends TestCase
+@RunWith(Parameterized.class)
+public class StoredClassCatalogTest extends TestBase
implements TransactionWorker {
static final String CATALOG_FILE = "catalogtest-catalog.db";
static final String STORE_FILE = "catalogtest-store.db";
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- for (int i = 0; i < TestEnv.ALL.length; i += 1) {
- suite.addTest(new StoredClassCatalogTest(TestEnv.ALL[i]));
- }
- return suite;
+ @Parameters
+ public static List<Object[]> genParams() {
+ List<Object[]> params = new ArrayList<Object[]>();
+ for (TestEnv testEnv : TestEnv.ALL)
+ params.add(new Object[]{testEnv});
+
+ return params;
}
private TestEnv testEnv;
@@ -69,20 +71,29 @@ public class StoredClassCatalogTest extends TestCase
public StoredClassCatalogTest(TestEnv testEnv) {
- super(makeTestName(testEnv));
this.testEnv = testEnv;
+ customName = makeTestName(testEnv);
}
static String makeTestName(TestEnv testEnv) {
return "StoredClassCatalogTest-" + testEnv.getName();
}
- @Override
+ @Before
public void setUp()
throws Exception {
- SharedTestUtils.printTestName(getName());
- env = testEnv.open(makeTestName(testEnv), false);
+ SharedTestUtils.printTestName(customName);
+
+ /*
+ * Copy the environment generated by StoredClassCatalogTestInit in
+ * test dest dir, which is required to perform this test.
+ */
+ SharedTestUtils.copyDir(
+ new File(SharedTestUtils.getDestDir(), customName),
+ new File(SharedTestUtils.getTestDir(), customName));
+
+ env = testEnv.open(customName, false);
runner = new TransactionRunner(env);
catalog = new StoredClassCatalog(openDb(CATALOG_FILE, false));
@@ -108,7 +119,7 @@ public class StoredClassCatalogTest extends TestCase
return DbCompat.testOpenDatabase(env, null, file, null, config);
}
- @Override
+ @After
public void tearDown() {
try {
@@ -139,8 +150,8 @@ public class StoredClassCatalogTest extends TestCase
runner = null;
}
}
-
- @Override
+
+ @Test
public void runTest()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTestInit.java b/test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTestInit.java
index 6fde045d..80117289 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTestInit.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/serial/StoredClassCatalogTestInit.java
@@ -1,16 +1,25 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
package com.sleepycat.collections.test.serial;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
-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 org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.bind.serial.SerialBinding;
import com.sleepycat.bind.serial.StoredClassCatalog;
@@ -22,6 +31,7 @@ import com.sleepycat.db.Database;
import com.sleepycat.db.DatabaseConfig;
import com.sleepycat.db.Environment;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
@@ -33,29 +43,20 @@ import com.sleepycat.util.test.TestEnv;
*
* @author Mark Hayes
*/
-public class StoredClassCatalogTestInit extends TestCase
+@RunWith(Parameterized.class)
+public class StoredClassCatalogTestInit extends TestBase
implements TransactionWorker {
static final String CATALOG_FILE = StoredClassCatalogTest.CATALOG_FILE;
static final String STORE_FILE = StoredClassCatalogTest.STORE_FILE;
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- for (int i = 0; i < TestEnv.ALL.length; i += 1) {
- suite.addTest(new StoredClassCatalogTestInit(TestEnv.ALL[i]));
- }
- return suite;
+ @Parameters
+ public static List<Object[]> genParams() {
+ List<Object[]> params = new ArrayList<Object[]>();
+ for (TestEnv testEnv : TestEnv.ALL)
+ params.add(new Object[]{testEnv});
+
+ return params;
}
private TestEnv testEnv;
@@ -67,16 +68,16 @@ public class StoredClassCatalogTestInit extends TestCase
public StoredClassCatalogTestInit(TestEnv testEnv) {
- super("StoredClassCatalogTestInit-" + testEnv.getName());
this.testEnv = testEnv;
+ customName = StoredClassCatalogTest.makeTestName(testEnv);
}
- @Override
+ @Before
public void setUp()
throws Exception {
-
- SharedTestUtils.printTestName(getName());
- env = testEnv.open(StoredClassCatalogTest.makeTestName(testEnv));
+
+ SharedTestUtils.printTestName(customName);
+ env = testEnv.open(customName);
runner = new TransactionRunner(env);
catalog = new StoredClassCatalog(openDb(CATALOG_FILE));
@@ -100,8 +101,9 @@ public class StoredClassCatalogTestInit extends TestCase
return DbCompat.testOpenDatabase(env, null, file, null, config);
}
- @Override
- public void tearDown() {
+ @After
+ public void tearDown()
+ throws Exception {
try {
if (catalog != null) {
@@ -114,6 +116,14 @@ public class StoredClassCatalogTestInit extends TestCase
if (env != null) {
env.close();
}
+
+ /*
+ * Copy environment generated by this test to test dest dir.
+ * Since the environment is necessary for StoreClassCatalogTest.
+ */
+ SharedTestUtils.copyDir(testEnv.getDirectory(customName, false),
+ new File(SharedTestUtils.getDestDir(), customName));
+
} catch (Exception e) {
System.err.println("Ignored exception during tearDown: ");
e.printStackTrace();
@@ -128,13 +138,13 @@ public class StoredClassCatalogTestInit extends TestCase
}
}
- @Override
+ @Test
public void runTest()
throws Exception {
-
+
runner.run(this);
}
-
+
public void doWork() {
TestSerial one = new TestSerial(null);
TestSerial two = new TestSerial(one);
diff --git a/test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java b/test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java
index 23261e59..700dc9d4 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
package com.sleepycat.collections.test.serial;
diff --git a/test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java.original b/test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java.original
index 55d9e9a3..51dd91f3 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java.original
+++ b/test/java/compat/src/com/sleepycat/collections/test/serial/TestSerial.java.original
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015 Oracle. All rights reserved.
*
*/
package com.sleepycat.collections.test.serial;
diff --git a/test/java/compat/src/com/sleepycat/collections/test/serial/TupleSerialFactoryTest.java b/test/java/compat/src/com/sleepycat/collections/test/serial/TupleSerialFactoryTest.java
index 27002bec..5eb5fc30 100644
--- a/test/java/compat/src/com/sleepycat/collections/test/serial/TupleSerialFactoryTest.java
+++ b/test/java/compat/src/com/sleepycat/collections/test/serial/TupleSerialFactoryTest.java
@@ -1,16 +1,25 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
package com.sleepycat.collections.test.serial;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
-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 org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.bind.serial.StoredClassCatalog;
import com.sleepycat.bind.serial.test.MarshalledObject;
@@ -25,34 +34,27 @@ import com.sleepycat.db.ForeignKeyDeleteAction;
import com.sleepycat.db.SecondaryConfig;
import com.sleepycat.db.SecondaryDatabase;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
* @author Mark Hayes
*/
-public class TupleSerialFactoryTest extends TestCase
- implements TransactionWorker {
- public static void main(String[] args) {
- junit.framework.TestResult tr =
- junit.textui.TestRunner.run(suite());
- if (tr.errorCount() > 0 ||
- tr.failureCount() > 0) {
- System.exit(1);
- } else {
- System.exit(0);
- }
- }
+@RunWith(Parameterized.class)
+public class TupleSerialFactoryTest extends TestBase
+ implements TransactionWorker {
- public static Test suite() {
- TestSuite suite = new TestSuite();
- for (int i = 0; i < TestEnv.ALL.length; i += 1) {
+ @Parameters
+ public static List<Object[]> genParams() {
+ List<Object[]> params = new ArrayList<Object[]>();
+ for (TestEnv testEnv : TestEnv.ALL) {
for (int sorted = 0; sorted < 2; sorted += 1) {
- suite.addTest(new TupleSerialFactoryTest(TestEnv.ALL[i],
- sorted != 0));
+ params.add(new Object[]{testEnv, sorted != 0 });
}
}
- return suite;
+
+ return params;
}
private TestEnv testEnv;
@@ -72,28 +74,28 @@ public class TupleSerialFactoryTest extends TestCase
public TupleSerialFactoryTest(TestEnv testEnv, boolean isSorted) {
- super(null);
this.testEnv = testEnv;
this.isSorted = isSorted;
String name = "TupleSerialFactoryTest-" + testEnv.getName();
name += isSorted ? "-sorted" : "-unsorted";
- setName(name);
+ customName = name;
}
- @Override
+ @Before
public void setUp()
throws Exception {
- SharedTestUtils.printTestName(getName());
- env = testEnv.open(getName());
+ super.setUp();
+ SharedTestUtils.printTestName(customName);
+ env = testEnv.open(customName);
runner = new TransactionRunner(env);
createDatabase();
}
- @Override
+ @After
public void tearDown() {
try {
@@ -135,7 +137,7 @@ public class TupleSerialFactoryTest extends TestCase
}
}
- @Override
+ @Test
public void runTest()
throws Exception {