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);
}
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);
}
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());
}
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());
}
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]"));
}
}
Aggregations