use of org.apache.camel.Processor in project camel by apache.
the class ExecProducerTest method testOverrideArgs.
/**
* Tests that the args are set literally.
*/
@Test
@DirtiesContext
public void testOverrideArgs() {
final String[] args = { "-version", "classpath:c:/program files/test/" };
producerTemplate.send(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("noinput");
exchange.getIn().setHeader(EXEC_COMMAND_ARGS, Arrays.asList(args));
}
});
List<String> commandArgs = execCommandExecutorMock.lastCommandResult.getCommand().getArgs();
assertEquals(args[0], commandArgs.get(0));
assertEquals(args[1], commandArgs.get(1));
}
use of org.apache.camel.Processor in project camel by apache.
the class ExecProducerTest method testInputLines.
@Test
@DirtiesContext
public void testInputLines() throws IOException {
// String must be convertible to InputStream
final String input = "line1" + LINE_SEPARATOR + "line2";
producerTemplate.send(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(input);
}
});
assertEquals(input, IOUtils.toString(execCommandExecutorMock.lastCommandResult.getCommand().getInput()));
}
use of org.apache.camel.Processor in project camel by apache.
the class ExecProducerTest method testNullInBody.
@Test
@DirtiesContext
public void testNullInBody() throws IOException {
// Null body must also be supported
Exchange e = producerTemplate.send(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(null);
}
});
ExecResult result = e.getIn().getBody(ExecResult.class);
assertNotNull(result);
assertNull(result.getCommand().getInput());
}
use of org.apache.camel.Processor in project camel by apache.
the class ExecProducerTest method testInputLinesNotConvertibleToInputStream.
@Test
@DirtiesContext
public void testInputLinesNotConvertibleToInputStream() throws IOException {
// String must be convertible to InputStream
final Integer notConvertibleToInputStreamBody = new Integer(1);
Exchange e = producerTemplate.send(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(notConvertibleToInputStreamBody);
}
});
ExecResult result = e.getIn().getBody(ExecResult.class);
assertNotNull(result);
assertNull(result.getCommand().getInput());
}
use of org.apache.camel.Processor in project camel by apache.
the class ExecProducerTest method testOverrideWorkingDir.
@Test
@DirtiesContext
public void testOverrideWorkingDir() {
final String workingDir = "c:/program files/test";
producerTemplate.send(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("");
exchange.getIn().setHeader(EXEC_COMMAND_WORKING_DIR, workingDir);
}
});
assertEquals(workingDir, execCommandExecutorMock.lastCommandResult.getCommand().getWorkingDir());
}
Aggregations