Modified: websites/production/camel/content/beanshell.html
==============================================================================
--- websites/production/camel/content/beanshell.html (original)
+++ websites/production/camel/content/beanshell.html Fri Aug 25 08:22:01 2017
@@ -41,7 +41,6 @@
   <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
   <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
   <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
   
   <script type="text/javascript">
   SyntaxHighlighter.defaults['toolbar'] = false;
@@ -115,46 +114,19 @@
 
 <p>You could follow the examples above to create an <a shape="rect" 
href="predicate.html">Predicate</a> in a <a shape="rect" 
href="message-filter.html">Message Filter</a> or as an <a shape="rect" 
href="expression.html">Expression</a> for a <a shape="rect" 
href="recipient-list.html">Recipient List</a></p>
 
-<h3 id="BeanShell-ScriptContextOptions"><code>ScriptContext</code> 
Options</h3><p>&#160;</p><div class="confluence-information-macro 
confluence-information-macro-information"><span class="aui-icon aui-icon-small 
aui-iconfont-info confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body">The&#160;<code>JSR-223</code> 
scripting language's&#160;<strong><code>ScriptContext</code></strong> is 
pre-configured with the following attributes all set at 
<strong><code>ENGINE_SCOPE</code></strong>.</div></div><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Attribute</p></th><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Value</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><span><code>camelContext</code><br 
clear="none"></span></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.cam
 el.CamelContext</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The Camel Context.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>context</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel Context (cannot be 
used in groovy).</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>exchange</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Exchange</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The current 
Exchange.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>properties</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.builder.script.PropertiesFunction</code></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> 
Function with a <st
 rong><code>resolve</code></strong> method to make it easier to use Camels <a 
shape="rect" href="properties.html">Properties</a> component from scripts. See 
further below for example.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>request</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p>The&#160;<strong><code>IN</code></strong> 
message.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>response</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Deprecated</strong>: 
The&#160;<strong><code>OUT</code></strong> message. 
The&#160;<strong><code>OUT</code></strong> message 
is&#160;<strong><code>null</code></strong> by default. Use the 
<strong><code>IN</code></strong> message instead.</p></td></tr></tbody>
 </table></div><p>See <a shape="rect" href="scripting-languages.html">Scripting 
Languages</a> for the list of languages with explicit DSL support.</p><h3 
id="BeanShell-PassingAdditionalArgumentstotheScriptingEngine">Passing 
Additional Arguments to 
the&#160;<code>ScriptingEngine</code></h3><p><strong>Available from Camel 
2.8</strong></p><p>You can provide additional arguments to the 
<strong><code>ScriptingEngine</code></strong> using a header on the Camel 
message with the key 
<strong><code>CamelScriptArguments</code></strong>.</p><p>Example:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public void testArgumentsExample() throws Exception {
-    getMockEndpoint(&quot;mock:result&quot;).expectedMessageCount(0);
-    getMockEndpoint(&quot;mock:unmatched&quot;).expectedMessageCount(1);
-
-    // additional arguments to ScriptEngine
-    Map&lt;String, Object&gt; arguments = new HashMap&lt;String, Object&gt;();
-    arguments.put(&quot;foo&quot;, &quot;bar&quot;);
-    arguments.put(&quot;baz&quot;, 7);
-
-    // those additional arguments is provided as a header on the Camel Message
-    template.sendBodyAndHeader(&quot;direct:start&quot;, &quot;hello&quot;, 
ScriptBuilder.ARGUMENTS, arguments);
-
-    assertMockEndpointsSatisfied();
-}
-]]></script>
-</div></div><h3 id="BeanShell-UsingPropertiesFunction">Using Properties 
Function</h3><p><strong>Available from Camel 2.9</strong></p><p>If you need to 
use the <a shape="rect" href="properties.html">Properties</a> component from a 
script to lookup property placeholders, then its a bit cumbersome to do so. For 
example, to set a header name&#160;<strong><code>myHeader</code></strong> with 
a value from a property placeholder, whose key is taken from a header named 
<strong><code>foo</code></strong>.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[.setHeader(&quot;myHeader&quot;).groovy(&quot;context.resolvePropertyPlaceholders(&#39;{{&#39;
 + request.headers.get(&#39;foo&#39;) + &#39;}}&#39;)&quot;)
-]]></script>
-</div></div><p>From <strong>Camel 2.9</strong>: you can now use the properties 
function and the same example is simpler:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[.setHeader(&quot;myHeader&quot;).groovy(&quot;properties.resolve(request.headers.get(&#39;foo&#39;))&quot;)
-]]></script>
-</div></div><h3 id="BeanShell-LoadingScriptFromExternalResource">Loading 
Script From External Resource</h3><p><strong>Available from Camel 
2.11</strong></p><p>You can externalize the script and have Camel load it from 
a resource such as <strong><code>classpath:</code></strong>, 
<strong><code>file:</code></strong>, or <strong><code>http:</code></strong>. 
This is done using the following syntax: 
<strong><code>resource:scheme:location</code></strong> e.g. to refer to a file 
on the classpath you can do:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[.setHeader(&quot;myHeader&quot;).groovy(&quot;resource:classpath:mygroovy.groovy&quot;)
-]]></script>
-</div></div><h3 
id="BeanShell-HowtoGettheResultfromMultipleStatementsScript">How to Get the 
Result from Multiple Statements Script</h3><p><strong>Available from Camel 
2.14</strong></p><p>The script engine's eval method returns 
a&#160;<strong><code>null</code></strong> when it runs a multi-statement 
script. However, Camel can look up the value of a script's result by using the 
key <strong><code>result</code></strong> from the value set. When writing a 
multi-statement script set the value of 
the&#160;<strong><code>result</code></strong> variable as the script return 
value.</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: text; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[bar = &quot;baz&quot;;
+<h3 id="BeanShell-ScriptContextOptions"><code>ScriptContext</code> 
Options</h3><p>&#160;</p><rich-text-body>The&#160;<code>JSR-223</code> 
scripting language's&#160;<strong><code>ScriptContext</code></strong> is 
pre-configured with the following attributes all set at 
<strong><code>ENGINE_SCOPE</code></strong>.</rich-text-body><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Attribute</p></th><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Value</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><span><code>camelContext</code><br 
clear="none"></span></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel 
Context.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>context</code></p></td><td co
 lspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel Context (cannot be 
used in groovy).</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>exchange</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Exchange</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The current 
Exchange.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>properties</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.builder.script.PropertiesFunction</code></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> 
Function with a <strong><code>resolve</code></strong> method to make it easier 
to use Camels <a shape="rect" href="properties.html">Properties</a> component 
from scripts. See further below for example.</p></td></tr><tr><td co
 lspan="1" rowspan="1" class="confluenceTd"><p><code>request</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p>The&#160;<strong><code>IN</code></strong> 
message.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>response</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Deprecated</strong>: 
The&#160;<strong><code>OUT</code></strong> message. 
The&#160;<strong><code>OUT</code></strong> message 
is&#160;<strong><code>null</code></strong> by default. Use the 
<strong><code>IN</code></strong> message 
instead.</p></td></tr></tbody></table></div><p>See <a shape="rect" 
href="scripting-languages.html">Scripting Languages</a> for the list of 
languages with explicit DSL support.</p><h3 
id="BeanShell-PassingAdditionalArgumentstotheScriptin
 gEngine">Passing Additional Arguments to 
the&#160;<code>ScriptingEngine</code></h3><p><strong>Available from Camel 
2.8</strong></p><p>You can provide additional arguments to the 
<strong><code>ScriptingEngine</code></strong> using a header on the Camel 
message with the key 
<strong><code>CamelScriptArguments</code></strong>.</p><p>Example:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java}</plain-text-body></p><h3
 id="BeanShell-UsingPropertiesFunction">Using Properties 
Function</h3><p><strong>Available from Camel 2.9</strong></p><p>If you need to 
use the <a shape="rect" href="properties.html">Properties</a> component from a 
script to lookup property placeholders, then its a bit cumbersome to do so. For 
example, to set a header name&#160;<strong><code>myHeader</code></strong> with 
a value from a property placeholder, whose key is taken from a header named 
<strong><code>foo</code><
 
/strong>.</p><plain-text-body>.setHeader("myHeader").groovy("context.resolvePropertyPlaceholders('{{'
 + request.headers.get('foo') + '}}')")
+</plain-text-body><p>From <strong>Camel 2.9</strong>: you can now use the 
properties function and the same example is simpler:</p><parameter 
ac:name="language">java</parameter><plain-text-body>.setHeader("myHeader").groovy("properties.resolve(request.headers.get('foo'))")
+</plain-text-body><h3 id="BeanShell-LoadingScriptFromExternalResource">Loading 
Script From External Resource</h3><p><strong>Available from Camel 
2.11</strong></p><p>You can externalize the script and have Camel load it from 
a resource such as <strong><code>classpath:</code></strong>, 
<strong><code>file:</code></strong>, or <strong><code>http:</code></strong>. 
This is done using the following syntax: 
<strong><code>resource:scheme:location</code></strong> e.g. to refer to a file 
on the classpath you can do:</p><parameter 
ac:name="language">java</parameter><plain-text-body>.setHeader("myHeader").groovy("resource:classpath:mygroovy.groovy")
+</plain-text-body><h3 
id="BeanShell-HowtoGettheResultfromMultipleStatementsScript">How to Get the 
Result from Multiple Statements Script</h3><p><strong>Available from Camel 
2.14</strong></p><p>The script engine's eval method returns 
a&#160;<strong><code>null</code></strong> when it runs a multi-statement 
script. However, Camel can look up the value of a script's result by using the 
key <strong><code>result</code></strong> from the value set. When writing a 
multi-statement script set the value of 
the&#160;<strong><code>result</code></strong> variable as the script return 
value.</p><parameter ac:name="language">text</parameter><plain-text-body>bar = 
"baz";
 # some other statements ... 
 # camel take the result value as the script evaluation result
 result = body * 2 + 1
-]]></script>
-</div></div><p>&#160;</p><h3 
id="BeanShell-Dependencies">Dependencies</h3><p>To use scripting languages in 
your camel routes you need to add the a dependency on 
<strong><code>camel-script</code></strong> which integrates the JSR-223 
scripting engine.</p><p>If you use maven you could just add the following to 
your <strong><code>pom.xml</code></strong>, substituting the version number for 
the latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
+</plain-text-body><p>&#160;</p><h3 
id="BeanShell-Dependencies">Dependencies</h3><p>To use scripting languages in 
your camel routes you need to add the a dependency on 
<strong><code>camel-script</code></strong> which integrates the JSR-223 
scripting engine.</p><p>If you use maven you could just add the following to 
your <strong><code>pom.xml</code></strong>, substituting the version number for 
the latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><parameter 
ac:name="">xml</parameter><plain-text-body>&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-script&lt;/artifactId&gt;
   &lt;version&gt;x.x.x&lt;/version&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div></div>
+</plain-text-body></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/blueprint-testing.html
==============================================================================
--- websites/production/camel/content/blueprint-testing.html (original)
+++ websites/production/camel/content/blueprint-testing.html Fri Aug 25 
08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Blueprint Testing
@@ -86,141 +75,48 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 
id="BlueprintTesting-BlueprintTesting">Blueprint 
Testing</h2><p><strong>Available as of Camel 2.10</strong></p><div 
class="confluence-information-macro 
confluence-information-macro-information"><span class="aui-icon aui-icon-small 
aui-iconfont-info confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p><strong>camel-test-blueprint</strong>
 does only support testing <em>one</em> CamelContext. So if you have two or 
more CamelContexts in your blueprint XML files, then only the CamelContext 
first found is used during testing.</p></div></div><p><a shape="rect" 
href="testing.html">Testing</a><span style="line-height: 1.4285715;"> is a 
crucial part of any development or integration work. Camel supports the 
definition of </span><a shape="rect" 
href="using-osgi-blueprint-with-camel.html">Blueprint routes</a><span 
style="line-height: 1.4285715;">, but given that Blueprint is an OSGi specific 
technology, writing uni
 t tests is quite difficult. This library leverages </span><a shape="rect" 
class="external-link" href="http://code.google.com/p/pojosr/"; rel="nofollow" 
style="line-height: 1.4285715;">PojoSR</a><span style="line-height: 
1.4285715;">&#160;(now Felix Connect) which provides a service registry without 
using a fully compliant OSGi container. This allows defining real unit tests 
(as opposed to integration tests using </span><a shape="rect" 
class="external-link" 
href="http://team.ops4j.org/wiki/display/paxexam/Pax+Exam"; rel="nofollow" 
style="line-height: 1.4285715;">Pax Exam</a><span style="line-height: 
1.4285715;">. Please make sure all test jars in your classpath are OSGi 
bundles.</span></p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-// tag::example[]
-// to use camel-test-blueprint, then extend the CamelBlueprintTestSupport 
class,
-// and add your unit tests methods as shown below.
-public class DebugBlueprintTest extends CamelBlueprintTestSupport {
-
-    private boolean debugBeforeMethodCalled;
-    private boolean debugAfterMethodCalled;
-
-    // override this method, and return the location of our Blueprint XML file 
to be used for testing
-    @Override
-    protected String getBlueprintDescriptor() {
-        return &quot;org/apache/camel/test/blueprint/camelContext.xml&quot;;
-    }
-
-    // here we have regular JUnit @Test method
-    @Test
-    public void testRoute() throws Exception {
-
-        // set mock expectations
-        getMockEndpoint(&quot;mock:a&quot;).expectedMessageCount(1);
-
-        // send a message
-        template.sendBody(&quot;direct:start&quot;, &quot;World&quot;);
-
-        // assert mocks
-        assertMockEndpointsSatisfied();
-
-        // assert on the debugBefore/debugAfter methods below being called as 
we&#39;ve enabled the debugger
-        assertTrue(debugBeforeMethodCalled);
-        assertTrue(debugAfterMethodCalled);
-    }
-
-    @Override
-    public boolean isUseDebugger() {
-        // must enable debugger
-        return true;
-    }
-
-    @Override
-    protected void debugBefore(Exchange exchange, org.apache.camel.Processor 
processor, ProcessorDefinition&lt;?&gt; definition, String id, String label) {
-        log.info(&quot;Before &quot; + definition + &quot; with body &quot; + 
exchange.getIn().getBody());
-        debugBeforeMethodCalled = true;
-    }
-
-    @Override
-    protected void debugAfter(Exchange exchange, org.apache.camel.Processor 
processor, ProcessorDefinition&lt;?&gt; definition, String id, String label, 
long timeTaken) {
-        log.info(&quot;After &quot; + definition + &quot; with body &quot; + 
exchange.getIn().getBody());
-        debugAfterMethodCalled = true;
-    }
-}
-// end::example[]
-]]></script>
-</div></div>Also notice the use of 
<strong><code>getBlueprintDescriptor</code></strong> to specify the location of 
the OSGi Blueprint XML file.<br clear="none"> If you have multiple OSGi 
Blueprint XML files, then you can specify them with a comma-separated list in 
the <strong><code>getBlueprintDescriptor</code></strong> method.<p>Here's the 
<a shape="rect" class="external-link" 
href="http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/camelContext.xml?view=markup";>Blueprint
 XML file</a>:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-&lt;!-- tag::example[] --&gt;
-&lt;blueprint xmlns=&quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot;
-           xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
-           xsi:schemaLocation=&quot;
-             http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd&quot;&gt;
-
-  &lt;camelContext 
xmlns=&quot;http://camel.apache.org/schema/blueprint&quot;&gt;
-
-    &lt;route&gt;
-      &lt;from uri=&quot;direct:start&quot;/&gt;
-      &lt;transform&gt;
-        &lt;simple&gt;Hello ${body}&lt;/simple&gt;
-      &lt;/transform&gt;
-      &lt;to uri=&quot;mock:a&quot;/&gt;
-    &lt;/route&gt;
-
-  &lt;/camelContext&gt;
-
-&lt;/blueprint&gt;
-&lt;!-- end::example[] --&gt;
-]]></script>
-</div></div>In order to define blueprint tests, add the following dependency 
to your pom:<div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
+<div class="wiki-content maincontent"><h2 
id="BlueprintTesting-BlueprintTesting">Blueprint 
Testing</h2><p><strong>Available as of Camel 
2.10</strong></p><rich-text-body><p><strong>camel-test-blueprint</strong> does 
only support testing <em>one</em> CamelContext. So if you have two or more 
CamelContexts in your blueprint XML files, then only the CamelContext first 
found is used during testing.</p></rich-text-body><p><a shape="rect" 
href="testing.html">Testing</a><span style="line-height: 1.4285715;"> is a 
crucial part of any development or integration work. Camel supports the 
definition of </span><a shape="rect" 
href="using-osgi-blueprint-with-camel.html">Blueprint routes</a><span 
style="line-height: 1.4285715;">, but given that Blueprint is an OSGi specific 
technology, writing unit tests is quite difficult. This library leverages 
</span><a shape="rect" class="external-link" 
href="http://code.google.com/p/pojosr/"; rel="nofollow" style="line-height: 
1.4285715;">PojoSR</a><span style="
 line-height: 1.4285715;">&#160;(now Felix Connect) which provides a service 
registry without using a fully compliant OSGi container. This allows defining 
real unit tests (as opposed to integration tests using </span><a shape="rect" 
class="external-link" 
href="http://team.ops4j.org/wiki/display/paxexam/Pax+Exam"; rel="nofollow" 
style="line-height: 1.4285715;">Pax Exam</a><span style="line-height: 
1.4285715;">. Please make sure all test jars in your classpath are OSGi 
bundles.</span><plain-text-body>{snippet:lang=java|id=example|url=camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java}</plain-text-body>Also
 notice the use of <strong><code>getBlueprintDescriptor</code></strong> to 
specify the location of the OSGi Blueprint XML file.<br clear="none"> If you 
have multiple OSGi Blueprint XML files, then you can specify them with a 
comma-separated list in the 
<strong><code>getBlueprintDescriptor</code></strong> method.</p><p>Here'
 s the <a shape="rect" class="external-link" 
href="http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/camelContext.xml?view=markup";>Blueprint
 XML 
file</a>:<plain-text-body>{snippet:lang=xml|id=example|url=camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/camelContext.xml}</plain-text-body>In
 order to define blueprint tests, add the following dependency to your 
pom:</p><parameter ac:name="">xml</parameter><plain-text-body>&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-test-blueprint&lt;/artifactId&gt;
   &lt;version&gt;2.10&lt;/version&gt;
   &lt;scope&gt;test&lt;/scope&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div><h3 id="BlueprintTesting-Classpathscanning">Classpath 
scanning</h3><p>By default PojoSR test container scans the test classpath for 
all the OSGi bundles available there. All the bundles with Blueprint descriptor 
files will be automatically started by the test container. If you would like to 
prevent particular bundles from being started by the test container, override 
the <code><strong>getBundleFilter</strong></code> method, just as demonstrated 
in the snippet below.&#160;</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[@Override
+</plain-text-body><h3 id="BlueprintTesting-Classpathscanning">Classpath 
scanning</h3><p>By default PojoSR test container scans the test classpath for 
all the OSGi bundles available there. All the bundles with Blueprint descriptor 
files will be automatically started by the test container. If you would like to 
prevent particular bundles from being started by the test container, override 
the <code><strong>getBundleFilter</strong></code> method, just as demonstrated 
in the snippet below.&#160;</p><parameter 
ac:name="language">java</parameter><plain-text-body>@Override
 protected String getBundleFilter() {
-  // I don&#39;t want test container to scan and load Logback bundle during 
the test
-  return &quot;(!(Bundle-SymbolicName=ch.qos.logback.core))&quot;;
+  // I don't want test container to scan and load Logback bundle during the 
test
+  return "(!(Bundle-SymbolicName=ch.qos.logback.core))";
 }
-]]></script>
-</div></div><p class="caseCommentStyle privateComment"><br clear="none">Keep 
in mind that not specifying the Blueprint descriptor in the 
getBlueprintDescriptor method will not prevent the test container from loading 
a given descriptor. The <code>getBundleFilter</code> method is the proper way 
of filtering out bundles you don't want to start during the test.</p><h3 
id="BlueprintTesting-SettingtimeoutwhengettingCamelContext">Setting timeout 
when getting CamelContext</h3><p><strong>Available as of Camel 
2.13.0/2.12.1/2.11.2</strong></p><p><code>CamelBlueprintTestSupport</code> 
waits 30 seconds for Camel Context to be ready by default, now you can override 
this value in two ways:</p><ul><li>Globally, by setting 
<code>org.apache.camel.test.blueprint.camelContextCreationTimeout</code> system 
property.</li><li>Locally for each test, by overriding 
<em>getCamelContextCreationTimeout</em> method.</li></ul><h3 
id="BlueprintTesting-Addingservicesonstartup">Adding services on 
startup</h3><p><str
 ong>Available as of Camel 2.11.2/2.12.0</strong></p><p>When using 
<code>camel-test-blueprint</code> you may do unit tests which requires using 
shared services which are not available during unit testing, but only in the 
real OSGi container, for example a shared <code>DataSource</code>.</p><p>To 
make it easier to register services on startup, such as a standalone 
<code>DataSource</code> or any other service, you can override the method 
<code>addServicesOnStartup</code> when your unit test class extends 
<code>CamelBlueprintTestSupport</code>.</p><p>In the example below we register 
a service <code>org.apache.camel.test.blueprint.MyService</code> using the name 
<code>myService</code> having a property <code>beer=Carlsberg</code>, as shown 
below:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[    @Override
+</plain-text-body><p class="caseCommentStyle privateComment"><br 
clear="none">Keep in mind that not specifying the Blueprint descriptor in the 
getBlueprintDescriptor method will not prevent the test container from loading 
a given descriptor. The <code>getBundleFilter</code> method is the proper way 
of filtering out bundles you don't want to start during the test.</p><h3 
id="BlueprintTesting-SettingtimeoutwhengettingCamelContext">Setting timeout 
when getting CamelContext</h3><p><strong>Available as of Camel 
2.13.0/2.12.1/2.11.2</strong></p><p><code>CamelBlueprintTestSupport</code> 
waits 30 seconds for Camel Context to be ready by default, now you can override 
this value in two ways:</p><ul><li>Globally, by setting 
<code>org.apache.camel.test.blueprint.camelContextCreationTimeout</code> system 
property.</li><li>Locally for each test, by overriding 
<em>getCamelContextCreationTimeout</em> method.</li></ul><h3 
id="BlueprintTesting-Addingservicesonstartup">Adding services on startup</h3><
 p><strong>Available as of Camel 2.11.2/2.12.0</strong></p><p>When using 
<code>camel-test-blueprint</code> you may do unit tests which requires using 
shared services which are not available during unit testing, but only in the 
real OSGi container, for example a shared <code>DataSource</code>.</p><p>To 
make it easier to register services on startup, such as a standalone 
<code>DataSource</code> or any other service, you can override the method 
<code>addServicesOnStartup</code> when your unit test class extends 
<code>CamelBlueprintTestSupport</code>.</p><p>In the example below we register 
a service <code>org.apache.camel.test.blueprint.MyService</code> using the name 
<code>myService</code> having a property <code>beer=Carlsberg</code>, as shown 
below:</p><plain-text-body>    @Override
     protected void addServicesOnStartup(Map&lt;String, 
KeyValueHolder&lt;Object, Dictionary&gt;&gt; services) {
-        services.put(&quot;myService&quot;, asService(myService, 
&quot;beer&quot;, &quot;Carlsberg&quot;));
+        services.put("myService", asService(myService, "beer", "Carlsberg"));
     }
-]]></script>
-</div></div><p>The asService is a builder method that makes it easy to 
register a service with a single property. If you need more properties you can 
use the <code>asService</code> method that takes a <code>Dictionary</code> as 
argument. And if you do not need any properties, then just pass in 
<code>null</code>, eg:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[services.put(&quot;myService&quot;, 
asService(myService, null));
-]]></script>
-</div></div><p>This allows us to use the service by calling a method on it 
from a Camel <a shape="rect" href="bean.html">Bean</a> component in a route as 
shown:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[    &lt;route&gt;
-      &lt;from uri=&quot;direct:start&quot;/&gt;
-      &lt;to uri=&quot;bean:myService&quot;/&gt;
-      &lt;to uri=&quot;mock:result&quot;/&gt;
+</plain-text-body><p>The asService is a builder method that makes it easy to 
register a service with a single property. If you need more properties you can 
use the <code>asService</code> method that takes a <code>Dictionary</code> as 
argument. And if you do not need any properties, then just pass in 
<code>null</code>, eg:</p><plain-text-body>services.put("myService", 
asService(myService, null));
+</plain-text-body><p>This allows us to use the service by calling a method on 
it from a Camel <a shape="rect" href="bean.html">Bean</a> component in a route 
as shown:</p><parameter ac:name="">xml</parameter><plain-text-body>    
&lt;route&gt;
+      &lt;from uri="direct:start"/&gt;
+      &lt;to uri="bean:myService"/&gt;
+      &lt;to uri="mock:result"/&gt;
     &lt;/route&gt;
-]]></script>
-</div></div><p>Notice the bean endpoint uses the service name 
<code>myService</code> which was the name we registered the service as. You can 
also use the fully qualified class name instead, which is more common with 
OSGi.</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[    @Override
+</plain-text-body><p>Notice the bean endpoint uses the service name 
<code>myService</code> which was the name we registered the service as. You can 
also use the fully qualified class name instead, which is more common with 
OSGi.</p><plain-text-body>    @Override
     protected void addServicesOnStartup(Map&lt;String, 
KeyValueHolder&lt;Object, Dictionary&gt;&gt; services) {
-        services.put(MyService.class.getName(), asService(myService, 
&quot;beer&quot;, &quot;Carlsberg&quot;));
+        services.put(MyService.class.getName(), asService(myService, "beer", 
"Carlsberg"));
     }
-]]></script>
-</div></div><p>And in the route we use the FQN name:</p><div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[    &lt;route&gt;
-      &lt;from uri=&quot;direct:start&quot;/&gt;
-      &lt;to 
uri=&quot;bean:org.apache.camel.test.blueprint.MyService&quot;/&gt;
-      &lt;to uri=&quot;mock:result&quot;/&gt;
+</plain-text-body><p>And in the route we use the FQN name:</p><parameter 
ac:name="">xml</parameter><plain-text-body>    &lt;route&gt;
+      &lt;from uri="direct:start"/&gt;
+      &lt;to uri="bean:org.apache.camel.test.blueprint.MyService"/&gt;
+      &lt;to uri="mock:result"/&gt;
     &lt;/route&gt;
-]]></script>
-</div></div><p>&#160;</p><p><span>From&#160;</span><strong>Camel 
2.16.0</strong><span>, an 
additional&#160;</span><span><code>addServicesOnStartup</code> method is 
available to be overridden making it ideal for when needing to specify multiple 
services with the same interface.</span><span>&#160;</span></p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[  @Override
+</plain-text-body><p>&#160;</p><p><span>From&#160;</span><strong>Camel 
2.16.0</strong><span>, an 
additional&#160;</span><span><code>addServicesOnStartup</code> method is 
available to be overridden making it ideal for when needing to specify multiple 
services with the same interface.</span><span>&#160;</span></p><parameter 
ac:name="language">java</parameter><plain-text-body>  @Override
   protected void addServicesOnStartup(List&lt;KeyValueHolder&lt;String, 
KeyValueHolder&lt;Object, Dictionary&gt;&gt;&gt; services) {
       Dictionary&lt;String, String&gt; dict1 = new Hashtable&lt;String, 
String&gt;();
-      dict1.put(&quot;osgi.jndi.service.name&quot;, &quot;jdbc/db1&quot;);
-        
+      dict1.put("osgi.jndi.service.name", "jdbc/db1");
+       &#160;
       Dictionary&lt;String, String&gt; dict2 = new Hashtable&lt;String, 
String&gt;();
-      dict2.put(&quot;osgi.jndi.service.name&quot;, &quot;jdbc/db2&quot;);
-        
+      dict2.put("osgi.jndi.service.name", "jdbc/db2");
+       &#160;
       services.add(asKeyValueService(javax.sql.DataSource.class.getName(), 
mockService1, dict1));
       services.add(asKeyValueService(javax.sql.DataSource.class.getName(), 
mockService2, dict2));
     }
-]]></script>
-</div></div><p><span>The <code>asKeyValueService</code> builder method can be 
used to construct the necessary parameters to create the service. The method 
takes in the name of the registered service, the object, and and a 
<code><span>Dictionary</span></code>&#160;as arguments.</span></p></div>
+</plain-text-body><p><span>The <code>asKeyValueService</code> builder method 
can be used to construct the necessary parameters to create the service. The 
method takes in the name of the registered service, the object, and and a 
<code><span>Dictionary</span></code>&#160;as arguments.</span></p></div>
         </td>
         <td valign="top">
           <div class="navigation">


Reply via email to