Search in sources :

Example 1 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class ModuleDetailsImplTest method testWriteAndReadProperties.

public void testWriteAndReadProperties() {
    Properties props = new Properties();
    props.putAll(DEFAULT_PROPS);
    ModuleDetails details = new ModuleDetailsImpl(props);
    // convert back to properties
    Properties processedProperties = details.getProperties();
    assertEquals("The number of properties changed", props.size(), processedProperties.size());
    assertEquals("The properties are different", props, processedProperties);
}
Also used : ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Properties(java.util.Properties)

Example 2 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class ModuleDetailsImplTest method testDefaults.

@SuppressWarnings("unused")
public void testDefaults() {
    Properties props = new Properties();
    props.putAll(DEFAULT_PROPS);
    ModuleDetails details = new ModuleDetailsImpl(props);
}
Also used : ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Properties(java.util.Properties)

Example 3 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class ModuleDetailsImplTest method testTrimming.

public void testTrimming() throws Exception {
    Properties props = new Properties();
    props.putAll(DEFAULT_PROPS);
    props.setProperty(ModuleDetails.PROP_INSTALL_STATE, "    ");
    ModuleDetails details = new ModuleDetailsImpl(props);
    assertEquals("Expected the install state to be UNKNOWN", ModuleInstallState.UNKNOWN, details.getInstallState());
}
Also used : ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Properties(java.util.Properties)

Example 4 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class ModuleManagementToolTest method testListAndInstall.

public void testListAndInstall() throws Exception {
    String warLocation = getFileLocation(".war", "module/test.war");
    String ampLocation = getFileLocation(".amp", "module/test_v1.amp");
    String ampV2Location = getFileLocation(".amp", "module/test_v2.amp");
    TFile war = new TFile(warLocation);
    List<ModuleDetails> details = this.manager.warHelper.listModules(war);
    assertNotNull(details);
    assertEquals(details.size(), 0);
    this.manager.installModule(ampLocation, warLocation);
    details = this.manager.warHelper.listModules(war);
    assertNotNull(details);
    assertEquals(details.size(), 1);
    ModuleDetails aModule = details.get(0);
    assertEquals("test", aModule.getId());
    assertEquals("1.0", aModule.getModuleVersionNumber().toString());
    this.manager.installModule(ampV2Location, warLocation);
    details = this.manager.warHelper.listModules(war);
    assertNotNull(details);
    assertEquals(details.size(), 1);
    aModule = details.get(0);
    assertEquals("test", aModule.getId());
    assertEquals("2.0", aModule.getModuleVersionNumber().toString());
    String testAmpDepV2Location = getFileLocation(".amp", "module/dependent_on_test_v2.amp");
    String testAmp7 = getFileLocation(".amp", "module/test_v7.amp");
    this.manager.installModule(testAmpDepV2Location, warLocation, false, true, false);
    this.manager.installModule(testAmp7, warLocation, false, true, false);
    details = this.manager.warHelper.listModules(war);
    assertNotNull(details);
    assertEquals(details.size(), 3);
    // Sort them by installation date
    Collections.sort(details, new Comparator<ModuleDetails>() {

        @Override
        public int compare(ModuleDetails a, ModuleDetails b) {
            return a.getInstallDate().compareTo(b.getInstallDate());
        }
    });
    ModuleDetails installedModule = details.get(0);
    assertEquals("test", installedModule.getId());
    assertEquals("2.0", installedModule.getModuleVersionNumber().toString());
    installedModule = details.get(1);
    assertEquals("org.alfresco.module.test.dependent", installedModule.getId());
    assertEquals("2.0", installedModule.getModuleVersionNumber().toString());
    installedModule = details.get(2);
    assertEquals("forcedtest", installedModule.getId());
    assertEquals("1.0", installedModule.getModuleVersionNumber().toString());
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails)

Example 5 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class WarHelperImplTest method testCheckCompatibleEditionUsingManifest.

@Test
public void testCheckCompatibleEditionUsingManifest() throws IOException {
    Properties props = dummyModuleProperties();
    ModuleDetails installingModuleDetails = new ModuleDetailsImpl(props);
    // enterprise edition
    TFile theWar = getFile(".war", "module/share-3.4.11.war");
    // Test for no edition specified
    // does not throw exception
    this.checkCompatibleEditionUsingManifest(theWar, installingModuleDetails);
    // Test for invalid edition
    props.setProperty(ModuleDetails.PROP_EDITIONS, "CommuniT");
    installingModuleDetails = new ModuleDetailsImpl(props);
    try {
        this.checkCompatibleEditionUsingManifest(theWar, installingModuleDetails);
        // should never get here
        fail();
    } catch (ModuleManagementToolException exception) {
        assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[CommuniT]"));
    }
    // should ignore case
    props.setProperty(ModuleDetails.PROP_EDITIONS, ("Enterprise"));
    installingModuleDetails = new ModuleDetailsImpl(props);
    // does not throw exception
    this.checkCompatibleEditionUsingManifest(theWar, installingModuleDetails);
    // should ignore case
    props.setProperty(ModuleDetails.PROP_EDITIONS, ("Community"));
    installingModuleDetails = new ModuleDetailsImpl(props);
    try {
        this.checkCompatibleEditionUsingManifest(theWar, installingModuleDetails);
        // should never get here
        fail();
    } catch (ModuleManagementToolException exception) {
        assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[Community]"));
    }
    theWar = getFile(".war", "module/share-4.2.a.war");
    this.checkCompatibleEditionUsingManifest(theWar, installingModuleDetails);
    String propertiesLocation = getFile(".amp", "module/test_v5.amp") + "/module.properties";
    installingModuleDetails = ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(propertiesLocation);
    try {
        this.checkCompatibleEdition(theWar, installingModuleDetails);
        // should never get here
        fail();
    } catch (ModuleManagementToolException exception) {
        assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[Enterprise]"));
    }
    theWar = getFile(".war", "module/share-3.4.11.war");
    // should succeed
    this.checkCompatibleEdition(theWar, installingModuleDetails);
    try {
        theWar = getFile(".war", "module/share-4.2.a.war");
        this.checkCompatibleEdition(theWar, installingModuleDetails);
        // should never get here
        fail();
    } catch (ModuleManagementToolException exception) {
        assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[Enterprise]"));
    }
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) ModuleDetailsImpl(org.alfresco.repo.module.ModuleDetailsImpl) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)27 TFile (de.schlichtherle.truezip.file.TFile)9 Properties (java.util.Properties)7 ModuleDetailsImpl (org.alfresco.repo.module.ModuleDetailsImpl)7 Test (org.junit.Test)7 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ModuleVersionNumber (org.alfresco.repo.module.ModuleVersionNumber)4 VersionNumber (org.alfresco.util.VersionNumber)4 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)3 ModuleDependency (org.alfresco.service.cmr.module.ModuleDependency)3 TFileInputStream (de.schlichtherle.truezip.file.TFileInputStream)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 ModulePackage (org.alfresco.rest.api.model.ModulePackage)2 AuditService (org.alfresco.service.cmr.audit.AuditService)2 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)2 FsSyncException (de.schlichtherle.truezip.fs.FsSyncException)1 BufferedInputStream (java.io.BufferedInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1