@Override protected PatchingTestStepBuilder internalAddModification(ContentModification modification) { builder.addContentModification(modification); return returnThis(); }
@Test public void testAddDirectory() throws Exception { final ContentItem item = new MiscContentItem("dir", new String[] { "test"}, NO_CONTENT, true, false); final ContentModification addDir = new ContentModification(item, NO_CONTENT, ModificationType.ADD); final String patchID = randomString(); final Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(addDir) .build(); // create the patch final File patchDir = mkdir(tempDir, patch.getPatchId()); createPatchXMLFile(patchDir, patch); final File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); // Apply PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); final File test = new File(env.getInstalledImage().getJbossHome(), "test"); assertTrue(test.exists()); assertTrue(test.isDirectory()); final File dir = new File(test, "dir"); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); rollback(patchID); }
.addContentModification(cp1Layer2Module2Added) .getParent() .addContentModification(cp1StandaloneModified) .addContentModification(cp1AddedByCP1Added) .addContentModification(cp1AddedByCP1RemovedByCP3Added) .build(); createPatchXMLFile(cp1Dir, cp1);
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); }
.oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileConflictModified) .addContentModification(fileNoConflictModified) .oneOffPatchElement(patchID, "base", false) .addContentModification(moduleConflictModified)
.addContentModification(cp2Layer2Module3Added) .getParent() .addContentModification(cp2StandaloneModified) .addContentModification(cp2AddedByCp2Added) .build(); createPatchXMLFile(cp2Dir, cp2);
.oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(dirRemoved) .build();
@Before public void setUp() throws Exception{ // with a file in it File binDir = mkdir(env.getInstalledImage().getJbossHome(), "bin"); String fileName = "standalone.sh"; removedFile = touch(binDir, fileName); dump(removedFile, "modified script to run standalone AS"); expectedModifiedHash = hashFile(removedFile); // let's simulate that the file has been modified by the users by using a hash that is not the file checksum byte[] unmodifiedHash = randomString().getBytes(StandardCharsets.UTF_8); String patchID = randomString(); File patchDir = mkdir(tempDir, patchID); File updatedFile = touch(patchDir, "misc", "bin", fileName); dump(updatedFile, "updated script"); // build a one-off patch for the base installation // with 1 removed file fileRemoved = new ContentModification(new MiscContentItem(fileName, new String[] { "bin" }, NO_CONTENT), unmodifiedHash, REMOVE); patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileRemoved) .build(); // create the patch createPatchXMLFile(patchDir, patch); zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); runner = newPatchTool(); }
builder.addContentModification(fileUpdated);
@Test public void testAddFile() throws Exception { // build a one-off patch for the base installation // with 1 added file String patchID = randomString(); File patchDir = mkdir(tempDir, patchID); ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh"); Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileAdded) .build(); assertFileDoesNotExist(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); assertFileExists(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); }
.addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded) .build();
.addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded) .build();
@Test public void testRemoveFile() throws Exception { // start from a base installation // with a file in it String fileName = "standalone.sh"; File standaloneShellFile = touch(env.getInstalledImage().getJbossHome(), "bin", fileName ); dump(standaloneShellFile, "original script to run standalone AS7"); // build a one-off patch for the base installation // with 1 removed file ContentModification fileRemoved = ContentModificationUtils.removeMisc(standaloneShellFile, "bin", fileName); Patch patch = PatchBuilder.create() .setPatchId(randomString()) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileRemoved) .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); /// file has been removed from the AS7 installation assertFileDoesNotExist(standaloneShellFile); // but it's been backed up assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "misc", "bin", fileName); }
.addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded) .build();
.addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded) .build();
.oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileModified) .build();
.addContentModification(moduleAdded) .getParent() .addContentModification(fileAdded) .build();
.addContentModification(moduleAdded) .getParent() .addContentModification(fileUpdated) .build(); createPatchXMLFile(patchDir, patch);
.addContentModification(moduleAdded) .getParent() .addContentModification(fileModified) .build(); createPatchXMLFile(patchDir, patch);
.upgradeIdentity(productConfig.getProductName(), productConfig.getProductVersion(), productConfig.getProductVersion() + "CP1") .getParent() .addContentModification(fileNoConflictModified) .upgradeElement(patchElementId, "base", false) .getParent()