use of org.jboss.as.patching.metadata.PatchBuilder in project wildfly-core by wildfly.
the class UpdateModifiedFileTaskTestCase method setUp.
@Before
public void setUp() throws Exception {
// with a file in it
File binDir = mkdir(env.getInstalledImage().getJbossHome(), "bin");
String fileName = "standalone.sh";
modifiedFile = touch(binDir, fileName);
dump(modifiedFile, "modified script to run standalone AS7");
expectedModifiedHash = hashFile(modifiedFile);
// 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);
// build a one-off patch for the base installation
// with 1 updated file
String patchID = randomString();
File patchDir = mkdir(tempDir, patchID);
File updatedFile = touch(patchDir, patchID, "misc", "bin", fileName);
dump(updatedFile, "updated script");
updatedHash = hashFile(updatedFile);
fileUpdated = new ContentModification(new MiscContentItem(fileName, new String[] { "bin" }, updatedHash), unmodifiedHash, MODIFY);
PatchBuilder builder = PatchBuilder.create().setPatchId(patchID).setDescription(randomString()).oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent();
// PatchElementImpl element = new PatchElementImpl("patch element 01");
// builder.addElement(element);
// element.setDescription("patch element 01 description");
// element.setNoUpgrade();
//
// PatchElementProviderImpl provider = new PatchElementProviderImpl("base", "4.5.6", false);
// provider.require("patch element 02");
// element.setProvider(provider);
builder.addContentModification(fileUpdated);
patch = builder.build();
// create the patch
createPatchXMLFile(patchDir, patch);
zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId());
runner = newPatchTool();
}
use of org.jboss.as.patching.metadata.PatchBuilder in project wildfly-core by wildfly.
the class MergingPatchMetadataTestCase method generateCP.
protected Patch generateCP(final String currentCP, final String nextCP, ModificationType type) {
final PatchBuilder patchBuilder = PatchBuilder.create().setPatchId(nextCP).setDescription(nextCP + " description");
patchBuilder.upgradeIdentity("identity", currentCP, nextCP);
final PatchElementBuilder elementBuilder = patchBuilder.upgradeElement("base-" + nextCP, "base", false);
if (ModificationType.ADD.equals(type)) {
elementBuilder.addModule("org.jboss.test", "main", moduleHash(nextCP)).addBundle("org.jboss.test", "main", bundleHash(nextCP)).addFile("test.txt", Arrays.asList(new String[] { "org", "jboss", "test" }), miscHash(nextCP), false);
} else if (ModificationType.MODIFY.equals(type)) {
elementBuilder.modifyModule("org.jboss.test", "main", moduleHash(currentCP), moduleHash(nextCP)).modifyBundle("org.jboss.test", "main", bundleHash(currentCP), bundleHash(nextCP)).modifyFile("test.txt", Arrays.asList(new String[] { "org", "jboss", "test" }), miscHash(currentCP), miscHash(nextCP), false);
} else {
elementBuilder.removeModule("org.jboss.test", "main", moduleHash(currentCP)).removeBundle("org.jboss.test", "main", bundleHash(currentCP)).removeFile("test.txt", Arrays.asList(new String[] { "org", "jboss", "test" }), miscHash(currentCP), false);
}
return patchBuilder.build();
}
use of org.jboss.as.patching.metadata.PatchBuilder in project wildfly-core by wildfly.
the class ConfigurationBackupTestCase method testCumulativePatch.
@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);
}
Aggregations