28
28
import org .apache .accumulo .core .data .Key ;
29
29
import org .apache .accumulo .core .data .KeyValue ;
30
30
import org .apache .accumulo .core .data .Value ;
31
- import org .apache .accumulo .core .util .PeekingIterator ;
32
31
import org .apache .hadoop .io .Text ;
33
32
import org .junit .Before ;
34
33
import org .junit .Test ;
35
34
import org .slf4j .Logger ;
36
35
import org .slf4j .LoggerFactory ;
37
36
37
+ import com .google .common .collect .Iterators ;
38
+ import com .google .common .collect .PeekingIterator ;
39
+
38
40
public class ChunkInputStreamTest {
39
41
private static final Logger log = LoggerFactory .getLogger (ChunkInputStream .class );
40
42
private List <Entry <Key ,Value >> data ;
@@ -103,8 +105,7 @@ private static void addData(List<Entry<Key,Value>> data, String row, String cf,
103
105
@ Test
104
106
public void testExceptionOnMultipleSetSourceWithoutClose () throws IOException {
105
107
ChunkInputStream cis = new ChunkInputStream ();
106
- PeekingIterator <Entry <Key ,Value >> pi = new PeekingIterator <>(data .iterator ());
107
- pi = new PeekingIterator <>(data .iterator ());
108
+ PeekingIterator <Entry <Key ,Value >> pi = Iterators .peekingIterator (data .iterator ());
108
109
cis .setSource (pi );
109
110
try {
110
111
cis .setSource (pi );
@@ -118,7 +119,7 @@ public void testExceptionOnMultipleSetSourceWithoutClose() throws IOException {
118
119
@ Test
119
120
public void testExceptionOnGetVisBeforeClose () throws IOException {
120
121
ChunkInputStream cis = new ChunkInputStream ();
121
- PeekingIterator <Entry <Key ,Value >> pi = new PeekingIterator <> (data .iterator ());
122
+ PeekingIterator <Entry <Key ,Value >> pi = Iterators . peekingIterator (data .iterator ());
122
123
123
124
cis .setSource (pi );
124
125
try {
@@ -136,7 +137,7 @@ public void testReadIntoBufferSmallerThanChunks() throws IOException {
136
137
ChunkInputStream cis = new ChunkInputStream ();
137
138
byte [] b = new byte [5 ];
138
139
139
- PeekingIterator <Entry <Key ,Value >> pi = new PeekingIterator <> (data .iterator ());
140
+ PeekingIterator <Entry <Key ,Value >> pi = Iterators . peekingIterator (data .iterator ());
140
141
141
142
cis .setSource (pi );
142
143
int read ;
@@ -188,7 +189,7 @@ public void testReadIntoBufferLargerThanChunks() throws IOException {
188
189
ChunkInputStream cis = new ChunkInputStream ();
189
190
byte [] b = new byte [20 ];
190
191
int read ;
191
- PeekingIterator <Entry <Key ,Value >> pi = new PeekingIterator <> (data .iterator ());
192
+ PeekingIterator <Entry <Key ,Value >> pi = Iterators . peekingIterator (data .iterator ());
192
193
193
194
cis .setSource (pi );
194
195
assertEquals (read = cis .read (b ), 8 );
@@ -247,7 +248,7 @@ public void testBadData() throws IOException {
247
248
ChunkInputStream cis = new ChunkInputStream ();
248
249
byte [] b = new byte [20 ];
249
250
int read ;
250
- PeekingIterator <Entry <Key ,Value >> pi = new PeekingIterator <> (baddata .iterator ());
251
+ PeekingIterator <Entry <Key ,Value >> pi = Iterators . peekingIterator (baddata .iterator ());
251
252
252
253
cis .setSource (pi );
253
254
assumeExceptionOnRead (cis , b );
@@ -293,7 +294,7 @@ public void testBadData() throws IOException {
293
294
294
295
assertFalse (pi .hasNext ());
295
296
296
- pi = new PeekingIterator <> (baddata .iterator ());
297
+ pi = Iterators . peekingIterator (baddata .iterator ());
297
298
cis .setSource (pi );
298
299
assumeExceptionOnClose (cis );
299
300
}
@@ -303,7 +304,7 @@ public void testBadDataWithoutClosing() throws IOException {
303
304
ChunkInputStream cis = new ChunkInputStream ();
304
305
byte [] b = new byte [20 ];
305
306
int read ;
306
- PeekingIterator <Entry <Key ,Value >> pi = new PeekingIterator <> (baddata .iterator ());
307
+ PeekingIterator <Entry <Key ,Value >> pi = Iterators . peekingIterator (baddata .iterator ());
307
308
308
309
cis .setSource (pi );
309
310
assumeExceptionOnRead (cis , b );
@@ -344,7 +345,7 @@ public void testBadDataWithoutClosing() throws IOException {
344
345
345
346
assertFalse (pi .hasNext ());
346
347
347
- pi = new PeekingIterator <> (baddata .iterator ());
348
+ pi = Iterators . peekingIterator (baddata .iterator ());
348
349
cis .setSource (pi );
349
350
assumeExceptionOnClose (cis );
350
351
}
@@ -354,7 +355,7 @@ public void testMultipleChunkSizes() throws IOException {
354
355
ChunkInputStream cis = new ChunkInputStream ();
355
356
byte [] b = new byte [20 ];
356
357
int read ;
357
- PeekingIterator <Entry <Key ,Value >> pi = new PeekingIterator <> (multidata .iterator ());
358
+ PeekingIterator <Entry <Key ,Value >> pi = Iterators . peekingIterator (multidata .iterator ());
358
359
359
360
b = new byte [20 ];
360
361
@@ -381,7 +382,7 @@ public void testMultipleChunkSizes() throws IOException {
381
382
@ Test
382
383
public void testSingleByteRead () throws IOException {
383
384
ChunkInputStream cis = new ChunkInputStream ();
384
- PeekingIterator <Entry <Key ,Value >> pi = new PeekingIterator <> (data .iterator ());
385
+ PeekingIterator <Entry <Key ,Value >> pi = Iterators . peekingIterator (data .iterator ());
385
386
386
387
cis .setSource (pi );
387
388
assertEquals ((byte ) 'a' , (byte ) cis .read ());
0 commit comments