camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller <christian.muel...@gmail.com>
Subject Re: Use a file as input to unit tests
Date Sat, 03 Nov 2012 15:53:20 GMT
May be context.getTypeConverter().convertTo(String.class,
this.getClass().getResourceAsStream("/src/data/someXmlFile.xml"));

Apache commons-io provides also some useful methods for this [1].

[1]
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOUtils.java?view=markup

Best,
Christian

On Sat, Nov 3, 2012 at 3:31 PM, eitland <erik.itland@gmail.com> wrote:

>
> I think I have seen an elegant way to use a file as input for a unit test
> in
> apache camel but my google skills are failing me.
>
> What I want is instead of:
>
> String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
>     <snip>...long real life xml that quickly fills up test files.</snip>";
> template.sendBody("direct:create", xml);
>
> What I think I have seen is something like:
>
> template.sendBody("direct:create",
> someCamelMetod("/src/data/someXmlFile.xml"));
>
> Anybody knows where/if this is documented?
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Use-a-file-as-input-to-unit-tests-tp5722069.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message