use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class ModuleManagementToolTest method extractToDir.
private String extractToDir(String extension, String location) {
File tmpDir = TempFileProvider.getTempDir();
try {
TFile zipFile = new TFile(this.getClass().getClassLoader().getResource(location).getPath());
TFile outDir = new TFile(tmpDir.getAbsolutePath() + "/moduleManagementToolTestDir" + System.currentTimeMillis());
outDir.mkdir();
zipFile.cp_rp(outDir);
TVFS.umount(zipFile);
return outDir.getPath();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class WarHelperImplTest method getFile.
private TFile getFile(String extension, String location) {
File file = TempFileProvider.createTempFile("moduleManagementToolTest-", extension);
InputStream is = this.getClass().getClassLoader().getResourceAsStream(location);
assertNotNull(is);
OutputStream os;
try {
os = new FileOutputStream(file);
FileCopyUtils.copy(is, os);
} catch (IOException error) {
error.printStackTrace();
}
return new TFile(file);
}
use of de.schlichtherle.truezip.file.TFile 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]"));
}
}
use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class WarHelperImplTest method testNoVersionProperties.
@Test
public void testNoVersionProperties() {
TFile theWar = getFile(".war", "module/empty.war");
ModuleDetails installingModuleDetails = new ModuleDetailsImpl("test_it", new ModuleVersionNumber("9999"), "Test Mod", "Testing module");
installingModuleDetails.setRepoVersionMin(new VersionNumber("10.1"));
// does not throw exception
this.checkCompatibleVersion(theWar, installingModuleDetails);
// does not throw exception
this.checkCompatibleEdition(theWar, installingModuleDetails);
}
use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class WarHelperImpl method checkCompatibleVersion.
@Override
public void checkCompatibleVersion(TFile war, ModuleDetails installingModuleDetails) {
// Version check
TFile propsFile = new TFile(war + VERSION_PROPERTIES);
if (propsFile != null && propsFile.exists()) {
log.info("INFO: Checking the war version using " + VERSION_PROPERTIES);
Properties warVers = loadProperties(propsFile);
VersionNumber warVersion = new VersionNumber(warVers.getProperty("version.major") + "." + warVers.getProperty("version.minor") + "." + warVers.getProperty("version.revision"));
checkVersions(warVersion, installingModuleDetails);
} else {
log.info("INFO: Checking the war version using the manifest.");
checkCompatibleVersionUsingManifest(war, installingModuleDetails);
}
}
Aggregations