{"id":37011,"date":"2015-02-16T19:00:33","date_gmt":"2015-02-16T17:00:33","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=37011"},"modified":"2015-02-12T12:59:29","modified_gmt":"2015-02-12T10:59:29","slug":"osgi-service-test-helper-serviceregistrationrule","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html","title":{"rendered":"OSGi Service Test Helper: ServiceRegistrationRule"},"content":{"rendered":"<p><a title=\"OSGi\" href=\"http:\/\/www.osgi.org\/Main\/HomePage\" target=\"_blank\">OSGi<\/a> Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about <a title=\"OSGi Service Test Helper: ServiceCollector\" href=\"\/2015\/02\/05\/osgi-service-test-helper-servicecollector\/\">writing simple service contribution verifications<\/a>, this time I introduce a <a title=\"JUnit Rules\" href=\"https:\/\/facon-biz.prossl.de\/2012\/09\/24\/junit-rules\/\">JUnit rule<\/a> that assists in testing interactions between components.<\/p>\n<h2>OSGi Service Tests for Component Interaction<\/h2>\n<p>Assume we have a service that notifies related observers bound according to the <a title=\"OSGi Whiteboard Pattern\" href=\"http:\/\/www.osgi.org\/wiki\/uploads\/Links\/whiteboard.pdf\" target=\"_blank\">whiteboard-pattern<\/a>. Precisely we have a <code>Service<\/code> declaration and <code>ServiceImpl<\/code> as in the previous post. Additionaly we support <code>ServiceListener<\/code>s that should be notified on particular actions.<\/p>\n<p>To represent such an action we broaden the service interface of our example with a method declaration called <code>Service#execute()<\/code>:<\/p>\n<pre class=\" brush:java\">public interface Service {\r\n  void execute();\r\n}<\/pre>\n<p>Beside the implementation of this <code>execute<\/code> method the contribution class have to provide the capabilities to bind and unbind <code>ServiceListener<\/code> references:<\/p>\n<pre class=\" brush:java\">public class ServiceImpl\r\n  implements Service\r\n{\r\n  public void execute() {\r\n    [...]\r\n  }\r\n\r\n  public void bind( ServiceListener listener ) {\r\n    [...]\r\n  }\r\n\r\n  public void unbind( ServiceListener listener ) {\r\n    [...]\r\n  }\r\n}<\/pre>\n<p>As notification destination the callback type <code>ServiceListener<\/code>s provides a method declaration called <code>ServiceListener#executed()<\/code>:<\/p>\n<pre class=\" brush:java\">public interface ServiceListener {\r\n  void executed();\r\n}<\/pre>\n<p>To complete the setup we have to register the service component, which we do again via <a title=\"Declarative Services\" href=\"http:\/\/wiki.osgi.org\/wiki\/Declarative_Services\" target=\"_blank\">declarative services<\/a>. Note the additional 0..n reference declaration:<\/p>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;scr:component\r\n  xmlns:scr=\"http:\/\/www.osgi.org\/xmlns\/scr\/v1.1.0\"\r\n  immediate=\"true\" \r\n  name=\"Implementation of Service API\"&gt;\r\n  &lt;implementation class=\"com.codeaffine.example.core.ServiceImpl\"\/&gt;\r\n  &lt;service&lt;\r\n    &lt;provide interface=\"com.codeaffine.example.api.Service\"\/&gt;\r\n  &lt;\/service&gt;\r\n  &lt;reference \r\n    bind=\"bind\" \r\n    unbind=\"unbind\"\r\n    cardinality=\"0..n\"\r\n    interface=\"com.codeaffine.example.api.ServiceListener\"\r\n    name=\"ServiceListener\"\r\n    policy=\"dynamic\" \/&gt;\r\n&lt;\/scr:component&gt;<\/pre>\n<p>Now the question is: How can we test that un-\/binding of a listener works correctly and notifications are dispatched as expected? The basic idea is to register a <code>ServiceListener<\/code> <a title=\"Test Isolation\" href=\"\/2014\/08\/27\/junit-in-a-nutshell-test-isolation\/\">spy<\/a> and trigger <code>Service#execute<\/code> on the actual service implementation.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The spy records calls to <code>execute<\/code> and allows to verify that <em>binding and notification<\/em> work as expected. Once we have ensured this, we can go on and deregister a primarily registered spy and verify that it is not notified about a subsequent action event. This makes sure unbinding works also as planned.<\/p>\n<p>However the test <a title=\"Test Structure\" href=\"\/2014\/08\/18\/junit-in-a-nutshell-test-structure\/\">fixture<\/a> for this scenario usually needs a bit of OSGi boilerplate. To reduce the clutter I have written a little JUnit rule that eases service registration and automatically performs a service registry cleanup after each test run.<\/p>\n<h2>ServiceRegistrationRule<\/h2>\n<p>As every other JUnit <code>TestRule<\/code> the <code>ServiceRegistrationRule<\/code> has to be provided as a public field in our <a title=\"What is a PDE JUnit test\" href=\"https:\/\/wiki.eclipse.org\/FAQ_What_is_a_PDE_JUnit_test%3F\" target=\"_blank\">PDE test<\/a>. Note how the rule uses a parameterized constructor given the class instance of the test case. This reference is used to get hold of an appropriate <code>BundleContext<\/code> for service de-\/registration.<\/p>\n<pre class=\" brush:java\">@Rule\r\npublic final ServiceRegistrationRule serviceRegistration\r\n  = new ServiceRegistrationRule( getClass() );\r\n\r\nprivate ServiceListener listener;\r\nprivate Service service;\r\n\r\n@Before\r\npublic void setUp() {\r\n  service = collectServices( Service.class, ServiceImpl.class ).get( 0 );\r\n  listener = mock( ServiceListener.class );\r\n}<\/pre>\n<p>The <a title=\"JUnit in a Nutshell: Test Structure\" href=\"\/2014\/08\/18\/junit-in-a-nutshell-test-structure\/\">implicit test setup<\/a> retrieves the registered <em>service under test<\/em> using the <code>ServiceCollector<\/code> I introduced in the <a title=\"OSGi Service Test Helper: ServiceCollector\" href=\"\/2015\/02\/05\/osgi-service-test-helper-servicecollector\/\">last post<\/a>. The listener <a title=\"Test Isolation\" href=\"\/2014\/08\/27\/junit-in-a-nutshell-test-isolation\/\" target=\"_blank\">DOC<\/a> is created as spy using <a title=\"mockito\" href=\"https:\/\/github.com\/mockito\/mockito\" target=\"_blank\">mockito<\/a>. The first test scenario described above looks like this:<\/p>\n<pre class=\" brush:java\">@Test\r\npublic void executeNotification() {\r\n  serviceRegistration.register( ServiceListener.class, listener );\r\n\r\n  service.execute();\r\n\r\n  verify( listener ).executed();\r\n}<\/pre>\n<p>Pretty straight forward, isn\u2019t it?<\/p>\n<p>Note that the <code>ServiceRegistrationRule<\/code> takes care of cleanup and removes the spy service from the service registry. To facilitate a test for the unbind scenario, the rule\u2019s <code>register<\/code> method returns a handle to the service registration:<\/p>\n<pre class=\" brush:java\">@Test\r\npublic void executeAfterListenerRemoval() {\r\n  Registration registration\r\n    = serviceRegistration.register( ServiceListener.class, listener );\r\n  registration.unregister();\r\n\r\n  service.execute();\r\n\r\n  verify( listener, never() ).executed();\r\n}<\/pre>\n<p>Line five (<code>registration.unregister()<\/code>) removes the listener spy from the service registry. This triggers an unbind and the listener gets never invoked. Of course a real world scenario could add additional tests for multiple listener registrations, exception handling and the like, but I think the concept has been made clear.<\/p>\n<h2>Conclusion<\/h2>\n<p>So far the <code>ServiceRegistrationRule<\/code> proves itself quite useful in our current project. It reduces boilerplate significantly and makes the tests cleaner and increases readability. The class is part of the <em>com.codeaffine.osgi.test.util<\/em> feature of the Xiliary P2 repository: <a title=\"Xiliary P2 Repository\" href=\"http:\/\/fappel.github.io\/xiliary\" target=\"_blank\">http:\/\/fappel.github.io\/xiliary<\/a><\/p>\n<p>In case you want to have a look at the code or file an issue you might also have a look at the Xiliary GitHub project: <a title=\"Xiliary GitHub Project\" href=\"https:\/\/github.com\/fappel\/xiliary\" target=\"_blank\">https:\/\/github.com\/fappel\/xiliary<\/a><\/p>\n<p>For everything else feel free to use the commenting section below. In a followup I will explain how to setup a <a title=\"Tycho Home\" href=\"https:\/\/eclipse.org\/tycho\/\" target=\"_blank\">maven-tycho<\/a> build with integrated PDE-Tests as those described above. This is somewhat tricky as tycho does not allow to access the bundles built by the current reactor, so stay tuned..<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/www.codeaffine.com\/2015\/02\/11\/osgi-service-test-helper-serviceregistrationrule\/\">OSGi Service Test Helper: ServiceRegistrationRule<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\/\">JCG partner<\/a> Rudiger Herrmann at the <a href=\"http:\/\/www.codeaffine.com\/\">Code Affine<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>OSGi Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about writing simple service contribution verifications, this time I introduce a JUnit rule that assists in testing interactions between components. OSGi Service Tests for Component Interaction Assume we have a service that notifies related &hellip;<\/p>\n","protected":false},"author":321,"featured_media":211,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[190],"class_list":["post-37011","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-osgi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>OSGi Service Test Helper: ServiceRegistrationRule - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"OSGi Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about writing simple service\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OSGi Service Test Helper: ServiceRegistrationRule - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"OSGi Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about writing simple service\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-02-16T17:00:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rudiger Herrmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rudiger Herrmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html\"},\"author\":{\"name\":\"Rudiger Herrmann\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/e00c96921175d8069228650cf201e3c6\"},\"headline\":\"OSGi Service Test Helper: ServiceRegistrationRule\",\"datePublished\":\"2015-02-16T17:00:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html\"},\"wordCount\":607,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/osgi-alliance-logo.jpg\",\"keywords\":[\"OSGi\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html\",\"name\":\"OSGi Service Test Helper: ServiceRegistrationRule - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/osgi-alliance-logo.jpg\",\"datePublished\":\"2015-02-16T17:00:33+00:00\",\"description\":\"OSGi Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about writing simple service\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/osgi-alliance-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/osgi-alliance-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/02\\\/osgi-service-test-helper-serviceregistrationrule.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"OSGi Service Test Helper: ServiceRegistrationRule\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/e00c96921175d8069228650cf201e3c6\",\"name\":\"Rudiger Herrmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a1d7de5a95b9fba129829d5467d88ca9db14d45a2879b1767dfd911faae27673?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a1d7de5a95b9fba129829d5467d88ca9db14d45a2879b1767dfd911faae27673?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a1d7de5a95b9fba129829d5467d88ca9db14d45a2879b1767dfd911faae27673?s=96&d=mm&r=g\",\"caption\":\"Rudiger Herrmann\"},\"sameAs\":[\"http:\\\/\\\/www.codeaffine.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/rudiger-herrmann\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OSGi Service Test Helper: ServiceRegistrationRule - Java Code Geeks","description":"OSGi Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about writing simple service","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html","og_locale":"en_US","og_type":"article","og_title":"OSGi Service Test Helper: ServiceRegistrationRule - Java Code Geeks","og_description":"OSGi Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about writing simple service","og_url":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2015-02-16T17:00:33+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","type":"image\/jpeg"}],"author":"Rudiger Herrmann","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Rudiger Herrmann","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html"},"author":{"name":"Rudiger Herrmann","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/e00c96921175d8069228650cf201e3c6"},"headline":"OSGi Service Test Helper: ServiceRegistrationRule","datePublished":"2015-02-16T17:00:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html"},"wordCount":607,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","keywords":["OSGi"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html","url":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html","name":"OSGi Service Test Helper: ServiceRegistrationRule - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","datePublished":"2015-02-16T17:00:33+00:00","description":"OSGi Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about writing simple service","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2015\/02\/osgi-service-test-helper-serviceregistrationrule.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"OSGi Service Test Helper: ServiceRegistrationRule"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/e00c96921175d8069228650cf201e3c6","name":"Rudiger Herrmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a1d7de5a95b9fba129829d5467d88ca9db14d45a2879b1767dfd911faae27673?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a1d7de5a95b9fba129829d5467d88ca9db14d45a2879b1767dfd911faae27673?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a1d7de5a95b9fba129829d5467d88ca9db14d45a2879b1767dfd911faae27673?s=96&d=mm&r=g","caption":"Rudiger Herrmann"},"sameAs":["http:\/\/www.codeaffine.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/rudiger-herrmann"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/37011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=37011"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/37011\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/211"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=37011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=37011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=37011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}