camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Borut Bolčina <borut.bolc...@gmail.com>
Subject Re: Configuring endpoint programmatically
Date Mon, 26 Mar 2012 12:23:40 GMT
It's the route that one is testing that matters. I added the noop option to:

from("file:src/test/resources?noop=true")

and then in the test method it does not matter how one constructs the
endpoint. So it boils down to:

@Test
public void testNumberOfWeatherStations() throws Exception {
 MockEndpoint mock = getMockEndpoint("mock:meteo1");
mock.expectedMessageCount(9);
 mock.setAssertPeriod(1000);

String fileName = "src/test/resources/observation_si_latest.xml";
 File meteo = new File(fileName);
 FileEndpoint endpoint = new FileEndpoint();
 endpoint.setFile(meteo);
 String content = context.getTypeConverter().convertTo(String.class, meteo);
 //send data to route
template.sendBodyAndHeader(endpoint, content, Exchange.FILE_NAME, fileName);
 mock.assertIsSatisfied();
}

Just curious, is there another way to send data to route
than template.sendBodyAndHeader?

-borut

Dne 26. marec 2012 14:04 je Borut Bolčina <borut.bolcina@gmail.com>napisal/-a:

> It felt like a solution, but still fails. The file is moved one level
> lower to src/test/resources/.camel folder just like before.
>
> @Test
>  public void testNumberOfWeatherStations() throws Exception {
> MockEndpoint mock = getMockEndpoint("mock:meteo1");
>  mock.expectedMessageCount(9);
> mock.setAssertPeriod(1000);
>
>  String fileName = "src/test/resources/observation_si_latest.xml";
> FileEndpoint endpoint = new FileEndpoint("file:" + fileName, new
> FileComponent());
>  endpoint.setNoop(true);
>  File meteo = new File(fileName);
>  String content = context.getTypeConverter().convertTo(String.class,
> meteo);
>  //send data to route
> template.sendBodyAndHeader(endpoint, content, Exchange.FILE_NAME,
> fileName);
>  mock.assertIsSatisfied();
> }
>
> Am I constructing the endpoint wrong?
>
> -borut
>
> Dne 26. marec 2012 13:37 je Claus Ibsen <claus.ibsen@gmail.com>napisal/-a:
>
> Hi
>>
>> Just use the setters on the file endpoint
>>
>> FileEndpoint endpoint = ...
>> endpoint.setNoop(true);
>>
>>
>> On Mon, Mar 26, 2012 at 1:16 PM, Borut Bolčina <borut.bolcina@gmail.com>
>> wrote:
>> > Hello again,
>> >
>> > The File component can be configured with some options, I am interested
>> in
>> > "noop=true". What can be done by:
>> >
>> > from("file:src/test/resources?fileName=myFile.xml&noop=true")
>> >
>> > is what I want to do it with code:
>> >
>> > String fileName = "src/test/resources/myFile.xml";
>> > Endpoint endpoint = new FileEndpoint("file:" + fileName, new
>> > FileComponent());
>> >  Map<String, Object> options = new HashMap();
>> > options.put("noop", "true");
>> >  endpoint.configureProperties(options);
>> >
>> > but it does not work - the file is still moved, which is something I do
>> not
>> > want. I tried with boolean value as well, but the same result. I found
>> > nothing in the mailing list, nor in the Camel book.
>> >
>> > I also tried:
>> >
>> > String fileName = "myFile.xml";
>> > FileComponent fileComponent = new FileComponent();
>> >  fileComponent.setCamelContext(context);
>> > Endpoint endpoint = fileComponent.createEndpoint("file:" + fileName);
>> >  Map<String, Object> options = new HashMap();
>> > options.put("noop", "true");
>> >  endpoint.configureProperties(options);
>> >
>> > but no success either.
>> >
>> > -borut
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>
>

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