Search in sources :

Example 1 with OsgiServiceModel

use of org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel 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"));
}
Also used : OsgiServiceModel(org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel) MockMimeTypeService(org.apache.sling.testing.mock.sling.services.MockMimeTypeService) Test(org.junit.Test)

Example 2 with OsgiServiceModel

use of org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel in project sling by apache.

the class AbstractSlingContextImplTest method testSlingModelsInvalidAdapt.

@Test
public void testSlingModelsInvalidAdapt() {
    OsgiServiceModel model = context.request().adaptTo(OsgiServiceModel.class);
    assertNull(model);
}
Also used : OsgiServiceModel(org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel) Test(org.junit.Test)

Example 3 with OsgiServiceModel

use of org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel in project sling by apache.

the class AbstractModelAdapterFactoryUtilTest method testInvalidAdapt.

@Test
public void testInvalidAdapt() {
    OsgiServiceModel model = context().request().adaptTo(OsgiServiceModel.class);
    assertNull(model);
}
Also used : OsgiServiceModel(org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel) Test(org.junit.Test)

Example 4 with OsgiServiceModel

use of org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel 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"));
}
Also used : OsgiServiceModel(org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel) MockMimeTypeService(org.apache.sling.testing.mock.sling.services.MockMimeTypeService) Test(org.junit.Test)

Aggregations

OsgiServiceModel (org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel)4 Test (org.junit.Test)4 MockMimeTypeService (org.apache.sling.testing.mock.sling.services.MockMimeTypeService)2