Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6950439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:05:32+00:00 2026-05-27T14:05:32+00:00

We’re using Spring for DI and Camel for routing/messaging. I’ve been asked to set

  • 0

We’re using Spring for DI and Camel for routing/messaging. I’ve been asked to set up some (JUnit) unit tests for our various components (which all route messages to one another in a pipeline fashion).

After taking a gander at the general Camel testing doc and Camel-Spring testing doc, it seems like the preferred method of unit testing camel endpoints is through the Spring Test Context Framework using subclasses of objects like AbstractJUnit38SpringContextTests and the sorts.

I have absolutely zero experience with any of these APIs. So, although they make for interesting reading, it’s tough for me to put them into context (no pun intended).

As such there are a few initial concepts I am struggling with:

For one, when is it appropriate to use a MockEndpoint, vs DataSet, vs Test?

Also, the Camel-Spring doc (link is above) provides the following example:

@ContextConfiguration
public class MyCamelTest extends AbstractJUnit38SpringContextTests {

    @Autowired
    protected CamelContext camelContext;

    @EndpointInject(uri = "mock:foo")
    protected MockEndpoint foo;

    public void testMocksAreValid() throws Exception {

        // lets add more expectations...
        MockEndpoint.assertIsSatisfied(camelContext);

        // now lets do some further assertions
        List<Exchange> list = foo.getReceivedExchanges();

        for (Exchange exchange : list) {
            Message in = exchange.getIn();
            ...
        }       
    }
}

If I’m even beginning to understand this API, then it seems like the code above it reading all the messages from a MockEndpoint named mock:foo…but I don’t see where those messages are coming from (how they get to the endpoint in the first place)!

So my second question is: what are the standard practices for determining which endpoints to “stub” (mock)? For instance what if the same JMS message queue is utilized by two endpoints living inside two different JARs/WARs: one a producer and the other, a consumer? In this case, ProducerComponent (living inside producer.war) is a Camel endpoint that pushes messages to someQueue. And ConsumerComponent (living inside of consumer.war) is another Camel endpoint consuming messages off of someQueue.

How would SO organize the unit tests for both components?

Thanks in advance for any nudges in the right direction!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:05:33+00:00Added an answer on May 27, 2026 at 2:05 pm

    The testing chapter in the Camel book is very good. I just extend CamelTestSupport and I use the mock stuff to be a dummy input or output to the route (I don’t worry about Spring or injecting things, etc). There is also a bunch of exotic stuff you can do by putting things (I forget what they are called) between components on a route to simulate failures and such. I highly recommend the above book, it’s very clear and accurate.

    For your second question, it depends I suppose on how your messages are being created. You could use a mock endpoint to either feed or consume from the queue (or both). There is a lot of good support in the mock endpoint to check messages.

    The CamelTestSupport and it’s superclass have a lot of useful methods for creating messages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.