@Override public InputStream getFileStream(String path) throws FileBasedHelperException { return this.fileBasedHelper.getFileStream(path); }
@Override public void close() throws IOException { this.fileBasedHelper.close(); }
@Override public void connect() throws FileBasedHelperException { this.fileBasedHelper.connect(); }
@Override public List<String> ls(String path) throws FileBasedHelperException { return this.fileBasedHelper.ls(path); }
@Override public List<String> ls(String path) throws FileBasedHelperException { return this.fileBasedHelper.ls(path); }
public void testReadRecordWithNonEmptyFiles() throws DataRecordException, IOException, FileBasedHelperException { String file1 = "file1.txt"; String file2 = "file2.txt"; String file3 = "file3.txt"; WorkUnitState state = new WorkUnitState(); state.setProp(ConfigurationKeys.SOURCE_FILEBASED_FILES_TO_PULL, Joiner.on(",").join(file1, file2, file3)); FileBasedHelper fsHelper = Mockito.mock(FileBasedHelper.class); Mockito.when(fsHelper.getFileStream(file1)).thenReturn(IOUtils.toInputStream("record1 \n record2")); Mockito.when(fsHelper.getFileStream(file2)).thenReturn(IOUtils.toInputStream("record3 \n record4")); Mockito.when(fsHelper.getFileStream(file3)).thenReturn(IOUtils.toInputStream("record5 \n record6 \n record7")); FileBasedExtractor<String, String> extractor = new DummyFileBasedExtractor<String, String>(state, fsHelper); Assert.assertEquals(getNumRecords(extractor), 7); }
@Override public void connect() throws FileBasedHelperException { this.fileBasedHelper.connect(); }
@Override public void close() throws IOException { this.fileBasedHelper.close(); }
public void testReadRecordWithEmptyFiles() throws DataRecordException, IOException, FileBasedHelperException { String file1 = "file1.txt"; String file2 = "file2.txt"; String file3 = "file3.txt"; WorkUnitState state = new WorkUnitState(); state.setProp(ConfigurationKeys.SOURCE_FILEBASED_FILES_TO_PULL, Joiner.on(",").join(file1, file2, file3)); FileBasedHelper fsHelper = Mockito.mock(FileBasedHelper.class); Mockito.when(fsHelper.getFileStream(file1)).thenReturn(IOUtils.toInputStream("")); Mockito.when(fsHelper.getFileStream(file2)).thenReturn(IOUtils.toInputStream("")); Mockito.when(fsHelper.getFileStream(file3)).thenReturn(IOUtils.toInputStream("")); FileBasedExtractor<String, String> extractor = new DummyFileBasedExtractor<String, String>(state, fsHelper); Assert.assertEquals(getNumRecords(extractor), 0); }
public void testReadRecordWithEmptyAndNonEmptyFiles() throws DataRecordException, IOException, FileBasedHelperException { String file1 = "file1.txt"; String file2 = "file2.txt"; String file3 = "file3.txt"; WorkUnitState state = new WorkUnitState(); state.setProp(ConfigurationKeys.SOURCE_FILEBASED_FILES_TO_PULL, Joiner.on(",").join(file1, file2, file3)); FileBasedHelper fsHelper = Mockito.mock(FileBasedHelper.class); Mockito.when(fsHelper.getFileStream(file1)).thenReturn(IOUtils.toInputStream("record1 \n record2")); Mockito.when(fsHelper.getFileStream(file2)).thenReturn(IOUtils.toInputStream("")); Mockito.when(fsHelper.getFileStream(file3)).thenReturn(IOUtils.toInputStream("record3 \n record4 \n record5")); FileBasedExtractor<String, String> extractor = new DummyFileBasedExtractor<String, String>(state, fsHelper); Assert.assertEquals(getNumRecords(extractor), 5); }
@Override public InputStream getFileStream(String path) throws FileBasedHelperException { return this.fileBasedHelper.getFileStream(path); }