public T addModuleWithContent(final String moduleName, byte[] resultingHash, final String... resourceContents) throws IOException { final ContentModification modification = ContentModificationUtils.addModule(getPatchDir(), getPatchId(), moduleName, resourceContents); return addContentModification(modification, resultingHash); }
public T addModuleWithRandomContent(final String moduleName, byte[] resultingHash) throws IOException { final ContentModification modification = ContentModificationUtils.addModule(getPatchDir(), getPatchId(), moduleName, randomString()); return addContentModification(modification, resultingHash); }
final File cp1Dir = mkdir(tempDir, cp1ID); cp1BaseModuleAdded = ContentModificationUtils.addModule(cp1Dir, baseCP1ID, moduleName); cp1BaseModule2Added = ContentModificationUtils.addModule(cp1Dir, baseCP1ID, moduleName + 2); cp1Layer1ModuleAdded = ContentModificationUtils.addModule(cp1Dir, layer1CP1ID, moduleName); cp1Layer2ModuleAdded = ContentModificationUtils.addModule(cp1Dir, layer2CP1ID, moduleName); cp1Layer2Module2Added = ContentModificationUtils.addModule(cp1Dir, layer2CP1ID, moduleName + "2"); cp1StandaloneModified = ContentModificationUtils.modifyMisc(cp1Dir, cp1ID, "updated by cp1", standaloneSh, "bin", standaloneSh.getName()); cp1AddedByCP1Added = ContentModificationUtils.addMisc(cp1Dir, cp1ID, "added by cp1", "bin", addedByCP1.getName());
@Test public void testWrongModuleContent() throws Exception { final PatchingTestBuilder builder = createDefaultBuilder(); // Add some random content ContentModificationUtils.addModule(builder.getRoot(), "base-patch-001", "test.module", randomString()); // Override the hash with a wrong one final ModuleItem item = new ModuleItem("test.module", "main", WRONG_HASH); final ContentModification wrongModification = new ContentModification(item, IoUtils.NO_CONTENT, ModificationType.ADD); final PatchingTestStepBuilder step1 = builder.createStepBuilder(); step1.oneOffPatchIdentity(PRODUCT_VERSION) .setPatchId("oo1") .oneOffPatchElement("base-patch-001", "base", false) .addContentModification(wrongModification) .getParent() .addFileWithRandomContent(null, "test", "content"); // try { apply(step1); Assert.fail("should have failed"); } catch (PatchingException e) { Assert.assertFalse(builder.hasFile("test", "content")); final InstalledIdentity identity = loadInstallationManager().getDefaultIdentity(); final PatchableTarget base = identity.getLayer("base"); Assert.assertFalse(base.getDirectoryStructure().getModulePatchDirectory("base-patch-001").exists()); Assert.assertFalse(identity.getInstalledImage().getPatchHistoryDir("oo1").exists()); } }
String layerPatchId = "mylayerPatchID"; String moduleName = "module1"; ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchId, moduleName);
@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()); }
"org", "jboss", "test"); cp2Layer2ModuleRemoved = ContentModificationUtils.removeModule(layer2ModuleDir, moduleName); cp2Layer2Module3Added = ContentModificationUtils.addModule(cp2Dir, layer2CP2ID, moduleName + "3");
String moduleName = "mymodule";//randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(oneOffPatchDir, oneOffLayerPatchID, moduleName); File releasePatchDir = mkdir(tempDir, releasePatchID); ContentModification moduleAddedInReleasePatch = ContentModificationUtils.addModule(releasePatchDir, releaseLayerPatchID, moduleName, "different content in the module");
String addOnPatchID = randomString(); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, addOnPatchID, moduleName); ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh");
String layerPatchId = "mylayerPatchID";//randomString(); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchId, moduleName); ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh");
String layerPatchId = "mylayerPatchID";//randomString(); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchId, moduleName); ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh");
String addOnPatchID = randomString(); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, addOnPatchID, moduleName); ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh");
String layerPatchId = "mylayerPatchID";//randomString(); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchId, moduleName); ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh");
ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchID, moduleName);
String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(releasePatchDir, releaseLayerPatchID, moduleName);
String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchID, moduleName); ContentModification fileModified = ContentModificationUtils.modifyMisc(patchDir, patchID, "updated script", standaloneShellFile, "bin", "standalone.sh");