[
https://issues.apache.org/jira/browse/SLING-8263?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jörg Hoh resolved SLING-8263.
-----------------------------
Resolution: Duplicate
duplicate to SLING-8244
> Osgi Mocks cannot handle r7 property names with $_$ in annotation config
> classes
> --------------------------------------------------------------------------------
>
> Key: SLING-8263
> URL: https://issues.apache.org/jira/browse/SLING-8263
> Project: Sling
> Issue Type: Improvement
> Components: Testing
> Affects Versions: Testing OSGi Mock 2.4.2
> Reporter: Jörg Hoh
> Priority: Major
>
> 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.
> {code:title=HealthCheckStatusEmail.java}
> @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;
> }
> {code}
> {code:title=HealthCheckStatusEmailTest.java}
> healthcheckService = new HealthCheckService();
> @Before
> public void setUp() throws Exception {
> configuration.put("recipients.email-addresses", "[email protected]");
> }
> @Test
> public void test () {
> context.registerInjectActivateService(healthcheckService, configuration);
> // test code
> }
> {code}
> But debugging showed, that this value {{[email protected]}} 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.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)