use of org.apache.sling.testing.mock.sling.services.MockSlingSettingService in project sling by apache.
the class SlingContextImpl method registerDefaultServices.
/**
* Default services that should be available for every unit test
*/
protected void registerDefaultServices() {
// scripting services (required by sling models impl since 1.3.6)
registerInjectActivateService(new ScriptEngineManagerFactory());
registerInjectActivateService(new BindingsValuesProvidersByContextImpl());
// sling models
registerInjectActivateService(new ModelAdapterFactory());
registerInjectActivateServiceByClassName("org.apache.sling.models.impl.FirstImplementationPicker", "org.apache.sling.models.impl.ResourceTypeBasedResourcePicker", "org.apache.sling.models.impl.injectors.BindingsInjector", "org.apache.sling.models.impl.injectors.ChildResourceInjector", "org.apache.sling.models.impl.injectors.OSGiServiceInjector", "org.apache.sling.models.impl.injectors.RequestAttributeInjector", "org.apache.sling.models.impl.injectors.ResourcePathInjector", "org.apache.sling.models.impl.injectors.SelfInjector", "org.apache.sling.models.impl.injectors.SlingObjectInjector", "org.apache.sling.models.impl.injectors.ValueMapInjector", "org.apache.sling.models.impl.via.BeanPropertyViaProvider", "org.apache.sling.models.impl.via.ChildResourceViaProvider", "org.apache.sling.models.impl.via.ForcedResourceTypeViaProvider", "org.apache.sling.models.impl.via.ResourceSuperTypeViaProvider");
// other services
registerService(SlingSettingsService.class, new MockSlingSettingService(DEFAULT_RUN_MODES));
registerService(MimeTypeService.class, new MockMimeTypeService());
registerInjectActivateService(new ResourceBuilderFactoryService());
// scan for models defined via bundle headers in classpath
ModelAdapterFactoryUtil.addModelsForManifestEntries(this.bundleContext());
}
use of org.apache.sling.testing.mock.sling.services.MockSlingSettingService in project sling by apache.
the class SlingContextImpl method runMode.
/**
* Set current run mode(s).
* @param runModes Run mode(s).
*/
public final void runMode(String... runModes) {
Set<String> newRunModes = ImmutableSet.<String>builder().add(runModes).build();
ServiceReference<SlingSettingsService> ref = bundleContext().getServiceReference(SlingSettingsService.class);
if (ref != null) {
MockSlingSettingService slingSettings = (MockSlingSettingService) bundleContext().getService(ref);
slingSettings.setRunModes(newRunModes);
}
}
Aggregations