From c22d28e6e1429e6684c41965821d5d0ef4d5e5ad Mon Sep 17 00:00:00 2001 From: Gethin James Date: Thu, 18 Oct 2012 09:35:12 +0000 Subject: [PATCH] Improved the testing around editions/versions for MMT checking. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42787 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/module/tool/WarHelperImpl.java | 2 +- .../repo/module/tool/WarHelperImplTest.java | 48 +++++++++++++++--- source/test-resources/module/test_v5.amp | Bin 0 -> 5044 bytes 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 source/test-resources/module/test_v5.amp diff --git a/source/java/org/alfresco/repo/module/tool/WarHelperImpl.java b/source/java/org/alfresco/repo/module/tool/WarHelperImpl.java index 60ffd9f05e..583e3b1689 100644 --- a/source/java/org/alfresco/repo/module/tool/WarHelperImpl.java +++ b/source/java/org/alfresco/repo/module/tool/WarHelperImpl.java @@ -85,7 +85,7 @@ public class WarHelperImpl implements WarHelper if (edition.endsWith(MANIFEST_COMMUNITY)) { //If it's a community version, so don't worry about it - log.info("Community edition war detected, the version number is non-numeric so we will not validate it."); + log.info("WARNING: Community edition war detected, the version number is non-numeric so we will not validate it."); } else { diff --git a/source/java/org/alfresco/repo/module/tool/WarHelperImplTest.java b/source/java/org/alfresco/repo/module/tool/WarHelperImplTest.java index 0a7cc1321d..04398457cf 100644 --- a/source/java/org/alfresco/repo/module/tool/WarHelperImplTest.java +++ b/source/java/org/alfresco/repo/module/tool/WarHelperImplTest.java @@ -1,8 +1,12 @@ package org.alfresco.repo.module.tool; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -14,9 +18,15 @@ import org.alfresco.service.cmr.module.ModuleDetails; import org.alfresco.util.TempFileProvider; import org.alfresco.util.VersionNumber; import org.junit.Test; -import de.schlichtherle.truezip.file.TFile; import org.springframework.util.FileCopyUtils; +import de.schlichtherle.truezip.file.TArchiveDetector; +import de.schlichtherle.truezip.file.TConfig; +import de.schlichtherle.truezip.file.TFile; +import de.schlichtherle.truezip.file.TFileInputStream; +import de.schlichtherle.truezip.fs.archive.zip.ZipDriver; +import de.schlichtherle.truezip.socket.sl.IOPoolLocator; + /** * Tests the war helper. * @@ -35,6 +45,9 @@ public class WarHelperImplTest extends WarHelperImpl System.out.println(message); } }); + + TConfig config = TConfig.get(); + config.setArchiveDetector(new TArchiveDetector("war|amp", new ZipDriver(IOPoolLocator.SINGLETON))); } @Test @@ -114,7 +127,7 @@ public class WarHelperImplTest extends WarHelperImpl } @Test - public void testCheckCompatibleVersionUsingManifest() + public void testCheckCompatibleVersionUsingManifest() throws IOException { //Now check the compatible versions using the manifest TFile theWar = getFile(".war", "module/share-3.4.11.war"); @@ -177,9 +190,9 @@ public class WarHelperImplTest extends WarHelperImpl 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); - + - } + } @Test public void testCheckCompatibleEdition() @@ -216,10 +229,11 @@ public class WarHelperImplTest extends WarHelperImpl props.setProperty(ModuleDetails.PROP_EDITIONS, ("enterprise,Community")); //should ignore case installingModuleDetails = new ModuleDetailsImpl(props); this.checkCompatibleVersion(theWar, installingModuleDetails); //does not throw exception + } @Test - public void testCheckCompatibleEditionUsingManifest() + public void testCheckCompatibleEditionUsingManifest() throws IOException { Properties props = dummyModuleProperties(); ModuleDetails installingModuleDetails = new ModuleDetailsImpl(props); @@ -259,6 +273,28 @@ public class WarHelperImplTest extends WarHelperImpl 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); + fail(); //should never get here + } 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"); + this.checkCompatibleEdition(theWar, installingModuleDetails);//should succeed + + try { + theWar = getFile(".war", "module/share-4.2.a.war"); + this.checkCompatibleEdition(theWar, installingModuleDetails); + fail(); //should never get here + } catch (ModuleManagementToolException exception) { + assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[Enterprise]")); + } + } diff --git a/source/test-resources/module/test_v5.amp b/source/test-resources/module/test_v5.amp new file mode 100644 index 0000000000000000000000000000000000000000..5c1a3dbe9f0f7364ba33545c61abb334f2609e29 GIT binary patch literal 5044 zcmeHKc{r478=uM2AX{WfF|H~5AjuYmP{_XIBFZwxXclK?Y#nPQgfEFgO&L^Fu8ufm z7_x+pnqxUa9cz5#SW>c|^1ZKjWIl(^Ki~EJb#B*l>OF-+e#NbKlQ>{~mj5E^dA< z7$60w^K`)9RoMzmd`U!q99F}AQzel#C2zbx8AI_UeMehz18oAyFBp&c4rtfrAS#AJ zT|tTiJ3zqNgYtA<4k;AR!(lLeZWv7cZ;+5{G_Xl3CXA{cM!-ip*^u5Ei&UQYBRX^b zo%IBPz~cDo(xiL@vzHX0EHL^v5&~Mw0w{nY8X_%6y7cFDWCN zXG6E0j6Jih-q&eID&KniX!Oh6WjTe=Y1YH}O3!Ll@`U%&r!x0nku0etMi08PIhmED zZ>TQYk&Nz8&JRY+%J_~<>(6zF_VoS`haLPn+_2kihf2qA$;Ey5%&g)HoIU7?@YCe$ z7#rhf8TzoTalO-AwG0bEx`k58V~ac?q~UzEXSK?Qedacn!JpxQM6`VB^#k1WDV15V z0I`0%=Te?N))|;~hjGOxTXVA&PEPJ#Y#VBFKAISAEJqIf7(?tRQLwj~{Gv_Inuhnc z2o*?7<%LVvsD*yMsnAn+V)E#z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