camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Test
Date Sun, 07 Aug 2011 19:00:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<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="https://cwiki.apache.org/confluence/display/CAMEL/Test">Test</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <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)
method|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#assertIsSatisfied(org.apache.camel.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|http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/test/TestEndpointTest.java?view=markup]
along with its [Spring XML|https://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/test/TestEndpointTest-context.xml].
<br></td></tr>
            <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>
    
            </table>
    </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">
test:expectedMessagesEndpointUri
</pre>
</div></div>

<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
class="code-keyword">true</span>"</span>);</span>
</pre>
</div></div>

<p>If your test then invokes the <a href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#assertIsSatisfied(org.apache.camel.CamelContext)"
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>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<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
Started</a></li>
</ul>

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

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Test">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=76577&revisedVersion=10&originalVersion=9">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Test?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message