@Override protected PatchElementTestStepBuilder internalAddModification(ContentModification modification) { builder.addContentModification(modification); return returnThis(); }
.getParent() .upgradeElement(baseCP1ID, BASE, false) .addContentModification(cp1BaseModuleAdded) .addContentModification(cp1BaseModule2Added) .getParent() .upgradeElement(layer1CP1ID, "layer1", false) .addContentModification(cp1Layer1ModuleAdded) .getParent() .upgradeElement(layer2CP1ID, "layer2", false) .addContentModification(cp1Layer2ModuleAdded) .addContentModification(cp1Layer2Module2Added) .getParent() .addContentModification(cp1StandaloneModified)
.getParent() .upgradeElement(baseCP2ID, BASE, false) .addContentModification(cp2BaseModuleModified) .addContentModification(cp2BaseModule2Removed) .getParent() .upgradeElement(layer2CP2ID, "layer2", false) .addContentModification(cp2Layer2ModuleRemoved) .addContentModification(cp2Layer2Module3Added) .getParent() .addContentModification(cp2StandaloneModified)
private void prepareCP3(final InstalledIdentity installedIdentity) throws IOException, Exception { final String cp3ID = "CP3"; final File cp3Dir = mkdir(tempDir, cp3ID); cp3StandaloneModified = ContentModificationUtils.modifyMisc(cp3Dir, cp3ID, "updated by cp3", standaloneSh, "bin", standaloneSh.getName()); cp3BaseModuleModified = ContentModificationUtils.modifyModule(cp3Dir, baseCP3ID, moduleName, cp2BaseModuleModified.getItem().getContentHash(), "cp3 content"); // cp3BaseModule2Added = ContentModificationUtils.addModule(cp3Dir, baseCP3ID, moduleName + "2"); the patchgen tool // would generate an update instead final File absentModuleXml = IoUtils.newFile(installedIdentity.getLayer("base").loadTargetInfo() .getDirectoryStructure().getModulePatchDirectory(baseCP2ID), "org", "jboss", "test2", "main", "module.xml"); cp3BaseModule2Added = ContentModificationUtils.modifyModule(cp3Dir, baseCP3ID, moduleName + "2", HashUtils.hashFile(absentModuleXml), "cp3 content"); final ContentModification cp3AddedByCP1RemovedByCP3Removed = ContentModificationUtils.removeMisc(addedByCP1RemovedByCP3, "bin", addedByCP1RemovedByCP3.getName()); cp3 = PatchBuilder.create() .setPatchId(cp3ID) .setDescription(randomString()) .upgradeIdentity(installedIdentity.getIdentity().getName(), productConfig.getProductVersion() + "_CP2", productConfig.getProductVersion() + "_CP3") .getParent() .upgradeElement(baseCP3ID, BASE, false) .addContentModification(cp3BaseModuleModified) .addContentModification(cp3BaseModule2Added) .getParent() .addContentModification(cp3StandaloneModified) .addContentModification(cp3AddedByCP1RemovedByCP3Removed) .build(); createPatchXMLFile(cp3Dir, cp3); cp3Zip = createZippedPatchFile(cp3Dir, cp3ID); }
.getParent() .oneOffPatchElement(layerPatchId, layerName, false) .addContentModification(moduleAdded) .getParent(); try {
@Test public void testCumulativePatch() throws Exception { // build a cumulative 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(); final PatchBuilder builder = PatchBuilder.create(); builder .setPatchId(patchID) .setDescription(randomString()) .upgradeIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion(), productConfig.getProductVersion() + "-CP1") .getParent() .upgradeElement(layerPatchID, BASE, false) .addContentModification(moduleAdded); Patch patch = builder.build(); checkApplyPatchAndRollbackRestoresBackupConfiguration(patchDir, patch); }
@Test public void testOneOffPatch() throws Exception { // build a one-off 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(); final PatchBuilder builder = PatchBuilder.create(); builder .setPatchId(patchID) .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion()) .getParent() .oneOffPatchElement(layerPatchID, BASE, false) .addContentModification(moduleAdded); Patch patch = builder.build(); checkApplyPatchAndRollbackRestoresBackupConfiguration(patchDir, patch); }
@Test public void testApplyOneOffPatch() throws Exception { // build a one-off patch for the base installation // with 1 added module String oneOffPatchID = randomString(); String oneOffLayerPatchID = randomString(); File oneOffPatchDir = mkdir(tempDir, oneOffPatchID); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(oneOffPatchDir, oneOffLayerPatchID, moduleName); Patch oneOffPatch = PatchBuilder.create() .setPatchId(oneOffPatchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .oneOffPatchElement(oneOffLayerPatchID, BASE, false) .addContentModification(moduleAdded) .getParent() .build(); createPatchXMLFile(oneOffPatchDir, oneOffPatch); File zippedPatch = createZippedPatchFile(oneOffPatchDir, oneOffPatchID); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, oneOffPatch); InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity(); File modulePatchDirectory = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(oneOffLayerPatchID); assertDirExists(modulePatchDirectory); assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash()); }
@Test public void testAddModule() throws Exception { // build a one-off patch for the base installation // with 1 added module String patchID = randomString(); File patchDir = mkdir(tempDir, patchID); String baseLayerPatchID = randomString(); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, baseLayerPatchID, moduleName); Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .oneOffPatchElement(baseLayerPatchID, 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(baseLayerPatchID); assertDirExists(modulePatchDirectory); assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash()); }
@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()); }
@Test public void testRemoveModule() throws Exception { String moduleName = randomString(); // create an empty module in the AS7 installation File baseModuleDir = newFile(env.getInstalledImage().getModulesDir(), SYSTEM, LAYERS, BASE); File moduleDir = createModule0(baseModuleDir, moduleName); // build a one-off patch for the installation base layer // with 1 module removed String baseLayerPatchID = randomString(); Patch patch = PatchBuilder.create() .setPatchId(randomString()) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .oneOffPatchElement(baseLayerPatchID, BASE, false) .addContentModification(ContentModificationUtils.removeModule(moduleDir)) .getParent() .build(); // create the patch File patchDir = mkdir(tempDir, patch.getPatchId()); createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); InstalledIdentity installedIdentity = loadInstalledIdentity(); File modulesPatchDir = installedIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(baseLayerPatchID); assertDirExists(modulesPatchDir); assertDefinedAbsentModule(modulesPatchDir, moduleName); }
.getParent() .oneOffPatchElement(oneOffLayerPatchID, BASE, false) .addContentModification(moduleAdded) .getParent() .build(); .getParent() .upgradeElement(releaseLayerPatchID, BASE, false) .addContentModification(moduleAddedInReleasePatch) .getParent() .build();
.getParent() .oneOffPatchElement(addOnPatchID, addOnName, true) .addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded)
.getParent() .oneOffPatchElement(layerPatchId, BASE, false) .addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded)
.getParent() .oneOffPatchElement(layerPatchId, layerName, false) .addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded)
.getParent() .oneOffPatchElement(baseLayerPatchID, BASE, false) .addContentModification(moduleModified) .getParent() .build();
.getParent() .oneOffPatchElement(addOnPatchID, addOnName, true) .addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded)
.getParent() .oneOffPatchElement(layerPatchId, layerName, false) .addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded)
.getParent() .oneOffPatchElement(layerPatchID, BASE, false) .addContentModification(moduleAdded) .getParent() .addContentModification(fileUpdated)
.getParent() .upgradeElement(layerPatchID, BASE, false) .addContentModification(moduleAdded) .getParent() .addContentModification(fileModified)