@Test public void testApplyReleasePatch() throws Exception { // build a Release patch for the base installation // with 1 added module String patchID = randomString(); String layerPatchID = randomString(); File patchDir = mkdir(tempDir, patchID); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchID, moduleName); InstalledIdentity installedIdentity = loadInstalledIdentity(); Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .upgradeIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion(), productConfig.getProductVersion() + "-Release1") .getParent() .upgradeElement(layerPatchID, BASE, false) .addContentModification(moduleAdded) .getParent() .build(); createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patchID); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity(); File modulePatchDirectory = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(layerPatchID); assertDirExists(modulePatchDirectory); assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash()); }
ContentModification fileModified = ContentModificationUtils.modifyMisc(patchDir, patchID, "updated script", standaloneShellFile, "bin", "standalone.sh"); InstalledIdentity installedIdentity = loadInstalledIdentity(); File zippedPatch = createZippedPatchFile(patchDir, patchID); Identity identityBeforePatch = loadInstalledIdentity().getIdentity(); assertFileContent(fileModified.getItem().getContentHash(), standaloneShellFile); InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity(); File modulePatchDirectory = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(layerPatchID); assertDirExists(modulePatchDirectory);
InstalledIdentity identityBeforePatch = loadInstalledIdentity(); final String resultingVersion = identityBeforePatch.getIdentity().getVersion() + "-Release1"; Patch releasePatch = PatchBuilder.create() InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity(); File modulePatchDirectory = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(releaseLayerPatchID); assertDirExists(modulePatchDirectory); assertPatchHasBeenApplied(resultOfOneOffPatch, oneOffPatch); InstalledIdentity installedIdentityAfterOneOffPatch = loadInstalledIdentity(); modulePatchDirectory = installedIdentityAfterOneOffPatch.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(oneOffLayerPatchID); assertDirExists(modulePatchDirectory); assertPatchHasBeenRolledBack(resultOfReleasePatchRollback, identityBeforePatch.getIdentity()); updatedInstalledIdentity = loadInstalledIdentity(); File layerModuleRoot = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModuleRoot(); assertDirDoesNotExist(newFile(layerModuleRoot, moduleName));
InstalledIdentity installedIdentity = loadInstalledIdentity(); final String resultingVersion = productConfig.getProductVersion() + "-Release1"; Patch releasePatch = PatchBuilder.create() InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity(); assertPatchHasBeenApplied(resultOfOneOffPatch, oneOffPatch); InstalledIdentity installedIdentityAfterOneOffPatch = loadInstalledIdentity(); modulePatchDirectory = installedIdentityAfterOneOffPatch.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(oneOffLayerPatchID); assertDirExists(modulePatchDirectory);
InstalledIdentity identityBeforePatch = loadInstalledIdentity(); assertPatchHasBeenApplied(resultOfOneOffPatch, oneOffPatch); InstalledIdentity installedIdentityAfterOneOffPatch = loadInstalledIdentity(); File modulePatchDirectory = installedIdentityAfterOneOffPatch.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(oneOffLayerPatchID); assertDirExists(modulePatchDirectory);