无法从 Camel 执行 OS 命令

Unable to execute OS Command from Camel

我正在尝试使用 Camel 的 exec 组件执行 OS 命令。不幸的是,我没有看到执行命令的任何输出。这是我的代码,其中包含从文档中获取的简单执行程序:

public class CamelExampleTest extends CamelTestSupport {

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("direct:startpoint").id("route1") //
                        .to("exec:wc?args=--words /usr/share/dict/words")//
                        .convertBodyTo(String.class) //
                        .process(new Processor() {

                    @Override
                    public void process(Exchange exchng) throws Exception {
                        String body = exchng.getIn().getBody(String.class);
                        System.out.println(body);


                    }
                }).to("mock:endpoint");
            }
        };
    }

    @Test
    public void test() throws InterruptedException {
        System.out.println("running test");
        MockEndpoint resultEndpoint = context.getEndpoint("mock:endpoint", MockEndpoint.class);

    }
 }

我的代码有明显错误吗?

您没有向 direct:startpoint 发送任何内容。

尝试这样的事情:

@Test
public void test() throws InterruptedException {
    System.out.println("running test");
    MockEndpoint resultEndpoint = context.getEndpoint("mock:endpoint", MockEndpoint.class);
    context.createProducerTemplate().sendBody("direct:startpoint","Hello world");
}