You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Henri Tremblay <he...@gmail.com> on 2013/01/04 16:52:37 UTC

Remove an advice

Hi,

Happy new year to everyone.

I'm doing integration tests. I'm reading from a JMS queue and then doing
some special stuff is the JMSMessageID already exist.

I want to test that the "special stuff" is correctly called.

So right now I'm doing this:
- Adding an advice at the beginning of the route that set the JMSMessageID
- Sending two messages

Everything is fine but since it's an integration tests, my route is now
dirty and cannot be reused for other tests. So I'm stuck.

I'm using a org.apache.camel.test.junit4.CamelTestSupport. The camel
context comes from a SingletonBeanFactory somewhere else (I can't change
that).

So, I would like a solution to get an "unweaved" route back.

The solution is can see:

   - But back the original route. (How?)
   - Remove the weaving on the route (How?)
   - Reload the context with it's original content (How?)
   - Set the JMSMessageId without weaving (How?)
   - ???

Any ideas are welcome

Cheers,
Henri

Re: Remove an advice

Posted by blacar <bc...@gmail.com>.
Hi Henri,

Did you find something about this? ... i am experiencing the same problem.

The advice get sticked someway even when i created it inside the test method
it seem is affecting other tests within the same test class.

Thanks,

RBC



--
View this message in context: http://camel.465427.n5.nabble.com/Remove-an-advice-tp5724915p5751028.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Remove an advice

Posted by Christian Müller <ch...@gmail.com>.
Can you share your route and your unit test? Than it's easier (for me) to
understand where your issues are.
Have a look at the many AdviceWith* unit tests at [1].

[1]
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/

Best,
Christian

On Sat, Jan 5, 2013 at 4:55 PM, Henri Tremblay <he...@gmail.com>wrote:

> Hum... I'm already creating the advice in the test (not in the setup).
>
> I'll try but isUseAdviceWith seems only not to start the context. So I
> don't see how this can help me to set my original route back.
>
>
>
> On 4 January 2013 18:06, Claus Ibsen <cl...@gmail.com> wrote:
>
> > On Fri, Jan 4, 2013 at 6:02 PM, Henri Tremblay <henri.tremblay@gmail.com
> >
> > wrote:
> > > That's what I'm doing.
> > >
> > >     routeDefinitionUnderTest.adviceWith(context(), new
> > > AdviceWithRouteBuilder() {
> > >
> > >       @Override
> > >       public void configure() throws Exception {
> > >         weaveById("doTry*").before().setHeader("JMSMessageID",
> > > constant("DuplicateID"));
> > >       }
> > >     });
> > >
> > > But I have two tests in my test case. The second one still use the
> > tainted
> > > context (yes, if you tell me that another test case won't have the
> > problem,
> > > I can separate the tests in two classes).
> > >
> >
> > You can do the advice in the test method itself. Then it ought to be
> > local to that given test only.
> >
> > As we do at
> > http://camel.apache.org/advicewith.html
> >
> > And see the green box about the tip.
> >
> >
> > >
> > > On 4 January 2013 17:11, Christian Müller <christian.mueller@gmail.com
> > >wrote:
> > >
> > >> You can use adviceWith [1] in your test. In this case you don't have
> to
> > >> touch your original route.
> > >>
> > >> [1] http://camel.apache.org/advicewith.html
> > >>
> > >> Best,
> > >> Christian
> > >>
> > >> On Fri, Jan 4, 2013 at 4:52 PM, Henri Tremblay <
> > henri.tremblay@gmail.com
> > >> >wrote:
> > >>
> > >> > Hi,
> > >> >
> > >> > Happy new year to everyone.
> > >> >
> > >> > I'm doing integration tests. I'm reading from a JMS queue and then
> > doing
> > >> > some special stuff is the JMSMessageID already exist.
> > >> >
> > >> > I want to test that the "special stuff" is correctly called.
> > >> >
> > >> > So right now I'm doing this:
> > >> > - Adding an advice at the beginning of the route that set the
> > >> JMSMessageID
> > >> > - Sending two messages
> > >> >
> > >> > Everything is fine but since it's an integration tests, my route is
> > now
> > >> > dirty and cannot be reused for other tests. So I'm stuck.
> > >> >
> > >> > I'm using a org.apache.camel.test.junit4.CamelTestSupport. The camel
> > >> > context comes from a SingletonBeanFactory somewhere else (I can't
> > change
> > >> > that).
> > >> >
> > >> > So, I would like a solution to get an "unweaved" route back.
> > >> >
> > >> > The solution is can see:
> > >> >
> > >> >    - But back the original route. (How?)
> > >> >    - Remove the weaving on the route (How?)
> > >> >    - Reload the context with it's original content (How?)
> > >> >    - Set the JMSMessageId without weaving (How?)
> > >> >    - ???
> > >> >
> > >> > Any ideas are welcome
> > >> >
> > >> > Cheers,
> > >> > Henri
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >>
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > Red Hat, Inc.
> > FuseSource is now part of Red Hat
> > Email: cibsen@redhat.com
> > Web: http://fusesource.com
> > Twitter: davsclaus
> > Blog: http://davsclaus.com
> > Author of Camel in Action: http://www.manning.com/ibsen
> >
>



--

Re: Remove an advice

Posted by Henri Tremblay <he...@gmail.com>.
Hum... I'm already creating the advice in the test (not in the setup).

I'll try but isUseAdviceWith seems only not to start the context. So I
don't see how this can help me to set my original route back.



On 4 January 2013 18:06, Claus Ibsen <cl...@gmail.com> wrote:

> On Fri, Jan 4, 2013 at 6:02 PM, Henri Tremblay <he...@gmail.com>
> wrote:
> > That's what I'm doing.
> >
> >     routeDefinitionUnderTest.adviceWith(context(), new
> > AdviceWithRouteBuilder() {
> >
> >       @Override
> >       public void configure() throws Exception {
> >         weaveById("doTry*").before().setHeader("JMSMessageID",
> > constant("DuplicateID"));
> >       }
> >     });
> >
> > But I have two tests in my test case. The second one still use the
> tainted
> > context (yes, if you tell me that another test case won't have the
> problem,
> > I can separate the tests in two classes).
> >
>
> You can do the advice in the test method itself. Then it ought to be
> local to that given test only.
>
> As we do at
> http://camel.apache.org/advicewith.html
>
> And see the green box about the tip.
>
>
> >
> > On 4 January 2013 17:11, Christian Müller <christian.mueller@gmail.com
> >wrote:
> >
> >> You can use adviceWith [1] in your test. In this case you don't have to
> >> touch your original route.
> >>
> >> [1] http://camel.apache.org/advicewith.html
> >>
> >> Best,
> >> Christian
> >>
> >> On Fri, Jan 4, 2013 at 4:52 PM, Henri Tremblay <
> henri.tremblay@gmail.com
> >> >wrote:
> >>
> >> > Hi,
> >> >
> >> > Happy new year to everyone.
> >> >
> >> > I'm doing integration tests. I'm reading from a JMS queue and then
> doing
> >> > some special stuff is the JMSMessageID already exist.
> >> >
> >> > I want to test that the "special stuff" is correctly called.
> >> >
> >> > So right now I'm doing this:
> >> > - Adding an advice at the beginning of the route that set the
> >> JMSMessageID
> >> > - Sending two messages
> >> >
> >> > Everything is fine but since it's an integration tests, my route is
> now
> >> > dirty and cannot be reused for other tests. So I'm stuck.
> >> >
> >> > I'm using a org.apache.camel.test.junit4.CamelTestSupport. The camel
> >> > context comes from a SingletonBeanFactory somewhere else (I can't
> change
> >> > that).
> >> >
> >> > So, I would like a solution to get an "unweaved" route back.
> >> >
> >> > The solution is can see:
> >> >
> >> >    - But back the original route. (How?)
> >> >    - Remove the weaving on the route (How?)
> >> >    - Reload the context with it's original content (How?)
> >> >    - Set the JMSMessageId without weaving (How?)
> >> >    - ???
> >> >
> >> > Any ideas are welcome
> >> >
> >> > Cheers,
> >> > Henri
> >> >
> >>
> >>
> >>
> >> --
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: Remove an advice

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 4, 2013 at 6:02 PM, Henri Tremblay <he...@gmail.com> wrote:
> That's what I'm doing.
>
>     routeDefinitionUnderTest.adviceWith(context(), new
> AdviceWithRouteBuilder() {
>
>       @Override
>       public void configure() throws Exception {
>         weaveById("doTry*").before().setHeader("JMSMessageID",
> constant("DuplicateID"));
>       }
>     });
>
> But I have two tests in my test case. The second one still use the tainted
> context (yes, if you tell me that another test case won't have the problem,
> I can separate the tests in two classes).
>

You can do the advice in the test method itself. Then it ought to be
local to that given test only.

As we do at
http://camel.apache.org/advicewith.html

And see the green box about the tip.


>
> On 4 January 2013 17:11, Christian Müller <ch...@gmail.com>wrote:
>
>> You can use adviceWith [1] in your test. In this case you don't have to
>> touch your original route.
>>
>> [1] http://camel.apache.org/advicewith.html
>>
>> Best,
>> Christian
>>
>> On Fri, Jan 4, 2013 at 4:52 PM, Henri Tremblay <henri.tremblay@gmail.com
>> >wrote:
>>
>> > Hi,
>> >
>> > Happy new year to everyone.
>> >
>> > I'm doing integration tests. I'm reading from a JMS queue and then doing
>> > some special stuff is the JMSMessageID already exist.
>> >
>> > I want to test that the "special stuff" is correctly called.
>> >
>> > So right now I'm doing this:
>> > - Adding an advice at the beginning of the route that set the
>> JMSMessageID
>> > - Sending two messages
>> >
>> > Everything is fine but since it's an integration tests, my route is now
>> > dirty and cannot be reused for other tests. So I'm stuck.
>> >
>> > I'm using a org.apache.camel.test.junit4.CamelTestSupport. The camel
>> > context comes from a SingletonBeanFactory somewhere else (I can't change
>> > that).
>> >
>> > So, I would like a solution to get an "unweaved" route back.
>> >
>> > The solution is can see:
>> >
>> >    - But back the original route. (How?)
>> >    - Remove the weaving on the route (How?)
>> >    - Reload the context with it's original content (How?)
>> >    - Set the JMSMessageId without weaving (How?)
>> >    - ???
>> >
>> > Any ideas are welcome
>> >
>> > Cheers,
>> > Henri
>> >
>>
>>
>>
>> --
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Remove an advice

Posted by Henri Tremblay <he...@gmail.com>.
That's what I'm doing.

    routeDefinitionUnderTest.adviceWith(context(), new
AdviceWithRouteBuilder() {

      @Override
      public void configure() throws Exception {
        weaveById("doTry*").before().setHeader("JMSMessageID",
constant("DuplicateID"));
      }
    });

But I have two tests in my test case. The second one still use the tainted
context (yes, if you tell me that another test case won't have the problem,
I can separate the tests in two classes).


On 4 January 2013 17:11, Christian Müller <ch...@gmail.com>wrote:

> You can use adviceWith [1] in your test. In this case you don't have to
> touch your original route.
>
> [1] http://camel.apache.org/advicewith.html
>
> Best,
> Christian
>
> On Fri, Jan 4, 2013 at 4:52 PM, Henri Tremblay <henri.tremblay@gmail.com
> >wrote:
>
> > Hi,
> >
> > Happy new year to everyone.
> >
> > I'm doing integration tests. I'm reading from a JMS queue and then doing
> > some special stuff is the JMSMessageID already exist.
> >
> > I want to test that the "special stuff" is correctly called.
> >
> > So right now I'm doing this:
> > - Adding an advice at the beginning of the route that set the
> JMSMessageID
> > - Sending two messages
> >
> > Everything is fine but since it's an integration tests, my route is now
> > dirty and cannot be reused for other tests. So I'm stuck.
> >
> > I'm using a org.apache.camel.test.junit4.CamelTestSupport. The camel
> > context comes from a SingletonBeanFactory somewhere else (I can't change
> > that).
> >
> > So, I would like a solution to get an "unweaved" route back.
> >
> > The solution is can see:
> >
> >    - But back the original route. (How?)
> >    - Remove the weaving on the route (How?)
> >    - Reload the context with it's original content (How?)
> >    - Set the JMSMessageId without weaving (How?)
> >    - ???
> >
> > Any ideas are welcome
> >
> > Cheers,
> > Henri
> >
>
>
>
> --
>

Re: Remove an advice

Posted by Christian Müller <ch...@gmail.com>.
You can use adviceWith [1] in your test. In this case you don't have to
touch your original route.

[1] http://camel.apache.org/advicewith.html

Best,
Christian

On Fri, Jan 4, 2013 at 4:52 PM, Henri Tremblay <he...@gmail.com>wrote:

> Hi,
>
> Happy new year to everyone.
>
> I'm doing integration tests. I'm reading from a JMS queue and then doing
> some special stuff is the JMSMessageID already exist.
>
> I want to test that the "special stuff" is correctly called.
>
> So right now I'm doing this:
> - Adding an advice at the beginning of the route that set the JMSMessageID
> - Sending two messages
>
> Everything is fine but since it's an integration tests, my route is now
> dirty and cannot be reused for other tests. So I'm stuck.
>
> I'm using a org.apache.camel.test.junit4.CamelTestSupport. The camel
> context comes from a SingletonBeanFactory somewhere else (I can't change
> that).
>
> So, I would like a solution to get an "unweaved" route back.
>
> The solution is can see:
>
>    - But back the original route. (How?)
>    - Remove the weaving on the route (How?)
>    - Reload the context with it's original content (How?)
>    - Set the JMSMessageId without weaving (How?)
>    - ???
>
> Any ideas are welcome
>
> Cheers,
> Henri
>



--