我对使用Apache Nifi非常陌生。几天前,我遇到了this问题(涉及自定义nifi处理器的问题)。调试并不能很好地帮助我。因此,我决定按照有关该问题的评论中的建议,探索nifi模拟框架(我应该已经做过,但是没有做过:)。
我试图做的是将单个流文件发送到自定义处理器。为此,我使用建议的here使用MergeContent(使用FlowFile v3版本)和PutFile处理器保存/序列化了实际的流文件。现在,我尝试使用GetFile处理器通过测试中的代码重新读取此文件,如下所示:
import static org.junit.Assert.*;
import java.util.List;
import org.junit.Test;
import org.apache.nifi.util.TestRunners;
import org.apache.nifi.processors.standard.GetFile;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
public class MyCustomProcessorTest {
@Test
public void testOnTrigger() {
TestRunner runner = TestRunners.newTestRunner(new GetFile());
runner.setProperty(GetFile.DIRECTORY, "C:\\Mahesh\\delete\\serialized-flow-files");
runner.setProperty(GetFile.KEEP_SOURCE_FILE, "true");
runner.run(1);
List<MockFlowFile> results = runner.getFlowFilesForRelationship(GetFile.REL_SUCCESS);
System.out.println("done");
}
}
这给了我以下错误:
我应该包括哪些Maven依赖关系以获得此类?我的方法还可以,还是有其他更可取的方法?
答案 0 :(得分:1)
我会再次检查org.apache.nifi:nifi-api:是否在类路径中。
如果使用Maven,我会运行 “ MVN依赖:树”来检查。