[
https://issues.apache.org/jira/browse/SLING-12385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17874265#comment-17874265
]
Henry Kuijpers commented on SLING-12385:
----------------------------------------
Another thing worth mentioning is that the service.ranking must be of type
integer to be properly compared to other service.ranking.
If the service.ranking is not an int, it will be considered as
service.ranking=0. See:
[https://github.com/apache/felix-dev/blob/bcf435d69ab0ab8e6a9f303fc3092e7731b9a1ea/configadmin/src/main/java/org/apache/felix/cm/impl/RankingComparator.java#L126]
> 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)