use of org.apache.camel.component.file.FileEndpoint in project camel by apache.
the class SpringFileRouteTest method testMocksAreValid.
@Test
public void testMocksAreValid() throws Exception {
// lets check that our injected endpoint is valid
FileEndpoint fileEndpoint = assertIsInstanceOf(FileEndpoint.class, inputFile);
assertEquals("File", new File("target/test-default-inbox"), fileEndpoint.getFile());
result.expectedBodiesReceived(expectedBody);
result.setResultWaitTime(5000);
template.sendBodyAndHeader(inputFile, expectedBody, Exchange.FILE_NAME, "hello.txt");
result.assertIsSatisfied();
}
use of org.apache.camel.component.file.FileEndpoint in project camel by apache.
the class FileLanguageExtSingleTest method createExchange.
public Exchange createExchange() {
// create the file
String uri = "file://target/filelanguage?fileExist=Override";
template.sendBodyAndHeader(uri, "Bye World", Exchange.FILE_NAME, "test/bye.def.txt");
// get the file handle
file = new File("target/filelanguage/test/bye.def.txt");
GenericFile<File> gf = FileConsumer.asGenericFile("target/filelanguage", file, null, false);
FileEndpoint endpoint = getMandatoryEndpoint(uri, FileEndpoint.class);
Exchange answer = endpoint.createExchange(gf);
endpoint.configureMessage(gf, answer.getIn());
Calendar cal = Calendar.getInstance();
cal.set(1974, Calendar.APRIL, 20);
answer.getIn().setHeader("birthday", cal.getTime());
cal.set(2008, Calendar.AUGUST, 8);
answer.getOut().setHeader("special", cal.getTime());
return answer;
}
use of org.apache.camel.component.file.FileEndpoint in project camel by apache.
the class FileLanguageTest method createExchange.
public Exchange createExchange() {
// create the file
String uri = "file://target/filelanguage?fileExist=Override";
template.sendBodyAndHeader(uri, "Hello World", Exchange.FILE_NAME, "test/hello.txt");
// get the file handle
file = new File("target/filelanguage/test/hello.txt");
GenericFile<File> gf = FileConsumer.asGenericFile("target/filelanguage", file, null, false);
FileEndpoint endpoint = getMandatoryEndpoint(uri, FileEndpoint.class);
Exchange answer = endpoint.createExchange(gf);
endpoint.configureMessage(gf, answer.getIn());
Calendar cal = Calendar.getInstance();
cal.set(1974, Calendar.APRIL, 20);
answer.getIn().setHeader("birthday", cal.getTime());
cal.set(2008, Calendar.AUGUST, 8);
answer.getOut().setHeader("special", cal.getTime());
return answer;
}
use of org.apache.camel.component.file.FileEndpoint in project camel by apache.
the class FileLanguageTest method testFileNameDoubleExtension.
public void testFileNameDoubleExtension() throws Exception {
file = new File("target/filelanguage/test/bigfile.tar.gz");
String uri = "file://target/filelanguage?fileExist=Override";
GenericFile<File> gf = FileConsumer.asGenericFile("target/filelanguage", file, null, false);
FileEndpoint endpoint = getMandatoryEndpoint(uri, FileEndpoint.class);
Exchange answer = endpoint.createExchange(gf);
endpoint.configureMessage(gf, answer.getIn());
assertEquals("bigfile.tar.gz", file.getName());
assertExpression(answer, "${file:onlyname}", "bigfile.tar.gz");
assertExpression(answer, "${file:ext}", "tar.gz");
}
Aggregations