コード例 #1
0
 @Test
 public void testHasNextRecordForEmptyFile() throws Exception {
   flatFileRecordReader.close();
   flatFileRecordReader = new FlatFileRecordReader(emptyDataSource);
   flatFileRecordReader.open();
   assertThat(flatFileRecordReader.hasNextRecord()).isFalse();
 }
コード例 #2
0
  @Test
  public void testReadNextRecord() throws Exception {
    StringRecord record = flatFileRecordReader.readNextRecord();
    assertThat(record.getHeader().getNumber()).isEqualTo(1l);
    assertThat(record.getPayload()).isEqualTo("id,user,message");

    record = flatFileRecordReader.readNextRecord();
    assertThat(record.getHeader().getNumber()).isEqualTo(2l);
    assertThat(record.getPayload()).isEqualTo("1,foo,easy batch rocks! #EasyBatch");
  }
コード例 #3
0
 @Before
 public void setUp() throws Exception {
   dataSource = new File(getFileUri("/tweets.csv"));
   emptyDataSource = new File(getFileUri("/empty-file.txt"));
   nonExistingDataSource = new File("./foo.bar");
   flatFileRecordReader = new FlatFileRecordReader(dataSource);
   flatFileRecordReader.open();
 }
コード例 #4
0
 @After
 public void tearDown() throws Exception {
   flatFileRecordReader.close();
 }
コード例 #5
0
 @Test
 public void testTotalRecordsForNonExistingFile() throws Exception {
   flatFileRecordReader.close();
   flatFileRecordReader = new FlatFileRecordReader(nonExistingDataSource);
   assertThat(flatFileRecordReader.getTotalRecords()).isNull();
 }
コード例 #6
0
 @Test
 public void testTotalRecordsForEmptyFile() throws Exception {
   flatFileRecordReader.close();
   flatFileRecordReader = new FlatFileRecordReader(emptyDataSource);
   assertThat(flatFileRecordReader.getTotalRecords()).isEqualTo(0l);
 }
コード例 #7
0
 @Test
 public void testGetDataSourceName() throws Exception {
   assertThat(flatFileRecordReader.getDataSourceName()).isEqualTo(dataSource.getAbsolutePath());
 }
コード例 #8
0
 @Test
 public void testTotalRecords() throws Exception {
   assertThat(flatFileRecordReader.getTotalRecords()).isEqualTo(3l);
 }
コード例 #9
0
 @Test
 public void testHasNextRecord() throws Exception {
   assertThat(flatFileRecordReader.hasNextRecord()).isTrue();
 }