CorpusDAOCollectionReader extends CasCollectionReader_ImplBase { @Override public void getNext(CAS aCAS) throws IOException, CollectionException { UriAnnotatorPair pair = uriAnnotatorPairsIterator.next(); try { corpusDAO .getDocumentCas(pair.getUri(), pair.getAnnotatorId(), aCAS); } catch (SAXException e) { getLogger().error( String.format("Exception at %s annotated by %s.", pair.getUri(), pair.getAnnotatorId())); e.printStackTrace(); throw new CollectionException(); } addSourceDocumentInformation(aCAS, pair); mCurrentIndex++; }  @Override void typeSystemInit(TypeSystem aTypeSystem); @Override void initialize(UimaContext context); @Override void getNext(CAS aCAS); @Override boolean hasNext(); @Override Progress[] getProgress(); final static String CORPUS_DAO_KEY; static final String SOURCE_DOCUMENT_INFORMATION_TYPE_NAME; static final String URI_FEAT_NAME; static final String ANNOTATOR_ID_FEAT_NAME; }
@Test public void testGetNext() throws CollectionException, IOException, ResourceInitializationException, URISyntaxException, SAXException, ParserConfigurationException { Set<String> sourceUris = new HashSet<String>(); while (reader.hasNext()) { CAS aCAS = CasCreationUtils.createCas(tsd, null, null, null); reader.getNext(aCAS); assertThat(aCAS.getDocumentText(), containsString("д")); String sourceUri = DocumentUtils.getDocumentUri(aCAS); sourceUris.add(sourceUri.substring(sourceUri.length() - 11)); } assertEquals(Sets.newHashSet("1/62007.txt", "1/65801.txt", "5/62007.txt", "5/75788.txt"), sourceUris); }