(TEPHRA-261) Make TransactionSystemTest extensible for other projects
This closes #59 from GitHub.
Signed-off-by: anew <anew@apache.org>
diff --git a/tephra-core/src/test/java/org/apache/tephra/ThriftTransactionSystemTest.java b/tephra-core/src/test/java/org/apache/tephra/ThriftTransactionSystemTest.java
index 0d7d9bf..757b620 100644
--- a/tephra-core/src/test/java/org/apache/tephra/ThriftTransactionSystemTest.java
+++ b/tephra-core/src/test/java/org/apache/tephra/ThriftTransactionSystemTest.java
@@ -73,7 +73,7 @@
zkServer = InMemoryZKServer.builder().setDataDir(tmpFolder.newFolder()).build();
zkServer.startAndWait();
- Configuration conf = getCommonConfiguration();
+ Configuration conf = getCommonConfiguration(null);
conf.setBoolean(TxConstants.Manager.CFG_DO_PERSIST, false);
conf.set(TxConstants.Service.CFG_DATA_TX_ZOOKEEPER_QUORUM, zkServer.getConnectionStr());
// we want to use a retry strategy that lets us query the number of times it retried:
diff --git a/tephra-core/src/test/java/org/apache/tephra/TransactionManagerTest.java b/tephra-core/src/test/java/org/apache/tephra/TransactionManagerTest.java
index b16d93d..5cc1354 100644
--- a/tephra-core/src/test/java/org/apache/tephra/TransactionManagerTest.java
+++ b/tephra-core/src/test/java/org/apache/tephra/TransactionManagerTest.java
@@ -58,7 +58,7 @@
@BeforeClass
public static void beforeClass() {
- conf = getCommonConfiguration();
+ conf = getCommonConfiguration(null);
conf.setInt(TxConstants.Manager.CFG_TX_CLEANUP_INTERVAL, 0); // no cleanup thread
// todo should create two sets of tests, one with LocalFileTxStateStorage and one with InMemoryTxStateStorage
txStateStorage = new InMemoryTransactionStateStorage();
diff --git a/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java b/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java
index 6cbda2f..b09c6c0 100644
--- a/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java
+++ b/tephra-core/src/test/java/org/apache/tephra/TransactionSystemTest.java
@@ -31,6 +31,7 @@
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
/**
* Base class for testing implementations of {@link TransactionSystemClient}.
@@ -45,9 +46,12 @@
/**
* Sets up the common properties required for the test cases defined here.
* Subclasses can call this and add more properties as needed.
+ *
+ * @param existing An existing configuration to be modified. If null, a new confoguration is created.
*/
- static Configuration getCommonConfiguration() {
- Configuration conf = new Configuration();
+ @SuppressWarnings("WeakerAccess")
+ protected static Configuration getCommonConfiguration(@Nullable Configuration existing) {
+ Configuration conf = existing != null ? existing : new Configuration();
conf.setInt(TxConstants.Manager.CFG_TX_MAX_TIMEOUT, (int) TimeUnit.DAYS.toSeconds(5)); // very long limit
conf.setInt(TxConstants.Manager.CFG_TX_CHANGESET_COUNT_LIMIT, 50);
conf.setInt(TxConstants.Manager.CFG_TX_CHANGESET_COUNT_WARN_THRESHOLD, 40);