/** * Creates a composite stage to scan and read a set of Kieker log directories. * * @param configuration configuration for the enclosed filters */ public LogsReaderCompositeStage(final Configuration configuration) { final String[] directoryNames = configuration.getStringArrayProperty(LOG_DIRECTORIES, ":"); final File[] directories = new File[directoryNames.length]; int i = 0; for (final String name : directoryNames) { directories[i++] = new File(name); } this.directoryScannerStage = new DirectoryScannerStage(directories); this.directoryReaderStage = new DirectoryReaderStage(configuration); this.connectPorts(this.directoryScannerStage.getOutputPort(), this.directoryReaderStage.getInputPort()); }
/** * Check whether the scanner produces nothing and terminates. */ @Test public void testEmptyArrayOfDirectories() { final DirectoryScannerStage producer = new DirectoryScannerStage(null); StageTester.test(producer).start(); Assert.assertThat(producer.getOutputPort(), StageTester.producesNothing()); }
/** * Check whether the scanner produces a File handle for each directory. There should be three * directories. However, the sequence can vary depending on the operating system and file system * properties. therefore, we use our own matcher. */ @Test public void testPopulatedArrayOfDirectories() { final DirectoryScannerStage producer = new DirectoryScannerStage(this.directories); StageTester.test(producer).start(); Assert.assertThat(producer.getOutputPort(), new RandomContentMatcher(this.results)); }