yes placeholders is the way I solved it myself. I coudn't get the advicewith
to work and it didnt really seem like a good fit.

So I have..

<endpoint uri="${myendpoint}"/>

like this..

int.properties
myendpoint=activemq:myendpoint

test.properties
myendpoint=mock:activemq-myendpoint

Is 2.8 final? or coming soon?


On Tue, Mar 29, 2011 at 3:14 PM, Claus Ibsen <[email protected]> wrote:

> Hi Tom
>
> Yeah the adviceWith started as a feature to advice single routes. But
> can also be used to mock and skip sending to endpoints as shown on
> those wiki pages.
>
> However its often easier to either
> - use property placeholders for uris, so you can use mock:xxx for unit
> tests, and mina:xxx for the real apps
> - or add the endpoint pre starting the routes
>
> In the latter you can most likely do something like:
>    context.addEndpoint("mina:xxx", new MockEndpoint());
>
> However in Camel 2.8 onwards its easier as you can replace entire
> components with mock using
>   context.addComponent("mina", context.getComponent("mock"));
>
>
>
> On Tue, Mar 29, 2011 at 10:35 AM, Tom Howe <[email protected]> wrote:
> > I tried this..
> >
> >        context.getRouteDefinitions().get(0).adviceWith(context, new
> > RouteBuilder() {
> >            @Override
> >            public void configure() throws Exception {
> >
> >
>  interceptSendToEndpoint("mock:mina:tcp://unreachable.splunk.server:9000")
> >                        .skipSendToOriginalEndpoint()
> >                        .to("mock:mina-advised");
> >            }
> >        });
> >
> >
> > I have multiple routes in my config - does get(0) just get the first
> route?
> >
> > I also tried this..
> >
> >        context.getRouteDefinition("toSplunk").adviceWith(context, new
> > RouteBuilder() {
> >            @Override
> >            public void configure() throws Exception {
> >
> >
>  interceptSendToEndpoint("mock:mina:tcp://unreachable.splunk.server:9000")
> >                        .skipSendToOriginalEndpoint()
> >                        .to("mock:mina-advised");
> >            }
> >        });
> >
> > and this (with direct component - not mock)..
> >        context.getRouteDefinition("toSplunk").adviceWith(context, new
> > RouteBuilder() {
> >            @Override
> >            public void configure() throws Exception {
> >
> >  interceptSendToEndpoint("mina:tcp://unreachable.splunk.server:9000")
> >                        .skipSendToOriginalEndpoint()
> >                        .to("mock:mina-advised");
> >            }
> >        });
> >
> > All give   java.nio.channels.UnresolvedAddressException because they are
> > trying to write to splunk server.
> >
> > My route looks like:
> >
> >        <route autoStartup="true" id="tosplunk" xmlns="
> > http://camel.apache.org/schema/spring";>
> >            <from uri="direct:splunk.in"/>
> >            <filter>
> >                <xpath>//*[local-name() = "event"]</xpath>
> >                <bean ref="unWrapEnvelopeXml"/>
> >                <bean ref="ispyXmlToSplunk"/>
> >                <to
> >
> uri="mina:tcp://unreachable.splunk.server:9000?textline=true&amp;textlineDelimiter=UNIX&amp;sync=false"/>
> >            </filter>
> >        </route>
> >
> >
> > Thanks, Tom
> >
> >
> >
> > On Mon, Mar 28, 2011 at 8:24 PM, Tom Howe <[email protected]> wrote:
> >
> >> Is this what you are pointing me to? .skipSendToOriginalEndpoint()
> >>
> >> How do I use this in my spring xml routes?
> >>
> >>
> >> On Mon, Mar 28, 2011 at 7:02 PM, Claus Ibsen <[email protected]
> >wrote:
> >>
> >>> See
> >>> http://camel.apache.org/advicewith.html
> >>>
> >>> On Mon, Mar 28, 2011 at 7:47 PM, Tom Howe <[email protected]> wrote:
> >>> > I have a route such as:
> >>> >
> >>> >  <route autoStartup="true" xmlns="
> http://camel.apache.org/schema/spring
> >>> ">
> >>> >         <from uri="activemq:somequeue"/>
> >>> >         ...
> >>> >         <to uri="http:hostname/some/path"/>
> >>> >   </route>
> >>> >
> >>> > If I set up mocking, using a wrapper xml file containing:
> >>> >
> >>> >    <bean id="mockAllEndpoints"
> >>> > class="org.apache.camel.impl.InterceptSendToMockEndpointStrategy"/>
> >>> >
> >>> > I can now intercept the endpoints to see what was sent but how to I
> >>> prevent
> >>> > the test from connecting to activemq and the remote http server so I
> can
> >>> run
> >>> > the test without any external interaction?
> >>> >
> >>> > I managed to use
> >>> >    <bean id="activemq"
> >>> > class="org.apache.camel.component.direct.DirectComponent" />
> >>> >
> >>> > to prevent activemq connecting, but the same trick did not work with
> >>> mina or
> >>> > http since the parameters passed are not appropriate.
> >>> >
> >>> >
> >>> > Thanks, Tom
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Claus Ibsen
> >>> -----------------
> >>> FuseSource
> >>> Email: [email protected]
> >>> Web: http://fusesource.com
> >>> Twitter: davsclaus
> >>> Blog: http://davsclaus.blogspot.com/
> >>> Author of Camel in Action: http://www.manning.com/ibsen/
> >>>
> >>
> >>
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: [email protected]
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Reply via email to