use of java.io.File in project camel by apache.
the class FileConsumerMoveExpressionTest method testRenameToComplexWithId.
public void testRenameToComplexWithId() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file://target/filelanguage/?exclude=.*bak" + "&move=backup-${id}-${file:name.noext}.bak").convertBodyTo(String.class).to("mock:result");
}
});
context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Bye World");
template.sendBodyAndHeader("file://target/filelanguage/", "Bye World", Exchange.FILE_NAME, "report2.txt");
assertMockEndpointsSatisfied();
oneExchangeDone.matchesMockWaitTime();
String id = mock.getExchanges().get(0).getIn().getMessageId();
File file = new File("target/filelanguage/backup-" + id + "-report2.bak");
assertTrue("File should have been renamed", file.exists());
}
use of java.io.File in project camel by apache.
the class FileConsumerMoveExpressionTest method testRenameToId.
public void testRenameToId() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file://target/filelanguage/?exclude=.*bak" + "&move=${id}.bak").convertBodyTo(String.class).to("mock:result");
}
});
context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
template.sendBodyAndHeader("file://target/filelanguage/", "Hello World", Exchange.FILE_NAME, "report.txt");
assertMockEndpointsSatisfied();
oneExchangeDone.matchesMockWaitTime();
String id = mock.getExchanges().get(0).getIn().getMessageId();
File file = new File("target/filelanguage/" + id + ".bak");
assertTrue("File should have been renamed", file.exists());
}
use of java.io.File in project camel by apache.
the class FileConsumerAbsolutePathWithAbsoluteMoveTest method setUp.
@Override
protected void setUp() throws Exception {
deleteDirectory("target/reports");
// use current dir as base as absolute path
base = new File("").getAbsolutePath() + "/target/reports";
super.setUp();
}
use of java.io.File in project camel by apache.
the class FileConsumerAbsolutePathWithRelativeMoveTest method setUp.
@Override
protected void setUp() throws Exception {
deleteDirectory("target/reports");
deleteDirectory("target/done");
// use current dir as base as absolute path
base = new File("").getAbsolutePath() + "/target/reports";
super.setUp();
}
use of java.io.File in project camel by apache.
the class FileConsumerAutoCreateDirectoryTest method testDoNotCreateDirectory.
public void testDoNotCreateDirectory() throws Exception {
deleteDirectory("target/file/foo");
Endpoint endpoint = context.getEndpoint("file://target/file/foo?autoCreate=false");
Consumer consumer = endpoint.createConsumer(new Processor() {
public void process(Exchange exchange) throws Exception {
// noop
}
});
consumer.start();
consumer.stop();
// the directory should NOT exists
File dir = new File("target/file/foo");
assertFalse("Directory should NOT be created", dir.exists());
}
Aggregations