Search in sources :

Example 6 with TFile

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;
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) TFile(de.schlichtherle.truezip.file.TFile)

Example 7 with TFile

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);
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) TFile(de.schlichtherle.truezip.file.TFile)

Example 8 with TFile

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

Example 9 with TFile

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);
}
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)

Example 10 with TFile

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);
    }
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) Properties(java.util.Properties) VersionNumber(org.alfresco.util.VersionNumber)

Aggregations

TFile (de.schlichtherle.truezip.file.TFile)28 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)9 Test (org.junit.Test)8 ModuleDetailsImpl (org.alfresco.repo.module.ModuleDetailsImpl)6 Properties (java.util.Properties)5 IOException (java.io.IOException)4 VersionNumber (org.alfresco.util.VersionNumber)4 TFileInputStream (de.schlichtherle.truezip.file.TFileInputStream)3 ModuleVersionNumber (org.alfresco.repo.module.ModuleVersionNumber)3 TFileOutputStream (de.schlichtherle.truezip.file.TFileOutputStream)2 TFileReader (de.schlichtherle.truezip.file.TFileReader)1 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Manifest (java.util.jar.Manifest)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1