use of java.io.File in project camel by apache.
the class FtpConsumerLocalWorkDirectoryAsAbsolutePathTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from(getFtpUrl()).process(new Processor() {
public void process(Exchange exchange) throws Exception {
File body = exchange.getIn().getBody(File.class);
assertNotNull(body);
assertTrue("Should be absolute path", body.isAbsolute());
assertTrue("Local work file should exists", body.exists());
assertEquals(FileUtil.normalizePath(base + "/hello.txt"), body.getPath());
}
}).to("mock:result", "file://target/out");
}
};
}
use of java.io.File in project camel by apache.
the class FtpConsumerLocalWorkDirectoryAsAbsolutePathTest method testLocalWorkDirectory.
@Test
public void testLocalWorkDirectory() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
mock.expectedMessageCount(1);
assertMockEndpointsSatisfied();
// give test some time to close file resources
Thread.sleep(6000);
// now the lwd file should be deleted
File local = new File("target/lwd/hello.txt");
assertFalse("Local work file should have been deleted", local.exists());
// and the out file should exists
File out = new File("target/out/hello.txt");
assertTrue("file should exists", out.exists());
assertEquals("Hello World", IOConverter.toString(out, null));
}
use of java.io.File in project camel by apache.
the class FtpConsumerLocalWorkDirectoryDirectTest method testLocalWorkDirectory.
@Test
public void testLocalWorkDirectory() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
assertTrue("Should process one file", notify.matchesMockWaitTime());
// and the out file should exists
File out = new File("target/out/hello.txt");
assertTrue("file should exists", out.exists());
assertEquals("Hello World", IOConverter.toString(out, null));
// now the lwd file should be deleted
File local = new File("target/lwd/hello.txt");
assertFalse("Local work file should have been deleted", local.exists());
}
use of java.io.File in project camel by apache.
the class FtpConsumerLocalWorkDirectoryTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from(getFtpUrl()).process(new Processor() {
public void process(Exchange exchange) throws Exception {
File body = exchange.getIn().getBody(File.class);
assertNotNull(body);
assertTrue("Local work file should exists", body.exists());
assertEquals(FileUtil.normalizePath("target/lwd/hello.txt"), body.getPath());
}
}).to("mock:result", "file://target/out");
}
};
}
use of java.io.File in project camel by apache.
the class FtpLoginNoRetryTest method testBadLogin.
@Test
public void testBadLogin() throws Exception {
try {
uploadFile("dummy", "cantremeber");
fail("Should have thrown a GenericFileOperationFailedException");
} catch (GenericFileOperationFailedException e) {
// expected
assertEquals(530, e.getCode());
}
// assert file NOT created
File file = new File(FTP_ROOT_DIR + "login/report.txt");
assertFalse("The file should NOT exists", file.exists());
}
Aggregations