You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@omid.apache.org by fp...@apache.org on 2016/05/11 18:06:23 UTC
[16/50] [abbrv] incubator-omid git commit: Remove JUnit asserts
Remove JUnit asserts
No changes in functionality have been done
Change-Id: I48a5409dacac0716191ce332f2d0bbe995ed5761
Project: http://git-wip-us.apache.org/repos/asf/incubator-omid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-omid/commit/4323560f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-omid/tree/4323560f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-omid/diff/4323560f
Branch: refs/heads/master
Commit: 4323560f3e8aa85795d601db76ee95c128ce188c
Parents: a5c2c2f
Author: Francisco Perez-Sorrosal <fp...@yahoo-inc.com>
Authored: Tue Apr 26 13:09:22 2016 -0700
Committer: Francisco Perez-Sorrosal <fp...@yahoo-inc.com>
Committed: Tue Apr 26 18:19:34 2016 -0700
----------------------------------------------------------------------
.../apache/omid/transaction/TestAutoFlush.java | 7 +-
.../apache/omid/transaction/TestCellUtils.java | 48 +-
.../omid/transaction/TestColumnIterator.java | 10 +-
.../apache/omid/transaction/TestDeletion.java | 38 +-
.../apache/omid/transaction/TestFilters.java | 34 +-
.../transaction/TestHBaseTransactionClient.java | 49 +-
.../apache/omid/transaction/TestReadPath.java | 12 +-
.../transaction/TestSingleColumnFamily.java | 17 +-
.../transaction/TestTransactionCleanup.java | 15 +-
.../transaction/TestTransactionConflict.java | 161 +++---
.../apache/omid/transaction/TestUpdateScan.java | 20 +-
.../committable/hbase/TestHBaseCommitTable.java | 64 +--
.../apache/omid/transaction/TestCompaction.java | 495 ++++++++-----------
.../omid/transaction/TestCompactorScanner.java | 16 +-
.../storage/TestHBaseTimestampStorage.java | 12 +-
.../omid/tso/client/TestMockTSOClient.java | 12 +-
.../java/org/apache/omid/tso/TestBatch.java | 21 +-
.../org/apache/omid/tso/TestLeaseManager.java | 4 +-
.../apache/omid/tso/TestRequestProcessor.java | 4 +-
.../org/apache/omid/tso/TestRetryProcessor.java | 9 +-
.../apache/omid/tso/TestTSOStateManager.java | 10 +-
...tionOfTSOClientServerBasicFunctionality.java | 4 +-
22 files changed, 469 insertions(+), 593 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java
index ac2052d..dca346b 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestAutoFlush.java
@@ -24,13 +24,14 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.Assert.assertEquals;
@Test(groups = "sharedHBase")
public class TestAutoFlush extends OmidTestBase {
@Test
public void testReadWithSeveralUncommitted(ITestContext context) throws Exception {
+
byte[] family = Bytes.toBytes(TEST_FAMILY);
byte[] row = Bytes.toBytes("row");
byte[] col = Bytes.toBytes("col1");
@@ -49,14 +50,14 @@ public class TestAutoFlush extends OmidTestBase {
// Data shouldn't be in DB yet
Get get = new Get(row);
Result result = table.getHTable().get(get);
- assertEquals("Writes are already in DB", 0, result.size());
+ assertEquals(result.size(), 0, "Writes are already in DB");
tm.commit(t);
// After commit, both the cell and shadow cell should be there.
// That's why we check for two elements in the test assertion
result = table.getHTable().get(get);
- assertEquals("Writes were not flushed to DB", 2, result.size());
+ assertEquals(result.size(), 2, "Writes were not flushed to DB");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestCellUtils.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestCellUtils.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestCellUtils.java
index 928b55b..351b57c 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestCellUtils.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestCellUtils.java
@@ -18,11 +18,11 @@
package org.apache.omid.transaction;
import com.google.common.base.Optional;
-import org.apache.omid.HBaseShims;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.HBaseShims;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -32,10 +32,10 @@ import java.util.List;
import java.util.SortedMap;
import static org.apache.omid.transaction.CellUtils.SHADOW_CELL_SUFFIX;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.fail;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
@Test(groups = "noHBase")
public class TestCellUtils {
@@ -72,27 +72,27 @@ public class TestCellUtils {
// and is placed at the end of the qualifier:
// qual_nameSUFFIX
KeyValue kv = new KeyValue(row, family, validShadowCellQualifier, value);
- assertTrue("Should include a valid shadowCell identifier", CellUtils.isShadowCell(kv));
+ assertTrue(CellUtils.isShadowCell(kv), "Should include a valid shadowCell identifier");
// We also accept this pattern in the qualifier:
// SUFFIXqual_nameSUFFIX
kv = new KeyValue(row, family, sandwichValidShadowCellQualifier, value);
- assertTrue("Should include a valid shadowCell identifier", CellUtils.isShadowCell(kv));
+ assertTrue(CellUtils.isShadowCell(kv), "Should include a valid shadowCell identifier");
// We also accept this pattern in the qualifier:
// qual_nameSUFFIXSUFFIX
kv = new KeyValue(row, family, doubleEndedValidShadowCellQualifier, value);
- assertTrue("Should include a valid shadowCell identifier", CellUtils.isShadowCell(kv));
+ assertTrue(CellUtils.isShadowCell(kv), "Should include a valid shadowCell identifier");
// We also accept this pattern in the qualifier:
// qual_nameSUFFIXqual_nameSUFFIXqual_nameSUFFIX
kv = new KeyValue(row, family, interleavedValidShadowCellQualifier, value);
- assertTrue("Should include a valid shadowCell identifier", CellUtils.isShadowCell(kv));
+ assertTrue(CellUtils.isShadowCell(kv), "Should include a valid shadowCell identifier");
// Test the qualifier passed is not a shadow cell
// qualifier if there's nothing else apart from the suffix
kv = new KeyValue(row, family, shadowCellSuffixToTest, value);
- assertFalse("Should not include a valid shadowCell identifier", CellUtils.isShadowCell(kv));
+ assertFalse(CellUtils.isShadowCell(kv), "Should not include a valid shadowCell identifier");
}
@@ -126,27 +126,27 @@ public class TestCellUtils {
// Check dup shadow cell with same MVCC is ignored
SortedMap<Cell, Optional<Cell>> cellsToShadowCells = CellUtils.mapCellsToShadowCells(badListWithDups);
- assertEquals("There should be only 1 key-value maps", 1, cellsToShadowCells.size());
+ assertEquals(cellsToShadowCells.size(), 1, "There should be only 1 key-value maps");
assertTrue(cellsToShadowCells.containsKey(cell1));
KeyValue firstKey = (KeyValue) cellsToShadowCells.firstKey();
KeyValue lastKey = (KeyValue) cellsToShadowCells.lastKey();
assertTrue(firstKey.equals(lastKey));
- assertTrue("Should be equal", 0 == Bytes.compareTo(
- firstKey.getValueArray(), firstKey.getValueOffset(), firstKey.getValueLength(),
- cell1.getValueArray(), cell1.getValueOffset(), cell1.getValueLength()));
+ assertTrue(0 == Bytes.compareTo(firstKey.getValueArray(), firstKey.getValueOffset(), firstKey.getValueLength(),
+ cell1.getValueArray(), cell1.getValueOffset(), cell1.getValueLength()),
+ "Should be equal");
// Modify dup shadow cell to have a greater MVCC and check that is replaced
HBaseShims.setKeyValueSequenceId((KeyValue) dupCell1WithAnotherValue, 1);
cellsToShadowCells = CellUtils.mapCellsToShadowCells(badListWithDups);
- assertEquals("There should be only 1 key-value maps", 1, cellsToShadowCells.size());
+ assertEquals(cellsToShadowCells.size(), 1, "There should be only 1 key-value maps");
assertTrue(cellsToShadowCells.containsKey(dupCell1WithAnotherValue));
firstKey = (KeyValue) cellsToShadowCells.firstKey();
lastKey = (KeyValue) cellsToShadowCells.lastKey();
assertTrue(firstKey.equals(lastKey));
- assertTrue("Should be equal", 0 == Bytes.compareTo(
- firstKey.getValueArray(), firstKey.getValueOffset(), firstKey.getValueLength(),
- dupCell1WithAnotherValue.getValueArray(), dupCell1WithAnotherValue.getValueOffset(),
- dupCell1WithAnotherValue.getValueLength()));
+ assertTrue(0 == Bytes.compareTo(firstKey.getValueArray(), firstKey.getValueOffset(),
+ firstKey.getValueLength(), dupCell1WithAnotherValue.getValueArray(),
+ dupCell1WithAnotherValue.getValueOffset(), dupCell1WithAnotherValue.getValueLength()),
+ "Should be equal");
// Check a list of cells with duplicate values
List<Cell> cellListWithDups = new ArrayList<>();
cellListWithDups.add(cell1);
@@ -158,7 +158,7 @@ public class TestCellUtils {
cellListWithDups.add(shadowCell2);
cellsToShadowCells = CellUtils.mapCellsToShadowCells(cellListWithDups);
- assertEquals("There should be only 3 key-value maps", 3, cellsToShadowCells.size());
+ assertEquals(cellsToShadowCells.size(), 3, "There should be only 3 key-value maps");
assertTrue(cellsToShadowCells.get(cell1).get().equals(shadowCell1));
assertTrue(cellsToShadowCells.get(dupCell1).get().equals(shadowCell1));
assertFalse(cellsToShadowCells.containsKey(delCell1)); // TODO This is strange and needs to be solved.
@@ -177,7 +177,7 @@ public class TestCellUtils {
cell.getQualifierOffset(),
cell.getQualifierLength());
byte[] expectedQualifier = com.google.common.primitives.Bytes.concat(qualifier, SHADOW_CELL_SUFFIX);
- assertEquals(expectedQualifier, suffixedQualifier);
+ assertEquals(suffixedQualifier, expectedQualifier);
}
@@ -191,7 +191,7 @@ public class TestCellUtils {
cell.getQualifierOffset(),
cell.getQualifierLength());
byte[] expectedQualifier = qualifier;
- assertEquals(expectedQualifier, resultedQualifier);
+ assertEquals(resultedQualifier, expectedQualifier);
// Test removal from a badly suffixed qualifier
byte[] badlySuffixedQualifier = com.google.common.primitives.Bytes.concat(qualifier, Bytes.toBytes("BAD"));
@@ -219,12 +219,12 @@ public class TestCellUtils {
byte[] suffixedQualifier = com.google.common.primitives.Bytes.concat(qualifier, shadowCellSuffixToTest);
int originalQualifierLength =
CellUtils.qualifierLengthFromShadowCellQualifier(suffixedQualifier, 0, suffixedQualifier.length);
- assertEquals(qualifier.length, originalQualifierLength);
+ assertEquals(originalQualifierLength, qualifier.length);
// Test passing qualifier without shadow cell suffix
originalQualifierLength =
CellUtils.qualifierLengthFromShadowCellQualifier(qualifier, 0, qualifier.length);
- assertEquals(qualifier.length, originalQualifierLength);
+ assertEquals(originalQualifierLength, qualifier.length);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestColumnIterator.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestColumnIterator.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestColumnIterator.java
index 3cc7185..f4df0b2 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestColumnIterator.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestColumnIterator.java
@@ -30,7 +30,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.Assert.assertEquals;
@Test(groups = "noHBase")
public class TestColumnIterator {
@@ -63,7 +63,7 @@ public class TestColumnIterator {
ImmutableList<Collection<Cell>> groupedColumnsWithoutShadowCells =
TTable.groupCellsByColumnFilteringShadowCells(cells);
Log.info("Column Groups " + groupedColumnsWithoutShadowCells);
- assertEquals("Should be 3 column groups", 3, groupedColumnsWithoutShadowCells.size());
+ assertEquals(groupedColumnsWithoutShadowCells.size(), 3, "Should be 3 column groups");
int group1Counter = 0;
int group2Counter = 0;
int group3Counter = 0;
@@ -89,8 +89,8 @@ public class TestColumnIterator {
}
}
- assertEquals("Group 1 should have 2 elems", 2, group1Counter);
- assertEquals("Group 2 should have 1 elems", 1, group2Counter);
- assertEquals("Group 3 should have 1 elems", 1, group3Counter);
+ assertEquals(group1Counter, 2, "Group 1 should have 2 elems");
+ assertEquals(group2Counter, 1, "Group 2 should have 1 elems");
+ assertEquals(group3Counter, 1, "Group 3 should have 1 elems");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java
index a03c685..6b7eaa5 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestDeletion.java
@@ -27,7 +27,6 @@ import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.AssertJUnit;
import org.testng.ITestContext;
import org.testng.annotations.Test;
@@ -35,6 +34,7 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@Test(groups = "sharedHBase")
@@ -85,17 +85,17 @@ public class TestDeletion extends OmidTestBase {
ResultScanner rs = tt.getScanner(tscan, new Scan());
Map<FamCol, Integer> count = countColsInRows(rs, famColA, famColB);
- AssertJUnit.assertEquals("ColA count should be equal to rowsWritten", rowsWritten, (int) count.get(famColA));
- AssertJUnit.assertEquals("ColB count should be equal to rowsWritten", rowsWritten, (int) count.get(famColB));
+ assertEquals((int) count.get(famColA), rowsWritten, "ColA count should be equal to rowsWritten");
+ assertEquals((int) count.get(famColB), rowsWritten, "ColB count should be equal to rowsWritten");
tm.commit(t2);
tscan = tm.begin();
rs = tt.getScanner(tscan, new Scan());
count = countColsInRows(rs, famColA, famColB);
- AssertJUnit
- .assertEquals("ColA count should be equal to rowsWritten - 1", (rowsWritten - 1), (int) count.get(famColA));
- AssertJUnit.assertEquals("ColB count should be equal to rowsWritten", rowsWritten, (int) count.get(famColB));
+ assertEquals((int) count.get(famColA), (rowsWritten - 1), "ColA count should be equal to rowsWritten - 1");
+ assertEquals((int) count.get(famColB), rowsWritten, "ColB count should be equal to rowsWritten");
+
}
@Test
@@ -123,17 +123,17 @@ public class TestDeletion extends OmidTestBase {
ResultScanner rs = tt.getScanner(tscan, new Scan());
Map<FamCol, Integer> count = countColsInRows(rs, famColA, famColB);
- AssertJUnit.assertEquals("ColA count should be equal to rowsWritten", rowsWritten, (int) count.get(famColA));
- AssertJUnit.assertEquals("ColB count should be equal to rowsWritten", rowsWritten, (int) count.get(famColB));
+ assertEquals((int) count.get(famColA), rowsWritten, "ColA count should be equal to rowsWritten");
+ assertEquals((int) count.get(famColB), rowsWritten, "ColB count should be equal to rowsWritten");
tm.commit(t2);
tscan = tm.begin();
rs = tt.getScanner(tscan, new Scan());
count = countColsInRows(rs, famColA, famColB);
- AssertJUnit
- .assertEquals("ColA count should be equal to rowsWritten - 1", (rowsWritten - 1), (int) count.get(famColA));
- AssertJUnit.assertEquals("ColB count should be equal to rowsWritten", rowsWritten, (int) count.get(famColB));
+ assertEquals((int) count.get(famColA), (rowsWritten - 1), "ColA count should be equal to rowsWritten - 1");
+ assertEquals((int) count.get(famColB), rowsWritten, "ColB count should be equal to rowsWritten");
+
}
/**
@@ -164,8 +164,8 @@ public class TestDeletion extends OmidTestBase {
ResultScanner rs = tt.getScanner(tscan, new Scan());
Map<FamCol, Integer> count = countColsInRows(rs, famColA, famColB);
- AssertJUnit.assertEquals("ColA count should be equal to rowsWritten", rowsWritten, (int) count.get(famColA));
- AssertJUnit.assertEquals("ColB count should be equal to rowsWritten", rowsWritten, (int) count.get(famColB));
+ assertEquals((int) count.get(famColA), rowsWritten, "ColA count should be equal to rowsWritten");
+ assertEquals((int) count.get(famColB), rowsWritten, "ColB count should be equal to rowsWritten");
tm.commit(t2);
tscan = tm.begin();
@@ -173,9 +173,9 @@ public class TestDeletion extends OmidTestBase {
count = countColsInRows(rs, famColA, famColB);
- AssertJUnit
- .assertEquals("ColA count should be equal to rowsWritten - 1", (rowsWritten - 1), (int) count.get(famColA));
- AssertJUnit.assertEquals("ColB count should be equal to rowsWritten", rowsWritten, (int) count.get(famColB));
+ assertEquals((int) count.get(famColA), (rowsWritten - 1), "ColA count should be equal to rowsWritten - 1");
+ assertEquals((int) count.get(famColB), rowsWritten, "ColB count should be equal to rowsWritten");
+
}
@Test
@@ -201,8 +201,7 @@ public class TestDeletion extends OmidTestBase {
ResultScanner rs = tt.getScanner(tscan, new Scan());
int rowsRead = countRows(rs);
- AssertJUnit.assertTrue("Expected " + rowsWritten + " rows but " + rowsRead + " found",
- rowsRead == rowsWritten);
+ assertTrue(rowsRead == rowsWritten, "Expected " + rowsWritten + " rows but " + rowsRead + " found");
tm.commit(t2);
@@ -210,8 +209,7 @@ public class TestDeletion extends OmidTestBase {
rs = tt.getScanner(tscan, new Scan());
rowsRead = countRows(rs);
- AssertJUnit.assertTrue("Expected " + (rowsWritten - 1) + " rows but " + rowsRead + " found",
- rowsRead == (rowsWritten - 1));
+ assertTrue(rowsRead == (rowsWritten - 1), "Expected " + (rowsWritten - 1) + " rows but " + rowsRead + " found");
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java
index 59853d2..32288b5 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestFilters.java
@@ -19,8 +19,6 @@ package org.apache.omid.transaction;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
-import org.apache.omid.committable.CommitTable;
-import org.apache.omid.metrics.NullMetricsProvider;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -32,6 +30,8 @@ import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.ValueFilter;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.committable.CommitTable;
+import org.apache.omid.metrics.NullMetricsProvider;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.testng.ITestContext;
@@ -40,8 +40,8 @@ import org.testng.annotations.Test;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.spy;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNull;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
/**
* Tests to verify that Get and Scan filters still work with transactions tables
@@ -68,6 +68,7 @@ public class TestFilters extends OmidTestBase {
}
private void testGet(ITestContext context, Filter f) throws Exception {
+
CommitTable.Client commitTableClient = spy(getCommitTable(context).getClient());
HBaseOmidClientConfiguration hbaseOmidClientConf = new HBaseOmidClientConfiguration();
@@ -89,19 +90,20 @@ public class TestFilters extends OmidTestBase {
g.setFilter(f);
Result r = table.get(t, g);
- assertEquals("should exist in result", 1, r.getColumnCells(family, col1).size());
- assertEquals("shouldn't exist in result", 0, r.getColumnCells(family, col2).size());
+ assertEquals(r.getColumnCells(family, col1).size(), 1, "should exist in result");
+ assertEquals(r.getColumnCells(family, col2).size(), 0 , "shouldn't exist in result");
g = new Get(row2);
g.setFilter(f);
r = table.get(t, g);
- assertEquals("should exist in result", 1, r.getColumnCells(family, col1).size());
- assertEquals("shouldn't exist in result", 0, r.getColumnCells(family, col2).size());
+ assertEquals(r.getColumnCells(family, col1).size(), 1, "should exist in result");
+ assertEquals(r.getColumnCells(family, col2).size(), 0, "shouldn't exist in result");
g = new Get(row3);
g.setFilter(f);
r = table.get(t, g);
- assertEquals("shouldn't exist in result", 0, r.getColumnCells(family, col2).size());
+ assertEquals(r.getColumnCells(family, col2).size(), 0, "shouldn't exist in result");
+
}
@Test(timeOut = 60_000)
@@ -115,6 +117,7 @@ public class TestFilters extends OmidTestBase {
}
private void testScan(ITestContext context, Filter f) throws Exception {
+
CommitTable.Client commitTableClient = spy(getCommitTable(context).getClient());
HBaseOmidClientConfiguration hbaseOmidClientConf = new HBaseOmidClientConfiguration();
@@ -136,17 +139,17 @@ public class TestFilters extends OmidTestBase {
ResultScanner rs = table.getScanner(t, s);
Result r = rs.next();
- assertEquals("should exist in result", 1, r.getColumnCells(family, col1).size());
- assertEquals("shouldn't exist in result", 0, r.getColumnCells(family, col2).size());
+ assertEquals(r.getColumnCells(family, col1).size(), 1, "should exist in result");
+ assertEquals(r.getColumnCells(family, col2).size(), 0, "shouldn't exist in result");
r = rs.next();
- assertEquals("should exist in result", 1, r.getColumnCells(family, col1).size());
- assertEquals("shouldn't exist in result", 0, r.getColumnCells(family, col2).size());
+ assertEquals(r.getColumnCells(family, col1).size(), 1, "should exist in result");
+ assertEquals(r.getColumnCells(family, col2).size(), 0, "shouldn't exist in result");
r = rs.next();
- assertNull("Last row shouldn't exist", r);
- }
+ assertNull(r, "Last row shouldn't exist");
+ }
private void writeRows(TTable table, TransactionManager tm, PostCommitActions postCommitter)
throws Exception {
@@ -188,4 +191,5 @@ public class TestFilters extends OmidTestBase {
// Expected, see comment above
}
}
+
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java
index 87410bd..c349657 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionClient.java
@@ -40,9 +40,9 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
@Test(groups = "sharedHBase")
public class TestHBaseTransactionClient extends OmidTestBase {
@@ -83,9 +83,9 @@ public class TestHBaseTransactionClient extends OmidTestBase {
HBaseCellId hBaseCellId3 = new HBaseCellId(htable, row2, family, qualifier, t3.getStartTimestamp());
HBaseTransactionClient hbaseTm = (HBaseTransactionClient) newTransactionManager(context);
- assertTrue("row1 should be committed", hbaseTm.isCommitted(hBaseCellId1));
- assertFalse("row2 should not be committed for kv2", hbaseTm.isCommitted(hBaseCellId2));
- assertTrue("row2 should be committed for kv3", hbaseTm.isCommitted(hBaseCellId3));
+ assertTrue(hbaseTm.isCommitted(hBaseCellId1), "row1 should be committed");
+ assertFalse(hbaseTm.isCommitted(hBaseCellId2), "row2 should not be committed for kv2");
+ assertTrue(hbaseTm.isCommitted(hBaseCellId3), "row2 should be committed for kv3");
}
@Test(timeOut = 30_000)
@@ -110,24 +110,16 @@ public class TestHBaseTransactionClient extends OmidTestBase {
// Do nothing
}
- assertTrue("Cell should be there",
- CellUtils.hasCell(row1,
- family,
- qualifier,
- t1.getStartTimestamp(),
- new TTableCellGetterAdapter(table)));
- assertFalse("Shadow cell should not be there",
- CellUtils.hasShadowCell(row1,
- family,
- qualifier,
- t1.getStartTimestamp(),
- new TTableCellGetterAdapter(table)));
+ assertTrue(CellUtils.hasCell(row1, family, qualifier, t1.getStartTimestamp(), new TTableCellGetterAdapter(table)),
+ "Cell should be there");
+ assertFalse(CellUtils.hasShadowCell(row1, family, qualifier, t1.getStartTimestamp(), new TTableCellGetterAdapter(table)),
+ "Shadow cell should not be there");
HTable htable = new HTable(hbaseConf, TEST_TABLE);
HBaseCellId hBaseCellId = new HBaseCellId(htable, row1, family, qualifier, t1.getStartTimestamp());
HBaseTransactionClient hbaseTm = (HBaseTransactionClient) newTransactionManager(context);
- assertTrue("row1 should be committed", hbaseTm.isCommitted(hBaseCellId));
+ assertTrue(hbaseTm.isCommitted(hBaseCellId), "row1 should be committed");
}
@Test(timeOut = 30_000)
@@ -159,7 +151,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
assertTrue(optionalCT.isPresent());
CommitTimestamp ct = optionalCT.get();
assertFalse(ct.isValid());
- assertEquals(CommitTable.INVALID_TRANSACTION_MARKER, ct.getValue());
+ assertEquals(ct.getValue(), CommitTable.INVALID_TRANSACTION_MARKER);
assertTrue(ct.getLocation().compareTo(COMMIT_TABLE) == 0);
// Finally test that we get the right commit timestamp for a committed tx
@@ -178,7 +170,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
assertTrue(optionalCT.isPresent());
ct = optionalCT.get();
assertTrue(ct.isValid());
- assertEquals(tx2.getCommitTimestamp(), ct.getValue());
+ assertEquals(ct.getValue(), tx2.getCommitTimestamp());
assertTrue(ct.getLocation().compareTo(COMMIT_TABLE) == 0);
}
}
@@ -212,7 +204,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
assertTrue(optionalCT.isPresent());
CommitTimestamp ct = optionalCT.get();
assertTrue(ct.isValid());
- assertEquals(tx1.getCommitTimestamp(), ct.getValue());
+ assertEquals(ct.getValue(), tx1.getCommitTimestamp());
assertTrue(ct.getLocation().compareTo(SHADOW_CELL) == 0);
}
@@ -277,7 +269,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
ctLocator);
assertTrue(ct.isValid());
long expectedCommitTS = tx1.getStartTimestamp() + 1;
- assertEquals(expectedCommitTS, ct.getValue());
+ assertEquals(ct.getValue(), expectedCommitTS);
assertTrue(ct.getLocation().compareTo(COMMIT_TABLE) == 0);
}
@@ -306,7 +298,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
CommitTimestamp ct = tm.locateCellCommitTimestamp(tx1.getStartTimestamp(), tm.tsoClient.getEpoch(),
ctLocator);
assertTrue(ct.isValid());
- assertEquals(tx1.getCommitTimestamp(), ct.getValue());
+ assertEquals(ct.getValue(), tx1.getCommitTimestamp());
assertTrue(ct.getLocation().compareTo(SHADOW_CELL) == 0);
}
@@ -346,7 +338,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
// Fake the current epoch to simulate a newer TSO
CommitTimestamp ct = tm.locateCellCommitTimestamp(tx1.getStartTimestamp(), CURRENT_EPOCH_FAKE, ctLocator);
assertFalse(ct.isValid());
- assertEquals(CommitTable.INVALID_TRANSACTION_MARKER, ct.getValue());
+ assertEquals(ct.getValue(), CommitTable.INVALID_TRANSACTION_MARKER);
assertTrue(ct.getLocation().compareTo(COMMIT_TABLE) == 0);
}
}
@@ -392,7 +384,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
CommitTimestamp ct = tm.locateCellCommitTimestamp(tx1.getStartTimestamp(), tm.tsoClient.getEpoch(),
ctLocator);
assertTrue(ct.isValid());
- assertEquals(tx1.getCommitTimestamp(), ct.getValue());
+ assertEquals(ct.getValue(), tx1.getCommitTimestamp());
assertTrue(ct.getLocation().compareTo(COMMIT_TABLE) == 0);
}
@@ -430,7 +422,7 @@ public class TestHBaseTransactionClient extends OmidTestBase {
CommitTimestamp ct = tm.locateCellCommitTimestamp(tx1.getStartTimestamp(), tm.tsoClient.getEpoch(),
ctLocator);
assertTrue(ct.isValid());
- assertEquals(tx1.getCommitTimestamp(), ct.getValue());
+ assertEquals(ct.getValue(), tx1.getCommitTimestamp());
assertTrue(ct.getLocation().compareTo(SHADOW_CELL) == 0);
}
@@ -457,9 +449,10 @@ public class TestHBaseTransactionClient extends OmidTestBase {
Maps.<Long, Long>newHashMap());
CommitTimestamp ct = tm.locateCellCommitTimestamp(CELL_TS, tm.tsoClient.getEpoch(), ctLocator);
assertTrue(ct.isValid());
- assertEquals(-1L, ct.getValue());
+ assertEquals(ct.getValue(), -1L);
assertTrue(ct.getLocation().compareTo(NOT_PRESENT) == 0);
}
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java
index 61cafba..2c48860 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestReadPath.java
@@ -30,9 +30,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
@Test(groups = "sharedHBase")
public class TestReadPath extends OmidTestBase {
@@ -59,7 +59,7 @@ public class TestReadPath extends OmidTestBase {
Get get = new Get(row);
Result result = table.get(t2, get);
- assertFalse("Should be unable to read column", result.containsColumn(family, col));
+ assertFalse(result.containsColumn(family, col), "Should be unable to read column");
}
@Test
@@ -89,9 +89,9 @@ public class TestReadPath extends OmidTestBase {
Get get = new Get(row);
Result result = table.get(t, get);
Cell cell = result.getColumnLatestCell(family, col);
- assertNotNull("KeyValue is null", cell);
+ assertNotNull(cell, "KeyValue is null");
byte[] value = CellUtil.cloneValue(cell);
- assertTrue("Read data doesn't match", Arrays.equals(data, value));
+ assertTrue(Arrays.equals(data, value), "Read data doesn't match");
tm.commit(t);
table.close();
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java
index 3ac86a4..87ed23c 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestSingleColumnFamily.java
@@ -27,12 +27,12 @@ import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertTrue;
@Test(groups = "sharedHBase")
public class TestSingleColumnFamily extends OmidTestBase {
- private static final Logger LOG = LoggerFactory.getLogger(TestSingleColumnFamily.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TestSingleColumnFamily.class);
@Test
public void testSingleColumnFamily(ITestContext context) throws Exception {
@@ -59,9 +59,7 @@ public class TestSingleColumnFamily extends OmidTestBase {
LOG.info("RES:" + tmp1 + ";" + tmp2);
count++;
}
- assertTrue("Can't see puts. I should see "
- + num + " but I see " + count
- , num == count);
+ assertTrue(num == count, "Can't see puts. I should see " + num + " but I see " + count);
tm.commit(t);
t = tm.begin();
@@ -94,12 +92,9 @@ public class TestSingleColumnFamily extends OmidTestBase {
LOG.debug("stop");
}
}
- assertTrue("Can't see puts. I should see "
- + num + " but I see " + count
- , num == count);
- assertTrue("Half of rows should equal row id, half not ("
- + modified + ", " + notmodified + ")"
- , modified == notmodified && notmodified == (num / 2));
+ assertTrue(num == count, "Can't see puts. I should see " + num + " but I see " + count);
+ assertTrue(modified == notmodified && notmodified == (num / 2),
+ "Half of rows should equal row id, half not (" + modified + ", " + notmodified + ")");
tm.commit(t);
LOG.info("End commiting");
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
index 1d95c06..c3f85f2 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
@@ -18,15 +18,15 @@
package org.apache.omid.transaction;
import com.google.common.util.concurrent.SettableFuture;
-import org.apache.omid.tso.client.AbortException;
-import org.apache.omid.tso.client.ForwardingTSOFuture;
-import org.apache.omid.tso.client.TSOClient;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.omid.tso.client.AbortException;
+import org.apache.omid.tso.client.ForwardingTSOFuture;
+import org.apache.omid.tso.client.TSOClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
@@ -36,7 +36,7 @@ import static org.mockito.Matchers.anySetOf;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.Assert.assertEquals;
@Test(groups = "sharedHBase")
public class TestTransactionCleanup extends OmidTestBase {
@@ -104,15 +104,14 @@ public class TestTransactionCleanup extends OmidTestBase {
ResultScanner resultScanner = txTable.getHTable().getScanner(scan);
int resultCount = 0;
for (Result result : resultScanner) {
- assertEquals(2, result.size()); // Size == 2, including the put and delete from cleanup
+ assertEquals(result.size(), 2); // Size == 2, including the put and delete from cleanup
LOG.trace("Result {}", result);
// The last element of the qualifier should have the Delete marker
byte encodedType = result.getColumnLatestCell(family, qual).getTypeByte();
- assertEquals(KeyValue.Type.Delete,
- KeyValue.Type.codeToType(encodedType));
+ assertEquals(KeyValue.Type.codeToType(encodedType), KeyValue.Type.Delete);
resultCount++;
}
- assertEquals(ROWS_MODIFIED, resultCount);
+ assertEquals(resultCount, ROWS_MODIFIED);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java
index 4cf2d38..a776a71 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionConflict.java
@@ -30,19 +30,18 @@ import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
@Test(groups = "sharedHBase")
public class TestTransactionConflict extends OmidTestBase {
private static final Logger LOG = LoggerFactory.getLogger(TestTransactionConflict.class);
-
@Test
public void runTestWriteWriteConflict(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
@@ -72,7 +71,7 @@ public class TestTransactionConflict extends OmidTestBase {
try {
tm.commit(t1);
- Assert.fail("Transaction should not commit successfully");
+ fail("Transaction should not commit successfully");
} catch (RollbackException e) {
}
}
@@ -132,11 +131,11 @@ public class TestTransactionConflict extends OmidTestBase {
boolean aborted = false;
try {
tm.commit(t1);
- assertTrue("Transaction commited successfully", false);
+ fail("Transaction commited successfully");
} catch (RollbackException e) {
aborted = true;
}
- assertTrue("Transaction didn't raise exception", aborted);
+ assertTrue(aborted, "Transaction didn't raise exception");
ResultScanner rs = tt2.getHTable().getScanner(fam, col);
@@ -145,7 +144,7 @@ public class TestTransactionConflict extends OmidTestBase {
while ((r = rs.next()) != null) {
count += r.size();
}
- assertEquals("Should have cell", 1, count);
+ assertEquals(count, 1, "Should have cell");
}
@Test
@@ -172,111 +171,107 @@ public class TestTransactionConflict extends OmidTestBase {
Get g = new Get(row).setMaxVersions();
g.addColumn(fam, col);
Result r = tt.getHTable().get(g);
- assertEquals("Unexpected size for read.", 1, r.size());
- assertTrue("Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)),
- Bytes.equals(data1, r.getValue(fam, col)));
+ assertEquals(r.size(), 1, "Unexpected size for read.");
+ assertTrue(Bytes.equals(data1, r.getValue(fam, col)),
+ "Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)));
Put p2 = new Put(row);
p2.add(fam, col, data2);
tt.put(t2, p2);
r = tt.getHTable().get(g);
- assertEquals("Unexpected size for read.", 2, r.size());
+ assertEquals(r.size(), 2, "Unexpected size for read.");
r = tt.get(t2, g);
- assertEquals("Unexpected size for read.", 1, r.size());
- assertTrue("Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)),
- Bytes.equals(data2, r.getValue(fam, col)));
+ assertEquals(r.size(),1, "Unexpected size for read.");
+ assertTrue(Bytes.equals(data2, r.getValue(fam, col)),
+ "Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)));
tm.commit(t1);
boolean aborted = false;
try {
tm.commit(t2);
- assertTrue("Transaction commited successfully", false);
+ fail("Transaction commited successfully");
} catch (RollbackException e) {
aborted = true;
}
- assertTrue("Transaction didn't raise exception", aborted);
+ assertTrue(aborted, "Transaction didn't raise exception");
r = tt.getHTable().get(g);
- assertEquals("Unexpected size for read.", 1, r.size());
- assertTrue("Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)),
- Bytes.equals(data1, r.getValue(fam, col)));
+ assertEquals(r.size(), 1, "Unexpected size for read.");
+ assertTrue(Bytes.equals(data1, r.getValue(fam, col)),
+ "Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)));
}
@Test
public void testCleanupWithDeleteRow(ITestContext context) throws Exception {
- try {
- TransactionManager tm = newTransactionManager(context);
- TTable tt = new TTable(hbaseConf, TEST_TABLE);
- Transaction t1 = tm.begin();
- LOG.info("Transaction created " + t1);
+ TransactionManager tm = newTransactionManager(context);
+ TTable tt = new TTable(hbaseConf, TEST_TABLE);
+
+ Transaction t1 = tm.begin();
+ LOG.info("Transaction created " + t1);
- int rowcount = 10;
- int count = 0;
+ int rowcount = 10;
+ int count = 0;
- byte[] fam = Bytes.toBytes(TEST_FAMILY);
- byte[] col = Bytes.toBytes("testdata");
- byte[] data1 = Bytes.toBytes("testWrite-1");
- byte[] data2 = Bytes.toBytes("testWrite-2");
+ byte[] fam = Bytes.toBytes(TEST_FAMILY);
+ byte[] col = Bytes.toBytes("testdata");
+ byte[] data1 = Bytes.toBytes("testWrite-1");
+ byte[] data2 = Bytes.toBytes("testWrite-2");
- byte[] modrow = Bytes.toBytes("test-del" + 3);
- for (int i = 0; i < rowcount; i++) {
- byte[] row = Bytes.toBytes("test-del" + i);
+ byte[] modrow = Bytes.toBytes("test-del" + 3);
+ for (int i = 0; i < rowcount; i++) {
+ byte[] row = Bytes.toBytes("test-del" + i);
- Put p = new Put(row);
- p.add(fam, col, data1);
- tt.put(t1, p);
- }
- tm.commit(t1);
+ Put p = new Put(row);
+ p.add(fam, col, data1);
+ tt.put(t1, p);
+ }
+ tm.commit(t1);
+
+ Transaction t2 = tm.begin();
+ LOG.info("Transaction created " + t2);
+ Delete d = new Delete(modrow);
+ tt.delete(t2, d);
+
+ ResultScanner rs = tt.getScanner(t2, new Scan());
+ Result r = rs.next();
+ count = 0;
+ while (r != null) {
+ count++;
+ LOG.trace("row: " + Bytes.toString(r.getRow()) + " count: " + count);
+ r = rs.next();
+ }
+ assertEquals(count, rowcount - 1, "Wrong count");
+
+ Transaction t3 = tm.begin();
+ LOG.info("Transaction created " + t3);
+ Put p = new Put(modrow);
+ p.add(fam, col, data2);
+ tt.put(t3, p);
+
+ tm.commit(t3);
- Transaction t2 = tm.begin();
- LOG.info("Transaction created " + t2);
- Delete d = new Delete(modrow);
- tt.delete(t2, d);
-
- ResultScanner rs = tt.getScanner(t2, new Scan());
- Result r = rs.next();
- count = 0;
- while (r != null) {
- count++;
- LOG.trace("row: " + Bytes.toString(r.getRow()) + " count: " + count);
- r = rs.next();
- }
- assertEquals("Wrong count", rowcount - 1, count);
-
- Transaction t3 = tm.begin();
- LOG.info("Transaction created " + t3);
- Put p = new Put(modrow);
- p.add(fam, col, data2);
- tt.put(t3, p);
-
- tm.commit(t3);
-
- boolean aborted = false;
- try {
- tm.commit(t2);
- assertTrue("Didn't abort", false);
- } catch (RollbackException e) {
- aborted = true;
- }
- assertTrue("Didn't raise exception", aborted);
-
- Transaction tscan = tm.begin();
- rs = tt.getScanner(tscan, new Scan());
+ boolean aborted = false;
+ try {
+ tm.commit(t2);
+ fail("Didn't abort");
+ } catch (RollbackException e) {
+ aborted = true;
+ }
+ assertTrue(aborted, "Didn't raise exception");
+
+ Transaction tscan = tm.begin();
+ rs = tt.getScanner(tscan, new Scan());
+ r = rs.next();
+ count = 0;
+ while (r != null) {
+ count++;
r = rs.next();
- count = 0;
- while (r != null) {
- count++;
- r = rs.next();
- }
- assertEquals("Wrong count", rowcount, count);
-
- } catch (Exception e) {
- LOG.error("Exception occurred", e);
- throw e;
}
+ assertEquals(count, rowcount, "Wrong count");
+
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java
index bfd8b70..16cbea4 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestUpdateScan.java
@@ -34,8 +34,8 @@ import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
@Test(groups = "sharedHBase")
public class TestUpdateScan extends OmidTestBase {
@@ -67,9 +67,7 @@ public class TestUpdateScan extends OmidTestBase {
int tmp = Bytes.toInt(r.getValue(Bytes.toBytes(TEST_FAMILY),
Bytes.toBytes(TEST_COL)));
LOG.info("Result:" + tmp);
- assertTrue("Bad value, should be "
- + startKeyValue + " but is " + tmp
- , tmp == startKeyValue);
+ assertTrue(tmp == startKeyValue, "Bad value, should be " + startKeyValue + " but is " + tmp);
} else {
Assert.fail("Bad result");
}
@@ -98,7 +96,7 @@ public class TestUpdateScan extends OmidTestBase {
LOG.info("Result: " + iTmp);
count++;
}
- assertEquals("Count is wrong", 1, count);
+ assertEquals(count, 1, "Count is wrong");
LOG.info("Rows found " + count);
tm.commit(t);
table.close();
@@ -136,8 +134,7 @@ public class TestUpdateScan extends OmidTestBase {
LOG.info("Result: " + iTmp);
count++;
}
- assertTrue("Count should be " + lInts.length + " but is " + count,
- count == lInts.length);
+ assertTrue(count == lInts.length, "Count should be " + lInts.length + " but is " + count);
LOG.info("Rows found " + count);
tm.commit(t);
@@ -151,8 +148,7 @@ public class TestUpdateScan extends OmidTestBase {
LOG.info("Result: " + iTmp);
count++;
}
- assertTrue("Count should be " + lInts.length + " but is " + count,
- count == lInts.length);
+ assertTrue(count == lInts.length, "Count should be " + lInts.length + " but is " + count);
LOG.info("Rows found " + count);
tm.commit(t);
}
@@ -206,8 +202,8 @@ public class TestUpdateScan extends OmidTestBase {
LOG.info("Result: " + iTmp);
count++;
}
- assertTrue("Count should be " + (lIntsA.length * lIntsC.length) + " but is " + count,
- count == lIntsA.length + lIntsC.length);
+ assertTrue(count == lIntsA.length + lIntsC.length,
+ "Count should be " + (lIntsA.length * lIntsC.length) + " but is " + count);
LOG.info("Rows found " + count);
tm.commit(t);
table.close();
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/4323560f/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java
----------------------------------------------------------------------
diff --git a/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java b/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java
index a7ba68c..9493a44 100644
--- a/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java
+++ b/hbase-commit-table/src/test/java/org/apache/omid/committable/hbase/TestHBaseCommitTable.java
@@ -19,11 +19,6 @@ package org.apache.omid.committable.hbase;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
-import org.apache.omid.committable.CommitTable;
-import org.apache.omid.committable.CommitTable.Client;
-import org.apache.omid.committable.CommitTable.CommitTimestamp;
-import org.apache.omid.committable.CommitTable.Writer;
-import org.apache.omid.committable.hbase.HBaseCommitTable.HBaseClient;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -35,6 +30,11 @@ import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.coprocessor.AggregationClient;
import org.apache.hadoop.hbase.client.coprocessor.LongColumnInterpreter;
+import org.apache.omid.committable.CommitTable;
+import org.apache.omid.committable.CommitTable.Client;
+import org.apache.omid.committable.CommitTable.CommitTimestamp;
+import org.apache.omid.committable.CommitTable.Writer;
+import org.apache.omid.committable.hbase.HBaseCommitTable.HBaseClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -47,9 +47,9 @@ import org.testng.annotations.Test;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
public class TestHBaseCommitTable {
@@ -139,14 +139,14 @@ public class TestHBaseCommitTable {
Client client = commitTable.getClient();
// Test that the first time the table is empty
- assertEquals("Rows should be 0!", 0, rowCount(TABLE_NAME, commitTableFamily));
+ assertEquals(rowCount(TABLE_NAME, commitTableFamily), 0, "Rows should be 0!");
// Test the successful creation of 1000 txs in the table
for (int i = 0; i < 1000; i++) {
writer.addCommittedTransaction(i, i + 1);
}
writer.flush();
- assertEquals("Rows should be 1000!", 1000, rowCount(TABLE_NAME, commitTableFamily));
+ assertEquals(rowCount(TABLE_NAME, commitTableFamily), 1000, "Rows should be 1000!");
// Test the we get the right commit timestamps for each previously inserted tx
for (long i = 0; i < 1000; i++) {
@@ -154,9 +154,9 @@ public class TestHBaseCommitTable {
assertTrue(commitTimestamp.isPresent());
assertTrue(commitTimestamp.get().isValid());
long ct = commitTimestamp.get().getValue();
- assertEquals("Commit timestamp should be " + (i + 1), (i + 1), ct);
+ assertEquals(ct, (i + 1), "Commit timestamp should be " + (i + 1));
}
- assertEquals("Rows should be 1000!", 1000, rowCount(TABLE_NAME, commitTableFamily));
+ assertEquals(rowCount(TABLE_NAME, commitTableFamily), 1000, "Rows should be 1000!");
// Test the successful deletion of the 1000 txs
Future<Void> f;
@@ -164,31 +164,31 @@ public class TestHBaseCommitTable {
f = client.completeTransaction(i);
f.get();
}
- assertEquals("Rows should be 0!", 0, rowCount(TABLE_NAME, commitTableFamily));
+ assertEquals(rowCount(TABLE_NAME, commitTableFamily), 0, "Rows should be 0!");
// Test we don't get a commit timestamp for a non-existent transaction id in the table
Optional<CommitTimestamp> commitTimestamp = client.getCommitTimestamp(0).get();
- assertFalse("Commit timestamp should not be present", commitTimestamp.isPresent());
+ assertFalse(commitTimestamp.isPresent(), "Commit timestamp should not be present");
// Test that the first time, the low watermark family in table is empty
- assertEquals("Rows should be 0!", 0, rowCount(TABLE_NAME, lowWatermarkFamily));
+ assertEquals(rowCount(TABLE_NAME, lowWatermarkFamily), 0, "Rows should be 0!");
// Test the unsuccessful read of the low watermark the first time
ListenableFuture<Long> lowWatermarkFuture = client.readLowWatermark();
- assertEquals("Low watermark should be 0", Long.valueOf(0), lowWatermarkFuture.get());
+ assertEquals(lowWatermarkFuture.get(), Long.valueOf(0), "Low watermark should be 0");
// Test the successful update of the low watermark
for (int lowWatermark = 0; lowWatermark < 1000; lowWatermark++) {
writer.updateLowWatermark(lowWatermark);
}
writer.flush();
- assertEquals("Should there be only one row!", 1, rowCount(TABLE_NAME, lowWatermarkFamily));
+ assertEquals(rowCount(TABLE_NAME, lowWatermarkFamily), 1, "Should there be only one row!");
// Test the successful read of the low watermark
lowWatermarkFuture = client.readLowWatermark();
long lowWatermark = lowWatermarkFuture.get();
- assertEquals("Low watermark should be 999", 999, lowWatermark);
- assertEquals("Should there be only one row!", 1, rowCount(TABLE_NAME, lowWatermarkFamily));
+ assertEquals(lowWatermark, 999, "Low watermark should be 999");
+ assertEquals(rowCount(TABLE_NAME, lowWatermarkFamily), 1, "Should there be only one row!");
}
@@ -210,7 +210,7 @@ public class TestHBaseCommitTable {
Client client = commitTable.getClient();
// Test that initially the table is empty
- assertEquals("Rows should be 0!", 0, rowCount(TABLE_NAME, commitTableFamily));
+ assertEquals(rowCount(TABLE_NAME, commitTableFamily), 0, "Rows should be 0!");
// Test that a transaction can be added properly to the commit table
writer.addCommittedTransaction(TX1_ST, TX1_CT);
@@ -219,28 +219,28 @@ public class TestHBaseCommitTable {
assertTrue(commitTimestamp.isPresent());
assertTrue(commitTimestamp.get().isValid());
long ct = commitTimestamp.get().getValue();
- assertEquals("Commit timestamp should be " + TX1_CT, TX1_CT, ct);
+ assertEquals(ct, TX1_CT, "Commit timestamp should be " + TX1_CT);
// Test that a committed transaction cannot be invalidated and
// preserves its commit timestamp after that
boolean wasInvalidated = client.tryInvalidateTransaction(TX1_ST).get();
- assertFalse("Transaction should not be invalidated", wasInvalidated);
+ assertFalse(wasInvalidated, "Transaction should not be invalidated");
commitTimestamp = client.getCommitTimestamp(TX1_ST).get();
assertTrue(commitTimestamp.isPresent());
assertTrue(commitTimestamp.get().isValid());
ct = commitTimestamp.get().getValue();
- assertEquals("Commit timestamp should be " + TX1_CT, TX1_CT, ct);
+ assertEquals(ct, TX1_CT, "Commit timestamp should be " + TX1_CT);
// Test that a non-committed transaction can be invalidated...
wasInvalidated = client.tryInvalidateTransaction(TX2_ST).get();
- assertTrue("Transaction should be invalidated", wasInvalidated);
+ assertTrue(wasInvalidated, "Transaction should be invalidated");
commitTimestamp = client.getCommitTimestamp(TX2_ST).get();
assertTrue(commitTimestamp.isPresent());
assertFalse(commitTimestamp.get().isValid());
ct = commitTimestamp.get().getValue();
- assertEquals("Commit timestamp should be " + CommitTable.INVALID_TRANSACTION_MARKER,
- CommitTable.INVALID_TRANSACTION_MARKER, ct);
+ assertEquals(ct, CommitTable.INVALID_TRANSACTION_MARKER,
+ "Commit timestamp should be " + CommitTable.INVALID_TRANSACTION_MARKER);
// ...and that if it has been already invalidated, it remains
// invalidated when someone tries to commit it
writer.addCommittedTransaction(TX2_ST, TX2_CT);
@@ -249,12 +249,12 @@ public class TestHBaseCommitTable {
assertTrue(commitTimestamp.isPresent());
assertFalse(commitTimestamp.get().isValid());
ct = commitTimestamp.get().getValue();
- assertEquals("Commit timestamp should be " + CommitTable.INVALID_TRANSACTION_MARKER,
- CommitTable.INVALID_TRANSACTION_MARKER, ct);
+ assertEquals(ct, CommitTable.INVALID_TRANSACTION_MARKER,
+ "Commit timestamp should be " + CommitTable.INVALID_TRANSACTION_MARKER);
// Test that at the end of the test, the commit table contains 2
// elements, which correspond to the two rows added in the test
- assertEquals("Rows should be 2!", 2, rowCount(TABLE_NAME, commitTableFamily));
+ assertEquals(rowCount(TABLE_NAME, commitTableFamily), 2, "Rows should be 2!");
}
@@ -274,7 +274,7 @@ public class TestHBaseCommitTable {
// Completing first transaction should be fine
client.completeTransaction(0).get();
- assertEquals("Rows should be 999!", 999, rowCount(TABLE_NAME, commitTableFamily));
+ assertEquals(rowCount(TABLE_NAME, commitTableFamily), 999, "Rows should be 999!");
// When closing, removing a transaction should throw an EE with an IOException
client.close();
@@ -284,8 +284,8 @@ public class TestHBaseCommitTable {
} catch (ExecutionException e) {
// Expected
}
- assertEquals("Delete queue size should be 0!", 0, client.deleteQueue.size());
- assertEquals("Rows should be 999!", 999, rowCount(TABLE_NAME, commitTableFamily));
+ assertEquals(client.deleteQueue.size(), 0, "Delete queue size should be 0!");
+ assertEquals(rowCount(TABLE_NAME, commitTableFamily), 999, "Rows should be 999!");
}