28
28
import java .io .IOException ;
29
29
import java .util .ArrayList ;
30
30
import java .util .Arrays ;
31
- import java .util .Collection ;
32
31
import java .util .LinkedList ;
33
32
import java .util .List ;
34
33
import java .util .Map ;
91
90
import org .junit .experimental .categories .Category ;
92
91
import org .junit .runner .RunWith ;
93
92
import org .junit .runners .Parameterized ;
93
+ import org .junit .runners .Parameterized .Parameters ;
94
94
import org .slf4j .Logger ;
95
95
import org .slf4j .LoggerFactory ;
96
96
@@ -115,21 +115,23 @@ public class TestFromClientSide5 extends FromClientSideBase {
115
115
@ ClassRule
116
116
public static final HBaseClassTestRule CLASS_RULE =
117
117
HBaseClassTestRule .forClass (TestFromClientSide5 .class );
118
+
118
119
@ Rule
119
120
public TableNameTestRule name = new TableNameTestRule ();
120
121
121
122
// To keep the child classes happy.
122
123
TestFromClientSide5 () {
123
124
}
124
125
125
- public TestFromClientSide5 (Class registry , int numHedgedReqs ) throws Exception {
126
+ public TestFromClientSide5 (Class <? extends ConnectionRegistry > registry , int numHedgedReqs )
127
+ throws Exception {
126
128
initialize (registry , numHedgedReqs , MultiRowMutationEndpoint .class );
127
129
}
128
130
129
- @ Parameterized . Parameters
130
- public static Collection parameters () {
131
- return Arrays .asList (new Object [][] { { MasterRegistry .class , 1 }, { MasterRegistry . class , 2 },
132
- { ZKConnectionRegistry .class , 1 } });
131
+ @ Parameters ( name = "{index}: registry={0}, numHedgedReqs={1}" )
132
+ public static List < Object []> parameters () {
133
+ return Arrays .asList (new Object [] { MasterRegistry .class , 1 },
134
+ new Object [] { MasterRegistry .class , 2 }, new Object [] { ZKConnectionRegistry . class , 1 });
133
135
}
134
136
135
137
@ AfterClass
@@ -771,10 +773,20 @@ private List<Result> doAppend(final boolean walUsed) throws IOException {
771
773
t .put (put_1 );
772
774
List <Result > results = new LinkedList <>();
773
775
try (ResultScanner scanner = t .getScanner (s )) {
776
+ // get one row(should be row3) from the scanner to make sure that we have send a request to
777
+ // region server, which means we have already set the read point, so later we should not see
778
+ // the new appended values.
779
+ Result r = scanner .next ();
780
+ assertNotNull (r );
781
+ results .add (r );
774
782
t .append (append_1 );
775
783
t .append (append_2 );
776
784
t .append (append_3 );
777
- for (Result r : scanner ) {
785
+ for (;;) {
786
+ r = scanner .next ();
787
+ if (r == null ) {
788
+ break ;
789
+ }
778
790
results .add (r );
779
791
}
780
792
}
@@ -788,11 +800,11 @@ public void testAppendWithoutWAL() throws Exception {
788
800
List <Result > resultsWithWal = doAppend (true );
789
801
List <Result > resultsWithoutWal = doAppend (false );
790
802
assertEquals (resultsWithWal .size (), resultsWithoutWal .size ());
791
- for (int i = 0 ; i != resultsWithWal .size (); ++i ) {
803
+ for (int i = 0 ; i < resultsWithWal .size (); ++i ) {
792
804
Result resultWithWal = resultsWithWal .get (i );
793
805
Result resultWithoutWal = resultsWithoutWal .get (i );
794
806
assertEquals (resultWithWal .rawCells ().length , resultWithoutWal .rawCells ().length );
795
- for (int j = 0 ; j != resultWithWal .rawCells ().length ; ++j ) {
807
+ for (int j = 0 ; j < resultWithWal .rawCells ().length ; ++j ) {
796
808
Cell cellWithWal = resultWithWal .rawCells ()[j ];
797
809
Cell cellWithoutWal = resultWithoutWal .rawCells ()[j ];
798
810
assertArrayEquals (CellUtil .cloneRow (cellWithWal ), CellUtil .cloneRow (cellWithoutWal ));
0 commit comments