use of org.springframework.test.annotation.DirtiesContext in project camel by apache.
the class ExecOutFileTest method testOutFileConvertToString.
@Test
@DirtiesContext
public void testOutFileConvertToString() throws Exception {
Exchange e = sendWithMockedExecutor();
assertEquals(FILE_CONTENT, e.getIn().getBody(String.class));
}
use of org.springframework.test.annotation.DirtiesContext in project camel by apache.
the class ExecOutFileTest method testOutFileConvertToByteArray.
@Test
@DirtiesContext
public void testOutFileConvertToByteArray() throws Exception {
Exchange e = sendWithMockedExecutor();
byte[] body = e.getIn().getBody(byte[].class);
assertEquals(FILE_CONTENT, new String(body));
}
use of org.springframework.test.annotation.DirtiesContext 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.springframework.test.annotation.DirtiesContext 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.springframework.test.annotation.DirtiesContext 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());
}
Aggregations