camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" ...@silverbullet.dk>
Subject RE: testNG test harness for Camel, sending and receiving messages
Date Sun, 21 Sep 2008 06:39:28 GMT
Hi

1)
When you put you message on the "final destination" with .to("destination") you can just add
the mock as well .to("mock:result", "destination");

Kinda like the wire tap:
http://activemq.apache.org/camel/wire-tap.html

The order doesn't matter so you can use: .to("destination", "mock:result"); instead


2)
Or you could probably add an interceptor on the final destination:

intercept("desintation").to("mock:result").proceed();
// here is your regular routes

proceed() makes sure the routing continues on the normal path. If you want it you can use
.stop() to terminate the routing. 

BTW: proceed() is default in Camel 1.4+ so you can omit it:
intercept("desintation").to("mock:result")




Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Mick Knutson [mailto:mknutson@baselogic.com] 
Sent: 21. september 2008 02:38
To: camel-user@activemq.apache.org
Subject: Re: testNG test harness for Camel, sending and receiving messages

I started trying to use the mock, but it does not seem to work the way I
envision.

I have a message I create, that gets consumed by my transformer, then the
transformer put the new message on another queue. So I need the final queue
to be the mock. But I am not sure how to define the destination endpoint.





On Fri, Sep 19, 2008 at 9:24 PM, Claus Ibsen <ci@silverbullet.dk> wrote:

> Hi
>
> Camel has the mock endpoint to be used for unit testing.
> http://activemq.apache.org/camel/mock.html
>
> It is used extensively in unit testing Camel itself and has great assert
> methods for all kind of assertions.
>
> BTW: the producerTemplate can also return the response from Camel if its an
> InOut exchange (request-reply such as a web service call etc.). Then you can
> assert the returned payload if it's expected. You have to use requestBody
> for InOut. sendBody is for InOnly.
>
> Object out = producerTemplate.requestBody("myEndpoint", "Hello World");
> assertEquals("Bye World", out);
>
> But check out the mock endpoint it's a killer for unit testing with Camel.
>
> There are even some similar components for unit testing, however not used
> as much:
> http://activemq.apache.org/camel/dataset.html
> for sending a lot of messages and expecting ordering
>
> And this one as well: Where you can get the message bodies from another
> endpoint, such as a file or database.
> http://activemq.apache.org/camel/test.html
>
>
> But start with the mock endpoint!
>
>
>
> Med venlig hilsen
>
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
>
> -----Original Message-----
> From: Mick Knutson [mailto:mknutson@baselogic.com]
> Sent: 20. september 2008 03:54
> To: camel-user@activemq.apache.org
> Subject: Re: testNG test harness for Camel, sending and receiving messages
>
> I have added my baseCamelTestNGTest class below, along with my
> implementation class because I want some design help.
> My issue is that I seem to be able to use a parameter in testng to send my
> initial message uri to start my process. But what I am not sure about, is
> how to use a parameter in testng to define a channel to look for my test
> message on, consume, and Assert the outcome.
>
>
> *BaseCamelTestNG.class:*
> *package com.servepath;
>
> import org.apache.camel.CamelTemplate;
> import org.apache.camel.CamelContext;
> import org.apache.camel.ProducerTemplate;
> import org.apache.camel.builder.RouteBuilder;
>
>
> import org.apache.camel.impl.DefaultCamelContext;
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.springframework.test.context.ContextConfiguration;
> import org.springframework.beans.factory.annotation.Autowired;
> import com.baselogic.test.SpringTestNGBase;
> import com.servepath.gogrid.changerequest.ChangeRequestRouteBuilder;
> import org.testng.annotations.*;
>
>
> /**
>  * This is the base class for all my Camel Tests.
>  */
> @ContextConfiguration(
>        locations = {"classpath:applicationContext-test.xml"}
> )
> public abstract class BaseCamelTestNGTest
>        extends SpringTestNGBase {
>
>    public transient Log log = LogFactory.getLog(this.getClass());
>
>
>    @Autowired
>    protected CamelContext camelContext;
>
>    //CamelTemplate camelTemplate;
>
>
>    @BeforeClass(groups = {"init"})
>    public void startCamel() {
>        try {
>
> log.debug("*****************************************************");
>            log.debug("Start Camel Context");
>            // create the camel context: // This is actually setup in the
> camel-context.xml
>            //camelContext = new DefaultCamelContext();
>
>            // add the routes to the camel Context.
>            setRoutes();
>
>            // start Camel Context
>            // create a camel template for sending messages:
>            //camelTemplate = new CamelTemplate(camelContext);
>
>            // start the camel context
>            camelContext.start();
>
> log.debug("*****************************************************");
>        } catch (Exception e) {
>            // this is an example -> don't handle exceptions:
>            e.printStackTrace();
>        }
>
>    }//
>
>    @AfterClass(groups = {"init"})
>    public void stopCamel() {
>        try {
>
> log.debug("----------------------------------------------------");
>            log.debug("Stop Camel Context");
>            //stop Camel Context
>            camelContext.stop();
>
> log.debug("----------------------------------------------------");
>        } catch (Exception e) {
>            // this is an example -> don't handle exceptions:
>            e.printStackTrace();
>        }
>    }//
>
>
>    /**
>     * Must add a route for each test.
>     */
>    public abstract void setRoutes()
>            throws Exception;
>
>
> } // The End...
>
> *
> *ChangeRequestTest.class:*
> *package com.servepath.changerequest;
>
> import java.sql.Date;
> import java.util.ArrayList;
> import java.util.Collection;
> import java.util.GregorianCalendar;
> import java.util.HashMap;
> import java.util.Map;
> import java.net.URL;
>
> import javax.annotation.Resource;
>
> import org.springframework.beans.factory.InitializingBean;
> import org.springframework.beans.factory.annotation.Autowired;
> import org.springframework.beans.factory.annotation.Qualifier;
> import org.springframework.test.context.ContextConfiguration;
> import org.testng.Assert;
> import org.testng.annotations.Test;
> import org.testng.annotations.Parameters;
> import org.testng.annotations.Optional;
> import org.apache.camel.EndpointInject;
> import org.apache.camel.ProducerTemplate;
> import org.apache.camel.MessageDriven;
> import org.apache.camel.Body;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.codehaus.jettison.json.JSONObject;
> import com.servepath.gogrid.changerequest.ChangeRequestRouteBuilder;
> import com.servepath.gogrid.changerequest.Constants;
> import com.servepath.BaseCamelTestNGTest;
>
>
> @ContextConfiguration(
>        locations = {"classpath:applicationContext-test.xml"}
> )
> public class ChangeRequestTest
>        extends BaseCamelTestNGTest
>        implements InitializingBean {
>
>
>    public ChangeRequestTest() {
>        super();
>    }
>
>    @Override
>    public void prepareSettings() {
>        log.debug("prepareSettings called");
>    }
>
>    @Override
>    public void setRoutes()
>            throws Exception {
>        // Add Routes to Camel Context
>        camelContext.addRoutes(new ChangeRequestRouteBuilder());
>    }//
>
>
> //=======================================================================//
>    //===== Start the Unit Tests
> ============================================//
>
> //=======================================================================//
>
>    @EndpointInject(uri = "mock:foo")
>    protected MockEndpoint foo;
>
>
>    @Test(groups = {"functional"})
>    //@Parameters({ "customerId" })
>    @Parameters({ "inputDestinationURI", "outputDestinationURI",
> "messageInputBody", "messageOutputBody" })
>    public void testCreateAndTransformJSONProvisionRequest(@Optional String
> inputDestinationURI,
>                                                           @Optional String
> outputDestinationURI,
>                                                           @Optional String
> messageInputBody,
>                                                           @Optional String
> messageOutputBody
>    )
>            throws Exception {
>        log.debug("----------------------------------------------------");
>        log.info("["+inputDestinationURI+"]\n");
>        log.info("["+outputDestinationURI+"]\n");
>        log.info("["+messageInputBody+"]\n");
>        log.info("["+messageOutputBody+"]\n");
>        log.info("testCreateAndTransformJSONProvisionRequest");
>
>        // setup RouteBuilder...
>
>        // Create and Send message to input queue
>        createMessage(inputDestinationURI, messageInputBody);
>
>        // not sure how to verify that my component gets the message.
>        //camelContext.
>
>        // verify that the destination channel
>        log.debug("----------------------------------------------------");
>    }
>
>
>
>
>    @EndpointInject(uri = Constants.CR_INPUT_CHANNEL)
>    ProducerTemplate producerTemplate;
>
>    public void createMessage(String inputDestinationURI, String
> messageInputBody)
>            throws Exception {
>        log.debug("----------------------------------------------------");
>        log.debug("----------------------------------------------------");
>        log.debug("inputDestinationURI: " + inputDestinationURI);
>        log.debug("messageInputBody: " + messageInputBody);
>        log.debug("----------------------------------------------------");
>        log.debug("----------------------------------------------------");
>
>        producerTemplate.sendBody(inputDestinationURI, messageInputBody);
>
>        Thread.sleep(3000); // wait for 3 seconds. Not sure why though...
>
>    }//
>
>
>
>
>    @MessageDriven(uri = Constants.CR_OUTPUT_CHANNEL)
>    public void verifyDestinationEndpoint(@Body String body) {
>        log.debug("----------------------------------------------------");
>        log.debug("verifyDestinationEndpoint");
>        log.debug("["+body+"]");
>        // process the inbound message here
>        log.debug("----------------------------------------------------");
>    }
>
>    @MessageDriven(uri = Constants.CR_INPUT_ERROR_CHANNEL)
>    public void verifyErrorEndpoint(@Body String body) {
>        log.debug("----------------------------------------------------");
>        log.debug("verifyErrorEndpoint");
>        log.debug("["+body+"]");
>        // process the inbound message here
>        log.debug("----------------------------------------------------");
>    }
>
>
> } // The End...
> *
>
>
> I bolded the 2 methods that I would want to validate the message on the
> respective channel, but want to dynamically inject the uri from a testng
> parameter so I can reuse this logic...
>
>
>
>
> On Fri, Sep 19, 2008 at 3:47 PM, Mick Knutson <mknutson@baselogic.com
> >wrote:
>
> > Here is what I do to run just my jarred components (paraphrased)...
> >
> > I have a baseCamelTest class that uses the SpringTestNG support to
> start-up
> > a spring context.
> >
> > Then, in my applicationContext-test.xml, I start my test broker and will
> > add my test routes.
> >
> > Now when i plan to go into a real system, like dev, stage, prod, I have
> my
> > 'live' routes in my applicationContextProd.xml that has my live broker,
> and
> > my live routes.
> >
> >
> > I guess the way you are mentioning would alos work, but means I have to
> > maintain an application.properties, or a filter. I guess i feel because I
> am
> > already using the applicationContext-test.xml to replace my broker, it
> just
> > seems more natural to me to switch the routes the same way.
> >
> >
> >
> >
> >
> >
> >
> >
> > On Fri, Sep 19, 2008 at 9:44 AM, Claus Ibsen <ci@silverbullet.dk> wrote:
> >
> >> Hi
> >>
> >> Mick can you give an example how you can easily switch between test and
> >> prod routes using Spring? I am looking into best practices as well using
> >> Spring and having Java DSL routing.
> >>
> >> What I was doing is to use Java DSL with alias names for the endpoints,
> >> and have the endpoints properly configured in spring XML. Then I can
> have
> >> spring XML with property placeholders.
> >> <endpoint id="input1" uri="activemq:${someQueueName}"/>
> >>
> >> Then I can use the "input1" alias in my java DSL.
> >> from("input1").to("xxx");
> >>
> >>
> >>
> >> Med venlig hilsen
> >>
> >> Claus Ibsen
> >> ......................................
> >> Silverbullet
> >> Skovsgårdsvænget 21
> >> 8362 Hørning
> >> Tlf. +45 2962 7576
> >> Web: www.silverbullet.dk
> >>
> >> -----Original Message-----
> >> From: Mick Knutson [mailto:mknutson@baselogic.com]
> >> Sent: 19. september 2008 18:29
> >> To: camel-user@activemq.apache.org
> >> Subject: Re: testNG test harness for Camel, sending and receiving
> messages
> >>
> >> The tcp issue was because in my @BeforeClass(), I had camelContext = new
> >> DefaultCamelContext(); whiche seemed to start the default tcp broker.
> But
> >> I
> >> am actually using Spring to start my broker, so I just removed that line
> >> and
> >> it worked fine.
> >>
> >> For the producer, I am using:
> >>    @EndpointInject(uri = Constants.CR_INPUT_CHANNEL)
> >>    ProducerTemplate producerTemplate;
> >>
> >> This works fine, but I would like some design input as to how to inject
> >> routes in TestNG for testing when I see that DSL is prefered over Spring
> >> Routing. With Spring Routing I can easily switch test, and prod routes.
> >> But
> >> not sure how easily to do this with dsl.
> >>
> >>
> >>
> >>
> >>
> >> On Thu, Sep 18, 2008 at 10:44 PM, Claus Ibsen <ci@silverbullet.dk>
> wrote:
> >>
> >> > Hi
> >> >
> >> > You get the ProducerTemplate from the CamelContext directly with the
> >> > createProducerTemplate() method.
> >> >
> >> > I have no clue why ActiveMQ embeds the TCP listener, maybe there is
> >> > somekind of spring .xml files included in one of the .jars or on your
> >> > classpath when running the test.
> >> >
> >> >
> >> >
> >> > Med venlig hilsen
> >> >
> >> > Claus Ibsen
> >> > ......................................
> >> > Silverbullet
> >> > Skovsgårdsvænget 21
> >> > 8362 Hørning
> >> > Tlf. +45 2962 7576
> >> > Web: www.silverbullet.dk
> >> >
> >> > -----Original Message-----
> >> > From: Mick Knutson [mailto:mknutson@baselogic.com]
> >> > Sent: 18. september 2008 20:59
> >> > To: camel-user@activemq.apache.org
> >> > Subject: Re: testNG test harness for Camel, sending and receiving
> >> messages
> >> >
> >> > I am making some headway.
> >> >
> >> > I have create a startup method:
> >> >    *@BeforeClass(groups = {"init"})
> >> >    public void startCamel() {
> >> >        try {
> >> >            log.debug("Start Camel Context");
> >> >            // create the camel context:
> >> >            camelContext = new DefaultCamelContext();
> >> >
> >> >            // add the routes to the camel Context
> >> >            camelContext.addRoutes(new ChangeRequestRouteBuilder());
> >> >
> >> >            // start Camel Context
> >> >            // create a camel template for sending messages:
> >> >            camelTemplate = new CamelTemplate(camelContext);
> >> >
> >> >            // I added this as the recommendation to the deprecated
> >> >            // camelTemplate above...
> >> >            //producerTemplate = new ProducerTemplate();
> >> >
> >> >            // start the camel context
> >> >            camelContext.start();
> >> >        } catch (Exception e) {
> >> >            // this is an example -> don't handle exceptions:
> >> >            e.printStackTrace();
> >> >        }
> >> >    }//
> >> > *
> >> >
> >> > But I have an issue. *CamelTemplate is deprecated, and
> >> **ProducerTemplate
> >> > is
> >> > abstract*. How how do I start using the *ProducerTemplate instead?
> >> >
> >> > *Also, in my SpringTestNG base, I start up my test context:*
> >> > **@ContextConfiguration(*
> >> > *        locations = {"classpath:applicationContext-test.xml"}*
> >> > *)*
> >> >
> >> > That includes:*
> >> > **<import resource="classpath:META-INF/spring/camel-context.xml" />*
> >> >
> >> > and I am using the embedded broker:
> >> >
> >> >    *<!-- lets configure the default ActiveMQ broker URL -->*
> >> > *    <bean id="activemq"
> >> > class="org.apache.camel.component.jms.JmsComponent">*
> >> > *        <property name="connectionFactory">*
> >> > *            <bean
> >> class="org.apache.activemq.ActiveMQConnectionFactory">*
> >> > *                <property name="brokerURL"
> >> >
> >>
> value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>*
> >> > *            </bean>*
> >> > *        </property>*
> >> > *    </bean>*
> >> >
> >> > so why do i keep getting the full default broker being searched for:
> >> >
> >> > *[myproject] DEBUG [ActiveMQ Task] FailoverTransport.doReconnect(671)
> |
> >> > Attempting connect to: tcp://localhost:61616
> >> > [myproject] DEBUG [ActiveMQ Task] FailoverTransport.doReconnect(699) |
> >> > Connect fail to: tcp://localhost:61616, reason:
> >> java.net.ConnectException:
> >> > Connection refused
> >> > [myproject] DEBUG [ActiveMQ Task] FailoverTransport.doReconnect(732) |
> >> > Waiting 30000 ms before attempting connection.
> >> > *
> >> >
> >> >
> >> >
> >> > On Wed, Sep 17, 2008 at 10:49 PM, James Strachan
> >> > <james.strachan@gmail.com>wrote:
> >> >
> >> > > I agree with everything Claus just said :) But another thing you can
> >> > > do is run the TestNG test case directly in your IDE as well without
> >> > > using Maven at all.
> >> > >
> >> > >
> >> > > 2008/9/18 Mick Knutson <mknutson@baselogic.com>:
> >> > > > I have created a base class extending
> >> AbstractTestNGSpringContextTests
> >> > as
> >> > > > you mentioned. I actually did the same to support bdunit.
> >> > > >
> >> > > > But there are a few things, related to camel that I am just not
> >> getting
> >> > > yet.
> >> > > >
> >> > > >
> >> > > >
> >> > > > * What does the camel-maven-plugin doing that my base class will
> not
> >> by
> >> > > > initializing the camel-context.xml?
> >> > > >
> >> > > > I tried to run my mvn install without the camel-maven-plugin.
I
> get
> >> the
> >> > > > camel-context initialized, but does not run the same as when
I run
> >> mvn
> >> > > > camel:run.
> >> > > >
> >> > > > *There is:*
> >> > > > *public class CRRouteBuilder extends RouteBuilder {
> >> > > > ....
> >> > > >    public static void main(String[] args) {
> >> > > >        new Main().run(args);
> >> > > >    }
> >> > > > *
> >> > > >
> >> > > > in my RouteBuilder and I guess I am not sure if this is started
by
> >> the
> >> > > > plugin to run or not.
> >> > > >
> >> > > > I tried mvn camel:run and keep getting a poll loop:
> >> > > >
> >> > > > *[myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@407374]
> >> > > > FileConsumer.pollFileOrDirectory(81) | Polling directory src/data
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@407374]
> >> > > > FileConsumer.isChanged(231) | file:src/data/message1.xml
> >> > isChanged:false
> >> > > > sizeCheck:false(0) lastModifiedCheck:false(0)
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@407374]
> >> > > > FileConsumer.isChanged(231) | file:src/data/message2.xml
> >> > isChanged:false
> >> > > > sizeCheck:false(0) lastModifiedCheck:false(0)
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@407374]
> >> > > > FileConsumer.isChanged(231) | file:src/data/message3.xml
> >> > isChanged:false
> >> > > > sizeCheck:false(0) lastModifiedCheck:false(0)
> >> > > > *
> >> > > >
> >> > > > so should I not use the plugin at all? And just start the
> >> camelContext
> >> > by
> >> > > > itself?
> >> > > >
> >> > > > Do I just need to have my testNG send a message to initiate the
> >> > process?
> >> > > >
> >> > > >
> >> > > > It seems that the process is initiated:
> >> > > >
> >> > > > *[myproject] DEBUG [VMTransport]
> >> > > ActiveMQConnection.onAsyncException(1695) |
> >> > > > Async exception with no exception listener:
> >> > > > org.apache.activemq.transport.TransportDisposedIOException: Peer
> >> > > > (vm://localhost#1) disposed.
> >> > > > org.apache.activemq.transport.TransportDisposedIOException: Peer
> >> > > > (vm://localhost#1) disposed.
> >> > > >    at
> >> > > >
> >> > >
> >> >
> >>
> org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:203)
> >> > > >    at
> >> > > >
> >> > >
> >> >
> >>
> org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
> >> > > >    at
> >> > > >
> >> > >
> >> >
> >>
> org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
> >> > > >    at
> >> > > >
> >> > >
> >> >
> >>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> >> > > >    at
> >> > > >
> >> > >
> >> >
> >>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> >> > > >    at java.lang.Thread.run(Thread.java:613)
> >> > > > [myproject] DEBUG [ActiveMQ Transport Stopper: vm://localhost#0]
> >> > > > TransportConnection.doStop(994) | Connection Stopped:
> >> vm://localhost#0
> >> > > > [myproject] INFO [ActiveMQ ShutdownHook]
> >> TransportConnector.stop(273) |
> >> > > > Connector vm://localhost Stopped
> >> > > > [myproject] DEBUG [Thread-2]
> >> > DefaultListableBeanFactory.destroyBean(447)
> >> > > |
> >> > > > Retrieved dependent beans for bean
> >> > > > 'org.apache.activemq.ActiveMQConnectionFactory#3dc0f4': [activemq]
> >> > > > [myproject] DEBUG [Thread-2]
> >> > DefaultListableBeanFactory.destroyBean(447)
> >> > > |
> >> > > > Retrieved dependent beans for bean 'camel:beanPostProcessor':
> >> [camel]
> >> > > > [myproject] DEBUG [Thread-2]
> >> > DefaultListableBeanFactory.destroyBean(447)
> >> > > |
> >> > > > Retrieved dependent beans for bean 'camel':
> >> [camel:beanPostProcessor,
> >> > > > org.apache.camel.component.file.FileComponent,
> >> > > > com.servepath.ChangeRequestTest]
> >> > > > myproject] DEBUG [Thread-2] DisposableBeanAdapter.destroy(148)
|
> >> > Invoking
> >> > > > destroy() on bean with name 'camel'
> >> > > > [myproject] INFO [ActiveMQ ShutdownHook] BrokerService.stop(512)
|
> >> > > ActiveMQ
> >> > > > JMS Message Broker (localhost,
> >> > > > ID:mick-knutsons-macbook.local-50355-1221698401973-0:0) stopped
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@698f02]
> >> > > > ScheduledPollConsumer.run(62) | Starting to poll:
> >> > > > Endpoint[file:src/data?noop=true]
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@698f02]
> >> > > > FileConsumer.pollFileOrDirectory(81)
> >> > > > | Polling directory src/data
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@698f02]
> >> > > > FileConsumer.isChanged(231) | file:src/data/message1.xml
> >> isChanged:true
> >> > > > sizeCheck:false(0) lastModifiedCheck:true(0)
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@698f02]
> >> > > > FileEndpoint.getFileStrategy(158) | Using file process strategy:
> >> > > >
> >> org.apache.camel.component.file.strategy.NoOpFileProcessStrategy@43095f
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@698f02]
> >> > > > FileConsumer.pollFile(122) | About to process file:
> >> > src/data/message1.xml
> >> > > > using exchange: Exchange[FileMessage: src/data/message1.xml]
> >> > > > [myproject] DEBUG [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@698f02]
> >> > > > FileProcessStrategySupport.begin(62) | Locking the file:
> >> > > > src/data/message1.xml using the lock file name:
> >> > > >
> >> > >
> >> >
> >>
> /opt/projects/changerequest/camel-example-spring/src/data/message1.xml.cameLock
> >> > > > [myproject] ERROR [Thread: 1
> >> > > > org.apache.camel.component.file.FileComponent@698f02]
> >> > > > BrokerService.start(466) | Failed to start ActiveMQ JMS Message
> >> Broker.
> >> > > > Reason: java.lang.IllegalStateException: Shutdown in progress
> >> > > >
> >> > > > *
> >> > > >
> >> > > > But there is an error in bold above.
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > On Tue, Sep 16, 2008 at 11:14 PM, James Strachan
> >> > > > <james.strachan@gmail.com>wrote:
> >> > > >
> >> > > >> 2008/9/16 Mick Knutson <mknutson@baselogic.com>:
> >> > > >> > I am trying to setup camel within Maven to start my
camel
> context
> >> > via
> >> > > the
> >> > > >> >           <plugin>
> >> > > >> >                <groupId>org.apache.camel</groupId>
> >> > > >> >                <artifactId>camel-maven-plugin</artifactId>
> >> > > >> >                <version>1.4.0</version>
> >> > > >> >            </plugin>
> >> > > >> >
> >> > > >> > Now I was hoping that someone has already created a
> >> baseCamelTestNG
> >> > > class
> >> > > >> to
> >> > > >> > start/stop camel, then helper class to send and receive
> messages.
> >> > > >> >
> >> > > >> > Then after the tests have run, the plugin can shutdown.
> >> > > >>
> >> > > >> BTW there's a Camel user list, I've CC'd so other camel users
can
> >> > listen
> >> > > >> too...
> >> > > >> http://activemq.apache.org/camel/discussion-forums.html
> >> > > >>
> >> > > >> The best approach for unit testing and sending & receiving
> messages
> >> is
> >> > > >> to use the Spring Testing mechanism which works with JUnit
3.x,
> 4.x
> >> or
> >> > > >> TestNG
> >> > > >> http://activemq.apache.org/camel/spring-testing.html
> >> > > >>
> >> > > >> for TestNG you might want to derive from
> >> > > AbstractTestNGSpringContextTests
> >> > > >> see
> >> > > >>
> >> > > >>
> >> > >
> >> >
> >>
> http://static.springframework.org/spring/docs/2.5.x/reference/testing.html#testcontext-fixture-di
> >> > > >>
> >> > > >> this then does the dependency injection with Spring and runs
your
> >> test
> >> > > >> case.
> >> > > >>
> >> > > >> To send messages you can inject a ProducerTemplate; then
to
> receive
> >> > > >> messages you can then use the @MessageDriven annotation on
a
> method
> >> -
> >> > > >> see the examples here
> >> > > >> http://activemq.apache.org/camel/bean-integration.html
> >> > > >>
> >> > > >> plus you can then inject mock endpoints for testing as well
as
> >> > described
> >> > > >> here
> >> > > >> http://activemq.apache.org/camel/spring-testing.html
> >> > > >> http://activemq.apache.org/camel/mock.html
> >> > > >>
> >> > > >> --
> >> > > >> James
> >> > > >> -------
> >> > > >> http://macstrac.blogspot.com/
> >> > > >>
> >> > > >> Open Source Integration
> >> > > >> http://open.iona.com
> >> > > >>
> >> > > >
> >> > > >
> >> > > >
> >> > > > --
> >> > > > ---
> >> > > > Thank You...
> >> > > >
> >> > > > Mick Knutson
> >> > > > BASE Logic, inc.
> >> > > > (415) 354-4215
> >> > > >
> >> > > > Website: http://baselogic.com
> >> > > > Blog: http://baselogic.com/blog
> >> > > > BLiNC Magazine: http://blincmagazine.com
> >> > > > Linked IN: http://linkedin.com/in/mickknutson
> >> > > > DJ Mick: http://djmick.com
> >> > > > MySpace: http://myspace.com/mickknutson
> >> > > > Vacation Rental: http://tahoe.baselogic.com
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > --
> >> > > James
> >> > > -------
> >> > > http://macstrac.blogspot.com/
> >> > >
> >> > > Open Source Integration
> >> > > http://open.iona.com
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> > ---
> >> > Thank You...
> >> >
> >> > Mick Knutson
> >> > BASE Logic, inc.
> >> > (415) 354-4215
> >> >
> >> > Website: http://baselogic.com
> >> > Blog: http://baselogic.com/blog
> >> > BLiNC Magazine: http://blincmagazine.com
> >> > Linked IN: http://linkedin.com/in/mickknutson
> >> > DJ Mick: http://djmick.com
> >> > MySpace: http://myspace.com/mickknutson
> >> > Vacation Rental: http://tahoe.baselogic.com
> >> >
> >>
> >>
> >>
> >> --
> >> ---
> >> Thank You...
> >>
> >> Mick Knutson
> >> BASE Logic, inc.
> >> (415) 354-4215
> >>
> >> Website: http://baselogic.com
> >> Blog: http://baselogic.com/blog
> >> BLiNC Magazine: http://blincmagazine.com
> >> Linked IN: http://linkedin.com/in/mickknutson
> >> DJ Mick: http://djmick.com
> >> MySpace: http://myspace.com/mickknutson
> >> Vacation Rental: http://tahoe.baselogic.com
> >>
> >
> >
> >
> > --
> > ---
> > Thank You...
> >
> > Mick Knutson
> > BASE Logic, inc.
> > (415) 354-4215
> >
> > Website: http://baselogic.com
> > Blog: http://baselogic.com/blog
> > BLiNC Magazine: http://blincmagazine.com
> > Linked IN: http://linkedin.com/in/mickknutson
> > DJ Mick: http://djmick.com
> > MySpace: http://myspace.com/mickknutson
> > Vacation Rental: http://tahoe.baselogic.com
> >
> >
>
>
> --
> ---
> Thank You...
>
> Mick Knutson
> BASE Logic, inc.
> (415) 354-4215
>
> Website: http://baselogic.com
> Blog: http://baselogic.com/blog
> BLiNC Magazine: http://blincmagazine.com
> Linked IN: http://linkedin.com/in/mickknutson
> DJ Mick: http://djmick.com
> MySpace: http://myspace.com/mickknutson
> Vacation Rental: http://tahoe.baselogic.com
>



-- 
---
Thank You...

Mick Knutson
BASE Logic, inc.
(415) 354-4215

Website: http://baselogic.com
Blog: http://baselogic.com/blog
BLiNC Magazine: http://blincmagazine.com
Linked IN: http://linkedin.com/in/mickknutson
DJ Mick: http://djmick.com
MySpace: http://myspace.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com

Mime
View raw message