summaryrefslogtreecommitdiff
path: root/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'test/java')
-rw-r--r--test/java/compat/README8
-rw-r--r--test/java/compat/chk.bdb3
-rw-r--r--test/java/compat/src/com/sleepycat/bind/serial/test/MarshalledObject.java2
-rw-r--r--test/java/compat/src/com/sleepycat/bind/serial/test/NullClassCatalog.java2
-rw-r--r--test/java/compat/src/com/sleepycat/bind/serial/test/SerialBindingTest.java62
-rw-r--r--test/java/compat/src/com/sleepycat/bind/serial/test/TestClassCatalog.java2
-rw-r--r--test/java/compat/src/com/sleepycat/bind/test/BindingSpeedTest.java59
-rw-r--r--test/java/compat/src/com/sleepycat/bind/tuple/test/MarshalledObject.java2
-rw-r--r--test/java/compat/src/com/sleepycat/bind/tuple/test/TupleBindingTest.java58
-rw-r--r--test/java/compat/src/com/sleepycat/bind/tuple/test/TupleFormatTest.java64
-rw-r--r--test/java/compat/src/com/sleepycat/bind/tuple/test/TupleOrderingTest.java62
-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
-rw-r--r--test/java/compat/src/com/sleepycat/db/util/DualTestCase.java34
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/BindingTest.java44
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/Enhanced0.java2
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/Enhanced1.java2
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/Enhanced2.java2
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/Enhanced3.java2
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/EvolveCase.java2
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java94
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java.original31
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/EvolveTest.java38
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/EvolveTestBase.java71
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/EvolveTestInit.java18
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/ForeignKeyTest.java83
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/IndexTest.java44
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/JoinTest.java24
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/NegativeTest.java57
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/OperationTest.java65
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/PersistTestUtils.java2
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/SequenceTest.java18
-rw-r--r--test/java/compat/src/com/sleepycat/persist/test/SubclassIndexTest.java22
-rw-r--r--test/java/compat/src/com/sleepycat/util/test/ExceptionWrapperTest.java43
-rw-r--r--test/java/compat/src/com/sleepycat/util/test/FastOutputStreamTest.java38
-rw-r--r--test/java/compat/src/com/sleepycat/util/test/PackedIntegerTest.java32
-rw-r--r--test/java/compat/src/com/sleepycat/util/test/SharedTestUtils.java161
-rw-r--r--test/java/compat/src/com/sleepycat/util/test/TestBase.java96
-rw-r--r--test/java/compat/src/com/sleepycat/util/test/TestEnv.java2
-rw-r--r--test/java/compat/src/com/sleepycat/util/test/TxnTestCase.java87
-rw-r--r--test/java/compat/src/com/sleepycat/util/test/UtfTest.java38
-rw-r--r--test/java/junit/makenewtest.sh2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/AppendRecnoTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/AssociateTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/BackupTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/CallbackTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/ClosedDbTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/DatabaseTest.java629
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/EncryptTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/EnvRegionSizeTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/HashCompareTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/LogCursorTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/MultipleCursorTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/PartialGetTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/PriorityTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/RepmgrConfigTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/RepmgrElectionTest.java2
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/RepmgrSiteTest.java136
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/RepmgrStartupTest.java17
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/TestUtils.java11
-rw-r--r--test/java/junit/src/com/sleepycat/db/test/VerboseConfigTest.java2
-rw-r--r--test/java/rep/tests/rep/TestEmptyLogElection.java2
-rw-r--r--test/java/rep/tests/rep/TestMirandaTimeout.java2
-rw-r--r--test/java/rep/tests/repmgrtests/EventHandler.java2
-rw-r--r--test/java/rep/tests/repmgrtests/PortsConfig.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestConfig.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestDrainAbandon.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestDrainCommitx.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestDrainIntInit.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestHeartbeats.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestNoClient.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestRedundantTakeover.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestRepmgr.java2
-rw-r--r--test/java/rep/tests/repmgrtests/TestStrictElect.java2
-rw-r--r--test/java/rep/tests/repmgrtests/Util.java2
-rw-r--r--test/java/rep/upgrades/current/repmgrtests/ConnectScript.java2
-rw-r--r--test/java/rep/upgrades/current/repmgrtests/CurrentImpl.java2
-rw-r--r--test/java/rep/upgrades/test/repmgrtests/AbstractUpgTest.java2
-rw-r--r--test/java/rep/upgrades/test/repmgrtests/Config.java2
-rw-r--r--test/java/rep/upgrades/test/repmgrtests/MyStats.java2
-rw-r--r--test/java/rep/upgrades/test/repmgrtests/SimpleConnectTest.java2
-rw-r--r--test/java/rep/upgrades/test/repmgrtests/TestMixedHeartbeats.java2
-rw-r--r--test/java/rep/upgrades/test/repmgrtests/TestReverseConnect.java2
-rw-r--r--test/java/rep/upgrades/test/repmgrtests/TestSimpleFwdConnect.java2
-rw-r--r--test/java/rep/upgrades/test/repmgrtests/TestSimpleRevConnect.java2
-rw-r--r--test/java/rep/upgrades/v46/repmgrtests/V46impl.java2
-rw-r--r--test/java/rep/upgrades/v47/repmgrtests/ConnectScript.java2
109 files changed, 2048 insertions, 1168 deletions
diff --git a/test/java/compat/README b/test/java/compat/README
index 1053cf67..61052252 100644
--- a/test/java/compat/README
+++ b/test/java/compat/README
@@ -8,15 +8,15 @@ External software requirements:
Java 1.5 or later.
The Sun JDK is normally used, but any compatible JVM should work.
- Apache Ant 7.0 or later.
+ Apache Ant 1.7.0 or later.
http://ant.apache.org/bindownload.cgi
- JUnit 3.8.1 or 3.8.2 (later versions do not currently work)
- http://prdownloads.sourceforge.net/junit/junit3.8.1.zip?download
+ JUnit 4.10 or later.
The bin directories of both Java and Ant must be in your executable path. The
junit.jar file must be available to Ant. The simplest way to do this is to copy
-the junit.jar file into your Ant's lib directory.
+the junit.jar file into your Ant's lib directory. You may also set JUNIT_JAR
+to point to the desired junit.jar file.
There are two configuration settings for specifying the DB release to be
tested:
diff --git a/test/java/compat/chk.bdb b/test/java/compat/chk.bdb
index f523bf33..6e8a92ac 100644
--- a/test/java/compat/chk.bdb
+++ b/test/java/compat/chk.bdb
@@ -43,6 +43,9 @@ case `uname` in
CP_SEP=":"
LD_LIBRARY_PATH="`pwd`/$DB_LIB_DIR:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
+ # Systems like Darwin use DYLD_LIBRARY_PATH.
+ DYLD_LIBRARY_PATH="`pwd`/$DB_LIB_DIR:$DYLD_LIBRARY_PATH"
+ export DYLD_LIBRARY_PATH
;;
esac
DB_JAR="$d/db.jar"
diff --git a/test/java/compat/src/com/sleepycat/bind/serial/test/MarshalledObject.java b/test/java/compat/src/com/sleepycat/bind/serial/test/MarshalledObject.java
index 57a44c99..93a87324 100644
--- a/test/java/compat/src/com/sleepycat/bind/serial/test/MarshalledObject.java
+++ b/test/java/compat/src/com/sleepycat/bind/serial/test/MarshalledObject.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/bind/serial/test/NullClassCatalog.java b/test/java/compat/src/com/sleepycat/bind/serial/test/NullClassCatalog.java
index fceeca02..b78eb21b 100644
--- a/test/java/compat/src/com/sleepycat/bind/serial/test/NullClassCatalog.java
+++ b/test/java/compat/src/com/sleepycat/bind/serial/test/NullClassCatalog.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/bind/serial/test/SerialBindingTest.java b/test/java/compat/src/com/sleepycat/bind/serial/test/SerialBindingTest.java
index 8d843156..91d2cf6d 100644
--- a/test/java/compat/src/com/sleepycat/bind/serial/test/SerialBindingTest.java
+++ b/test/java/compat/src/com/sleepycat/bind/serial/test/SerialBindingTest.java
@@ -1,17 +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.bind.serial.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.Serializable;
-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.EntityBinding;
import com.sleepycat.bind.serial.ClassCatalog;
@@ -19,50 +24,27 @@ import com.sleepycat.bind.serial.SerialBinding;
import com.sleepycat.bind.serial.SerialSerialBinding;
import com.sleepycat.bind.serial.TupleSerialMarshalledBinding;
import com.sleepycat.db.DatabaseEntry;
-import com.sleepycat.util.ExceptionUnwrapper;
import com.sleepycat.util.FastOutputStream;
-import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
/**
* @author Mark Hayes
*/
-public class SerialBindingTest extends TestCase {
+public class SerialBindingTest extends TestBase {
private ClassCatalog catalog;
private DatabaseEntry buffer;
private DatabaseEntry keyBuffer;
- 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(SerialBindingTest.class);
- return suite;
- }
-
- public SerialBindingTest(String name) {
-
- super(name);
- }
-
- @Override
+ @Before
public void setUp() {
- SharedTestUtils.printTestName("SerialBindingTest." + getName());
catalog = new TestClassCatalog();
buffer = new DatabaseEntry();
keyBuffer = new DatabaseEntry();
}
- @Override
+ @After
public void tearDown() {
/* Ensure that GC can cleanup. */
@@ -71,17 +53,6 @@ public class SerialBindingTest extends TestCase {
keyBuffer = null;
}
- @Override
- public void runTest()
- throws Throwable {
-
- try {
- super.runTest();
- } catch (Exception e) {
- throw ExceptionUnwrapper.unwrap(e);
- }
- }
-
private void primitiveBindingTest(Object val) {
Class cls = val.getClass();
@@ -101,6 +72,7 @@ public class SerialBindingTest extends TestCase {
} catch (IllegalArgumentException expected) {}
}
+ @Test
public void testPrimitiveBindings() {
primitiveBindingTest("abc");
@@ -114,6 +86,7 @@ public class SerialBindingTest extends TestCase {
primitiveBindingTest(new Double(123.123));
}
+ @Test
public void testNullObjects() {
SerialBinding binding = new SerialBinding(catalog, null);
@@ -123,6 +96,7 @@ public class SerialBindingTest extends TestCase {
assertEquals(null, binding.entryToObject(buffer));
}
+ @Test
public void testSerialSerialBinding() {
SerialBinding keyBinding = new SerialBinding(catalog, String.class);
@@ -142,6 +116,7 @@ public class SerialBindingTest extends TestCase {
// also tests TupleSerialBinding since TupleSerialMarshalledBinding extends
// it
+ @Test
public void testTupleSerialMarshalledBinding() {
SerialBinding valueBinding = new SerialBinding(catalog,
@@ -165,6 +140,7 @@ public class SerialBindingTest extends TestCase {
assertEquals("index2", val.getIndexKey2());
}
+ @Test
public void testBufferSize() {
CaptureSizeBinding binding =
@@ -196,6 +172,7 @@ public class SerialBindingTest extends TestCase {
}
}
+ @Test
public void testBufferOverride() {
FastOutputStream out = new FastOutputStream(10);
@@ -282,6 +259,7 @@ public class SerialBindingTest extends TestCase {
* a crude test because to create a truly working class loader is a large
* undertaking.
*/
+ @Test
public void testClassloaderOverride() {
DatabaseEntry entry = new DatabaseEntry();
diff --git a/test/java/compat/src/com/sleepycat/bind/serial/test/TestClassCatalog.java b/test/java/compat/src/com/sleepycat/bind/serial/test/TestClassCatalog.java
index 2490d658..be457f77 100644
--- a/test/java/compat/src/com/sleepycat/bind/serial/test/TestClassCatalog.java
+++ b/test/java/compat/src/com/sleepycat/bind/serial/test/TestClassCatalog.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/bind/test/BindingSpeedTest.java b/test/java/compat/src/com/sleepycat/bind/test/BindingSpeedTest.java
index 6dc24246..1bdbc657 100644
--- a/test/java/compat/src/com/sleepycat/bind/test/BindingSpeedTest.java
+++ b/test/java/compat/src/com/sleepycat/bind/test/BindingSpeedTest.java
@@ -1,15 +1,17 @@
/*-
* 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.bind.test;
+import static org.junit.Assert.assertTrue;
+
import java.io.Externalizable;
-import java.io.InputStreamReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
@@ -19,13 +21,16 @@ import java.io.Serializable;
import java.io.Writer;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
import javax.xml.parsers.SAXParserFactory;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -37,11 +42,13 @@ import com.sleepycat.bind.tuple.TupleOutput;
import com.sleepycat.util.FastInputStream;
import com.sleepycat.util.FastOutputStream;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
/**
* @author Mark Hayes
*/
-public class BindingSpeedTest extends TestCase {
+@RunWith(Parameterized.class)
+public class BindingSpeedTest extends TestBase {
static final String JAVA_UNSHARED = "java-unshared".intern();
static final String JAVA_SHARED = "java-shared".intern();
@@ -54,28 +61,13 @@ public class BindingSpeedTest extends TestCase {
static final int RUN_COUNT = 1000;
static final boolean VERBOSE = false;
- 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();
- suite.addTest(new BindingSpeedTest(JAVA_UNSHARED));
- suite.addTest(new BindingSpeedTest(JAVA_SHARED));
- suite.addTest(new BindingSpeedTest(JAVA_EXTERNALIZABLE));
- suite.addTest(new BindingSpeedTest(XML_SAX));
- suite.addTest(new BindingSpeedTest(TUPLE));
- suite.addTest(new BindingSpeedTest(REFLECT_METHOD));
- suite.addTest(new BindingSpeedTest(REFLECT_FIELD));
- return suite;
+ @Parameters
+ public static List<Object[]> genParams(){
+
+ return Arrays.asList(new Object[][]{{JAVA_UNSHARED}, {JAVA_SHARED},
+ {JAVA_EXTERNALIZABLE}, {XML_SAX},
+ {TUPLE}, {REFLECT_METHOD},
+ {REFLECT_FIELD}});
}
private String command;
@@ -90,16 +82,15 @@ public class BindingSpeedTest extends TestCase {
public BindingSpeedTest(String name) {
- super("BindingSpeedTest." + name);
command = name;
+ customName = "BindingSpeedTest." + name;
}
- @Override
+ @Test
public void runTest()
throws Exception {
- SharedTestUtils.printTestName(getName());
-
+ SharedTestUtils.printTestName(customName);
boolean isTuple = false;
boolean isReflectMethod = false;
boolean isReflectField = false;
@@ -211,7 +202,7 @@ public class BindingSpeedTest extends TestCase {
}
}
- @Override
+ @After
public void tearDown() {
/* Ensure that GC can cleanup. */
diff --git a/test/java/compat/src/com/sleepycat/bind/tuple/test/MarshalledObject.java b/test/java/compat/src/com/sleepycat/bind/tuple/test/MarshalledObject.java
index 3ea7b40a..87346823 100644
--- a/test/java/compat/src/com/sleepycat/bind/tuple/test/MarshalledObject.java
+++ b/test/java/compat/src/com/sleepycat/bind/tuple/test/MarshalledObject.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/bind/tuple/test/TupleBindingTest.java b/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleBindingTest.java
index 3feeb3bc..a5601879 100644
--- a/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleBindingTest.java
+++ b/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleBindingTest.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.bind.tuple.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.math.BigDecimal;
import java.math.BigInteger;
-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.EntityBinding;
import com.sleepycat.bind.EntryBinding;
@@ -41,48 +45,24 @@ import com.sleepycat.bind.tuple.TupleMarshalledBinding;
import com.sleepycat.bind.tuple.TupleOutput;
import com.sleepycat.bind.tuple.TupleTupleMarshalledBinding;
import com.sleepycat.db.DatabaseEntry;
-import com.sleepycat.util.ExceptionUnwrapper;
import com.sleepycat.util.FastOutputStream;
-import com.sleepycat.util.test.SharedTestUtils;
/**
* @author Mark Hayes
*/
-public class TupleBindingTest extends TestCase {
+public class TupleBindingTest {
private DatabaseEntry buffer;
private DatabaseEntry keyBuffer;
- 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(TupleBindingTest.class);
- return suite;
- }
-
- public TupleBindingTest(String name) {
-
- super(name);
- }
-
- @Override
+ @Before
public void setUp() {
- SharedTestUtils.printTestName("TupleBindingTest." + getName());
buffer = new DatabaseEntry();
keyBuffer = new DatabaseEntry();
}
- @Override
+ @After
public void tearDown() {
/* Ensure that GC can cleanup. */
@@ -90,16 +70,6 @@ public class TupleBindingTest extends TestCase {
keyBuffer = null;
}
- @Override
- public void runTest()
- throws Throwable {
-
- try {
- super.runTest();
- } catch (Exception e) {
- throw ExceptionUnwrapper.unwrap(e);
- }
- }
private void primitiveBindingTest(Class primitiveCls, Class compareCls,
Object val, int byteSize) {
@@ -143,6 +113,7 @@ public class TupleBindingTest extends TestCase {
assertEquals(val2, val3);
}
+ @Test
public void testPrimitiveBindings() {
primitiveBindingTest(String.class, String.class,
@@ -356,6 +327,7 @@ public class TupleBindingTest extends TestCase {
new BigDecimal("123456789.123456"));
}
+ @Test
public void testTupleInputBinding() {
EntryBinding binding = new TupleInputBinding();
@@ -373,6 +345,7 @@ public class TupleBindingTest extends TestCase {
}
// also tests TupleBinding since TupleMarshalledBinding extends it
+ @Test
public void testTupleMarshalledBinding() {
EntryBinding binding =
@@ -390,6 +363,7 @@ public class TupleBindingTest extends TestCase {
// also tests TupleTupleBinding since TupleTupleMarshalledBinding extends
// it
+ @Test
public void testTupleTupleMarshalledBinding() {
EntityBinding binding =
@@ -411,6 +385,7 @@ public class TupleBindingTest extends TestCase {
assertEquals("index2", val.getIndexKey2());
}
+ @Test
public void testBufferSize() {
CaptureSizeBinding binding = new CaptureSizeBinding();
@@ -452,6 +427,7 @@ public class TupleBindingTest extends TestCase {
}
}
+ @Test
public void testBufferOverride() {
TupleOutput out = new TupleOutput(new byte[10]);
diff --git a/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleFormatTest.java b/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleFormatTest.java
index 823ecaaa..3480abba 100644
--- a/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleFormatTest.java
+++ b/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleFormatTest.java
@@ -1,65 +1,45 @@
/*-
* 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.bind.tuple.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
-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.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;
import com.sleepycat.db.DatabaseEntry;
-import com.sleepycat.util.test.SharedTestUtils;
/**
* @author Mark Hayes
*/
-public class TupleFormatTest extends TestCase {
+public class TupleFormatTest {
private TupleInput in;
private TupleOutput out;
private DatabaseEntry buffer;
- 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(TupleFormatTest.class);
- return suite;
- }
-
- public TupleFormatTest(String name) {
-
- super(name);
- }
-
- @Override
+ @Before
public void setUp() {
- SharedTestUtils.printTestName("TupleFormatTest." + getName());
buffer = new DatabaseEntry();
out = new TupleOutput();
}
- @Override
+ @After
public void tearDown() {
/* Ensure that GC can cleanup. */
@@ -87,6 +67,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(0, in.available());
}
+ @Test
public void testString() {
stringTest("");
@@ -130,6 +111,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(0, in.available());
}
+ @Test
public void testFixedString() {
fixedStringTest(new char[0]);
@@ -157,6 +139,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(0, in.available());
}
+ @Test
public void testNullString() {
out.reset();
@@ -229,6 +212,7 @@ public class TupleFormatTest extends TestCase {
}
}
+ @Test
public void testChars() {
charsTest(new char[0]);
@@ -282,6 +266,7 @@ public class TupleFormatTest extends TestCase {
}
}
+ @Test
public void testBytes() {
bytesTest(new char[0]);
@@ -320,6 +305,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(0, in.available());
}
+ @Test
public void testBoolean() {
booleanTest(true);
@@ -360,6 +346,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(expected, in.readUnsignedByte());
}
+ @Test
public void testUnsignedByte() {
unsignedByteTest(0);
@@ -397,6 +384,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(expected, in.readUnsignedShort());
}
+ @Test
public void testUnsignedShort() {
unsignedShortTest(0);
@@ -442,6 +430,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(expected, in.readUnsignedInt());
}
+ @Test
public void testUnsignedInt() {
unsignedIntTest(0L);
@@ -485,6 +474,7 @@ public class TupleFormatTest extends TestCase {
assertEquals((byte) val, in.readByte());
}
+ @Test
public void testByte() {
byteTest(0);
@@ -524,6 +514,7 @@ public class TupleFormatTest extends TestCase {
assertEquals((short) val, in.readShort());
}
+ @Test
public void testShort() {
shortTest(0);
@@ -563,6 +554,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(val, in.readInt());
}
+ @Test
public void testInt() {
intTest(0);
@@ -602,6 +594,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(val, in.readLong());
}
+ @Test
public void testLong() {
longTest(0);
@@ -647,6 +640,7 @@ public class TupleFormatTest extends TestCase {
}
}
+ @Test
public void testFloat() {
floatTest(0);
@@ -704,6 +698,7 @@ public class TupleFormatTest extends TestCase {
}
}
+ @Test
public void testDouble() {
doubleTest(0);
@@ -764,6 +759,7 @@ public class TupleFormatTest extends TestCase {
}
}
+ @Test
public void testSortedFloat() {
sortedFloatTest(0);
@@ -821,6 +817,7 @@ public class TupleFormatTest extends TestCase {
}
}
+ @Test
public void testSortedDouble() {
sortedDoubleTest(0);
@@ -878,6 +875,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(val, in.readPackedInt());
}
+ @Test
public void testPackedInt() {
/* Exhaustive value testing is in PackedIntTest. */
@@ -907,6 +905,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(val, in.readPackedLong());
}
+ @Test
public void testPackedLong() {
/* Exhaustive value testing is in PackedIntTest. */
@@ -936,6 +935,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(val, in.readSortedPackedInt());
}
+ @Test
public void testSortedPackedInt() {
/* Exhaustive value testing is in sortedPackedIntTest. */
@@ -987,6 +987,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(val, in.readSortedPackedLong());
}
+ @Test
public void testSortedPackedLong() {
/* Exhaustive value testing is in sortedPackedLongTest. */
@@ -1053,6 +1054,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(val, in.readBigInteger());
}
+ @Test
public void testBigInteger() {
/* Exhaustive value testing is in bigIntegerTest. */
@@ -1094,6 +1096,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(val, in.readBigDecimal());
}
+ @Test
public void testBigDecimal() {
/* Exhaustive value testing is in BigDecimal. */
@@ -1145,6 +1148,7 @@ public class TupleFormatTest extends TestCase {
assertEquals(0, val.compareTo(in.readSortedBigDecimal()));
}
+ @Test
public void testSortedBigDecimal() {
/* Exhaustive value testing is in BigDecimal. */
diff --git a/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleOrderingTest.java b/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleOrderingTest.java
index 5beec774..b29bd257 100644
--- a/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleOrderingTest.java
+++ b/test/java/compat/src/com/sleepycat/bind/tuple/test/TupleOrderingTest.java
@@ -1,60 +1,39 @@
/*-
* 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.bind.tuple.test;
-import java.math.BigInteger;
+import static org.junit.Assert.fail;
+
import java.math.BigDecimal;
+import java.math.BigInteger;
-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.tuple.TupleOutput;
-import com.sleepycat.util.test.SharedTestUtils;
/**
* @author Mark Hayes
*/
-public class TupleOrderingTest extends TestCase {
+public class TupleOrderingTest {
private TupleOutput out;
private byte[] prevBuf;
- 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(TupleOrderingTest.class);
- return suite;
- }
-
- public TupleOrderingTest(String name) {
-
- super(name);
- }
-
- @Override
+ @Before
public void setUp() {
- SharedTestUtils.printTestName("TupleOrderingTest." + getName());
out = new TupleOutput();
prevBuf = null;
}
- @Override
+ @After
public void tearDown() {
/* Ensure that GC can cleanup. */
@@ -143,6 +122,7 @@ public class TupleOrderingTest extends TestCase {
out.reset();
}
+ @Test
public void testString() {
final String[] DATA = {
@@ -177,6 +157,7 @@ public class TupleOrderingTest extends TestCase {
check();
}
+ @Test
public void testFixedString() {
final char[][] DATA = {
@@ -188,6 +169,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testChars() {
final char[][] DATA = {
@@ -200,6 +182,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testBytes() {
final char[][] DATA = {
@@ -212,6 +195,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testBoolean() {
final boolean[] DATA = {
@@ -223,6 +207,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testUnsignedByte() {
final int[] DATA = {
@@ -234,6 +219,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testUnsignedShort() {
final int[] DATA = {
@@ -245,6 +231,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testUnsignedInt() {
final long[] DATA = {
@@ -257,6 +244,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testByte() {
final byte[] DATA = {
@@ -270,6 +258,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testShort() {
final short[] DATA = {
@@ -285,6 +274,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testInt() {
final int[] DATA = {
@@ -302,6 +292,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testLong() {
final long[] DATA = {
@@ -321,6 +312,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testFloat() {
// Only positive floats and doubles are ordered deterministically
@@ -343,6 +335,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testDouble() {
// Only positive floats and doubles are ordered deterministically
@@ -365,6 +358,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testSortedFloat() {
final float[] DATA = {
@@ -413,6 +407,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testSortedDouble() {
final double[] DATA = {
@@ -464,6 +459,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testPackedIntAndLong() {
/* Only packed int/long values from 0 to 630 are ordered correctly */
for (int i = 0; i <= 630; i += 1) {
@@ -477,6 +473,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testSortedPackedInt() {
final int[] DATA = {
Integer.MIN_VALUE, Integer.MIN_VALUE + 1,
@@ -493,6 +490,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testSortedPackedLong() {
final long[] DATA = {
Long.MIN_VALUE, Long.MIN_VALUE + 1,
@@ -511,6 +509,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testBigInteger() {
final BigInteger[] DATA = {
new BigInteger("-1111111111111111111111111"),
@@ -542,6 +541,7 @@ public class TupleOrderingTest extends TestCase {
}
}
+ @Test
public void testSortedBigDecimal() {
final BigDecimal[] DATA = {
new BigDecimal(BigInteger.valueOf(Long.MIN_VALUE),
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 {
diff --git a/test/java/compat/src/com/sleepycat/db/util/DualTestCase.java b/test/java/compat/src/com/sleepycat/db/util/DualTestCase.java
index a109a4d0..8e34fcc8 100644
--- a/test/java/compat/src/com/sleepycat/db/util/DualTestCase.java
+++ b/test/java/compat/src/com/sleepycat/db/util/DualTestCase.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$
*/
@@ -11,27 +11,22 @@ package com.sleepycat.db.util;
import java.io.File;
import java.io.FileNotFoundException;
-import junit.framework.TestCase;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
-public class DualTestCase extends TestCase {
+public class DualTestCase extends TestBase {
- private Environment env;
private boolean setUpInvoked = false;
public DualTestCase() {
super();
}
- protected DualTestCase(String name) {
- super(name);
- }
-
@Override
- protected void setUp()
+ public void setUp()
throws Exception {
setUpInvoked = true;
@@ -39,20 +34,20 @@ public class DualTestCase extends TestCase {
}
@Override
- protected void tearDown()
+ public void tearDown()
throws Exception {
if (!setUpInvoked) {
throw new IllegalStateException
("tearDown was invoked without a corresponding setUp() call");
}
- destroy();
super.tearDown();
}
protected Environment create(File envHome, EnvironmentConfig envConfig)
throws DatabaseException {
+ Environment env = null;
try {
env = new Environment(envHome, envConfig);
} catch (FileNotFoundException e) {
@@ -61,25 +56,10 @@ public class DualTestCase extends TestCase {
return env;
}
- protected void close(Environment environment)
+ protected void close(Environment env)
throws DatabaseException {
env.close();
- env = null;
- }
-
- protected void destroy()
- throws Exception {
-
- if (env != null) {
- try {
- /* Close in case we hit an exception and didn't close */
- env.close();
- } catch (RuntimeException e) {
- /* OK if already closed */
- }
- env = null;
- }
}
public static boolean isReplicatedTest(Class<?> testCaseClass) {
diff --git a/test/java/compat/src/com/sleepycat/persist/test/BindingTest.java b/test/java/compat/src/com/sleepycat/persist/test/BindingTest.java
index 88ac6683..17e87ba5 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/BindingTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/BindingTest.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.
*
*/
@@ -10,6 +10,12 @@ package com.sleepycat.persist.test;
import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
import static com.sleepycat.persist.model.Relationship.ONE_TO_MANY;
import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
+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;
@@ -36,6 +42,10 @@ import java.util.TreeSet;
import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import com.sleepycat.bind.EntryBinding;
import com.sleepycat.compat.DbCompat;
import com.sleepycat.db.DatabaseConfig;
@@ -68,12 +78,13 @@ import com.sleepycat.persist.raw.RawField;
import com.sleepycat.persist.raw.RawObject;
import com.sleepycat.persist.raw.RawType;
import com.sleepycat.util.test.SharedTestUtils;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
* @author Mark Hayes
*/
-public class BindingTest extends TestCase {
+public class BindingTest extends TestBase {
private static final String STORE_PREFIX = "persist#foo#";
@@ -84,15 +95,18 @@ public class BindingTest extends TestCase {
private DatabaseEntry keyEntry;
private DatabaseEntry dataEntry;
- @Override
- public void setUp() {
- envHome = new File(System.getProperty(SharedTestUtils.DEST_DIR));
- SharedTestUtils.emptyDir(envHome);
+ @Before
+ public void setUp()
+ throws Exception {
+
+ envHome = SharedTestUtils.getTestDir();
+ super.setUp();
+
keyEntry = new DatabaseEntry();
dataEntry = new DatabaseEntry();
}
- @Override
+ @After
public void tearDown() {
if (env != null) {
try {
@@ -153,6 +167,7 @@ public class BindingTest extends TestCase {
env = null;
}
+ @Test
public void testBasic()
throws FileNotFoundException, DatabaseException {
@@ -216,6 +231,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testSimpleTypes()
throws FileNotFoundException, DatabaseException {
@@ -309,6 +325,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testArrayTypes()
throws FileNotFoundException, DatabaseException {
@@ -404,6 +421,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testEnumTypes()
throws FileNotFoundException, DatabaseException {
@@ -481,6 +499,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testEnumObjectTypes()
throws FileNotFoundException, DatabaseException {
@@ -520,6 +539,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testProxyTypes()
throws FileNotFoundException, DatabaseException {
@@ -664,6 +684,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testEmbedded()
throws FileNotFoundException, DatabaseException {
@@ -786,6 +807,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testSubclass()
throws FileNotFoundException, DatabaseException {
@@ -835,6 +857,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testSuperclass()
throws FileNotFoundException, DatabaseException {
@@ -890,6 +913,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testAbstract()
throws FileNotFoundException, DatabaseException {
@@ -1059,6 +1083,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testCompositeKey()
throws FileNotFoundException, DatabaseException {
@@ -1189,6 +1214,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testComparableKey()
throws FileNotFoundException, DatabaseException {
@@ -1316,6 +1342,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testSecKeys()
throws FileNotFoundException, DatabaseException {
@@ -1785,6 +1812,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testSecKeyRefToPriKey()
throws FileNotFoundException, DatabaseException {
@@ -1843,6 +1871,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testSecKeyInSuperclass()
throws FileNotFoundException, DatabaseException {
@@ -1908,6 +1937,7 @@ public class BindingTest extends TestCase {
}
}
+ @Test
public void testSecKeyInSubclass()
throws FileNotFoundException, DatabaseException {
diff --git a/test/java/compat/src/com/sleepycat/persist/test/Enhanced0.java b/test/java/compat/src/com/sleepycat/persist/test/Enhanced0.java
index 90ca6700..e42ca46b 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/Enhanced0.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/Enhanced0.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/persist/test/Enhanced1.java b/test/java/compat/src/com/sleepycat/persist/test/Enhanced1.java
index 638c82a1..062aa968 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/Enhanced1.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/Enhanced1.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/persist/test/Enhanced2.java b/test/java/compat/src/com/sleepycat/persist/test/Enhanced2.java
index b29a5501..8032a553 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/Enhanced2.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/Enhanced2.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/persist/test/Enhanced3.java b/test/java/compat/src/com/sleepycat/persist/test/Enhanced3.java
index 32a14b8b..9c413a51 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/Enhanced3.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/Enhanced3.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/persist/test/EvolveCase.java b/test/java/compat/src/com/sleepycat/persist/test/EvolveCase.java
index d8c13b4d..0f00265a 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/EvolveCase.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/EvolveCase.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.persist.test;
diff --git a/test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java b/test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java
index f4a5c93e..5b96d8a9 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.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.persist.test;
@@ -7965,4 +7965,96 @@ class EvolveClasses {
return new ProxiedClass(((IntegerClass)data[0]).data);
}
}
+
+ @Persistent(version=1)
+ static class MultipleSelfRefsEmbed {
+ MultipleSelfRefs ref;
+ MultipleSelfRefsEmbed embed;
+ /* ref2 is a new field. */
+ MultipleSelfRefs ref2;
+ }
+
+ /**
+ * Test multiple refs in an attempt to reproduce a bug where an assertion
+ * fired in Evolver.evolveInternal. This did not reproduce the bug,
+ * apparently because a very specific sequence of nested references is
+ * needed. But the test is included in case it is useful for other
+ * reasons. [#21869]
+ */
+ @Entity(version=1)
+ static class MultipleSelfRefs
+ extends EvolveCase {
+
+ private static final String NAME = PREFIX + "MultipleSelfRefs";
+
+ @PrimaryKey
+ int key;
+
+ MultipleSelfRefs ref;
+ MultipleSelfRefsEmbed embed;
+ /* ref2 is a new field. */
+ MultipleSelfRefs ref2;
+
+ @Override
+ void checkEvolvedModel(EntityModel model,
+ Environment env,
+ boolean oldTypesExist) {
+ checkEntity(true, model, env, NAME, 1, null);
+ if (oldTypesExist) {
+ checkVersions(model, NAME, 1, NAME, 0);
+ } else {
+ checkVersions(model, NAME, 1);
+ }
+ }
+
+ @Override
+ void readObjects(EntityStore store, boolean doUpdate)
+ throws DatabaseException {
+
+ PrimaryIndex<Integer, MultipleSelfRefs>
+ index = store.getPrimaryIndex
+ (Integer.class,
+ MultipleSelfRefs.class);
+ MultipleSelfRefs obj = index.get(99);
+ TestCase.assertNotNull(obj);
+ TestCase.assertEquals(99, obj.key);
+
+ if (doUpdate) {
+ index.put(obj);
+ }
+ }
+
+ @Override
+ void copyRawObjects(RawStore rawStore, EntityStore newStore)
+ throws DatabaseException {
+
+ PrimaryIndex<Integer, MultipleSelfRefs>
+ index = newStore.getPrimaryIndex
+ (Integer.class,
+ MultipleSelfRefs.class);
+ RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
+ index.put((MultipleSelfRefs)
+ newStore.getModel().convertRawObject(raw));
+ }
+
+ @Override
+ void readRawObjects(RawStore store,
+ boolean expectEvolved,
+ boolean expectUpdated)
+ throws DatabaseException {
+
+ RawObject obj;
+ if (expectEvolved) {
+ obj = readRaw(store, 99, NAME, 1, CASECLS, 0);
+ } else {
+ obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
+ }
+ if (expectEvolved && expectUpdated) {
+ checkRawFields(obj, "key", 99, "ref", ref, "embed", embed,
+ "ref2", ref2);
+ } else {
+ checkRawFields(obj, "key", 99, "ref", ref, "embed", embed);
+ }
+ }
+ }
}
diff --git a/test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java.original b/test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java.original
index 3fdba6aa..244ba60c 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java.original
+++ b/test/java/compat/src/com/sleepycat/persist/test/EvolveClasses.java.original
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2000, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2000, 2015 Oracle. All rights reserved.
*
*/
package com.sleepycat.persist.test;
@@ -3144,4 +3144,33 @@ class EvolveClasses {
return new ProxiedClass(data[0]);
}
}
+
+ /* [#21869] */
+ @Persistent
+ static class MultipleSelfRefsEmbed {
+ MultipleSelfRefs ref;
+ MultipleSelfRefsEmbed embed;
+ }
+
+ @Entity
+ static class MultipleSelfRefs
+ extends EvolveCase {
+
+ @PrimaryKey
+ int key;
+
+ MultipleSelfRefs ref;
+ MultipleSelfRefsEmbed embed;
+
+ @Override
+ void writeObjects(EntityStore store)
+ throws DatabaseException {
+
+ PrimaryIndex<Integer, MultipleSelfRefs>
+ index = store.getPrimaryIndex
+ (Integer.class, MultipleSelfRefs.class);
+ key = 99;
+ index.put(this);
+ }
+ }
}
diff --git a/test/java/compat/src/com/sleepycat/persist/test/EvolveTest.java b/test/java/compat/src/com/sleepycat/persist/test/EvolveTest.java
index d2a5f4a0..89b10e4c 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/EvolveTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/EvolveTest.java
@@ -1,14 +1,17 @@
/*-
* 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.persist.test;
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-import junit.framework.Test;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import com.sleepycat.persist.evolve.EvolveConfig;
import com.sleepycat.persist.evolve.EvolveEvent;
@@ -28,15 +31,14 @@ import com.sleepycat.util.test.SharedTestUtils;
*/
public class EvolveTest extends EvolveTestBase {
+ public EvolveTest(String originalClsName, String evolvedClsName)
+ throws Exception {
+ super(originalClsName, evolvedClsName);
+ }
+
/* Toggle to use listener every other test case. */
private static boolean useEvolveListener;
- public static Test suite()
- throws Exception {
-
- return getSuite(EvolveTest.class);
- }
-
private int evolveNRead;
private int evolveNConverted;
@@ -44,22 +46,25 @@ public class EvolveTest extends EvolveTestBase {
return true;
}
- @Override
- public void tearDown() {
- try { super.tearDown(); } catch (Throwable e) { }
- }
-
- @Override
+ @Before
public void setUp()
- throws IOException {
+ throws Exception {
+ super.setUp();
+
/* Copy the log files created by EvolveTestInit. */
envHome = getTestInitHome(true /*evolved*/);
envHome.mkdirs();
SharedTestUtils.emptyDir(envHome);
SharedTestUtils.copyFiles(getTestInitHome(false /*evolved*/), envHome);
}
+
+ @After
+ public void tearDown() {
+ try { super.tearDown(); } catch (Throwable e) { }
+ }
+ @Test
public void testLazyEvolve()
throws Exception {
@@ -151,6 +156,7 @@ public class EvolveTest extends EvolveTestBase {
closeAll();
}
+ @Test
public void testEagerEvolve()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/persist/test/EvolveTestBase.java b/test/java/compat/src/com/sleepycat/persist/test/EvolveTestBase.java
index 651f26b0..c1e2f77a 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/EvolveTestBase.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/EvolveTestBase.java
@@ -1,17 +1,22 @@
/*-
* 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.persist.test;
+import static org.junit.Assert.fail;
+
import java.io.File;
import java.io.FileNotFoundException;
-import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.List;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
@@ -22,6 +27,7 @@ import com.sleepycat.persist.evolve.IncompatibleClassException;
import com.sleepycat.persist.model.AnnotationModel;
import com.sleepycat.persist.model.EntityModel;
import com.sleepycat.persist.raw.RawStore;
+import com.sleepycat.util.test.TestBase;
import com.sleepycat.util.test.TestEnv;
/**
@@ -29,7 +35,8 @@ import com.sleepycat.util.test.TestEnv;
*
* @author Mark Hayes
*/
-public abstract class EvolveTestBase extends TestCase {
+@RunWith(Parameterized.class)
+public abstract class EvolveTestBase extends TestBase {
/*
* When adding a evolve test class, three places need to be changed:
@@ -242,6 +249,8 @@ public abstract class EvolveTestBase extends TestCase {
null,
"ProxyClassObjectArrayFieldChanged",
null,
+ "MultipleSelfRefs",
+ null,
//*/
};
@@ -255,40 +264,35 @@ public abstract class EvolveTestBase extends TestCase {
EvolveCase caseObj;
String caseLabel;
- static TestSuite getSuite(Class testClass)
- throws Exception {
-
- TestSuite suite = new TestSuite();
+ @Parameters
+ public static List<Object[]> genParams() {
+ return paramsHelper();
+ }
+
+ protected static List<Object[]> paramsHelper() {
+ List<Object[]> list = new ArrayList<Object[]>();
for (int i = 0; i < ALL.length; i += 2) {
- String originalClsName = ALL[i];
- String evolvedClsName = ALL[i + 1];
- if (evolvedClsName == null) {
- evolvedClsName = originalClsName;
- }
- TestSuite baseSuite = new TestSuite(testClass);
- Enumeration e = baseSuite.tests();
- while (e.hasMoreElements()) {
- EvolveTestBase test = (EvolveTestBase) e.nextElement();
- test.init(originalClsName, evolvedClsName);
- suite.addTest(test);
+ if (ALL[i+1] == null) {
+ list.add(new Object[]{ALL[i], ALL[i]});
+ } else {
+ list.add(new Object[]{ALL[i], ALL[i+1]});
}
}
- return suite;
- }
-
- private void init(String originalClsName,
- String evolvedClsName)
- throws Exception {
-
- String caseClsName = useEvolvedClass() ?
- evolvedClsName : originalClsName;
- caseClsName = "com.sleepycat.persist.test.EvolveClasses$" +
- caseClsName;
+
+ return list;
+ }
+
+ public EvolveTestBase(String originalClsName, String evolvedClsName)
+ throws Exception{
+ String caseClsName = useEvolvedClass() ? evolvedClsName
+ : originalClsName;
+ caseClsName = "com.sleepycat.persist.test.EvolveClasses$" + caseClsName;
this.caseClsName = caseClsName;
this.caseCls = Class.forName(caseClsName);
this.caseObj = (EvolveCase) caseCls.newInstance();
this.caseLabel = evolvedClsName;
+ customName = "-" + caseLabel;
}
abstract boolean useEvolvedClass();
@@ -299,12 +303,9 @@ public abstract class EvolveTestBase extends TestCase {
(evolved ? "evolved" : "original") + '/' + caseLabel);
}
- @Override
+ @After
public void tearDown() {
- /* Set test name for reporting; cannot be done in the ctor or setUp. */
- setName(caseLabel + '-' + getName());
-
if (env != null) {
try {
closeAll();
diff --git a/test/java/compat/src/com/sleepycat/persist/test/EvolveTestInit.java b/test/java/compat/src/com/sleepycat/persist/test/EvolveTestInit.java
index 80b44a52..33f35d86 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/EvolveTestInit.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/EvolveTestInit.java
@@ -1,12 +1,15 @@
/*-
* 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.persist.test;
-import junit.framework.Test;
+import static org.junit.Assert.fail;
+
+import org.junit.Before;
+import org.junit.Test;
import com.sleepycat.util.test.SharedTestUtils;
@@ -20,10 +23,9 @@ import com.sleepycat.util.test.SharedTestUtils;
*/
public class EvolveTestInit extends EvolveTestBase {
- public static Test suite()
- throws Exception {
-
- return getSuite(EvolveTestInit.class);
+ public EvolveTestInit(String originalClsName, String evolvedClsName)
+ throws Exception {
+ super(originalClsName, evolvedClsName);
}
@Override
@@ -31,13 +33,15 @@ public class EvolveTestInit extends EvolveTestBase {
return false;
}
- @Override
+ @Before
public void setUp() {
+
envHome = getTestInitHome(false /*evolved*/);
envHome.mkdirs();
SharedTestUtils.emptyDir(envHome);
}
+ @Test
public void testInit()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/persist/test/ForeignKeyTest.java b/test/java/compat/src/com/sleepycat/persist/test/ForeignKeyTest.java
index 1ef8ac3f..5e68cd08 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/ForeignKeyTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/ForeignKeyTest.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.
*
*/
@@ -11,11 +11,19 @@ import static com.sleepycat.persist.model.DeleteAction.ABORT;
import static com.sleepycat.persist.model.DeleteAction.CASCADE;
import static com.sleepycat.persist.model.DeleteAction.NULLIFY;
import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
+import static org.junit.Assert.assertEquals;
+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.Enumeration;
+import java.util.ArrayList;
+import java.util.List;
-import junit.framework.Test;
-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.compat.DbCompat;
import com.sleepycat.db.DatabaseException;
@@ -34,39 +42,53 @@ import com.sleepycat.util.test.TxnTestCase;
/**
* @author Mark Hayes
*/
+@RunWith(Parameterized.class)
public class ForeignKeyTest extends TxnTestCase {
- private static final DeleteAction[] ACTIONS = {
+ protected static final DeleteAction[] ACTIONS = {
ABORT,
NULLIFY,
CASCADE,
};
- private static final String[] ACTION_LABELS = {
+ protected static final String[] ACTION_LABELS = {
"ABORT",
"NULLIFY",
"CASCADE",
};
- public static Test suite() {
- testClass = ForeignKeyTest.class;
- TestSuite suite = new TestSuite();
- for (int i = 0; i < ACTIONS.length; i += 1) {
- for (int j = 0; j < 2; j++) {
- TestSuite txnSuite = txnTestSuite(null, null);
- Enumeration e = txnSuite.tests();
- while (e.hasMoreElements()) {
- ForeignKeyTest test = (ForeignKeyTest) e.nextElement();
- test.onDelete = ACTIONS[i];
- test.onDeleteLabel = ACTION_LABELS[i];
- test.useSubclass = (j == 0);
- test.useSubclassLabel =
- (j == 0) ? "UseSubclass" : "UseBaseclass";
- suite.addTest(test);
- }
+ @Parameters
+ public static List<Object[]> genParams() {
+ return paramsHelper(false);
+ }
+
+ protected static List<Object[]> paramsHelper(boolean rep) {
+ final String[] txnTypes = getTxnTypes(null, rep);
+ final List<Object[]> newParams = new ArrayList<Object[]>();
+ int i = 0;
+ for (final DeleteAction action : ACTIONS) {
+ for (final String type : txnTypes) {
+ newParams.add(new Object[]
+ {type, action, ACTION_LABELS[i], "UseSubclass"});
+ newParams.add(new Object[]
+ {type, action, ACTION_LABELS[i], "UseBaseclass"});
}
+ i++;
}
- return suite;
+ return newParams;
+ }
+
+ public ForeignKeyTest(String type,
+ DeleteAction action,
+ String label,
+ String useClassLabel){
+ initEnvConfig();
+ txnType = type;
+ isTransactional = (txnType != TXN_NULL);
+ onDelete = action;
+ onDeleteLabel = label;
+ useSubclassLabel = useClassLabel;
+ customName = txnType + '-' + onDeleteLabel + "-" + useSubclassLabel;
}
private EntityStore store;
@@ -74,18 +96,10 @@ public class ForeignKeyTest extends TxnTestCase {
private PrimaryIndex<String, Entity2> pri2;
private SecondaryIndex<String, String, Entity1> sec1;
private SecondaryIndex<String, String, Entity2> sec2;
- private DeleteAction onDelete;
- private String onDeleteLabel;
+ private final DeleteAction onDelete;
+ private final String onDeleteLabel;
private boolean useSubclass;
- private String useSubclassLabel;
-
- @Override
- public void tearDown()
- throws Exception {
-
- super.tearDown();
- setName(getName() + '-' + onDeleteLabel + "-" + useSubclassLabel);
- }
+ private final String useSubclassLabel;
private void open()
throws DatabaseException {
@@ -109,6 +123,7 @@ public class ForeignKeyTest extends TxnTestCase {
store.close();
}
+ @Test
public void testForeignKeys()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/persist/test/IndexTest.java b/test/java/compat/src/com/sleepycat/persist/test/IndexTest.java
index a1063f57..ebe86ca7 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/IndexTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/IndexTest.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.
*
*/
@@ -11,6 +11,10 @@ import static com.sleepycat.persist.model.Relationship.MANY_TO_MANY;
import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
import static com.sleepycat.persist.model.Relationship.ONE_TO_MANY;
import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collection;
@@ -23,7 +27,11 @@ import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
-import junit.framework.Test;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.collections.MapEntryParameter;
import com.sleepycat.db.DatabaseException;
@@ -47,14 +55,22 @@ import com.sleepycat.util.test.TxnTestCase;
*
* @author Mark Hayes
*/
+@RunWith(Parameterized.class)
public class IndexTest extends TxnTestCase {
private static final int N_RECORDS = 5;
private static final int THREE_TO_ONE = 3;
- public static Test suite() {
- testClass = IndexTest.class;
- return txnTestSuite(null, null);
+ @Parameters
+ public static List<Object[]> genParams() {
+ return getTxnParams(null, false);
+ }
+
+ public IndexTest(String type){
+ initEnvConfig();
+ txnType = type;
+ isTransactional = (txnType != TXN_NULL);
+ customName = txnType;
}
private EntityStore store;
@@ -129,17 +145,10 @@ public class IndexTest extends TxnTestCase {
rawStore = null;
}
- @Override
- public void setUp()
- throws Exception {
-
- super.setUp();
- }
-
/**
* The store must be closed before closing the environment.
*/
- @Override
+ @After
public void tearDown()
throws Exception {
@@ -165,6 +174,7 @@ public class IndexTest extends TxnTestCase {
/**
* Primary keys: {0, 1, 2, 3, 4}
*/
+ @Test
public void testPrimary()
throws DatabaseException {
@@ -228,6 +238,7 @@ public class IndexTest extends TxnTestCase {
/**
* { 0:0, 1:-1, 2:-2, 3:-3, 4:-4 }
*/
+ @Test
public void testOneToOne()
throws DatabaseException {
@@ -251,6 +262,7 @@ public class IndexTest extends TxnTestCase {
/**
* { 0:0, 1:1, 2:2, 3:0, 4:1 }
*/
+ @Test
public void testManyToOne()
throws DatabaseException {
@@ -277,6 +289,7 @@ public class IndexTest extends TxnTestCase {
/**
* { 0:{}, 1:{10}, 2:{20,21}, 3:{30,31,32}, 4:{40,41,42,43}
*/
+ @Test
public void testOneToMany()
throws DatabaseException {
@@ -305,6 +318,7 @@ public class IndexTest extends TxnTestCase {
/**
* { 0:{}, 1:{0}, 2:{0,1}, 3:{0,1,2}, 4:{0,1,2,3}
*/
+ @Test
public void testManyToMany()
throws DatabaseException {
@@ -836,10 +850,10 @@ public class IndexTest extends TxnTestCase {
private int manyToOne;
@SecondaryKey(relate=ONE_TO_MANY)
- private Set<Integer> oneToMany = new TreeSet<Integer>();
+ private final Set<Integer> oneToMany = new TreeSet<Integer>();
@SecondaryKey(relate=MANY_TO_MANY)
- private Set<Integer> manyToMany = new TreeSet<Integer>();
+ private final Set<Integer> manyToMany = new TreeSet<Integer>();
private MyEntity() {}
diff --git a/test/java/compat/src/com/sleepycat/persist/test/JoinTest.java b/test/java/compat/src/com/sleepycat/persist/test/JoinTest.java
index 6ffb6c5a..774c72fa 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/JoinTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/JoinTest.java
@@ -1,18 +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.persist.test;
import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Transaction;
@@ -30,13 +35,21 @@ import com.sleepycat.util.test.TxnTestCase;
/**
* @author Mark Hayes
*/
+@RunWith(Parameterized.class)
public class JoinTest extends TxnTestCase {
private static final int N_RECORDS = 5;
- public static Test suite() {
- testClass = JoinTest.class;
- return txnTestSuite(null, null);
+ @Parameters
+ public static List<Object[]> genParams() {
+ return getTxnParams(null, false);
+ }
+
+ public JoinTest(String type){
+ initEnvConfig();
+ txnType = type;
+ isTransactional = (txnType != TXN_NULL);
+ customName = txnType;
}
private EntityStore store;
@@ -72,6 +85,7 @@ public class JoinTest extends TxnTestCase {
store.close();
}
+ @Test
public void testJoin()
throws DatabaseException {
diff --git a/test/java/compat/src/com/sleepycat/persist/test/NegativeTest.java b/test/java/compat/src/com/sleepycat/persist/test/NegativeTest.java
index 8810eded..aba7e7c9 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/NegativeTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/NegativeTest.java
@@ -1,21 +1,30 @@
/*-
* 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.persist.test;
+import static com.sleepycat.persist.model.DeleteAction.NULLIFY;
import static com.sleepycat.persist.model.Relationship.ONE_TO_MANY;
import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
-import static com.sleepycat.persist.model.DeleteAction.NULLIFY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Locale;
-import junit.framework.Test;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.db.DatabaseConfig;
import com.sleepycat.db.DatabaseException;
@@ -39,11 +48,19 @@ import com.sleepycat.util.test.TxnTestCase;
*
* @author Mark Hayes
*/
+@RunWith(Parameterized.class)
public class NegativeTest extends TxnTestCase {
- public static Test suite() {
- testClass = NegativeTest.class;
- return txnTestSuite(null, null);
+ @Parameters
+ public static List<Object[]> genParams() {
+ return getTxnParams(null, false);
+ }
+
+ public NegativeTest(String type){
+ initEnvConfig();
+ txnType = type;
+ isTransactional = (txnType != TXN_NULL);
+ customName = txnType;
}
private EntityStore store;
@@ -77,14 +94,7 @@ public class NegativeTest extends TxnTestCase {
store = null;
}
- @Override
- public void setUp()
- throws Exception {
-
- super.setUp();
- }
-
- @Override
+ @After
public void tearDown()
throws Exception {
@@ -99,6 +109,7 @@ public class NegativeTest extends TxnTestCase {
super.tearDown();
}
+ @Test
public void testBadKeyClass1()
throws DatabaseException {
@@ -123,12 +134,13 @@ public class NegativeTest extends TxnTestCase {
static class UseBadKeyClass1 {
@PrimaryKey
- private BadKeyClass1 f1 = new BadKeyClass1();
+ private final BadKeyClass1 f1 = new BadKeyClass1();
@SecondaryKey(relate=ONE_TO_ONE)
- private BadKeyClass1 f2 = new BadKeyClass1();
+ private final BadKeyClass1 f2 = new BadKeyClass1();
}
+ @Test
public void testBadSequenceKeys()
throws DatabaseException {
@@ -202,6 +214,7 @@ public class NegativeTest extends TxnTestCase {
* A proxied object may not current contain a field that references the
* parent proxy. [#15815]
*/
+ @Test
public void testProxyNestedRef()
throws DatabaseException {
@@ -232,6 +245,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Disallow primary keys on entity subclasses. [#15757]
*/
+ @Test
public void testEntitySubclassWithPrimaryKey()
throws DatabaseException {
@@ -321,6 +335,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Disallow storing null entities. [#19085]
*/
+ @Test
public void testNullEntity()
throws DatabaseException {
@@ -343,6 +358,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Disallow embedded entity classes and subclasses. [#16077]
*/
+ @Test
public void testEmbeddedEntity()
throws DatabaseException {
@@ -448,6 +464,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Disallow SecondaryKey collection with no type parameter. [#15950]
*/
+ @Test
public void testTypelessKeyCollection()
throws DatabaseException {
@@ -472,7 +489,7 @@ public class NegativeTest extends TxnTestCase {
private int x;
@SecondaryKey(relate=ONE_TO_MANY)
- private Collection keys = new ArrayList();
+ private final Collection keys = new ArrayList();
TypelessKeyCollectionEntity(int x) {
this.x = x;
@@ -484,6 +501,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Disallow a persistent proxy that extends an entity. [#15950]
*/
+ @Test
public void testProxyEntity()
throws DatabaseException {
@@ -519,6 +537,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Wrapper type not allowed for nullified foreign key.
*/
+ @Test
public void testBadNullifyKey()
throws DatabaseException {
@@ -555,6 +574,7 @@ public class NegativeTest extends TxnTestCase {
/**
* @Persistent not allowed on an enum.
*/
+ @Test
public void testPersistentEnum()
throws DatabaseException {
@@ -584,6 +604,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Disallow a reference to an interface marked @Persistent.
*/
+ @Test
public void testPersistentInterface()
throws DatabaseException {
@@ -617,6 +638,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Disallow reference to @Persistent inner class.
*/
+ @Test
public void testPersistentInnerClass()
throws DatabaseException {
@@ -651,6 +673,7 @@ public class NegativeTest extends TxnTestCase {
/**
* Disallow @Entity inner class.
*/
+ @Test
public void testSetConfigAfterOpen()
throws DatabaseException {
diff --git a/test/java/compat/src/com/sleepycat/persist/test/OperationTest.java b/test/java/compat/src/com/sleepycat/persist/test/OperationTest.java
index 137bb6cb..014cdbbc 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/OperationTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/OperationTest.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.
*
*/
@@ -13,6 +13,12 @@ import static com.sleepycat.persist.model.Relationship.MANY_TO_MANY;
import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
import static com.sleepycat.persist.model.Relationship.ONE_TO_MANY;
import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
+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.EnumSet;
@@ -22,7 +28,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import junit.framework.Test;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import com.sleepycat.compat.DbCompat;
import com.sleepycat.db.Database;
@@ -52,13 +62,21 @@ import com.sleepycat.util.test.TxnTestCase;
*
* @author Mark Hayes
*/
+@RunWith(Parameterized.class)
public class OperationTest extends TxnTestCase {
private static final String STORE_NAME = "test";
- public static Test suite() {
- testClass = OperationTest.class;
- return txnTestSuite(null, null);
+ @Parameters
+ public static List<Object[]> genParams() {
+ return getTxnParams(null, false);
+ }
+
+ public OperationTest(String type){
+ initEnvConfig();
+ txnType = type;
+ isTransactional = (txnType != TXN_NULL);
+ customName = txnType;
}
private EntityStore store;
@@ -105,17 +123,10 @@ public class OperationTest extends TxnTestCase {
store = null;
}
- @Override
- public void setUp()
- throws Exception {
-
- super.setUp();
- }
-
/**
* The store must be closed before closing the environment.
*/
- @Override
+ @After
public void tearDown()
throws Exception {
@@ -130,6 +141,7 @@ public class OperationTest extends TxnTestCase {
super.tearDown();
}
+ @Test
public void testReadOnly()
throws DatabaseException {
@@ -157,6 +169,7 @@ public class OperationTest extends TxnTestCase {
+ @Test
public void testUninitializedCursor()
throws DatabaseException {
@@ -204,6 +217,7 @@ public class OperationTest extends TxnTestCase {
close();
}
+ @Test
public void testCursorCount()
throws DatabaseException {
@@ -238,6 +252,7 @@ public class OperationTest extends TxnTestCase {
close();
}
+ @Test
public void testCursorUpdate()
throws DatabaseException {
@@ -321,6 +336,7 @@ public class OperationTest extends TxnTestCase {
close();
}
+ @Test
public void testCursorDelete()
throws DatabaseException {
@@ -426,6 +442,7 @@ public class OperationTest extends TxnTestCase {
close();
}
+ @Test
public void testDeleteFromSubIndex()
throws DatabaseException {
@@ -503,6 +520,7 @@ public class OperationTest extends TxnTestCase {
private MyEntity() {}
}
+ @Test
public void testSharedSequence()
throws DatabaseException {
@@ -546,6 +564,7 @@ public class OperationTest extends TxnTestCase {
private Integer key;
}
+ @Test
public void testSeparateSequence()
throws DatabaseException {
@@ -591,6 +610,7 @@ public class OperationTest extends TxnTestCase {
private Integer key;
}
+ @Test
public void testCompositeSequence()
throws DatabaseException {
@@ -699,6 +719,7 @@ public class OperationTest extends TxnTestCase {
* NullPointerException in JE 3.0.12. No SR was created because the use
* case is very obscure and was discovered by code inspection.
*/
+ @Test
public void testOpenRawStoreReadOnly()
throws DatabaseException {
@@ -723,6 +744,7 @@ public class OperationTest extends TxnTestCase {
* referenced when getSecondaryIndex was called. This was a bug in JE
* 3.0.12, reported on OTN. [#15103]
*/
+ @Test
public void testToManyKeyClass()
throws DatabaseException {
@@ -744,6 +766,7 @@ public class OperationTest extends TxnTestCase {
* fail with "IllegalArgumentException: Wrong secondary key class: ..."
* when the store was opened read-only. [#15156]
*/
+ @Test
public void testToManyReadOnly()
throws DatabaseException {
@@ -790,6 +813,7 @@ public class OperationTest extends TxnTestCase {
* be opened automatically. If X is not opened, foreign key constraints
* will not be enforced. [#15358]
*/
+ @Test
public void testAutoOpenRelatedEntity()
throws DatabaseException {
@@ -854,12 +878,14 @@ public class OperationTest extends TxnTestCase {
}
}
+ @Test
public void testSecondaryBulkLoad1()
throws DatabaseException {
doSecondaryBulkLoad(true);
}
+ @Test
public void testSecondaryBulkLoad2()
throws DatabaseException {
@@ -945,6 +971,7 @@ public class OperationTest extends TxnTestCase {
close();
}
+ @Test
public void testPersistentFields()
throws DatabaseException {
@@ -1004,6 +1031,7 @@ public class OperationTest extends TxnTestCase {
* getSecondaryConfig. This was a bug in JE 3.3.69, reported on OTN.
* [#16407]
*/
+ @Test
public void testKeyClassInitialization()
throws DatabaseException {
@@ -1012,6 +1040,7 @@ public class OperationTest extends TxnTestCase {
close();
}
+ @Test
public void testKeyName()
throws DatabaseException {
@@ -1063,6 +1092,7 @@ public class OperationTest extends TxnTestCase {
* subclass instance, which contains a secondary key, without registering
* the subclass up front. [#16399]
*/
+ @Test
public void testPutEntitySubclassWithoutRegisterClass()
throws DatabaseException {
@@ -1092,6 +1122,7 @@ public class OperationTest extends TxnTestCase {
* Checks that registerClass avoids an exception when storing an entity
* subclass instance, which defines a secondary key. [#16399]
*/
+ @Test
public void testPutEntitySubclassWithRegisterClass()
throws DatabaseException {
@@ -1123,6 +1154,7 @@ public class OperationTest extends TxnTestCase {
* registerClass is sufficient and subsequent use of the store does not
* require it. [#16399]
*/
+ @Test
public void testPutEntitySubclassWithRegisterClass2()
throws DatabaseException {
@@ -1160,6 +1192,7 @@ public class OperationTest extends TxnTestCase {
* avoid an exception when storing an entity subclass instance, which
* defines a secondary key. [#16399]
*/
+ @Test
public void testPutEntitySubclassWithGetSubclassIndex()
throws DatabaseException {
@@ -1191,6 +1224,7 @@ public class OperationTest extends TxnTestCase {
* getSubclassIndex is sufficient and subsequent use of the store does not
* require it. [#16399]
*/
+ @Test
public void testPutEntitySubclassWithGetSubclassIndex2()
throws DatabaseException {
@@ -1260,6 +1294,7 @@ public class OperationTest extends TxnTestCase {
private ExtendedStatement() {}
}
+ @Test
public void testCustomCompare()
throws DatabaseException {
@@ -1329,7 +1364,7 @@ public class OperationTest extends TxnTestCase {
private ReverseIntKey secKey1;
@SecondaryKey(relate=ONE_TO_MANY)
- private Set<ReverseIntKey> secKey2 = new HashSet<ReverseIntKey>();
+ private final Set<ReverseIntKey> secKey2 = new HashSet<ReverseIntKey>();
private CustomCompareEntity() {}
@@ -1390,6 +1425,7 @@ public class OperationTest extends TxnTestCase {
* comparator. The comparator is initialized on its first use, just as if
* recovery were run.
*/
+ @Test
public void testStoredComparators()
throws DatabaseException {
@@ -1562,6 +1598,7 @@ public class OperationTest extends TxnTestCase {
}
}
+ @Test
public void testEmbeddedMapTypes()
throws DatabaseException {
open();
diff --git a/test/java/compat/src/com/sleepycat/persist/test/PersistTestUtils.java b/test/java/compat/src/com/sleepycat/persist/test/PersistTestUtils.java
index 76fd96cd..0b564a4f 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/PersistTestUtils.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/PersistTestUtils.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.persist.test;
diff --git a/test/java/compat/src/com/sleepycat/persist/test/SequenceTest.java b/test/java/compat/src/com/sleepycat/persist/test/SequenceTest.java
index b7c751ed..b6c3aacc 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/SequenceTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/SequenceTest.java
@@ -1,14 +1,20 @@
/*-
* 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.persist.test;
+import static org.junit.Assert.assertEquals;
+
import java.io.File;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
import com.sleepycat.db.util.DualTestCase;
@@ -30,26 +36,24 @@ public class SequenceTest extends DualTestCase {
private File envHome;
private Environment env;
- @Override
+ @Before
public void setUp()
throws Exception {
super.setUp();
-
- envHome = new File(System.getProperty(SharedTestUtils.DEST_DIR));
- SharedTestUtils.emptyDir(envHome);
+ envHome = SharedTestUtils.getTestDir();
}
- @Override
+ @After
public void tearDown()
throws Exception {
super.tearDown();
-
envHome = null;
env = null;
}
+ @Test
public void testSequenceKeys()
throws Exception {
diff --git a/test/java/compat/src/com/sleepycat/persist/test/SubclassIndexTest.java b/test/java/compat/src/com/sleepycat/persist/test/SubclassIndexTest.java
index b7715fb3..31c1e4bc 100644
--- a/test/java/compat/src/com/sleepycat/persist/test/SubclassIndexTest.java
+++ b/test/java/compat/src/com/sleepycat/persist/test/SubclassIndexTest.java
@@ -1,16 +1,25 @@
/*-
* 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.persist.test;
import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
+import static org.junit.Assert.assertEquals;
+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.io.File;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
@@ -36,22 +45,19 @@ public class SubclassIndexTest extends DualTestCase {
private Environment env;
private EntityStore store;
- @Override
+ @Before
public void setUp()
throws Exception {
+ envHome = SharedTestUtils.getTestDir();
super.setUp();
-
- envHome = new File(System.getProperty(SharedTestUtils.DEST_DIR));
- SharedTestUtils.emptyDir(envHome);
}
- @Override
+ @After
public void tearDown()
throws Exception {
super.tearDown();
-
envHome = null;
env = null;
}
@@ -83,6 +89,7 @@ public class SubclassIndexTest extends DualTestCase {
env = null;
}
+ @Test
public void testSubclassIndex()
throws DatabaseException {
@@ -161,6 +168,7 @@ public class SubclassIndexTest extends DualTestCase {
* created up front also. So this test is somewhat less useful, but still
* nice to have around. [#16399]
*/
+ @Test
public void testAddSecKey()
throws DatabaseException {
diff --git a/test/java/compat/src/com/sleepycat/util/test/ExceptionWrapperTest.java b/test/java/compat/src/com/sleepycat/util/test/ExceptionWrapperTest.java
index 233690d2..47763af5 100644
--- a/test/java/compat/src/com/sleepycat/util/test/ExceptionWrapperTest.java
+++ b/test/java/compat/src/com/sleepycat/util/test/ExceptionWrapperTest.java
@@ -1,19 +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.util.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
import com.sleepycat.util.ExceptionUnwrapper;
import com.sleepycat.util.IOExceptionWrapper;
@@ -22,35 +24,9 @@ import com.sleepycat.util.RuntimeExceptionWrapper;
/**
* @author Mark Hayes
*/
-public class ExceptionWrapperTest 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() {
- TestSuite suite = new TestSuite(ExceptionWrapperTest.class);
- return suite;
- }
-
- public ExceptionWrapperTest(String name) {
-
- super(name);
- }
-
- @Override
- public void setUp() {
-
- SharedTestUtils.printTestName("ExceptionWrapperTest." + getName());
- }
+public class ExceptionWrapperTest extends TestBase {
+ @Test
public void testIOWrapper() {
try {
throw new IOExceptionWrapper(new RuntimeException("msg"));
@@ -65,6 +41,7 @@ public class ExceptionWrapperTest extends TestCase {
}
}
+ @Test
public void testRuntimeWrapper() {
try {
throw new RuntimeExceptionWrapper(new IOException("msg"));
@@ -79,6 +56,7 @@ public class ExceptionWrapperTest extends TestCase {
}
}
+ @Test
public void testErrorWrapper() {
try {
throw new RuntimeExceptionWrapper(new Error("msg"));
@@ -101,6 +79,7 @@ public class ExceptionWrapperTest extends TestCase {
* Generates a stack trace for a nested exception and checks the output
* for the nested exception.
*/
+ @Test
public void testStackTrace() {
/* Nested stack traces are not avilable in Java 1.3. */
diff --git a/test/java/compat/src/com/sleepycat/util/test/FastOutputStreamTest.java b/test/java/compat/src/com/sleepycat/util/test/FastOutputStreamTest.java
index 3d103e9f..c20e896e 100644
--- a/test/java/compat/src/com/sleepycat/util/test/FastOutputStreamTest.java
+++ b/test/java/compat/src/com/sleepycat/util/test/FastOutputStreamTest.java
@@ -1,50 +1,24 @@
/*-
* 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.util.test;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
import com.sleepycat.util.FastOutputStream;
/**
* @author Mark Hayes
*/
-public class FastOutputStreamTest 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() {
- TestSuite suite = new TestSuite(FastOutputStreamTest.class);
- return suite;
- }
-
- public FastOutputStreamTest(String name) {
-
- super(name);
- }
-
- @Override
- public void setUp() {
-
- SharedTestUtils.printTestName("FastOutputStreamTest." + getName());
- }
+public class FastOutputStreamTest extends TestBase {
+ @Test
public void testBufferSizing() {
FastOutputStream fos = new FastOutputStream();
assertEquals
diff --git a/test/java/compat/src/com/sleepycat/util/test/PackedIntegerTest.java b/test/java/compat/src/com/sleepycat/util/test/PackedIntegerTest.java
index 33ab22f4..8baa607e 100644
--- a/test/java/compat/src/com/sleepycat/util/test/PackedIntegerTest.java
+++ b/test/java/compat/src/com/sleepycat/util/test/PackedIntegerTest.java
@@ -1,18 +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.util.test;
-import junit.framework.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
import com.sleepycat.util.PackedInteger;
-public class PackedIntegerTest extends TestCase {
+public class PackedIntegerTest extends TestBase {
static final long V119 = 119L;
static final long MAX_1 = 0xFFL;
static final long MAX_2 = 0xFFFFL;
@@ -22,28 +23,7 @@ public class PackedIntegerTest extends TestCase {
static final long MAX_6 = 0xFFFFFFFFFFFFL;
static final long MAX_7 = 0xFFFFFFFFFFFFFFL;
- 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 PackedIntegerTest();
- }
-
- public PackedIntegerTest() {
-
- super("PackedIntegerTest");
- }
-
- @Override
+ @Test
public void runTest() {
/* Packed int tests. */
diff --git a/test/java/compat/src/com/sleepycat/util/test/SharedTestUtils.java b/test/java/compat/src/com/sleepycat/util/test/SharedTestUtils.java
index 38f1aa68..d992d3f6 100644
--- a/test/java/compat/src/com/sleepycat/util/test/SharedTestUtils.java
+++ b/test/java/compat/src/com/sleepycat/util/test/SharedTestUtils.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.
*
*/
@@ -15,6 +15,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.channels.FileChannel;
import junit.framework.TestCase;
@@ -28,22 +29,66 @@ public class SharedTestUtils {
/* Common system properties for running tests */
public static String DEST_DIR = "testdestdir";
+ public static String TEST_ENV_DIR = "testenvdirroot";
+ public static String FAILURE_DIR = "failurecopydir";
+ public static String DEFAULT_DEST_DIR = "build/test/classes";
+ public static String DEFAULT_TEST_DIR_ROOT = "build/test/envdata";
+ public static String DEFAULT_FAIL_DIR = "build/test/failures";
public static String NO_SYNC = "txnnosync";
public static String LONG_TEST = "longtest";
+ public static String COPY_LIMIT = "copylimit";
public static final DatabaseConfig DBCONFIG_CREATE = new DatabaseConfig();
static {
DBCONFIG_CREATE.setAllowCreate(true);
}
+
+ /**
+ * The environment store compiled class files and generated environment by
+ * test that is distinctive with test environment.
+ */
+ public static File getDestDir() {
+ String dir = System.getProperty(DEST_DIR, DEFAULT_DEST_DIR);
+ File file = new File(dir);
+ if (!file.isDirectory())
+ file.mkdir();
+
+ return file;
+ }
- private static File getTestDir() {
- String dir = System.getProperty(DEST_DIR);
- if (dir == null || dir.length() == 0) {
- throw new IllegalArgumentException
- ("System property must be set to test data directory: " +
- DEST_DIR);
- }
- return new File(dir);
+ /**
+ * If not define system property "testenvdirroot", use build/test/envdata
+ * as test environment root directory.
+ */
+ public static File getTestDir() {
+ String dir = System.getProperty(TEST_ENV_DIR, DEFAULT_TEST_DIR_ROOT);
+ File file = new File(dir);
+ if (!file.isDirectory())
+ file.mkdir();
+
+ return file;
+ }
+
+ /**
+ * Allow to set up self defined directory store failure copy.
+ */
+ public static File getFailureCopyDir() {
+ String dir = System.getProperty(FAILURE_DIR, DEFAULT_FAIL_DIR);
+ File file = new File(dir);
+ if (!file.isDirectory())
+ file.mkdir();
+
+ return file;
+ }
+
+ /**
+ * If test failed, copy its environment to other location. The default
+ * limit is 10, but our test support the value via system property.
+ */
+ public static int getCopyLimit() {
+ String limit = System.getProperty(COPY_LIMIT, "10");
+
+ return Integer.parseInt(limit);
}
/**
@@ -91,13 +136,16 @@ public class SharedTestUtils {
dir.mkdirs();
}
}
-
+
+ /**
+ * @return A sub-directory of current test destination directory.
+ */
public static File getNewDir(String name) {
File dir = new File(getTestDir(), name);
emptyDir(dir);
return dir;
}
-
+
public static File getNewFile() {
return getNewFile("test-file");
}
@@ -174,4 +222,95 @@ public class SharedTestUtils {
}
}
}
+
+ /**
+ * Copy everything in test destination directory to another place for
+ * future evaluation when test failed.
+ */
+ public static void copyDir(File fromDir, File toDir)
+ throws Exception {
+
+ if (fromDir == null || toDir == null)
+ throw new NullPointerException("File location error");
+
+ if (!fromDir.isDirectory())
+ throw new IllegalStateException
+ (fromDir + " should be a directory");
+
+ if (!toDir.exists() && !toDir.mkdirs())
+ throw new IllegalStateException("Unable to create copy dest dir:" +
+ toDir);
+
+ String[] list = fromDir.list();
+ if (list != null) {
+
+ for (String fileName : list) {
+ File file = new File(fromDir, fileName);
+ if (file.isDirectory())
+ copyDir(file, new File(toDir, fileName));
+ else
+ copyFile(file, new File(toDir, fileName));
+ }
+ }
+ }
+
+ /**
+ * Copy file to specified location.
+ */
+ private static void copyFile(File from, File to)
+ throws Exception {
+
+ if (to.isDirectory())
+ to = new File(to, from.getName());
+
+ FileInputStream fis = null;
+ FileOutputStream fos = null;
+ FileChannel fcin = null;
+ FileChannel fcout = null;
+
+ try {
+ fis = new FileInputStream(from);
+ fos = new FileOutputStream(to);
+ fcin = fis.getChannel();
+ fcout = fos.getChannel();
+ fcin.transferTo(0, fcin.size(), fcout);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ if (fos != null) {
+ fos.close();
+ }
+ }
+ }
+
+ /**
+ * Clean up everything in JE test destination directory including all kind
+ * files and sub directories generated by last test except je.properties.
+ */
+ public static void cleanUpTestDir(File dir) {
+ if (!dir.isDirectory() || !dir.exists())
+ throw new IllegalStateException(
+ "Not an existing directory: " + dir);
+ File[] files = dir.listFiles();
+ if (files == null)
+ return;
+
+ for (File file : files) {
+ if ("je.properties".equals(file.getName()))
+ continue;
+
+ if (file.isDirectory()) {
+ cleanUpTestDir(file);
+
+ if (file.list().length == 0 && !file.delete())
+ throw new IllegalStateException(
+ "Unable to delete" + file);
+ } else {
+ if(!file.delete())
+ throw new IllegalStateException(
+ "Unable to delete " + file);
+ }
+ }
+ }
}
diff --git a/test/java/compat/src/com/sleepycat/util/test/TestBase.java b/test/java/compat/src/com/sleepycat/util/test/TestBase.java
new file mode 100644
index 00000000..d7d0f46e
--- /dev/null
+++ b/test/java/compat/src/com/sleepycat/util/test/TestBase.java
@@ -0,0 +1,96 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2002, 2015 Oracle and/or its affiliates. All rights reserved.
+ *
+ */
+
+package com.sleepycat.util.test;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+/**
+ * The base class for all JE unit tests.
+ */
+public abstract class TestBase {
+
+ /*
+ * Need to provide a customized name suffix for those tests which are
+ * Parameterized.
+ *
+ * This is because we need to provide a unique directory name for those
+ * failed tests. Parameterized class would reuse test cases, so class name
+ * plus the test method is not unique. User should set the customName
+ * in the constructor of a Parameterized test.
+ */
+ protected String customName;
+
+ /**
+ * The rule we use to control every test case, the core of this rule is
+ * copy the testing environment, files, sub directories to another place
+ * for future investigation, if any of test failed. But we do have a limit
+ * to control how many times we copy because of disk space. So once the
+ * failure counter exceed limit, it won't copy the environment any more.
+ */
+ @Rule
+ public TestRule watchman = new TestWatcher() {
+
+ /* Copy Environments when the test failed. */
+ @Override
+ protected void failed(Throwable t, Description desc) {
+ String dirName = makeFileName(desc);
+ try {
+ copyEnvironments(dirName);
+ } catch (Exception e) {
+ throw new RuntimeException
+ ("can't copy env dir to " + dirName + " after failure", e);
+ }
+ }
+
+ @Override
+ protected void succeeded(Description desc){
+ }
+ };
+
+ @Before
+ public void setUp()
+ throws Exception {
+
+ SharedTestUtils.cleanUpTestDir(SharedTestUtils.getTestDir());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Provision for future use
+ }
+
+ /**
+ * Copy the testing directory to other place.
+ */
+ private void copyEnvironments(String path) throws Exception{
+
+ File failureDir = SharedTestUtils.getFailureCopyDir();
+ if (failureDir.list().length < SharedTestUtils.getCopyLimit()) {
+ SharedTestUtils.copyDir(SharedTestUtils.getTestDir(),
+ new File(failureDir, path));
+ }
+ }
+
+ /**
+ * Get failure copy directory name.
+ */
+ private String makeFileName(Description desc) {
+ String name = desc.getClassName() + "-" + desc.getMethodName();
+ if (customName != null) {
+ name = name + "-" + customName;
+ }
+ return name;
+ }
+}
diff --git a/test/java/compat/src/com/sleepycat/util/test/TestEnv.java b/test/java/compat/src/com/sleepycat/util/test/TestEnv.java
index 9bbdc576..80bf691d 100644
--- a/test/java/compat/src/com/sleepycat/util/test/TestEnv.java
+++ b/test/java/compat/src/com/sleepycat/util/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.
*
*/
diff --git a/test/java/compat/src/com/sleepycat/util/test/TxnTestCase.java b/test/java/compat/src/com/sleepycat/util/test/TxnTestCase.java
index 69aef341..0fada37f 100644
--- a/test/java/compat/src/com/sleepycat/util/test/TxnTestCase.java
+++ b/test/java/compat/src/com/sleepycat/util/test/TxnTestCase.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.
*
*/
@@ -10,10 +10,10 @@ package com.sleepycat.util.test;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Enumeration;
+import java.util.List;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Before;
import com.sleepycat.compat.DbCompat;
import com.sleepycat.db.CursorConfig;
@@ -45,7 +45,6 @@ public abstract class TxnTestCase extends DualTestCase {
public static final String TXN_AUTO = "txn-auto";
public static final String TXN_USER = "txn-user";
public static final String TXN_CDB = "txn-cdb";
- protected static Class<? extends TestCase> testClass;
protected File envHome;
protected Environment env;
@@ -53,13 +52,17 @@ public abstract class TxnTestCase extends DualTestCase {
protected String txnType;
protected boolean isTransactional;
- /**
- * Returns a txn test suite. If txnTypes is null, all three types are run.
- */
- public static TestSuite txnTestSuite(EnvironmentConfig envConfig,
- String[] txnTypes) {
+ public static List<Object[]> getTxnParams(String[] txnTypes, boolean rep) {
+ final List<Object[]> list = new ArrayList<Object[]>();
+ for (final String type : getTxnTypes(txnTypes, rep)) {
+ list.add(new Object[] {type});
+ }
+ return list;
+ }
+
+ public static String[] getTxnTypes(String[] txnTypes, boolean rep) {
if (txnTypes == null) {
- if (isReplicatedTest(testClass)) {
+ if (rep) {
txnTypes = new String[] { // Skip non-transactional tests
TxnTestCase.TXN_USER,
TxnTestCase.TXN_AUTO };
@@ -76,68 +79,43 @@ public abstract class TxnTestCase extends DualTestCase {
} else {
if (!DbCompat.CDB) {
/* Remove TxnTestCase.TXN_CDB, if there is any. */
- ArrayList<String> tmp = new ArrayList<String>
- (Arrays.asList(txnTypes));
+ final ArrayList<String> tmp =
+ new ArrayList<String>(Arrays.asList(txnTypes));
tmp.remove(TxnTestCase.TXN_CDB);
txnTypes = new String[tmp.size()];
tmp.toArray(txnTypes);
}
}
- if (envConfig == null) {
- envConfig = new EnvironmentConfig();
- envConfig.setAllowCreate(true);
- }
- TestSuite suite = new TestSuite();
- for (int i = 0; i < txnTypes.length; i += 1) {
- TestSuite baseSuite = new TestSuite(testClass);
- Enumeration e = baseSuite.tests();
- while (e.hasMoreElements()) {
- TxnTestCase test = (TxnTestCase) e.nextElement();
- test.txnInit(envConfig, txnTypes[i]);
- suite.addTest(test);
- }
- }
- return suite;
+ return txnTypes;
}
- private void txnInit(EnvironmentConfig envConfig, String txnType) {
-
- this.envConfig = envConfig;
- this.txnType = txnType;
- isTransactional = (txnType != TXN_NULL);
- }
-
- @Override
+ @Before
public void setUp()
throws Exception {
super.setUp();
envHome = SharedTestUtils.getNewDir();
- }
-
- @Override
- public void runTest()
- throws Throwable {
-
openEnv();
- super.runTest();
- closeEnv();
}
- @Override
+ @After
public void tearDown()
throws Exception {
- /* Set test name for reporting; cannot be done in the ctor or setUp. */
- setName(txnType + ':' + getName());
-
super.tearDown();
+ closeEnv();
env = null;
-
- try {
- SharedTestUtils.emptyDir(envHome);
- } catch (Throwable e) {
- System.out.println("tearDown: " + e);
+ }
+
+ protected void initEnvConfig() {
+ if (envConfig == null) {
+ envConfig = new EnvironmentConfig();
+ envConfig.setAllowCreate(true);
+
+ /* Always use write-no-sync (by default) to speed up tests. */
+ if (!envConfig.getTxnNoSync() && !envConfig.getTxnWriteNoSync()) {
+ envConfig.setTxnWriteNoSync(true);
+ }
}
}
@@ -196,9 +174,8 @@ public abstract class TxnTestCase extends DualTestCase {
if (txnType == TXN_USER) {
return env.beginTransaction(parentTxn, config);
- } else {
- return null;
}
+ return null;
}
/**
diff --git a/test/java/compat/src/com/sleepycat/util/test/UtfTest.java b/test/java/compat/src/com/sleepycat/util/test/UtfTest.java
index 8d1c4aa2..fec9137e 100644
--- a/test/java/compat/src/com/sleepycat/util/test/UtfTest.java
+++ b/test/java/compat/src/com/sleepycat/util/test/UtfTest.java
@@ -1,18 +1,18 @@
/*-
* 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.util.test;
+import static org.junit.Assert.fail;
+
import java.io.DataOutputStream;
import java.util.Arrays;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
import com.sleepycat.util.FastOutputStream;
import com.sleepycat.util.UtfOps;
@@ -20,40 +20,14 @@ import com.sleepycat.util.UtfOps;
/**
* @author Mark Hayes
*/
-public class UtfTest 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() {
- TestSuite suite = new TestSuite(UtfTest.class);
- return suite;
- }
-
- public UtfTest(String name) {
-
- super(name);
- }
-
- @Override
- public void setUp() {
-
- SharedTestUtils.printTestName("UtfTest." + getName());
- }
+public class UtfTest extends TestBase {
/**
* Compares the UtfOps implementation to the java.util.DataOutputStream
* (and by implication DataInputStream) implementation, character for
* character in the full Unicode set.
*/
+ @Test
public void testMultibyte()
throws Exception {
diff --git a/test/java/junit/makenewtest.sh b/test/java/junit/makenewtest.sh
index 0ff04e68..60e36004 100644
--- a/test/java/junit/makenewtest.sh
+++ b/test/java/junit/makenewtest.sh
@@ -42,7 +42,7 @@ namelower=`echo $1 | tr -t [:upper:] [:lower:]`
echo "/*-" >> $outname
echo " * See the file LICENSE for redistribution information." >> $outname
echo " * " >> $outname
-echo " * Copyright (c) 2002, 2012 Oracle and/or its affiliates. All rights reserved." >> $outname
+echo " * Copyright (c) 2002, 2015 Oracle and/or its affiliates. All rights reserved." >> $outname
echo " *" >> $outname
echo " */" >> $outname
echo "" >> $outname
diff --git a/test/java/junit/src/com/sleepycat/db/test/AppendRecnoTest.java b/test/java/junit/src/com/sleepycat/db/test/AppendRecnoTest.java
index f3c8b307..f70ca823 100644
--- a/test/java/junit/src/com/sleepycat/db/test/AppendRecnoTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/AppendRecnoTest.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/junit/src/com/sleepycat/db/test/AssociateTest.java b/test/java/junit/src/com/sleepycat/db/test/AssociateTest.java
index 3cf8b187..2f9c0540 100644
--- a/test/java/junit/src/com/sleepycat/db/test/AssociateTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/AssociateTest.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/junit/src/com/sleepycat/db/test/BackupTest.java b/test/java/junit/src/com/sleepycat/db/test/BackupTest.java
index 6b41336d..f5303870 100644
--- a/test/java/junit/src/com/sleepycat/db/test/BackupTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/BackupTest.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/junit/src/com/sleepycat/db/test/CallbackTest.java b/test/java/junit/src/com/sleepycat/db/test/CallbackTest.java
index 2b65f79b..6668dd59 100644
--- a/test/java/junit/src/com/sleepycat/db/test/CallbackTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/CallbackTest.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/junit/src/com/sleepycat/db/test/ClosedDbTest.java b/test/java/junit/src/com/sleepycat/db/test/ClosedDbTest.java
index 4d0e72b3..f2848825 100644
--- a/test/java/junit/src/com/sleepycat/db/test/ClosedDbTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/ClosedDbTest.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/junit/src/com/sleepycat/db/test/DatabaseTest.java b/test/java/junit/src/com/sleepycat/db/test/DatabaseTest.java
index c3a03885..a5886fa8 100644
--- a/test/java/junit/src/com/sleepycat/db/test/DatabaseTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/DatabaseTest.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.
*
*/
@@ -18,27 +18,37 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+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 com.sleepycat.db.BtreeStats;
import com.sleepycat.db.Cursor;
import com.sleepycat.db.CursorConfig;
import com.sleepycat.db.Database;
import com.sleepycat.db.DatabaseConfig;
import com.sleepycat.db.DatabaseEntry;
import com.sleepycat.db.DatabaseException;
+import com.sleepycat.db.DatabaseStream;
+import com.sleepycat.db.DatabaseStreamConfig;
import com.sleepycat.db.DatabaseType;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
+import com.sleepycat.db.HashStats;
import com.sleepycat.db.HeapStats;
import com.sleepycat.db.LockMode;
+import com.sleepycat.db.MultipleDataEntry;
import com.sleepycat.db.OperationStatus;
+import com.sleepycat.db.PartitionHandler;
import com.sleepycat.db.Transaction;
import java.io.File;
import java.io.IOException;
import java.io.FileNotFoundException;
+import java.lang.reflect.Array;
import com.sleepycat.db.test.TestUtils;
public class DatabaseTest {
@@ -68,37 +78,38 @@ public class DatabaseTest {
}
/*
- * Test creating a new database.
+ * Test creating a new database, and then
+ * opening and adding records to an existing database.
*/
@Test public void test1()
throws DatabaseException, FileNotFoundException
{
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+ itemcount = 0;
+
+ // Create a new database.
TestOptions options = new TestOptions();
options.db_config.setErrorPrefix("DatabaseTest::test1 ");
rundb(itemcount++, options);
- }
-
- /*
- * Test opening and adding to an existing database.
- */
- @Test public void test2()
- throws DatabaseException, FileNotFoundException
- {
- TestOptions options = new TestOptions();
- options.db_config.setErrorPrefix("DatabaseTest::test2 ");
+ // Open and add records to the existing database.
rundb(itemcount++, options);
}
/*
- * Test modifying the error prefix multiple times ?
+ * Test modifying the error prefix multiple times.
*/
- @Test public void test3()
+ @Test public void test2()
throws DatabaseException, FileNotFoundException
{
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+ itemcount = 0;
+
TestOptions options = new TestOptions();
- options.db_config.setErrorPrefix("DatabaseTest::test3 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test2 ");
for (int i=0; i<100; i++)
options.db_config.setErrorPrefix("str" + i);
@@ -109,11 +120,15 @@ public class DatabaseTest {
/*
* Test opening a database with an env.
*/
- @Test public void test4()
+ @Test public void test3()
throws DatabaseException, FileNotFoundException
{
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+ itemcount = 0;
+
TestOptions options = new TestOptions();
- options.db_config.setErrorPrefix("DatabaseTest::test4 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test3 ");
EnvironmentConfig envc = new EnvironmentConfig();
envc.setAllowCreate(true);
@@ -127,11 +142,15 @@ public class DatabaseTest {
/*
* Test opening multiple databases using the same env.
*/
- @Test public void test5()
+ @Test public void test4()
throws DatabaseException, FileNotFoundException
{
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+ itemcount = 0;
+
TestOptions options = new TestOptions();
- options.db_config.setErrorPrefix("DatabaseTest::test5 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test4 ");
EnvironmentConfig envc = new EnvironmentConfig();
envc.setAllowCreate(true);
@@ -146,15 +165,22 @@ public class DatabaseTest {
}
/*
- * Test just opening and closing a DB and an Env without doing any operations.
+ * Test just opening and closing a DB and an Env without
+ * doing any operations.
*/
- @Test public void test6()
+ @Test public void test5()
throws DatabaseException, FileNotFoundException
{
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+
TestOptions options = new TestOptions();
- options.db_config.setErrorPrefix("DatabaseTest::test6 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test5 ");
+ options.db_config.setAllowCreate(true);
- Database db = new Database(TestUtils.getDBFileName(DATABASETEST_DBNAME), null, options.db_config);
+ Database db =
+ new Database(TestUtils.getDBFileName(DATABASETEST_DBNAME),
+ null, options.db_config);
EnvironmentConfig envc = new EnvironmentConfig();
envc.setAllowCreate(true);
@@ -169,14 +195,14 @@ public class DatabaseTest {
}
/*
- * test7 leaves a db and dbenv open; it should be detected.
+ * test6 leaves a db and dbenv open; it should be detected.
*/
/* Not sure if relevant with current API.
- @Test public void test7()
+ @Test public void test6()
throws DatabaseException, FileNotFoundException
{
TestOptions options = new TestOptions();
- options.db_config.setErrorPrefix("DatabaseTest::test7 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test6 ");
Database db = new Database(TestUtils.getDBFileName(DATABASETEST_DBNAME), null, options.db_config);
@@ -192,25 +218,25 @@ public class DatabaseTest {
/*
* Test leaving database and cursors open won't harm.
*/
- @Test public void test10()
+ @Test public void test8()
throws DatabaseException, FileNotFoundException
{
System.out.println("\nTest 10 transactional.");
- test10_int(true);
+ test8_int(true);
System.out.println("\nTest 10 non-transactional.");
- test10_int(false);
+ test8_int(false);
}
- void test10_int(boolean havetxn)
+ void test8_int(boolean havetxn)
throws DatabaseException, FileNotFoundException
{
String name;
Transaction txn = null;
-
itemcount = 0;
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR, TestUtils.getDBFileName(DATABASETEST_DBNAME));
TestOptions options = new TestOptions();
options.save_db = true;
- options.db_config.setErrorPrefix("DatabaseTest::test10 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test8 ");
EnvironmentConfig envc = new EnvironmentConfig();
envc.setAllowCreate(true);
@@ -273,14 +299,16 @@ public class DatabaseTest {
/*
* Test creating a new database.
*/
- @Test public void test8()
+ @Test public void test7()
throws DatabaseException, FileNotFoundException
{
- TestUtils.removeall(true, false, TestUtils.BASETEST_DBDIR, TestUtils.getDBFileName(DATABASETEST_DBNAME));
- itemcount = 0;
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+ itemcount = 0;
+
TestOptions options = new TestOptions();
options.save_db = true;
- options.db_config.setErrorPrefix("DatabaseTest::test8 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test7 ");
EnvironmentConfig envc = new EnvironmentConfig();
envc.setAllowCreate(true);
@@ -308,20 +336,21 @@ public class DatabaseTest {
options.database.close();
options.database = null;
+ options.db_env.close();
}
/*
* Test setting database handle exclusive lock.
*/
- @Test public void test11()
+ @Test public void test9()
throws DatabaseException, FileNotFoundException
{
TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR, TestUtils.getDBFileName(DATABASETEST_DBNAME));
itemcount = 0;
TestOptions options = new TestOptions();
options.save_db = true;
- options.db_config.setErrorPrefix("DatabaseTest::test11 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test9 ");
EnvironmentConfig envc = new EnvironmentConfig();
envc.setAllowCreate(true);
@@ -365,13 +394,13 @@ public class DatabaseTest {
/*
* Test setting metadata directory
*/
- @Test public void test12()
+ @Test public void test10()
throws DatabaseException, FileNotFoundException
{
TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR, TestUtils.getDBFileName(DATABASETEST_DBNAME));
itemcount = 0;
TestOptions options = new TestOptions();
- options.db_config.setErrorPrefix("DatabaseTest::test12 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test10 ");
EnvironmentConfig envc = new EnvironmentConfig();
envc.setAllowCreate(true);
@@ -393,12 +422,12 @@ public class DatabaseTest {
/*
* Test setting heap region size
*/
- @Test public void test13()
+ @Test public void test11()
throws DatabaseException, FileNotFoundException
{
TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR, TestUtils.getDBFileName(DATABASETEST_DBNAME));
TestOptions options = new TestOptions();
- options.db_config.setErrorPrefix("DatabaseTest::test13 ");
+ options.db_config.setErrorPrefix("DatabaseTest::test11 ");
options.db_config.setAllowCreate(true);
options.db_config.setType(DatabaseType.HEAP);
options.db_config.setHeapRegionSize(4);
@@ -412,6 +441,170 @@ public class DatabaseTest {
db.close();
}
+ /*
+ * Test creating partition database by keys
+ */
+ @Test public void test12()
+ throws DatabaseException, Exception, FileNotFoundException
+ {
+ // Test the success case
+ String errpfx = "DatabaseTest::test12 ";
+
+ // Create the partition key
+ int parts = 3;
+ MultipleDataEntry keyRanges = new MultipleDataEntry();
+ keyRanges.setData(new byte[1024]);
+ keyRanges.setUserBuffer(1024, true);
+
+ DatabaseEntry kdbt1 = new DatabaseEntry();
+ DatabaseEntry kdbt2 = new DatabaseEntry();
+ kdbt1.setData("d".getBytes());
+ kdbt2.setData("g".getBytes());
+
+ keyRanges.append(kdbt1);
+ keyRanges.append(kdbt2);
+
+ // Success case: set partition by key
+ test_partition_db(parts, keyRanges, null, 0, errpfx);
+
+ // Test the exception case: parts != (size of key array + 1)
+ parts++;
+ try {
+ test_partition_db(parts, keyRanges, null, 0, errpfx);
+ throw new Exception("Unexpected exception: setPartitionByRange" +
+ "should fail as parts != (size of key array + 1).");
+ } catch (IllegalArgumentException e) {
+ }
+
+ // Test the exception case: keys == null
+ try {
+ test_partition_db(parts, null, null, 0, errpfx);
+ throw new Exception("Unexpected exception: database open should" +
+ "fail as partition key array and callback are null.");
+ } catch (IllegalArgumentException e) {
+ }
+
+ // Test the exception case: there is no data in the keys
+ try {
+ test_partition_db(parts, new MultipleDataEntry(), null, 0, errpfx);
+ throw new Exception("Unexpected exception: database open should" +
+ "fail as there is no data in the partition keys which is" +
+ "a MultipleDataEntry. ");
+ } catch (IllegalArgumentException e) {
+ }
+
+ // Test the exception case: parts == 1
+ try {
+ test_partition_db(1, null, null, 2, errpfx);
+ throw new Exception("Unexpected exception: database open should" +
+ "fail as the number of partition is set to 1.");
+ } catch (IllegalArgumentException e) {
+ }
+
+ }
+
+ /*
+ * Test creating partition database by callback
+ */
+ @Test public void test13()
+ throws DatabaseException, Exception, FileNotFoundException
+ {
+ String errpfx = "DatabaseTest::test13 ";
+
+ // Success case: set partition by callback
+ PartitionCallback part_func = new PartitionCallback();
+ int parts = 2;
+ test_partition_db(parts, null, part_func, 1, errpfx);
+
+ // Test the exception case: callback and key array are both set
+ MultipleDataEntry keyRanges = new MultipleDataEntry();
+ keyRanges.setData(new byte[1024]);
+ keyRanges.setUserBuffer(1024, true);
+ DatabaseEntry kdbt = new DatabaseEntry();
+ kdbt.setData("b".getBytes());
+ keyRanges.append(kdbt);
+
+ try {
+ test_partition_db(parts, keyRanges, part_func, 2, errpfx);
+ throw new Exception("Unexpected exception: database open should " +
+ "fail as partition callback and key array are both set.");
+ } catch (IllegalArgumentException e) {
+ }
+
+ }
+
+ /*
+ * Test setting the blob directory and threshold value.
+ */
+ @Test public void test14()
+ throws DatabaseException, Exception, FileNotFoundException
+ {
+ TestOptions options = new TestOptions();
+ options.db_config.setErrorPrefix("DatabaseTest::test14 ");
+ options.save_db = true;
+
+ EnvironmentConfig envc = new EnvironmentConfig();
+ envc.setAllowCreate(true);
+ envc.setInitializeCache(true);
+
+ // Test setting the blob directory.
+ String dir[] = {"null", "", "BLOBDIR"};
+ for (int i = -1; i < dir.length; i++) {
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+ // Set the blob directory.
+ if (i >= 0) {
+ if (dir[i].compareTo("null") == 0)
+ envc.setBlobDir(null);
+ else
+ envc.setBlobDir(new java.io.File(dir[i]));
+ }
+ // Set the blob threshold value.
+ envc.setBlobThreshold(10485760);
+ // Open the env.
+ options.db_env = new Environment(TestUtils.BASETEST_DBFILE, envc);
+ // Verify the blob directory and threshold value.
+ assertEquals(10485760,
+ options.db_env.getConfig().getBlobThreshold());
+ if (i == -1 || dir[i].compareTo("null") == 0)
+ assertNull(options.db_env.getConfig().getBlobDir());
+ else
+ assertEquals(0, options.db_env.getConfig().getBlobDir().
+ toString().compareTo(dir[i]));
+ options.db_env.close();
+ }
+
+ // Test setting the db blob threshold value and open it with no env.
+ test_blob_db(0, null, 3,
+ TestUtils.BASETEST_DBDIR + File.separator + "DBBLOB",
+ 0, "DatabaseTest::test14 ", DatabaseType.BTREE);
+
+ // Test setting the blob directory in the database and then
+ // opening the db within env and verifying the setting is ignored.
+ test_blob_db(3, null, 0, "DBBLOB",
+ 0, "DatabaseTest::test14 ", DatabaseType.BTREE);
+ test_blob_db(3, "ENVBLOB", 0, "DBBLOB",
+ 0, "DatabaseTest::test14 ", DatabaseType.BTREE);
+
+ // Test setting the blob directory in the environment.
+ test_blob_db(3, "ENVBLOB", 0, null,
+ 0, "DatabaseTest::test14 ", DatabaseType.BTREE);
+
+ // Test the db blob threshold value defaults to env blob threshold
+ // value.
+ test_blob_db(3, null, 0, null,
+ 0, "DatabaseTest::test14 ", DatabaseType.BTREE);
+
+ // Test setting db own blob threshold and open it within the env.
+ test_blob_db(4, null, 3, null,
+ 0, "DatabaseTest::test14 ", DatabaseType.HASH);
+
+ // Test putting the data items whose size does not reach the blob
+ // threshold but set as blob data items.
+ test_blob_db(3, null, 0, null,
+ 1, "DatabaseTest::test14 ", DatabaseType.HEAP);
+ }
+
// Check that key/data for 0 - count-1 are already present,
// and write a key/data for count. The key and data are
// both "0123...N" where N == count-1.
@@ -529,6 +722,345 @@ public class DatabaseTest {
else if (options.database == null)
options.database = db;
}
+
+ // Test if setPartitionByRange and setPartitionByCallback work by the
+ // following steps: 1) config the partition by keys and/or callback;
+ // 2) open the database; 3) insert some records; 4) verify the partition
+ // configs; 5) close the database.
+ //
+ // The parameter "apicall" indicates which API is tested. If it is 0,
+ // test setPartitionByRange. If it is 1, test setPartitionByCallback.
+ // Otherwise test both of them.
+ void test_partition_db(int nparts, MultipleDataEntry keys,
+ PartitionHandler funcp, int apicall, String errpfx)
+ throws DatabaseException, FileNotFoundException,
+ IllegalArgumentException
+ {
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+ TestOptions options = new TestOptions();
+ options.db_config.setErrorPrefix(errpfx);
+ options.db_config.setAllowCreate(true);
+ options.db_config.setType(DatabaseType.BTREE);
+ // Config the partition.
+ // Parameter apicall:
+ // If 0 then call setPartitionByRange;
+ // If 1 then call setPartitionByCallback;
+ // Otherwise call both.
+ if (apicall == 0)
+ options.db_config.setPartitionByRange(nparts, keys);
+ else if (apicall == 1)
+ options.db_config.setPartitionByCallback(nparts, funcp);
+ else {
+ options.db_config.setPartitionByRange(nparts, keys);
+ options.db_config.setPartitionByCallback(nparts, funcp);
+ }
+
+ // Open the database.
+ Database db = new Database(
+ TestUtils.getDBFileName(DATABASETEST_DBNAME),
+ null, options.db_config);
+
+ // Insert some records.
+ String[] records = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
+ "x", "y", "z"};
+ DatabaseEntry ddbt, kdbt;
+ for (int i = 0; i < records.length; i++) {
+ kdbt = new DatabaseEntry();
+ ddbt = new DatabaseEntry();
+ kdbt.setData(records[i].getBytes());
+ ddbt.setData(records[i].getBytes());
+ db.putNoOverwrite(null, kdbt, ddbt);
+ }
+
+ // Verify the number of partitions.
+ assertEquals(nparts, db.getConfig().getPartitionParts());
+
+ // Verify the number of partitioned files.
+ File testdir = new File(TestUtils.BASETEST_DBDIR);
+ File[] flist = testdir.listFiles();
+ int cnt = 0;
+ for (int i = 0; i < Array.getLength(flist); i++) {
+ if (flist[i].getName().substring(0, 6).compareTo("__dbp.") == 0)
+ cnt++;
+ }
+ assertEquals(nparts, cnt);
+
+ // Verify the keys.
+ if (keys != null) {
+ MultipleDataEntry orig_key = new MultipleDataEntry(keys.getData());
+ MultipleDataEntry get_key =new MultipleDataEntry(
+ db.getConfig().getPartitionKeys().getData());
+ String s1, s2;
+ for (kdbt = new DatabaseEntry(), ddbt = new DatabaseEntry();
+ orig_key.next(kdbt) == true;
+ kdbt = new DatabaseEntry(), ddbt = new DatabaseEntry()) {
+ assertEquals(true, get_key.next(ddbt));
+ s1 = new String(kdbt.getData(), kdbt.getOffset(), kdbt.getSize());
+ s2 = new String(ddbt.getData(), ddbt.getOffset(), ddbt.getSize());
+ assertEquals(0, s1.compareTo(s2));
+ }
+ assertEquals(false, get_key.next(ddbt));
+ }
+
+ // Verify the callback.
+ assertEquals(funcp, db.getConfig().getPartitionHandler());
+
+ // Close the database.
+ db.close();
+
+ }
+
+ // Test if the BLOB basic APIs work by the following steps:
+ // 1) configure the blob threshold value and blob directory;
+ // 2) open the database with/without the environment;
+ // 3) insert and verify the blob data by database methods;
+ // 4) insert blob data by cursor, update the blob data and verify
+ // the update by database stream;
+ // 5) verify the blob configs, whether the blobs are created in
+ // expected location and the stats;
+ // 6) close the database and environment.
+ //
+ // The parameter "env_threshold" indicates the blob threshold value
+ // set in the environment and whether the database is opened within
+ // the enviornment. If it is <= 0, open the database without the
+ // enviornment. Otherwise open the database within the enviornment.
+ // The parameter "blobdbt" indicates whether DatabaseEntry.setBlob()
+ // is called on the data items to put. If it is not 0, set the data
+ // items as blob data and make its size < the blob threshold. Otherwise
+ // make the size of the data item reach the threshold and do not set
+ // the data item as blob data.
+ void test_blob_db(int env_threshold, String env_blob_dir,
+ int db_threshold, String db_blob_dir, int blobdbt,
+ String errpfx, DatabaseType dbtype)
+ throws DatabaseException, Exception, FileNotFoundException
+ {
+ // The blob threshold is set at least once either in the environment
+ // or in the database.
+ if (env_threshold <= 0 && db_threshold <= 0)
+ return;
+
+ TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR,
+ TestUtils.getDBFileName(DATABASETEST_DBNAME));
+ TestOptions options = new TestOptions();
+ options.db_config.setErrorPrefix(errpfx);
+ options.db_config.setAllowCreate(true);
+ options.db_config.setType(dbtype);
+
+ // Configure and open the environment.
+ EnvironmentConfig envc = new EnvironmentConfig();
+ if (env_threshold <= 0)
+ options.db_env = null;
+ else {
+ envc.setAllowCreate(true);
+ envc.setErrorStream(TestUtils.getErrorStream());
+ envc.setInitializeCache(true);
+ envc.setBlobThreshold(env_threshold);
+ if (env_blob_dir != null)
+ envc.setBlobDir(new java.io.File(env_blob_dir));
+ options.db_env = new Environment(TestUtils.BASETEST_DBFILE, envc);
+ }
+
+ // Configure and open the database.
+ if (db_threshold > 0)
+ options.db_config.setBlobThreshold(db_threshold);
+ if (db_blob_dir != null)
+ options.db_config.setBlobDir(new java.io.File(db_blob_dir));
+ if (options.db_env == null)
+ options.database =
+ new Database(TestUtils.getDBFileName(DATABASETEST_DBNAME),
+ null, options.db_config);
+ else {
+ options.database = options.db_env.openDatabase(null,
+ DATABASETEST_DBNAME, null, options.db_config);
+ }
+
+ // Insert and verify some blob data by database method, and then
+ // update the blob data by database stream and verify the update.
+ Cursor cursor = options.database.openCursor(null, null);
+ DatabaseStream dbs;
+ DatabaseStreamConfig dbs_config = new DatabaseStreamConfig();
+ dbs_config.setSyncPerWrite(true);
+ assertEquals(true, dbs_config.getSyncPerWrite());
+ assertEquals(false, dbs_config.getReadOnly());
+ String[] records = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
+ "x", "y", "z"};
+ DatabaseEntry ddbt, kdbt, sdbt;
+ String data;
+ for (int i = 0; i < records.length; i++) {
+ kdbt = new DatabaseEntry();
+ ddbt = new DatabaseEntry();
+ kdbt.setData(records[i].getBytes());
+ data = records[i];
+ if (blobdbt != 0) {
+ ddbt.setBlob(true);
+ assertTrue(ddbt.getBlob());
+ } else {
+ for (int j = 1;
+ j < options.database.getConfig().getBlobThreshold(); j++)
+ data = data + records[i];
+ }
+ ddbt.setData(data.getBytes());
+ if (dbtype == DatabaseType.HEAP)
+ options.database.append(null, kdbt, ddbt);
+ else
+ options.database.put(null, kdbt, ddbt);
+
+ // Verify the blob data by database get method.
+ assertEquals(OperationStatus.SUCCESS,
+ options.database.get(null, kdbt, ddbt, null));
+ assertArrayEquals(data.getBytes(), ddbt.getData());
+
+ // Update the blob data by database stream and verify the update.
+ assertEquals(OperationStatus.SUCCESS,
+ cursor.getSearchKey(kdbt, ddbt, null));
+ dbs = cursor.openDatabaseStream(dbs_config);
+ assertEquals(data.length(), dbs.size());
+ sdbt = new DatabaseEntry("abc".getBytes());
+ assertEquals(OperationStatus.SUCCESS, dbs.write(sdbt, dbs.size()));
+ assertEquals(OperationStatus.SUCCESS,
+ dbs.read(sdbt, 0, (int)dbs.size()));
+ assertArrayEquals((data + "abc").getBytes(), sdbt.getData());
+ dbs.close();
+ }
+ cursor.close();
+
+ // Insert the blob data by cursor, update the blob data by database
+ // stream and verify the update.
+ if (dbtype != DatabaseType.HEAP) {
+ cursor = options.database.openCursor(null, null);
+ kdbt = new DatabaseEntry("abc".getBytes());
+ ddbt = new DatabaseEntry("abc".getBytes());
+ ddbt.setBlob(true);
+ assertEquals(true, ddbt.getBlob());
+ assertEquals(OperationStatus.SUCCESS,
+ cursor.putKeyFirst(kdbt, ddbt));
+
+ dbs = cursor.openDatabaseStream(dbs_config);
+ assertEquals(3, dbs.size());
+ sdbt = new DatabaseEntry("defg".getBytes());
+ assertEquals(OperationStatus.SUCCESS, dbs.write(sdbt, dbs.size()));
+
+ // Verify datbase stream writing/reading with
+ // partial DatabaseEntry will fail.
+ try {
+ kdbt.setPartial(true);
+ assertEquals(true, kdbt.getPartial());
+ dbs.write(kdbt, 0);
+ throw new Exception("database stream write/read"
+ + "with partial DatabaseEntry should fail");
+ } catch (IllegalArgumentException e) {
+ }
+
+ try {
+ dbs.read(kdbt, 0, (int)dbs.size());
+ throw new Exception("database stream read"
+ + "with partial DatabaseEntry should fail");
+ } catch (IllegalArgumentException e) {
+ }
+
+ dbs.close();
+
+ // Verify the update and that database stream can not write when it
+ // is configured to be read-only.
+ dbs_config.setReadOnly(true);
+ assertEquals(true, dbs_config.getReadOnly());
+ dbs = cursor.openDatabaseStream(dbs_config);
+ assertEquals(7, dbs.size());
+ assertEquals(OperationStatus.SUCCESS,
+ dbs.read(sdbt, 0, (int)dbs.size()));
+ assertArrayEquals("abcdefg".getBytes(), sdbt.getData());
+ try {
+ dbs.write(sdbt, 7);
+ throw new Exception("database stream write should fail"
+ + "as it is configured to be read-only");
+ } catch (IllegalArgumentException e) {
+ }
+ dbs.close();
+
+ cursor.close();
+ }
+
+ // Verify the blob config of the enviornment.
+ if (options.db_env != null && env_threshold > 0) {
+ assertEquals(env_threshold,
+ options.db_env.getConfig().getBlobThreshold());
+ if (env_blob_dir == null)
+ assertNull(options.db_env.getConfig().getBlobDir());
+ else
+ assertEquals(0, options.db_env.getConfig().
+ getBlobDir().toString().compareTo(env_blob_dir));
+ }
+
+ // Verify the blob config of the database.
+ assertEquals(db_threshold > 0 ? db_threshold : env_threshold,
+ options.database.getConfig().getBlobThreshold());
+ String blrootdir;
+ if (options.db_env != null) {
+ if (env_blob_dir == null)
+ blrootdir = "__db_bl";
+ else
+ blrootdir = env_blob_dir;
+ } else if (db_blob_dir == null) {
+ blrootdir = "__db_bl";
+ } else {
+ blrootdir = db_blob_dir;
+ }
+ assertEquals(0, options.database.getConfig().
+ getBlobDir().toString().compareTo(blrootdir));
+
+ // Verify the blobs are created in the expected location.
+ // This part of test is disabled since the Database.getBlobSubDir()
+ // is not expsed to users.
+ //if (options.db_env != null)
+ // blrootdir = options.db_env.getHome().toString() + "/" + blrootdir;
+ //assertNotNull(options.database.getBlobSubDir().toString());
+ //File blobdir = new File(blrootdir + "/" +
+ // options.database.getBlobSubDir().toString());
+ //assertTrue(blobdir.listFiles().length > records.length);
+
+ // Verify the stats.
+ if (dbtype == DatabaseType.HASH) {
+ HashStats stats = (HashStats)options.database.getStats(null, null);
+ assertEquals(records.length + 1, stats.getNumBlobs());
+ } else if (dbtype == DatabaseType.HEAP) {
+ HeapStats stats = (HeapStats)options.database.getStats(null, null);
+ assertEquals(records.length, stats.getHeapNumBlobs());
+ } else {
+ BtreeStats stats =
+ (BtreeStats)options.database.getStats(null, null);
+ assertEquals(records.length + 1, stats.getNumBlobs());
+ }
+
+ // Close the database and set up the blob directory configuration
+ // used in removing the database.
+ options.database.close();
+ if (options.db_env != null)
+ blrootdir = TestUtils.BASETEST_DBDIR + File.separator + blrootdir;
+ options.db_config.setBlobDir(new File(blrootdir));
+
+ // TestUtils.removeall does not work on the blob database since it
+ // removes the database with the default database configuration. So
+ // remove the blob database with blob configuration here.
+ Database.remove(TestUtils.getDBFileName(DATABASETEST_DBNAME),
+ null, options.db_config);
+
+ // All blobs are deleted but the blob directory remains after db
+ // remove. Verify it and delete the blob directory.
+ File[] files = options.db_config.getBlobDir().listFiles();
+ assertTrue(files.length > 0);
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory())
+ assertEquals(0, files[i].listFiles().length);
+ }
+ TestUtils.removeDir(blrootdir);
+
+ // Close the environment.
+ if (options.db_env != null)
+ options.db_env.close();
+ }
}
@@ -561,3 +1093,16 @@ class TestOptions
}
}
+
+class PartitionCallback implements PartitionHandler
+{
+ public int partition(Database db, DatabaseEntry key)
+ {
+ String data = new String(key.getData());
+
+ if (data.compareTo("d") >= 0)
+ return 1;
+ else
+ return 0;
+ }
+}
diff --git a/test/java/junit/src/com/sleepycat/db/test/EncryptTest.java b/test/java/junit/src/com/sleepycat/db/test/EncryptTest.java
index 57c6faba..89bbd197 100644
--- a/test/java/junit/src/com/sleepycat/db/test/EncryptTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/EncryptTest.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/junit/src/com/sleepycat/db/test/EnvRegionSizeTest.java b/test/java/junit/src/com/sleepycat/db/test/EnvRegionSizeTest.java
index 4259c6df..3e1e9033 100644
--- a/test/java/junit/src/com/sleepycat/db/test/EnvRegionSizeTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/EnvRegionSizeTest.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/junit/src/com/sleepycat/db/test/HashCompareTest.java b/test/java/junit/src/com/sleepycat/db/test/HashCompareTest.java
index 18d11f57..7be5e6c4 100644
--- a/test/java/junit/src/com/sleepycat/db/test/HashCompareTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/HashCompareTest.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/junit/src/com/sleepycat/db/test/LogCursorTest.java b/test/java/junit/src/com/sleepycat/db/test/LogCursorTest.java
index b6a5b08b..25476832 100644
--- a/test/java/junit/src/com/sleepycat/db/test/LogCursorTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/LogCursorTest.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/junit/src/com/sleepycat/db/test/MultipleCursorTest.java b/test/java/junit/src/com/sleepycat/db/test/MultipleCursorTest.java
index e7374d31..5854c8cd 100644
--- a/test/java/junit/src/com/sleepycat/db/test/MultipleCursorTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/MultipleCursorTest.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/junit/src/com/sleepycat/db/test/PartialGetTest.java b/test/java/junit/src/com/sleepycat/db/test/PartialGetTest.java
index 35d97721..791032fa 100644
--- a/test/java/junit/src/com/sleepycat/db/test/PartialGetTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/PartialGetTest.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/junit/src/com/sleepycat/db/test/PriorityTest.java b/test/java/junit/src/com/sleepycat/db/test/PriorityTest.java
index 8f8d7cf4..506252ab 100644
--- a/test/java/junit/src/com/sleepycat/db/test/PriorityTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/PriorityTest.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/junit/src/com/sleepycat/db/test/RepmgrConfigTest.java b/test/java/junit/src/com/sleepycat/db/test/RepmgrConfigTest.java
index f8d8b789..b7423484 100644
--- a/test/java/junit/src/com/sleepycat/db/test/RepmgrConfigTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/RepmgrConfigTest.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/junit/src/com/sleepycat/db/test/RepmgrElectionTest.java b/test/java/junit/src/com/sleepycat/db/test/RepmgrElectionTest.java
index e2bf6a3e..d25d729b 100644
--- a/test/java/junit/src/com/sleepycat/db/test/RepmgrElectionTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/RepmgrElectionTest.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.
*/
package com.sleepycat.db.test;
diff --git a/test/java/junit/src/com/sleepycat/db/test/RepmgrSiteTest.java b/test/java/junit/src/com/sleepycat/db/test/RepmgrSiteTest.java
index 2024169d..4a5955e4 100644
--- a/test/java/junit/src/com/sleepycat/db/test/RepmgrSiteTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/RepmgrSiteTest.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
*
* $Id$
*
@@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.FileNotFoundException;
import com.sleepycat.db.*;
public class RepmgrSiteTest extends EventHandlerAdapter
@@ -147,6 +148,127 @@ public class RepmgrSiteTest extends EventHandlerAdapter
env.close();
}
+ @Test public void testPartialRep() throws Exception
+ {
+ // Start up master.
+ File mHomeDir = new File(homedirName + File.separator + "master");
+ mHomeDir.mkdir();
+ ReplicationManagerSiteConfig mConf =
+ new ReplicationManagerSiteConfig(host, port);
+ mConf.setLocalSite(true);
+ mConf.setGroupCreator(true);
+ envConfig.addReplicationManagerSite(mConf);
+ long mport = port;
+
+ Environment mEnv = new Environment(mHomeDir, envConfig);
+
+ mEnv.replicationManagerStart(4,
+ ReplicationManagerStartPolicy.REP_MASTER);
+
+ // Set up the environments for the client sites.
+ ReplicationManagerSiteConfig hConf =
+ new ReplicationManagerSiteConfig(host, port);
+ hConf.setBootstrapHelper(true);
+ File cHomeDir1 = new File(homedirName + File.separator + "client1");
+ cHomeDir1.mkdir();
+ port++;
+ ReplicationManagerSiteConfig cConf1 =
+ new ReplicationManagerSiteConfig(host, port);
+ cConf1.setLocalSite(true);
+ EnvironmentConfig cEnvConfig1 = initEnvConfig();
+ cEnvConfig1.addReplicationManagerSite(cConf1);
+ cEnvConfig1.addReplicationManagerSite(hConf);
+ // Set the client 1 site as a partial view.
+ cEnvConfig1.setReplicationView(new RepViewCallback());
+ Environment cEnv1 = new Environment(cHomeDir1, cEnvConfig1);
+
+ File cHomeDir2 = new File(homedirName + File.separator + "client2");
+ cHomeDir2.mkdir();
+ port++;
+ ReplicationManagerSiteConfig cConf2 =
+ new ReplicationManagerSiteConfig(host, port);
+ cConf2.setLocalSite(true);
+ EnvironmentConfig cEnvConfig2 = initEnvConfig();
+ cEnvConfig2.addReplicationManagerSite(cConf2);
+ cEnvConfig2.addReplicationManagerSite(hConf);
+ // Set the client 2 site as a full view.
+ cEnvConfig2.setReplicationView(null);
+ Environment cEnv2 = new Environment(cHomeDir2, cEnvConfig2);
+
+ // Create 2 db files on the master site.
+ DatabaseConfig db_config = new DatabaseConfig();
+ db_config.setErrorStream(TestUtils.getErrorStream());
+ db_config.setErrorPrefix("RepmgrSiteTest::testPartialRep ");
+ db_config.setType(DatabaseType.BTREE);
+ db_config.setAllowCreate(true);
+ db_config.setTransactional(true);
+
+ Database db1 = mEnv.openDatabase(null, "db1.db", null, db_config);
+ Database db2 = mEnv.openDatabase(null, "db2.db", null, db_config);
+ db1.close();
+ db2.close();
+
+ // Start the client sites.
+ cEnv1.replicationManagerStart(4,
+ ReplicationManagerStartPolicy.REP_CLIENT);
+ assertTrue(waitForStartUpDone(cEnv1));
+ cEnv2.replicationManagerStart(4,
+ ReplicationManagerStartPolicy.REP_CLIENT);
+ assertTrue(waitForStartUpDone(cEnv2));
+
+ // Verify that the database file db1.db is replicated to both client
+ // sites, but db2.db is replicated only to the client 2 site.
+ db_config.setAllowCreate(false);
+ db1 = cEnv1.openDatabase(null, "db1.db", null, db_config);
+ try {
+ db2 = cEnv1.openDatabase(null, "db2.db", null, db_config);
+ throw new Exception();
+ } catch (FileNotFoundException e) {
+ }
+ db1.close();
+
+ db1 = cEnv2.openDatabase(null, "db1.db", null, db_config);
+ db2 = cEnv2.openDatabase(null, "db2.db", null, db_config);
+ db1.close();
+ db2.close();
+
+ // Verify the clients are views locally and from remote site.
+ ReplicationManagerSiteInfo[] siteLists =
+ mEnv.getReplicationManagerSiteList();
+ assertEquals(2, siteLists.length);
+ assertEquals(true, siteLists[0].isView());
+ assertEquals(true, siteLists[1].isView());
+ ReplicationStats repStats =
+ cEnv1.getReplicationStats(StatsConfig.DEFAULT);
+ assertEquals(true, repStats.getView());
+ repStats = cEnv2.getReplicationStats(StatsConfig.DEFAULT);
+ assertEquals(true, repStats.getView());
+
+ // Verify the master is not a view locally or from remote site.
+ siteLists = cEnv1.getReplicationManagerSiteList();
+ assertEquals(2, siteLists.length);
+ int i;
+ for (i = 0; i < siteLists.length; i++) {
+ if (siteLists[i].addr.port == mport)
+ break;
+ }
+ assertTrue(i < siteLists.length);
+ assertEquals(false, siteLists[i].isView());
+ repStats = mEnv.getReplicationStats(StatsConfig.DEFAULT);
+ assertEquals(false, repStats.getView());
+
+ // Get the replication manager statistics.
+ ReplicationManagerStats masterStats =
+ mEnv.getReplicationManagerStats(StatsConfig.DEFAULT);
+ assertEquals(1, masterStats.getSiteParticipants());
+ assertEquals(3, masterStats.getSiteTotal());
+ assertEquals(2, masterStats.getSiteViews());
+
+ cEnv2.close();
+ cEnv1.close();
+ mEnv.close();
+ }
+
@Test public void testRepmgrSiteConfig() throws Exception
{
// Start up master.
@@ -339,3 +461,15 @@ public class RepmgrSiteTest extends EventHandlerAdapter
mEnv.close();
}
}
+
+class RepViewCallback implements ReplicationViewHandler
+{
+ public boolean partial_view(Environment dbenv, String name, int flags)
+ throws DatabaseException
+ {
+ if (name.compareTo("db1.db") == 0)
+ return true;
+ else
+ return false;
+ }
+}
diff --git a/test/java/junit/src/com/sleepycat/db/test/RepmgrStartupTest.java b/test/java/junit/src/com/sleepycat/db/test/RepmgrStartupTest.java
index 2897752e..f2014d33 100644
--- a/test/java/junit/src/com/sleepycat/db/test/RepmgrStartupTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/RepmgrStartupTest.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.
*
*/
@@ -117,6 +117,21 @@ public class RepmgrStartupTest extends EventHandlerAdapter
try {
// start replication manager
dbenv.replicationManagerStart(3, ReplicationManagerStartPolicy.REP_MASTER);
+ EnvironmentConfig cfg = dbenv.getConfig();
+ assertEquals(cfg.getReplicationManagerIncomingQueueMax(), 100L * 1024L * 1024L);
+ long gigabyte = 1024L * 1024L * 1024L;
+ long megabyte = 1024L * 1024L;
+ // Test setting repmgr incoming queue size > 1GB.
+ cfg.setReplicationManagerIncomingQueueMax(123456L * gigabyte + 654321L);
+ dbenv.setConfig(cfg);
+ cfg = dbenv.getConfig();
+ assertEquals(cfg.getReplicationManagerIncomingQueueMax(), 123456L * gigabyte + 654321L);
+ // Test setting repmgr incoming queue size < 1GB.
+ cfg.setReplicationManagerIncomingQueueMax(10L * megabyte);
+ dbenv.setConfig(cfg);
+ cfg = dbenv.getConfig();
+ assertEquals(cfg.getReplicationManagerIncomingQueueMax(), 10L * megabyte);
+
} catch(DatabaseException dbe) {
fail("Unexpected database exception came from replicationManagerStart." + dbe);
}
diff --git a/test/java/junit/src/com/sleepycat/db/test/TestUtils.java b/test/java/junit/src/com/sleepycat/db/test/TestUtils.java
index 083b1123..22bff5dc 100644
--- a/test/java/junit/src/com/sleepycat/db/test/TestUtils.java
+++ b/test/java/junit/src/com/sleepycat/db/test/TestUtils.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.
*
*/
@@ -136,10 +136,13 @@ public class TestUtils
} else if(!deldir.isDirectory()) {
return false;
} else {
- // The following will fail if the directory contains sub-dirs.
File[] contents = deldir.listFiles();
- for (int i = 0; i < contents.length; i++)
- contents[i].delete();
+ for (int i = 0; i < contents.length; i++) {
+ if (contents[i].isDirectory())
+ removeDir(contents[i].toString());
+ else
+ contents[i].delete();
+ }
deldir.delete();
}
} catch (Exception e) {
diff --git a/test/java/junit/src/com/sleepycat/db/test/VerboseConfigTest.java b/test/java/junit/src/com/sleepycat/db/test/VerboseConfigTest.java
index 7e66d556..e2eb264e 100644
--- a/test/java/junit/src/com/sleepycat/db/test/VerboseConfigTest.java
+++ b/test/java/junit/src/com/sleepycat/db/test/VerboseConfigTest.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.
*/
package com.sleepycat.db.test;
diff --git a/test/java/rep/tests/rep/TestEmptyLogElection.java b/test/java/rep/tests/rep/TestEmptyLogElection.java
index 709babe2..7d215e9e 100644
--- a/test/java/rep/tests/rep/TestEmptyLogElection.java
+++ b/test/java/rep/tests/rep/TestEmptyLogElection.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/rep/TestMirandaTimeout.java b/test/java/rep/tests/rep/TestMirandaTimeout.java
index 138d2fc8..88aa4788 100644
--- a/test/java/rep/tests/rep/TestMirandaTimeout.java
+++ b/test/java/rep/tests/rep/TestMirandaTimeout.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/EventHandler.java b/test/java/rep/tests/repmgrtests/EventHandler.java
index 06bac58b..f9aeb14f 100644
--- a/test/java/rep/tests/repmgrtests/EventHandler.java
+++ b/test/java/rep/tests/repmgrtests/EventHandler.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/PortsConfig.java b/test/java/rep/tests/repmgrtests/PortsConfig.java
index c664be16..b549fa9a 100644
--- a/test/java/rep/tests/repmgrtests/PortsConfig.java
+++ b/test/java/rep/tests/repmgrtests/PortsConfig.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestConfig.java b/test/java/rep/tests/repmgrtests/TestConfig.java
index 5adb42dd..2862a1ae 100644
--- a/test/java/rep/tests/repmgrtests/TestConfig.java
+++ b/test/java/rep/tests/repmgrtests/TestConfig.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestDrainAbandon.java b/test/java/rep/tests/repmgrtests/TestDrainAbandon.java
index 77133804..b7d57592 100644
--- a/test/java/rep/tests/repmgrtests/TestDrainAbandon.java
+++ b/test/java/rep/tests/repmgrtests/TestDrainAbandon.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestDrainCommitx.java b/test/java/rep/tests/repmgrtests/TestDrainCommitx.java
index b7deef9d..1c4f2696 100644
--- a/test/java/rep/tests/repmgrtests/TestDrainCommitx.java
+++ b/test/java/rep/tests/repmgrtests/TestDrainCommitx.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestDrainIntInit.java b/test/java/rep/tests/repmgrtests/TestDrainIntInit.java
index 260285d6..dbc39a73 100644
--- a/test/java/rep/tests/repmgrtests/TestDrainIntInit.java
+++ b/test/java/rep/tests/repmgrtests/TestDrainIntInit.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestHeartbeats.java b/test/java/rep/tests/repmgrtests/TestHeartbeats.java
index 67830632..8d97529b 100644
--- a/test/java/rep/tests/repmgrtests/TestHeartbeats.java
+++ b/test/java/rep/tests/repmgrtests/TestHeartbeats.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestNoClient.java b/test/java/rep/tests/repmgrtests/TestNoClient.java
index 0ef71258..49bed5e5 100644
--- a/test/java/rep/tests/repmgrtests/TestNoClient.java
+++ b/test/java/rep/tests/repmgrtests/TestNoClient.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestRedundantTakeover.java b/test/java/rep/tests/repmgrtests/TestRedundantTakeover.java
index b0127ad1..8d64da2d 100644
--- a/test/java/rep/tests/repmgrtests/TestRedundantTakeover.java
+++ b/test/java/rep/tests/repmgrtests/TestRedundantTakeover.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestRepmgr.java b/test/java/rep/tests/repmgrtests/TestRepmgr.java
index 25fe19f8..2d31329f 100644
--- a/test/java/rep/tests/repmgrtests/TestRepmgr.java
+++ b/test/java/rep/tests/repmgrtests/TestRepmgr.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/TestStrictElect.java b/test/java/rep/tests/repmgrtests/TestStrictElect.java
index fdc74ca0..a4329a21 100644
--- a/test/java/rep/tests/repmgrtests/TestStrictElect.java
+++ b/test/java/rep/tests/repmgrtests/TestStrictElect.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/tests/repmgrtests/Util.java b/test/java/rep/tests/repmgrtests/Util.java
index f059941c..712e883b 100644
--- a/test/java/rep/tests/repmgrtests/Util.java
+++ b/test/java/rep/tests/repmgrtests/Util.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/current/repmgrtests/ConnectScript.java b/test/java/rep/upgrades/current/repmgrtests/ConnectScript.java
index bca9522d..26379ab4 100644
--- a/test/java/rep/upgrades/current/repmgrtests/ConnectScript.java
+++ b/test/java/rep/upgrades/current/repmgrtests/ConnectScript.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/current/repmgrtests/CurrentImpl.java b/test/java/rep/upgrades/current/repmgrtests/CurrentImpl.java
index ff776417..0b755705 100644
--- a/test/java/rep/upgrades/current/repmgrtests/CurrentImpl.java
+++ b/test/java/rep/upgrades/current/repmgrtests/CurrentImpl.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/test/repmgrtests/AbstractUpgTest.java b/test/java/rep/upgrades/test/repmgrtests/AbstractUpgTest.java
index 009cee85..7a545df0 100644
--- a/test/java/rep/upgrades/test/repmgrtests/AbstractUpgTest.java
+++ b/test/java/rep/upgrades/test/repmgrtests/AbstractUpgTest.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/test/repmgrtests/Config.java b/test/java/rep/upgrades/test/repmgrtests/Config.java
index cf28a917..1d2fe899 100644
--- a/test/java/rep/upgrades/test/repmgrtests/Config.java
+++ b/test/java/rep/upgrades/test/repmgrtests/Config.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/test/repmgrtests/MyStats.java b/test/java/rep/upgrades/test/repmgrtests/MyStats.java
index fed0f565..6b43f802 100644
--- a/test/java/rep/upgrades/test/repmgrtests/MyStats.java
+++ b/test/java/rep/upgrades/test/repmgrtests/MyStats.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/test/repmgrtests/SimpleConnectTest.java b/test/java/rep/upgrades/test/repmgrtests/SimpleConnectTest.java
index e0668bc4..ccca4def 100644
--- a/test/java/rep/upgrades/test/repmgrtests/SimpleConnectTest.java
+++ b/test/java/rep/upgrades/test/repmgrtests/SimpleConnectTest.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/test/repmgrtests/TestMixedHeartbeats.java b/test/java/rep/upgrades/test/repmgrtests/TestMixedHeartbeats.java
index 387fb42e..c6b5b012 100644
--- a/test/java/rep/upgrades/test/repmgrtests/TestMixedHeartbeats.java
+++ b/test/java/rep/upgrades/test/repmgrtests/TestMixedHeartbeats.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/test/repmgrtests/TestReverseConnect.java b/test/java/rep/upgrades/test/repmgrtests/TestReverseConnect.java
index c45328d6..d278b47a 100644
--- a/test/java/rep/upgrades/test/repmgrtests/TestReverseConnect.java
+++ b/test/java/rep/upgrades/test/repmgrtests/TestReverseConnect.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/test/repmgrtests/TestSimpleFwdConnect.java b/test/java/rep/upgrades/test/repmgrtests/TestSimpleFwdConnect.java
index 9aa4ae52..17e34ebb 100644
--- a/test/java/rep/upgrades/test/repmgrtests/TestSimpleFwdConnect.java
+++ b/test/java/rep/upgrades/test/repmgrtests/TestSimpleFwdConnect.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/test/repmgrtests/TestSimpleRevConnect.java b/test/java/rep/upgrades/test/repmgrtests/TestSimpleRevConnect.java
index db9ba505..903533d9 100644
--- a/test/java/rep/upgrades/test/repmgrtests/TestSimpleRevConnect.java
+++ b/test/java/rep/upgrades/test/repmgrtests/TestSimpleRevConnect.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/v46/repmgrtests/V46impl.java b/test/java/rep/upgrades/v46/repmgrtests/V46impl.java
index af85293a..9127ff04 100644
--- a/test/java/rep/upgrades/v46/repmgrtests/V46impl.java
+++ b/test/java/rep/upgrades/v46/repmgrtests/V46impl.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
diff --git a/test/java/rep/upgrades/v47/repmgrtests/ConnectScript.java b/test/java/rep/upgrades/v47/repmgrtests/ConnectScript.java
index 08a7f36f..718a805b 100644
--- a/test/java/rep/upgrades/v47/repmgrtests/ConnectScript.java
+++ b/test/java/rep/upgrades/v47/repmgrtests/ConnectScript.java
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/