@@ -4761,7 +4761,7 @@ public void testDeleteIllegal() throws IOException {
4761
4761
4762
4762
@ Test
4763
4763
public void testCheckAndMutationIllegal () throws IOException {
4764
- // check and mute 只支持一行操作
4764
+ // checkAndPut 只支持一行操作
4765
4765
try {
4766
4766
Put put = new Put ("key_7" .getBytes ());
4767
4767
put .add ("family1" .getBytes (), "column1_1" .getBytes (), "value2" .getBytes ());
@@ -4772,20 +4772,6 @@ public void testCheckAndMutationIllegal() throws IOException {
4772
4772
Assert .assertTrue (e .getMessage ().contains ("doesn't match the original one" ));
4773
4773
}
4774
4774
4775
- // check and mute 只支持一行操作
4776
- try {
4777
- RowMutations mutations = new RowMutations ("key_7" .getBytes ());
4778
- Put put = new Put ("key_7" .getBytes ());
4779
- put .add ("family1" .getBytes (), "column1_1" .getBytes (), "value2" .getBytes ());
4780
- mutations .add (put );
4781
- boolean ret = hTable .checkAndMutate ("key_8" .getBytes (), "family1" .getBytes (),
4782
- "column1_1" .getBytes (), CompareFilter .CompareOp .EQUAL , "value1" .getBytes (),
4783
- mutations );
4784
- fail ();
4785
- } catch (IOException e ) {
4786
- Assert .assertTrue (e .getMessage ().contains ("mutation row is not equal check row error" ));
4787
- }
4788
-
4789
4775
try {
4790
4776
Put put = new Put ("key_8" .getBytes ());
4791
4777
put .add ("family2" .getBytes (), "column1_1" .getBytes (), "value2" .getBytes ());
@@ -4942,6 +4928,7 @@ public void testCheckAndDelete() throws IOException {
4942
4928
public void testCheckAndMutate () throws IOException {
4943
4929
// Mutate 只支持操作一行数据
4944
4930
String key = "checkAndMutateKey" ;
4931
+ String key1 = "checkAndMutateKey1" ;
4945
4932
String column1 = "checkAndMutateColumn" ;
4946
4933
String column2 = "checkAndMutateColumn2" ;
4947
4934
String value1 = "value1" ;
@@ -5080,6 +5067,36 @@ public void testCheckAndMutate() throws IOException {
5080
5067
get .setMaxVersions (Integer .MAX_VALUE );
5081
5068
r = hTable .get (get );
5082
5069
Assert .assertEquals (10 , r .raw ().length );
5070
+
5071
+ // test different row operations
5072
+ put1 = new Put (key1 .getBytes ());
5073
+ put1 .add (family .getBytes (), column1 .getBytes (), t , value1 .getBytes ());
5074
+ put1 .add (family .getBytes (), column2 .getBytes (), t , value2 .getBytes ());
5075
+
5076
+ put2 = new Put (key1 .getBytes ());
5077
+ put2 .add (family .getBytes (), column1 .getBytes (), t + 3 , value2 .getBytes ());
5078
+ put2 .add (family .getBytes (), column2 .getBytes (), t + 3 , value1 .getBytes ());
5079
+
5080
+ put3 = new Put (key1 .getBytes ());
5081
+ put3 .add (family .getBytes (), column1 .getBytes (), t + 5 , value1 .getBytes ());
5082
+ put3 .add (family .getBytes (), column2 .getBytes (), t + 5 , value2 .getBytes ());
5083
+
5084
+ rowMutations = new RowMutations (key1 .getBytes ());
5085
+ rowMutations .add (put1 );
5086
+ rowMutations .add (put2 );
5087
+ rowMutations .add (put3 );
5088
+ // check specific row in server and execute different row operations
5089
+ assertTrue (hTable .checkAndMutate (key .getBytes (), family .getBytes (), column1 .getBytes (),
5090
+ CompareFilter .CompareOp .EQUAL , value1 .getBytes (), rowMutations ));
5091
+
5092
+ assertTrue (hTable .checkAndMutate (key .getBytes (), family .getBytes (), column2 .getBytes (),
5093
+ CompareFilter .CompareOp .GREATER , value1 .getBytes (), rowMutations ));
5094
+
5095
+ assertFalse (hTable .checkAndMutate (key .getBytes (), family .getBytes (), column1 .getBytes (),
5096
+ CompareFilter .CompareOp .LESS , value1 .getBytes (), rowMutations ));
5097
+
5098
+ assertFalse (hTable .checkAndMutate (key .getBytes (), family .getBytes (), column2 .getBytes (),
5099
+ CompareFilter .CompareOp .GREATER , value2 .getBytes (), rowMutations ));
5083
5100
}
5084
5101
5085
5102
@ Test
@@ -5189,7 +5206,7 @@ public void testCellTTL() throws Exception {
5189
5206
try {
5190
5207
tryPut (hTable , errorPut );
5191
5208
} catch (Exception e ) {
5192
- assertTrue (e .getCause ().getCause (). toString ().contains ("Unknown column 'TTL'" ));
5209
+ assertTrue (e .getCause ().toString ().contains ("Unknown column 'TTL'" ));
5193
5210
}
5194
5211
// test put and get
5195
5212
tryPut (hTable , put1 );
0 commit comments