@@ -4761,7 +4761,7 @@ public void testDeleteIllegal() throws IOException {
47614761
47624762 @ Test
47634763 public void testCheckAndMutationIllegal () throws IOException {
4764- // check and mute 只支持一行操作
4764+ // checkAndPut 只支持一行操作
47654765 try {
47664766 Put put = new Put ("key_7" .getBytes ());
47674767 put .add ("family1" .getBytes (), "column1_1" .getBytes (), "value2" .getBytes ());
@@ -4772,20 +4772,6 @@ public void testCheckAndMutationIllegal() throws IOException {
47724772 Assert .assertTrue (e .getMessage ().contains ("doesn't match the original one" ));
47734773 }
47744774
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-
47894775 try {
47904776 Put put = new Put ("key_8" .getBytes ());
47914777 put .add ("family2" .getBytes (), "column1_1" .getBytes (), "value2" .getBytes ());
@@ -4942,6 +4928,7 @@ public void testCheckAndDelete() throws IOException {
49424928 public void testCheckAndMutate () throws IOException {
49434929 // Mutate 只支持操作一行数据
49444930 String key = "checkAndMutateKey" ;
4931+ String key1 = "checkAndMutateKey1" ;
49454932 String column1 = "checkAndMutateColumn" ;
49464933 String column2 = "checkAndMutateColumn2" ;
49474934 String value1 = "value1" ;
@@ -5080,6 +5067,36 @@ public void testCheckAndMutate() throws IOException {
50805067 get .setMaxVersions (Integer .MAX_VALUE );
50815068 r = hTable .get (get );
50825069 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 ));
50835100 }
50845101
50855102 @ Test
@@ -5189,7 +5206,7 @@ public void testCellTTL() throws Exception {
51895206 try {
51905207 tryPut (hTable , errorPut );
51915208 } catch (Exception e ) {
5192- assertTrue (e .getCause ().getCause (). toString ().contains ("Unknown column 'TTL'" ));
5209+ assertTrue (e .getCause ().toString ().contains ("Unknown column 'TTL'" ));
51935210 }
51945211 // test put and get
51955212 tryPut (hTable , put1 );
0 commit comments