FAQ
I'm trying to test a route that moves a message from the file system to an
ftp server. I have a simple route defined as follows:






I'd like to unit test the transfer by using a mock component for the ftp
component. The Camel in Action book has some great examples on using mock
components but they all create the routes containing the mock components
directly in the test classes. I'm wondering how I can write a unit test
testing my main spring DSL code but instead of specifying the ftp component
in my route, use the mock component instead.

Can this be done?



--
View this message in context: http://camel.465427.n5.nabble.com/Question-about-using-mocks-tp4291965p4291965.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Search Discussions

  • Hadrian Zbarcea at Apr 8, 2011 at 9:31 pm
    You mean by using the properties component [1]?

    It may not be immediately obvious from the examples there, but you can have something like
    <route>
    <from uri="direct:start"/>
    <to uri="{{destination}}"/>
    </route>

    And the 'destination' would be defined in a properties file specific to your environment. So you'd only have to modify the url in a properties file, no recompile or anything. That works with the all the dsls (java, spring).

    Does this help?
    Hadrian

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


    On Apr 8, 2011, at 5:18 PM, jpalmer1026 wrote:

    I'm trying to test a route that moves a message from the file system to an
    ftp server. I have a simple route defined as follows:






    I'd like to unit test the transfer by using a mock component for the ftp
    component. The Camel in Action book has some great examples on using mock
    components but they all create the routes containing the mock components
    directly in the test classes. I'm wondering how I can write a unit test
    testing my main spring DSL code but instead of specifying the ftp component
    in my route, use the mock component instead.

    Can this be done?



    --
    View this message in context: http://camel.465427.n5.nabble.com/Question-about-using-mocks-tp4291965p4291965.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Richard Kettelerij at Apr 8, 2011 at 9:36 pm
    Hi,

    This is possible as of Camel 2.7, see http://camel.apache.org/mock.html and
    in particular the section called "Mocking existing endpoints with XML DSL".

    You may also want to take a look at MockFtpServer (
    http://mockftpserver.sourceforge.net/). It's great for writing integration
    tests.

    Regards,
    Richard
    On Fri, Apr 8, 2011 at 11:18 PM, jpalmer1026 wrote:

    I'm trying to test a route that moves a message from the file system to an
    ftp server. I have a simple route defined as follows:






    I'd like to unit test the transfer by using a mock component for the ftp
    component. The Camel in Action book has some great examples on using mock
    components but they all create the routes containing the mock components
    directly in the test classes. I'm wondering how I can write a unit test
    testing my main spring DSL code but instead of specifying the ftp component
    in my route, use the mock component instead.

    Can this be done?



    --
    View this message in context:
    http://camel.465427.n5.nabble.com/Question-about-using-mocks-tp4291965p4291965.html
    Sent from the Camel - Users mailing list archive at Nabble.com.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedApr 8, '11 at 9:18p
activeApr 8, '11 at 9:36p
posts3
users3
websitecamel.apache.org

People

Translate

site design / logo © 2023 Grokbase