Search in sources :

Example 11 with ModuleVersionNumber

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

the class ModuleComponentHelperTest method testStartComponentsV00.

public void testStartComponentsV00() {
    ModuleVersionNumber moduleVersion = new ModuleVersionNumber("0.0");
    startComponents(moduleVersion);
}
Also used : ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber)

Example 12 with ModuleVersionNumber

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

the class ModuleComponentHelperTest method testStartComponentsV30.

public void testStartComponentsV30() {
    ModuleVersionNumber moduleVersion = new ModuleVersionNumber("3.0");
    startComponents(moduleVersion);
}
Also used : ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber)

Example 13 with ModuleVersionNumber

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

the class ModuleComponentHelperTest method testStartComponentsV35.

public void testStartComponentsV35() {
    ModuleVersionNumber moduleVersion = new ModuleVersionNumber("3.5");
    startComponents(moduleVersion);
}
Also used : ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber)

Example 14 with ModuleVersionNumber

use of org.alfresco.repo.module.ModuleVersionNumber 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)

Example 15 with ModuleVersionNumber

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

the class WarHelperImplTest method testCheckCompatibleVersionUsingManifest.

@Test
public void testCheckCompatibleVersionUsingManifest() throws IOException {
    // Now check the compatible versions using the manifest
    TFile theWar = getFile(".war", "module/share-3.4.11.war");
    ModuleDetails installingModuleDetails = new ModuleDetailsImpl("test_it", new ModuleVersionNumber("9999"), "Test Mod", "Testing module");
    installingModuleDetails.setRepoVersionMin(new VersionNumber("10.1"));
    try {
        this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
        // should never get here
        fail();
    } catch (ModuleManagementToolException exception) {
        assertTrue(exception.getMessage().contains("must be installed on a war version equal to or greater than 10.1"));
    }
    installingModuleDetails.setRepoVersionMin(new VersionNumber("1.1"));
    // does not throw exception
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    installingModuleDetails.setRepoVersionMax(new VersionNumber("3.0"));
    try {
        this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
        // should never get here
        fail();
    } catch (ModuleManagementToolException exception) {
        assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 3.0"));
    }
    installingModuleDetails.setRepoVersionMax(new VersionNumber("99"));
    // does not throw exception
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    // current war version
    installingModuleDetails.setRepoVersionMin(new VersionNumber("3.4.11"));
    // current war version
    installingModuleDetails.setRepoVersionMax(new VersionNumber("3.4.11"));
    // does not throw exception
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    // current war version
    installingModuleDetails.setRepoVersionMin(new VersionNumber("3.4.7"));
    // current war version
    installingModuleDetails.setRepoVersionMax(new VersionNumber("3.4.11"));
    // does not throw exception
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    try {
        // current war version
        installingModuleDetails.setRepoVersionMin(new VersionNumber("3.4.0"));
        // current war version
        installingModuleDetails.setRepoVersionMax(new VersionNumber("3.4.10"));
        // does not throw exception
        this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
        // should never get here
        fail("Should not pass as current version is 3.4.11 and the max value is 3.4.10");
    } catch (ModuleManagementToolException exception) {
        assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 3.4.10"));
    }
    theWar = getFile(".war", "module/share-4.2.a.war");
    installingModuleDetails = new ModuleDetailsImpl("test_it", new ModuleVersionNumber("9999"), "Test Mod", "Testing module");
    installingModuleDetails.setRepoVersionMin(new VersionNumber("101.1"));
    // this should fail BUT we are using a non-numeric version number so instead it passes without validation
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    theWar = getFile(".war", "module/alfresco-4.2.a.war");
    // this should fail BUT we are using a non-numeric version number so instead it passes without validation
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) ModuleDetailsImpl(org.alfresco.repo.module.ModuleDetailsImpl) ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) VersionNumber(org.alfresco.util.VersionNumber) ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) Test(org.junit.Test)

Aggregations

ModuleVersionNumber (org.alfresco.repo.module.ModuleVersionNumber)15 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)4 VersionNumber (org.alfresco.util.VersionNumber)4 TFile (de.schlichtherle.truezip.file.TFile)3 ModuleDetailsImpl (org.alfresco.repo.module.ModuleDetailsImpl)3 Test (org.junit.Test)3 Serializable (java.io.Serializable)2 RegistryKey (org.alfresco.repo.admin.registry.RegistryKey)2 FsSyncException (de.schlichtherle.truezip.fs.FsSyncException)1 IOException (java.io.IOException)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 RegistryService (org.alfresco.repo.admin.registry.RegistryService)1 ModuleServiceImpl (org.alfresco.repo.module.ModuleServiceImpl)1 ModuleManagementToolException (org.alfresco.repo.module.tool.ModuleManagementToolException)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)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