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