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

Julian Sedding commented on SLING-12385:
----------------------------------------

[~bartthierens] further to Henry's comments, your assumption that a lower 
service ranking is ordered before a higher one is wrong.

{quote}
The _ranking order_ is defined as follows:
 * Sorted on descending ranking number (highest first)
 * If the ranking numbers are equal, sorted on ascending {{service.id}} 
property (oldest first).
{quote}

Source: 
https://docs.osgi.org/specification/osgi.core/8.0.0/framework.service.html#framework.service.servicerankingorder

> OSGi mock context seems to not take service ranking into account
> ----------------------------------------------------------------
>
>                 Key: SLING-12385
>                 URL: https://issues.apache.org/jira/browse/SLING-12385
>             Project: Sling
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: Testing OSGi Mock 3.4.2
>            Reporter: Bart Thierens
>            Priority: Major
>
> Logging this issue here as I can't log it in github.  I assume this is the 
> correct approach.
> I am unable to make my registered services in a test case mimick the same 
> ordering behaviour than in an actual OSGi environment.  The 
> AemContext/AemContextImpl/SlingContextImpl/OsgiContextImpl does not respect 
> the `@ServiceRanking` annotation, nor the component property 
> "service.ranking".
> It seems vital to be able to test that a certain part of application logic 
> executes certain services in order, and that seems impossible now - unless 
> the developer registers the services exactly in the order he expects them, 
> which beats the purpose of the test.
> If this is documented behaviour, I can't find it anywhere... (And it's still 
> not correct imho)
> Personal use case: A certain component that has "processors" (which are 
> components implementing a single service) that are ordered by service ranking 
> (low = first, high = later). When a service is disabled/unregistered, 
> registered or even re-registered, the order must stay consistent (low => 
> high).  This actually works perfectly, but not in test-cases.
> I created a demo (AEM) project that showcases this problem: 
> [https://github.com/senn/aemcontext-no-serviceranking-ordering]
> It contains tests for the various context implementations and also a separate 
> branch that has the same issue without `@ServiceRanking` and with the 
> "service.ranking" properties.
> I don't have a fix ready, but might look into it in a few weeks when I have 
> time.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to