Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Duplicate
-
Testing OSGi Mock 2.4.2
-
None
-
None
Description
I try to unittest osgi components which use r7 property names containing the "$_$" style to embed the "-" character according to OSGI r7 (chapter 105.15.2, metatypes). I also use the annotation-style configuration approach.
@Designate(ocd=HealthcheckService.Config) public class HealthCheckService, { @AttributeDefinnition(...) public @interface Config { @AttributeDefinition() String recipients_email$_$addresses; } @Activate protected void activate (Config conf) { String recipient = conf.recipients_email$_$addresses; }
healthcheckService = new HealthCheckService(); @Before public void setUp() throws Exception { configuration.put("recipients.email-addresses", "test@example.com"); } @Test public void test () { context.registerInjectActivateService(healthcheckService, configuration); // test code }
But debugging showed, that this value test@example.com was never written into the field recipient of the HealthCheckService component.
I tracked it down into the OsgiMocks library, where in the shaded class "osgimock.org.apache.felix.scr.impl.inject.Annotations" the method toObject, where the the method "fixup" is called with the value recipients.email$_$addresses; it returns recipients.email.addresses, but I expect recipients.email.addresses.
To me the problem seems to be that the shaded Felix SCR library does not support OSGI r7 here (and therefor not this specific mapping introduced in r7).
The only workaround I see right now is to use a different signature for the activate() method to avoid this incorrect translation for these property names.
Attachments
Issue Links
- duplicates
-
SLING-8244 Upgrade shaded felix.scr version to support OSGi R7 annotation hyphenated properties
- Closed