You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ankelee <an...@gmail.com> on 2010/04/13 11:06:08 UTC
Testing and dynamic filenames.
Hello
Using Camel 2.3.0 SNAPSHOT I've made a route where I use a wireTap to back
up any incoming files and timestamp the filename like so:
from("file://" + props.getProperty("directory.incoming"))
.routeId("processing")
.setHeader("backupFileName").simple("${date:now:yyyyMMddHH}/${file:name}.bak")
.wireTap("file://" + props.getProperty("directory.incoming.backup")+
"?fileName=${in.header.backupFileName}")...and so on.
I want to test that the backups are created and would like to do something
like this:
String filename;
RouteDefinition route = context.getRouteDefinition("processing");
route.adviceWith(new RouteBuilder() {
public void configure() throws Exception {
intercept().process(new Processor() {
@Override
public void process(Exchange ex) throws Exception {
filename = ex.getIn().getHeader("backupFileName", String.class);
}
});
}
});
Obviously this doesn't work since 'filename' is out of scope for the
Processor. Can I access the header using normal Java or do you have any
ideas how to do this? Maybe I have to reconsider how to test the backup
part?
--
View this message in context: http://old.nabble.com/Testing-and-dynamic-filenames.-tp28221755p28221755.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Testing and dynamic filenames.
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Just check that there is a new file in the backup folder.
And its file content is as expected.
On Tue, Apr 13, 2010 at 11:06 AM, ankelee <an...@gmail.com> wrote:
>
> Hello
>
> Using Camel 2.3.0 SNAPSHOT I've made a route where I use a wireTap to back
> up any incoming files and timestamp the filename like so:
>
> from("file://" + props.getProperty("directory.incoming"))
> .routeId("processing")
>
> .setHeader("backupFileName").simple("${date:now:yyyyMMddHH}/${file:name}.bak")
> .wireTap("file://" + props.getProperty("directory.incoming.backup")+
> "?fileName=${in.header.backupFileName}")...and so on.
>
> I want to test that the backups are created and would like to do something
> like this:
>
> String filename;
> RouteDefinition route = context.getRouteDefinition("processing");
> route.adviceWith(new RouteBuilder() {
> public void configure() throws Exception {
> intercept().process(new Processor() {
> @Override
> public void process(Exchange ex) throws Exception {
> filename = ex.getIn().getHeader("backupFileName", String.class);
> }
> });
> }
> });
>
> Obviously this doesn't work since 'filename' is out of scope for the
> Processor. Can I access the header using normal Java or do you have any
> ideas how to do this? Maybe I have to reconsider how to test the backup
> part?
> --
> View this message in context: http://old.nabble.com/Testing-and-dynamic-filenames.-tp28221755p28221755.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus