Search in sources :

Example 26 with TFile

use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.

the class WarHelperImplTest method testIsShareWar.

/**
 * Tests to see if the war is a share war.
 */
@Test
public void testIsShareWar() {
    // Version 4.1.0
    TFile theWar = getFile(".war", "module/test.war");
    assertFalse(this.isShareWar(theWar));
    theWar = getFile(".war", "module/empty.war");
    assertFalse(this.isShareWar(theWar));
    theWar = getFile(".war", "module/alfresco-4.2.a.war");
    assertFalse(this.isShareWar(theWar));
    theWar = getFile(".war", "module/share-4.2.a.war");
    assertTrue(this.isShareWar(theWar));
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) Test(org.junit.Test)

Example 27 with TFile

use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.

the class ModuleManagementToolTest method checkContentsOfFile.

private void checkContentsOfFile(String location, String expectedContents) throws IOException {
    File file = new TFile(location);
    assertTrue(file.exists());
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(new TFileInputStream(file)));
        String line = reader.readLine();
        assertNotNull(line);
        assertEquals(expectedContents, line.trim());
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (Throwable e) {
            }
        }
    }
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) TFileInputStream(de.schlichtherle.truezip.file.TFileInputStream) TFile(de.schlichtherle.truezip.file.TFile)

Example 28 with TFile

use of de.schlichtherle.truezip.file.TFile 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

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