use of org.jboss.as.patching.tool.PatchingResult in project wildfly-core by wildfly.
the class FileTaskTestCase method testRemoveDirectoryAndRollback.
@Test
public void testRemoveDirectoryAndRollback() throws Exception {
// start from a base installation
// Create a directory
File test = mkdir(env.getInstalledImage().getJbossHome(), "test");
String one = "one";
String two = "two";
File fileOne = touch(test, one);
// touch one
touch(fileOne);
dump(fileOne, randomString());
File fileTwo = touch(test, two);
// touch two
touch(fileTwo);
dump(fileTwo, randomString());
File subDirOne = mkdir(test, "sub");
File subOne = touch(subDirOne, one);
touch(subOne);
dump(subOne, randomString());
File subTwo = touch(subDirOne, two);
touch(subTwo);
dump(subTwo, randomString());
// build a one-off patch for the base installation
// with 1 removed directory
// randomString();
String patchID = "patchID";
ContentModification dirRemoved = ContentModificationUtils.removeMisc(test);
Patch patch = PatchBuilder.create().setPatchId(patchID).setDescription(randomString()).oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().addContentModification(dirRemoved).build();
// create the patch
File patchDir = mkdir(tempDir, patch.getPatchId());
createPatchXMLFile(patchDir, patch);
File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId());
Identity identityBeforePatch = loadInstalledIdentity().getIdentity();
// Apply
PatchingResult result = executePatch(zippedPatch);
assertPatchHasBeenApplied(result, patch);
assertFalse(test.exists());
// Rollback
result = rollback(patch.getPatchId());
assertPatchHasBeenRolledBack(result, identityBeforePatch);
assertTrue(test.exists());
assertTrue(fileOne.isFile());
assertTrue(fileTwo.isFile());
assertTrue(subOne.isFile());
assertTrue(subTwo.isFile());
}
use of org.jboss.as.patching.tool.PatchingResult in project wildfly-core by wildfly.
the class FileTaskTestCase method testAddFile.
@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());
}
Aggregations