@Test @TailAvailable public void testOS() throws Exception { OSDelegatingFileTailingMessageProducer adapter = new OSDelegatingFileTailingMessageProducer(); adapter.setOptions(TAIL_OPTIONS_FOLLOW_NAME_ALL_LINES); testGuts(adapter, "stdOutReader"); }
@Test @TailAvailable public void canRecalculateCommandWhenFileOrOptionsChanged() throws IOException { File firstFile = File.createTempFile("first", ".txt"); String firstOptions = "-f options"; File secondFile = File.createTempFile("second", ".txt"); String secondOptions = "-f newoptions"; OSDelegatingFileTailingMessageProducer adapter = new OSDelegatingFileTailingMessageProducer(); adapter.setFile(firstFile); adapter.setOptions(firstOptions); adapter.setOutputChannel(new QueueChannel()); adapter.setTailAttemptsDelay(500); adapter.setBeanFactory(mock(BeanFactory.class)); adapter.afterPropertiesSet(); adapter.start(); assertEquals("tail " + firstOptions + " " + firstFile.getAbsolutePath(), adapter.getCommand()); adapter.stop(); adapter.setFile(secondFile); adapter.start(); assertEquals("tail " + firstOptions + " " + secondFile.getAbsolutePath(), adapter.getCommand()); adapter.stop(); adapter.setOptions(secondOptions); adapter.start(); assertEquals("tail " + secondOptions + " " + secondFile.getAbsolutePath(), adapter.getCommand()); adapter.stop(); }
FileTailingMessageProducerSupport adapter; if (this.delay == null && this.end == null && this.reopen == null) { adapter = new OSDelegatingFileTailingMessageProducer(); ((OSDelegatingFileTailingMessageProducer) adapter).setEnableStatusReader(this.enableStatusReader); if (this.nativeOptions != null) {
public class MyApplicationListener implements ApplicationListener<ContextRefreshedEvent> { @Autowired @Qualifier("outputChannel") private SubscribableChannel outputChannel; @Override public void onApplicationEvent(ContextRefreshedEvent event) { OSDelegatingFileTailingMessageProducer tailer = new OSDelegatingFileTailingMessageProducer(); tailer.setOutputChannel(outputChannel); tailer.setFile(new File("/file/to/tail.txt")); tailer.setOptions("-f -n 0"); tailer.afterPropertiesSet(); tailer.start(); } }