Search in sources :

Example 1 with ModuleServiceImpl

use of org.alfresco.repo.module.ModuleServiceImpl in project alfresco-repository by Alfresco.

the class ModuleServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    moduleService = new ModuleServiceImpl();
    Resource simpleMod = new PathMatchingResourcePatternResolver().getResource("classpath:alfresco/module/simplemodule.properties");
    assertNotNull(simpleMod);
    RegistryService reg = mock(RegistryService.class);
    ApplicationContext applicationContext = mock(ApplicationContext.class);
    when(reg.getProperty((RegistryKey) any())).thenAnswer(new Answer<Serializable>() {

        public Serializable answer(InvocationOnMock invocation) throws Throwable {
            RegistryKey key = (RegistryKey) invocation.getArguments()[0];
            return new ModuleVersionNumber("1.1");
        }
    });
    doReturn(Arrays.asList("fee", "alfresco-simple-module", "fo")).when(reg).getChildElements((RegistryKey) any());
    doReturn(new Resource[] { simpleMod }).when(applicationContext).getResources(anyString());
    moduleService.setRegistryService(reg);
    moduleService.setApplicationContext(applicationContext);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) Serializable(java.io.Serializable) ModuleServiceImpl(org.alfresco.repo.module.ModuleServiceImpl) ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Resource(org.springframework.core.io.Resource) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) RegistryService(org.alfresco.repo.admin.registry.RegistryService) RegistryKey(org.alfresco.repo.admin.registry.RegistryKey) Before(org.junit.Before)

Aggregations

Serializable (java.io.Serializable)1 RegistryKey (org.alfresco.repo.admin.registry.RegistryKey)1 RegistryService (org.alfresco.repo.admin.registry.RegistryService)1 ModuleServiceImpl (org.alfresco.repo.module.ModuleServiceImpl)1 ModuleVersionNumber (org.alfresco.repo.module.ModuleVersionNumber)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 ApplicationContext (org.springframework.context.ApplicationContext)1 Resource (org.springframework.core.io.Resource)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1