Hi!
I wanted to use poll enrich to pick up different files from host, based on
the path and filename.
I was thinking to have something like:
file:/?fileName=${in.body}
Where body is an absolute path of the file. I wasn't able to make it work.
I've created a unit test, where I set up three file. One I try to consume
with defining path after the : but the other two example I try to use
relative path.
Based on other topic thread and the camel file language description. Both
the second and third test case should work. Meaning files are copied. On my
machine which is Windows XP using Camel 2.9.2 they are failing.
There is also an interesting entry in the log file:
DEBUG Creating endpoint
uri=[file:///C:/DOCUME%7E1/myuser/LOCALS%7E1/Temp/junit4621650582543353407/?fileName=subfolder%2Ftest2.txt&idempotent=false&noop=true&recursive=false],
path=[/C:/DOCUME~1/myuser/LOCALS~1/Temp/junit4621650582543353407/],
parameters=[{fileName=subfolder/test2.txt, idempotent=false, noop=true,
recursive=false}]
Note the '/' is replaced, with %2F at the fileName section.
I've tried to replicate the test case using spring DSL
In the log file this is what appear:
DEBUG Camel Routes:
[EventDrivenConsumerRoute[Endpoint[file://removed_for_anonimity/?fileName=/source/mytest.txt&idempotent=false&noop=true&recursive=false]
->
Instrumentation:route[DelegateAsync[UnitOfWork(RouteContextProcessor[Channel[sendTo(Endpoint[file://removed_for_anonimity/temp/poll?fileName=test3.txt])]])]]]]
Here slashes wasn't replaced to %2F. But the solution didn't work. Any idea
what I'm messing up?
David
-----
package experiments.camel.file;
import java.io.File;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class DynamicFileEndpointsTest extends CamelTestSupport{
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Before
public void createFileToCopy() throws Exception{
temporaryFolder.newFolder("subfolder");
temporaryFolder.newFile("subfolder/test1.txt");
temporaryFolder.newFile("subfolder/test2.txt");
temporaryFolder.newFile("subfolder/test3.txt");
temporaryFolder.newFolder("target");
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from(temporaryFolder.getRoot().toURI() +
"/subfolder/?fileName=test1.txt&noop=true&idempotent=false")
.to(new
File(temporaryFolder.getRoot(),"target").toURI().toString());
from(temporaryFolder.getRoot().toURI() +
"?fileName=subfolder/test2.txt&noop=true&idempotent=false&recursive=false")
.to(new
File(temporaryFolder.getRoot(),"target").toURI().toString());
from(temporaryFolder.getRoot().toURI() +
"?fileName=subfolder/test3.txt&noop=true&idempotent=false&recursive=true")
.to(new
File(temporaryFolder.getRoot(),"target").toURI().toString());
}
};
}
@Test
public void testTarget1() throws Exception {
Thread.sleep(2000);
assertTrue(new File(temporaryFolder.getRoot(),
"target/test1.txt").exists());
}
@Test
public void testTarget2() throws Exception {
Thread.sleep(2000);
assertTrue(new File(temporaryFolder.getRoot(),
"target/test2.txt").exists());
}
@Test
public void testTarget3() throws Exception {
Thread.sleep(2000);
assertTrue(new File(temporaryFolder.getRoot(),
"target/test3.txt").exists());
}
}
--
View this message in context:
http://camel.465427.n5.nabble.com/Cannot-use-fileName-property-for-path-extension-tp5716085.html
Sent from the Camel - Users mailing list archive at Nabble.com.