use of org.apache.sling.testing.mock.sling.services.MockMimeTypeService 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.MockMimeTypeService in project sling by apache.
the class AbstractModelAdapterFactoryUtilTest method testOsgiService.
@Test
public void testOsgiService() {
context().registerService(MimeTypeService.class, new MockMimeTypeService());
OsgiServiceModel model = context().resourceResolver().adaptTo(OsgiServiceModel.class);
assertNotNull(model);
assertNotNull(model.getMimeTypeService());
assertEquals("text/html", model.getMimeTypeService().getMimeType("html"));
}
use of org.apache.sling.testing.mock.sling.services.MockMimeTypeService in project sling by apache.
the class AbstractSlingContextImplTest method testSlingModelsOsgiService.
@Test
public void testSlingModelsOsgiService() {
context.registerService(new MockMimeTypeService());
OsgiServiceModel model = context.resourceResolver().adaptTo(OsgiServiceModel.class);
assertNotNull(model.getMimeTypeService());
assertEquals("text/html", model.getMimeTypeService().getMimeType("html"));
}
Aggregations