FilesCollectionReader extends JCasCollectionReader_ImplBase { public static CollectionReaderDescription getDescription(String fileOrDir) throws ResourceInitializationException { return CollectionReaderFactory.createReaderDescription( FilesCollectionReader.class, null, PARAM_ROOT_FILE, fileOrDir); }  static CollectionReaderDescription getDescription(String fileOrDir); static CollectionReader getCollectionReader(String fileOrDir); static CollectionReaderDescription getDescriptionWithView(String dir, String viewName); static CollectionReader getCollectionReaderWithView(String dir, String viewName); static CollectionReaderDescription getDescriptionWithPatterns(
      String dir,
      String viewName,
      String... patterns); static CollectionReader getCollectionReaderWithPatterns(
      String dir,
      String viewName,
      String... patterns); static CollectionReaderDescription getDescriptionWithSuffixes(
      String dir,
      String viewName,
      String... suffixes); static CollectionReader getCollectionReaderWithSuffixes(
      String dir,
      String viewName,
      String... suffixes); @Override void initialize(UimaContext context); void getNext(JCas jCas); Progress[] getProgress(); boolean hasNext(); void close(); static final String PARAM_ROOT_FILE; static final String PARAM_VIEW_NAME; static final String PARAM_LANGUAGE; static final String PARAM_ENCODING; static final String PARAM_SUFFIXES; static final String PARAM_PATTERNS; static final String PARAM_NAME_FILES_FILE_NAMES; static final String PARAM_FILE_NAMES; static final String PARAM_IGNORE_SYSTEM_FILES; }
@Test public void testFilePaths() throws Exception { CollectionReaderDescription desc = FilesCollectionReader.getDescription(this.inputDir); Set<String> pathsSet = new HashSet<String>(); pathsSet.addAll(Arrays.asList(this.paths)); for (JCas jc : new JCasIterable(desc)) { String docPath = ViewUriUtil.getURI(jc).toString(); assertTrue(pathsSet.contains(docPath)); pathsSet.remove(docPath); } assertTrue(pathsSet.isEmpty()); }
@Test public void testSingleFile() throws Exception { String path = "src/test/resources/html/1.html"; CollectionReaderDescription desc = FilesCollectionReader.getDescription(path); List<String> pathsList = new ArrayList<String>(); for (JCas jc : new JCasIterable(desc)) { pathsList.add(ViewUriUtil.getURI(jc).toString().replace('\\', '/')); } assertEquals(1, pathsList.size()); assertTrue(pathsList.get(0).endsWith(path)); }
@Test(expected = UIMAException.class) public void testBadFileException() throws Exception { CollectionReaderFactory.createReader(FilesCollectionReader.getDescription("data/hmtl")); }