public void testIgnore() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("Hello World"); mock.expectedFileExists("target/file/hello.txt", "Hello World"); template.sendBodyAndHeader( "file://target/file?fileExist=Ignore", "Bye World", Exchange.FILE_NAME, "hello.txt"); assertMockEndpointsSatisfied(); }
@Test public void testRouteToFileOnly() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); mock.expectedFileExists(path + "/to/out/hello.txt"); template.sendBodyAndHeader("direct:report", "Hello World", Exchange.FILE_NAME, "hello.txt"); assertMockEndpointsSatisfied(); }
@Test public void testIgnore() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("Hello World"); mock.expectedFileExists(FTP_ROOT_DIR + "exist/hello.txt", "Hello World"); template.sendBodyAndHeader(getFtpUrl(), "Bye World", Exchange.FILE_NAME, "hello.txt"); assertMockEndpointsSatisfied(); }
public void testSplitStreamingWithChoice() throws Exception { getMockEndpoint("mock:other").expectedMessageCount(0); MockEndpoint mock = getMockEndpoint("mock:body"); mock.expectedBodiesReceived("line1", "line2", "line3"); // should be moved to this directory after we are done mock.expectedFileExists("target/filesplit/.camel/splitme.txt"); String body = "line1" + LS + "line2" + LS + "line3"; template.sendBodyAndHeader("file://target/filesplit", body, Exchange.FILE_NAME, "splitme.txt"); assertMockEndpointsSatisfied(); }
/** * Write a file without chmod set, should work normally and not throw an exception for invalid * chmod value * * @throws Exception */ public void testWriteNoChmod() throws Exception { if (!canTest()) { return; } MockEndpoint mock = getMockEndpoint("mock:noChmod"); mock.expectedMessageCount(1); String testFileName = "noChmod.txt"; String fullTestFileName = TEST_DIRECTORY + testFileName; String testFileContent = "Writing file with no chmod option at " + new Date(); mock.expectedFileExists(fullTestFileName, testFileContent); template.sendBodyAndHeader( "direct:writeNoChmod", testFileContent, Exchange.FILE_NAME, testFileName); assertMockEndpointsSatisfied(); }
private void runChmodCheck(String routeSuffix, String expectedPermissions) throws Exception { MockEndpoint mock = getMockEndpoint("mock:chmod" + routeSuffix); mock.expectedMessageCount(1); String testFileName = "chmod" + routeSuffix + ".txt"; String fullTestFileName = TEST_DIRECTORY + testFileName; String testFileContent = "Writing file with chmod " + routeSuffix + " option at " + new Date(); mock.expectedFileExists(fullTestFileName, testFileContent); template.sendBodyAndHeader( "direct:write" + routeSuffix, testFileContent, Exchange.FILE_NAME, testFileName); File f = new File(fullTestFileName); Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(f.toPath(), LinkOption.NOFOLLOW_LINKS); assertEquals(expectedPermissions, PosixFilePermissions.toString(permissions)); assertEquals(expectedPermissions.replace("-", "").length(), permissions.size()); assertMockEndpointsSatisfied(); }