camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Camel > Test
Date Sun, 07 Aug 2011 19:00:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="">Test</a></h2>
    <h4>Page <b>edited</b> by             <a href="">Claus
                         <h4>Changes (1)</h4>
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >If your test then invokes the [MockEndpoint.assertIsSatisfied(camelContext)
your test case will perform the necessary assertions. <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Here
is a [real example test case using Mock and Spring|]
along with its [Spring XML|].
            <tr><td class="diff-unchanged" > <br>To see how you can set
other expectations on the test endpoint, see the [Mock] component. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Test-TestComponent"></a>Test Component</h2>

<p><a href="/confluence/display/CAMEL/Testing" title="Testing">Testing</a>
of distributed and asynchronous processing is notoriously difficult. The <a href="/confluence/display/CAMEL/Mock"
title="Mock">Mock</a>, <a href="/confluence/display/CAMEL/Test" title="Test">Test</a>
and <a href="/confluence/display/CAMEL/DataSet" title="DataSet">DataSet</a> endpoints
work great with the <a href="/confluence/display/CAMEL/Testing" title="Testing">Camel
Testing Framework</a> to simplify your unit and integration testing using <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns"
title="Enterprise Integration Patterns">Enterprise Integration Patterns</a> and Camel's
large range of <a href="/confluence/display/CAMEL/Components" title="Components">Components</a>
together with the powerful <a href="/confluence/display/CAMEL/Bean+Integration" title="Bean
Integration">Bean Integration</a>.</p>

<p>The <b>test</b> component extends the <a href="/confluence/display/CAMEL/Mock"
title="Mock">Mock</a> component to support pulling messages from another endpoint
on startup to set the expected message bodies on the underlying <a href="/confluence/display/CAMEL/Mock"
title="Mock">Mock</a> endpoint. That is, you use the test endpoint in a route and
messages arriving on it will be implicitly compared to some expected messages extracted from
some other location.</p>

<p>So you can use, for example, an expected set of message bodies as files. This will
then set up a properly configured <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a>
endpoint, which is only valid if the received messages match the number of expected messages
and their message payloads are equal.</p>

<h3><a name="Test-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">

<p>Where <b>expectedMessagesEndpointUri</b> refers to some other <a href="/confluence/display/CAMEL/Component"
title="Component">Component</a> URI that the expected message bodies are pulled from
before starting the test. </p>

<h3><a name="Test-Example"></a>Example</h3>

<p>For example, you could write a test case as follows:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"seda:someEndpoint"</span>).
  to(<span class="code-quote">"test:file:<span class="code-comment">//data/expectedOutput?noop=<span

<p>If your test then invokes the <a href=""
class="external-link" rel="nofollow">MockEndpoint.assertIsSatisfied(camelContext) method</a>,
your test case will perform the necessary assertions.</p>

<p>To see how you can set other expectations on the test endpoint, see the <a href="/confluence/display/CAMEL/Mock"
title="Mock">Mock</a> component.</p>

<h3><a name="Test-SeeAlso"></a>See Also</h3>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting

	<li><a href="/confluence/display/CAMEL/Spring+Testing" title="Spring Testing">Spring

        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
        <a href="">View Online</a>
        <a href="">View
        <a href=";showCommentArea=true#addcomment">Add

View raw message