CombinationReader extends CasCollectionReader_ImplBase { public static File descriptionToFile(CollectionReaderDescription desc) throws IOException, SAXException { File tempFile = File.createTempFile("combReader", "desc"); FileWriterWithEncoding writer = new FileWriterWithEncoding(tempFile, "UTF-8"); desc.toXML(writer); return tempFile; }  @Override void initialize(UimaContext context); @Override void getNext(CAS aCAS); @Override boolean hasNext(); @Override Progress[] getProgress(); static File descriptionToFile(CollectionReaderDescription desc); static final String PARAM_READERS; }
@Test public void combinationReaderTest() throws Exception { List<File> readerFiles = new ArrayList<>(); readerFiles.add( CombinationReader.descriptionToFile(CollectionReaderFactory.createReaderDescription( TextReader.class, TextReader.PARAM_SOURCE_LOCATION, "src/test/resources/texts/a/*.txt")) ); readerFiles.add( CombinationReader.descriptionToFile(CollectionReaderFactory.createReaderDescription( TextReader.class, TextReader.PARAM_SOURCE_LOCATION, "src/test/resources/texts/b/*.txt")) ); CollectionReaderDescription combinationReader = createReaderDescription( CombinationReader.class, CombinationReader.PARAM_READERS, readerFiles.toArray() ); int i = 0; for (JCas jcas : new JCasIterable(combinationReader)) { i++; System.out.println(jcas.getDocumentText()); } assertEquals(4, i); }