You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2014/02/19 14:19:36 UTC

svn commit: r898508 - in /websites/production/camel/content: blueprint-testing.html cache/main.pageCache

Author: buildbot
Date: Wed Feb 19 13:19:36 2014
New Revision: 898508

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/blueprint-testing.html
    websites/production/camel/content/cache/main.pageCache

Modified: websites/production/camel/content/blueprint-testing.html
==============================================================================
--- websites/production/camel/content/blueprint-testing.html (original)
+++ websites/production/camel/content/blueprint-testing.html Wed Feb 19 13:19:36 2014
@@ -86,12 +86,7 @@
 	<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>
-
-<p><a shape="rect" href="testing.html">Testing</a> is a crucial part of any development or integration work.  Camel supports the definition of <a shape="rect" href="using-osgi-blueprint-with-camel.html">Blueprint routes</a>, but given Blueprint is an OSGi specific technology, writing unit tests is quite difficult.  This library leverages <a shape="rect" class="external-link" href="http://code.google.com/p/pojosr/" rel="nofollow">PojoSR</a> which provides a service registry without using a fully compliant OSGi container.  This allows defining real unit tests (as opposed to integration tests using <a shape="rect" class="external-link" href="http://team.ops4j.org/wiki/display/paxexam/Pax+Exam" rel="nofollow">Pax Exam</a>. Please make sure all test jars in you class path are OSGi bundle.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<div class="wiki-content maincontent"><h2 id="BlueprintTesting-BlueprintTesting">Blueprint Testing</h2><p><strong>Available as of Camel 2.10</strong></p><p><a shape="rect" href="testing.html">Testing</a> is a crucial part of any development or integration work. Camel supports the definition of <a shape="rect" href="using-osgi-blueprint-with-camel.html">Blueprint routes</a>, but given Blueprint is an OSGi specific technology, writing unit tests is quite difficult. This library leverages <a shape="rect" class="external-link" href="http://code.google.com/p/pojosr/" rel="nofollow">PojoSR</a> which provides a service registry without using a fully compliant OSGi container. This allows defining real unit tests (as opposed to integration tests using <a shape="rect" class="external-link" href="http://team.ops4j.org/wiki/display/paxexam/Pax+Exam" rel="nofollow">Pax Exam</a>. Please make sure all test jars in you class path are OSGi bundle.</p><div class="code panel pdl" style="border-width: 
 1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
 // to use camel-test-blueprint, then extend the CamelBlueprintTestSupport class,
 // and add your unit tests methods as shown below.
@@ -143,13 +138,7 @@ public class DebugBlueprintTest extends 
     }
 }
 ]]></script>
-</div></div>
-
-<p>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>: </p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>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>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
 &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;
@@ -170,78 +159,45 @@ If you have multiple OSGi Blueprint XML 
 
 &lt;/blueprint&gt;
 ]]></script>
-</div></div>
-
-<p>In order to define blueprint tests, add the following dependency in your pom:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;dependency&gt;
+</div></div><p>In order to define blueprint tests, add the following dependency in your pom:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&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-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 sec 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 is 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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-    @Override
+</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 on the snippet below.&#160;</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@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;;
+}
+]]></script>
+</div></div><p class="caseCommentStyle privateComment"><br clear="none">Keep in mind that not specifying the Blueprint descriptor in the <strong><code>getBlueprintDescriptor</code></strong> method will not prevent the test container from loading given descriptor. Bundle filter 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 sec 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 is 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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[    @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;));
     }
 ]]></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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-services.put(&quot;myService&quot;, asService(myService, null));
+</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="theme: Default; brush: java; gutter: false" 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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-    &lt;route&gt;
+</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="theme: Default; brush: xml; gutter: false" 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;
     &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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-    @Override
+</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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[    @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;));
     }
 ]]></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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-    &lt;route&gt;
+</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="theme: Default; brush: xml; gutter: false" 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;

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.