camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark <elihusma...@gmail.com>
Subject Re: Return contents of a file in a route
Date Thu, 18 Aug 2016 19:20:54 GMT
but then why would .log("${body}") print out the contents of the file?


On Thu, Aug 18, 2016 at 3:13 PM, Brad Johnson <brad.johnson@mediadriver.com>
wrote:

> That makes some sense as I believe what you're getting there is the handle
> to the GenericFile object and not the contents itself. You probably have to
> put a transform/simple to get the contents but I don't recall off the top
> of my head.
>
> On Thu, Aug 18, 2016 at 2:00 PM, Mark <elihusmails@gmail.com> wrote:
>
> > Actually, it is working when I use .log("${body}").  It prints out the
> > contents of the file.
> >
> > When I was calling .to("log:FILE") it was not printing the file contents,
> > but I think I was reading the log statement incorrectly.
> >
> > What is strange is that the test app that makes the HTTP GET command only
> > gets back absolute filename in the response body.
> >
> >
> >
> >
> > On Thu, Aug 18, 2016 at 2:51 PM, Brad Johnson <
> > brad.johnson@mediadriver.com>
> > wrote:
> >
> > > Are you getting any errors?  How are you testing it?
> > >
> > > The reason I ask is are you sure that it is finding the file at that
> > > location?  Are you doing this as a test stub to deploy for others to
> use
> > or
> > > is this something you want to test during unit tests only?  You can use
> > > mocks or other mechanism for that. If you put some .log("${body}")
> before
> > > and after that .from what do you see?
> > >
> > > Brad
> > >
> > > On Thu, Aug 18, 2016 at 1:33 PM, Mark <elihusmails@gmail.com> wrote:
> > >
> > > > I want to be able to simulate a system that I'm integrating with.
> I'd
> > > like
> > > > a route to return the contents of a file in a REST DSL route.  Is it
> > > > possible to do this in Camel?  This is what I'd like to do:
> > > >
> > > > restConfiguration()
> > > >    .component("jetty")
> > > >    .host("localhost")
> > > >    .port(1234)
> > > >    .bindingMode(RestBindingMode.off);
> > > >
> > > >   rest().path("/mystuff")
> > > >        .get("/testing").bindingMode(RestBindingMode.json)
> > > >   .route()
> > > > .setHeader(Exchange.CONTENT_TYPE).constant("application/json")
> > > >
> > > >          <!-- set body to contents of file -->
> > > >           ???  .from("file:myfile.json");   ???
> > > >
> > > > I tried adding the "from("file:myfile.json")" to my route, but the
> > > results
> > > > do not come back.
> > > >
> > >
> >
>

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