You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Stefan Seifert (Jira)" <ji...@apache.org> on 2021/03/08 20:41:00 UTC

[jira] [Commented] (SLING-9708) Osgi Mocks cannot support map-only activate signature

    [ https://issues.apache.org/jira/browse/SLING-9708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17297691#comment-17297691 ] 

Stefan Seifert commented on SLING-9708:
---------------------------------------

following the error message this is not a problem with the calling the component's activate method (which supports a map-only signature for quite along time), but with calling a bind method "bindAuthorizationService" where osgi-mock currently does not fully support all allowed signatures (see SLING-7284).
marking as duplicated of SLING-7284.

in case you really have a problem with the activate method, please have a look at the unit tests:
https://github.com/apache/sling-org-apache-sling-testing-osgi-mock/blob/8521c37905817c56865934389318a2939222413f/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java#L106-L116
https://github.com/apache/sling-org-apache-sling-testing-osgi-mock/blob/master/test-services/src/main/java/org/apache/sling/testing/mock/osgi/testsvc/osgiserviceutil/activatedeactivate/Service3.java

> Osgi Mocks cannot support map-only activate signature
> -----------------------------------------------------
>
>                 Key: SLING-9708
>                 URL: https://issues.apache.org/jira/browse/SLING-9708
>             Project: Sling
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: Testing OSGi Mock 2.4.16
>            Reporter: Ian Reasor
>            Priority: Major
>
> Calling OsgiContext.registerInjectActivateService(T service,
>  java.util.Map<String, Object> properties) on a service with an activate method that has a signature in the style of:
> {code:java}
> protected void activate(Map<String, Object> props){code}
> results in a RuntimeException:
> {quote}java.lang.RuntimeException: Bind method with name bindAuthorizationService not found for reference 'authorizationService' for class <SERVICE_UNDER_TEST>
> {quote}
> It seems that the framework expects a BundleContext to be present in the activate method's signature.  I was able to work around this issue by updating the method signature to:
> {code:java}
> protected void activate(BundleContext bundleContext, Map<String, Object> props){code}
> but ideally, we would be able to use either signature. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)