sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seifert <>
Subject RE: [CaConfig][OSGI Mocks] Provide custom configuration for the CaConfig components...
Date Tue, 28 Jan 2020 21:19:18 GMT
the problem is that the reconfiguration is done too late, and the service is already instantiated
and the configuration not updated.
sling mocks/osgi mocks currently only supports providing configuration before the service
is registered.

if you put your configuration code in a beforeSetup block of the context initialization instead
of the setUp() method it should work - example:

    public final AemContext context = new AemContextBuilder(ResourceResolverType.JCR_MOCK)
        .beforeSetUp(context -> {
            ConfigurationAdmin configurationAdmin = context.getService(ConfigurationAdmin.class);
            Configuration serviceConfiguration = configurationAdmin.getConfiguration(DefaultContextPathStrategy.class.getName());
            Dictionary<String, Object> props = new Hashtable<>();
            props.put("configRefResourceNames", new String[] { ".", "jcr:content" });
            props.put("configRefPropertyNames", "cq:conf");


>-----Original Message-----
>From: Daniel Platon []
>Sent: Tuesday, January 28, 2020 3:31 PM
>Subject: [CaConfig][OSGI Mocks] Provide custom configuration for the
>CaConfig components...
>Hi everyone,
>I'm trying to use the "Apache Sling Context-Aware Configuration Mock
>Plugin" in my unit tests and I stumbled into an issue: I want to
>provide a custom configuration for
> and it
>doesn't work.
>I followed the docs at [0] to provide my own setting for
>configBucketNames but it's not taken into account. I'm pretty sure I
>do something wrong but I cannot figure out what.
>Relevant code at [1].
>Thank you and have a nice day,
>Daniel Platon

View raw message