sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r1004130 - in /websites/staging/sling/trunk/content: ./ documentation/development/osgi-mock.html
Date Wed, 04 Jan 2017 14:04:35 GMT
Author: buildbot
Date: Wed Jan  4 14:04:34 2017
New Revision: 1004130

Staging update by buildbot for sling

    websites/staging/sling/trunk/content/   (props changed)

Propchange: websites/staging/sling/trunk/content/
--- cms:source-revision (original)
+++ cms:source-revision Wed Jan  4 14:04:34 2017
@@ -1 +1 @@

Modified: websites/staging/sling/trunk/content/documentation/development/osgi-mock.html
--- websites/staging/sling/trunk/content/documentation/development/osgi-mock.html (original)
+++ websites/staging/sling/trunk/content/documentation/development/osgi-mock.html Wed Jan
 4 14:04:34 2017
@@ -123,6 +123,7 @@ h2:hover > .headerlink, h3:hover > .head
 <li><a href="#osgi-context-junit-rule">OSGi Context JUnit Rule</a></li>
 <li><a href="#getting-osgi-mock-objects">Getting OSGi mock objects</a></li>
 <li><a href="#activation-and-dependency-injection">Activation and Dependency
+<li><a href="#provide-your-own-configuration-via-configadmin">Provide your own
configuration via ConfigAdmin</a></li>
 <li><a href="#context-plugins">Context Plugins</a></li>
@@ -298,6 +299,21 @@ are preset in the classpath at <code>/OS
 missing if your clean and build the project within your IDE (e.g. Eclipse). In this case
you have to compile the
 project again with maven and can run the tests - or use a Maven IDE Integration like m2eclipse.</li>
+<h3 id="provide-your-own-configuration-via-configadmin">Provide your own configuration
via ConfigAdmin<a class="headerlink" href="#provide-your-own-configuration-via-configadmin"
title="Permanent link">&para;</a></h3>
+<p>If you want to provide your own configuration to an OSGi service that you do not
register and activate itself in the mock context you can provide your own custom OSGi configuration
via the mock implementation of the <code>ConfigAdmin</code> service.</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+5</pre></div></td><td class="code"><div class="codehilite"><pre><span
class="n">ConfigurationAdmin</span> <span class="n">configAdmin</span>
<span class="o">=</span> <span class="n">context</span><span class="o">.</span><span
class="na">getService</span><span class="o">(</span><span class="n">ConfigurationAdmin</span><span
class="o">.</span><span class="na">class</span><span class="o">);</span>
+<span class="n">Configuration</span> <span class="n">myServiceConfig</span>
<span class="o">=</span> <span class="n">configAdmin</span><span
class="o">.</span><span class="na">getConfiguration</span><span class="o">(</span><span
class="n">MY_SERVICE_PID</span><span class="o">);</span>
+<span class="n">Dictionary</span><span class="o">&lt;</span><span
class="n">String</span><span class="o">,</span> <span class="n">Object</span><span
class="o">&gt;</span> <span class="n">props</span> <span class="o">=</span>
<span class="k">new</span> <span class="n">Hashtable</span><span
class="o">&lt;</span><span class="n">String</span><span class="o">,</span>
<span class="n">Object</span><span class="o">&gt;();</span>
+<span class="n">props</span><span class="o">.</span><span class="na">put</span><span
class="o">(</span><span class="s">&quot;prop1&quot;</span><span
class="o">,</span> <span class="s">&quot;value1&quot;</span><span
+<span class="n">myServiceConfig</span><span class="o">.</span><span
class="na">update</span><span class="o">(</span><span class="n">props</span><span
 <h3 id="context-plugins">Context Plugins<a class="headerlink" href="#context-plugins"
title="Permanent link">&para;</a></h3>
 <p>OSGi Mocks supports "Context Plugins" that hook into the lifecycle of each test
run and can prepare test setup before or after the other setUp actions, and execute test tear
down code before or after the other tearDown action.</p>
 <p>To define a plugin implement the <code>;OsgiContextImpl&gt;</code>
interface. For convenience it is recommended to extend the abstract class <code>;OsgiContextImpl&gt;</code>.
These plugins can be used with OSGi Mock context, but also with context instances deriving
from it like Sling Mocks and AEM Mocks. In most cases you would just override the <code>afterSetUp</code>
method. In this method you can register additional OSGi services or do other preparation work.
It is recommended to define a constant pointing to a singleton of a plugin instance for using
@@ -315,7 +331,7 @@ project again with maven and can run the
 <li><a href="">Apache
Sling Context-Aware Configuration Mock Plugin Test</a></li>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1773500 by sseifert on Sat, 10 Dec 2016 07:59:19 +0000
+        Rev. 1777318 by sseifert on Wed, 4 Jan 2017 14:04:18 +0000
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

View raw message