use of org.jboss.as.test.patching.PatchingTestUtil.createPatchXMLFile in project wildfly-core by wildfly.
the class OverridePreserveTestCase method testOverrideOnePreserveOneMiscFile.
/**
* Prepare a patch that modifies two misc files. [LICENSE.txt, README.txt]
* Modify these two files before installing the patch.
* apply patch with --override=LICENSE.xt --preserve=README.txt
* rollback patch with --preserve=README.txt --override=LICENSE.txt
*/
@Test
public void testOverrideOnePreserveOneMiscFile() throws Exception {
// prepare the patch
String patchID = randomString();
File oneOffPatchDir = mkdir(tempDir, patchID);
ContentModification file1Modified = ContentModificationUtils.modifyMisc(oneOffPatchDir, patchID, file1patchedContent, new File(FILE1), "README.txt");
ContentModification file2Modified = ContentModificationUtils.modifyMisc(oneOffPatchDir, patchID, file2patchedContent, new File(FILE2), "LICENSE.txt");
ProductConfig productConfig = new ProductConfig(PRODUCT, AS_VERSION, "main");
Patch oneOffPatch = PatchBuilder.create().setPatchId(patchID).setDescription("A one-off patch modifying two misc files.").oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().addContentModification(file1Modified).addContentModification(file2Modified).build();
PatchingTestUtil.createPatchXMLFile(oneOffPatchDir, oneOffPatch);
File zippedPatch = PatchingTestUtil.createZippedPatchFile(oneOffPatchDir, patchID);
// modify files
PatchingTestUtil.setFileContent(FILE1, file1modifiedContent);
PatchingTestUtil.setFileContent(FILE2, file2modifiedContent);
// apply the patch without override/preserve
controller.start();
Assert.assertFalse("Server should reject patch installation in this case", CliUtilsForPatching.applyPatch(zippedPatch.getAbsolutePath()));
Assert.assertEquals("Misc file should not be overwritten", file1modifiedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should not be overwritten", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
// apply patch with --override=LICENSE,txt --preserve=README.txt
Assert.assertTrue("Patch should be accepted", CliUtilsForPatching.applyPatch(zippedPatch.getAbsolutePath(), String.format(CliUtilsForPatching.OVERRIDE, "LICENSE.txt"), String.format(CliUtilsForPatching.PRESERVE, "README.txt")));
Assert.assertTrue("server should be in restart-required mode", CliUtilsForPatching.doesServerRequireRestart());
controller.stop();
controller.start();
Assert.assertTrue("The patch " + patchID + " should be listed as installed", CliUtilsForPatching.getInstalledPatches().contains(patchID));
Assert.assertEquals("Misc file should not be overwritten", file1modifiedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should be overwritten", file2patchedContent, PatchingTestUtil.readFile(FILE2));
// rollback patch
Assert.assertTrue("Rollback should be accepted", CliUtilsForPatching.rollbackPatch(patchID, String.format(CliUtilsForPatching.OVERRIDE, "LICENSE.txt"), String.format(CliUtilsForPatching.PRESERVE, "README.txt")));
Assert.assertTrue("server should be in restart-required mode", CliUtilsForPatching.doesServerRequireRestart());
controller.stop();
controller.start();
try {
Assert.assertFalse("The patch " + patchID + " NOT should be listed as installed", CliUtilsForPatching.getInstalledPatches().contains(patchID));
Assert.assertEquals("Misc file should not be overridden", file1modifiedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should be restored", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
// no patches present
assertPatchElements(PatchingTestUtil.BASE_MODULE_DIRECTORY, null, false);
} finally {
controller.stop();
}
}
use of org.jboss.as.test.patching.PatchingTestUtil.createPatchXMLFile in project wildfly-core by wildfly.
the class OverridePreserveTestCase method testPreserveMiscFiles.
/**
* Prepare a patch that modifies two misc files. [LICENSE.txt, README.txt]
* Modify these two files before installing the patch.
* apply patch with --preserve=README.txt,OVERRIDE.txt
* rollback patch with --preserve=README.txt --override=LICENSE.txt
*/
@Test
public void testPreserveMiscFiles() throws Exception {
// prepare the patch
String patchID = randomString();
File oneOffPatchDir = mkdir(tempDir, patchID);
ContentModification file1Modified = ContentModificationUtils.modifyMisc(oneOffPatchDir, patchID, file1patchedContent, new File(FILE1), "README.txt");
ContentModification file2Modified = ContentModificationUtils.modifyMisc(oneOffPatchDir, patchID, file2patchedContent, new File(FILE2), "LICENSE.txt");
ProductConfig productConfig = new ProductConfig(PRODUCT, AS_VERSION, "main");
Patch oneOffPatch = PatchBuilder.create().setPatchId(patchID).setDescription("A one-off patch modifying two misc files.").oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().addContentModification(file1Modified).addContentModification(file2Modified).build();
PatchingTestUtil.createPatchXMLFile(oneOffPatchDir, oneOffPatch);
File zippedPatch = PatchingTestUtil.createZippedPatchFile(oneOffPatchDir, patchID);
// modify files
PatchingTestUtil.setFileContent(FILE1, file1modifiedContent);
PatchingTestUtil.setFileContent(FILE2, file2modifiedContent);
// apply the patch without override/preserve
controller.start();
Assert.assertFalse("Server should reject patch installation in this case", CliUtilsForPatching.applyPatch(zippedPatch.getAbsolutePath()));
Assert.assertEquals("Misc file should not be overwritten", file1modifiedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should not be overwritten", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
// apply patch with --preserve=LICENSE,txt,README.txt
Assert.assertTrue("Patch should be accepted", CliUtilsForPatching.applyPatch(zippedPatch.getAbsolutePath(), String.format(CliUtilsForPatching.PRESERVE, "README.txt,LICENSE.txt")));
Assert.assertTrue("server should be in restart-required mode", CliUtilsForPatching.doesServerRequireRestart());
controller.stop();
controller.start();
Assert.assertTrue("The patch " + patchID + " should be listed as installed", CliUtilsForPatching.getInstalledPatches().contains(patchID));
Assert.assertEquals("Misc file should not be overwritten", file1modifiedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should not be overwritten", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
// rollback patch
Assert.assertTrue("Rollback should be accepted", CliUtilsForPatching.rollbackPatch(patchID, String.format(CliUtilsForPatching.OVERRIDE, "LICENSE.txt"), String.format(CliUtilsForPatching.PRESERVE, "README.txt")));
Assert.assertTrue("server should be in restart-required mode", CliUtilsForPatching.doesServerRequireRestart());
controller.stop();
controller.start();
Assert.assertFalse("The patch " + patchID + " NOT should be listed as installed", CliUtilsForPatching.getInstalledPatches().contains(patchID));
Assert.assertEquals("Misc file should not be overridden", file1modifiedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should not be overridden", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
controller.stop();
}
use of org.jboss.as.test.patching.PatchingTestUtil.createPatchXMLFile in project wildfly-core by wildfly.
the class OverridePreserveTestCase method testOverrideAllMiscFiles.
/**
* Prepare a patch that modifies two misc files. [LICENSE.txt, README.txt]
* Modify these two files before installing the patch.
* apply patch with --override-all
* rollback patch with --preserve=README.txt --override=LICENSE.txt
*/
@Test
public void testOverrideAllMiscFiles() throws Exception {
// prepare the patch
String patchID = randomString();
File oneOffPatchDir = mkdir(tempDir, patchID);
ContentModification file1Modified = ContentModificationUtils.modifyMisc(oneOffPatchDir, patchID, file1patchedContent, new File(FILE1), "README.txt");
ContentModification file2Modified = ContentModificationUtils.modifyMisc(oneOffPatchDir, patchID, file2patchedContent, new File(FILE2), "LICENSE.txt");
ProductConfig productConfig = new ProductConfig(PRODUCT, AS_VERSION, "main");
Patch oneOffPatch = PatchBuilder.create().setPatchId(patchID).setDescription("A one-off patch modifying two misc files.").oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().addContentModification(file1Modified).addContentModification(file2Modified).build();
PatchingTestUtil.createPatchXMLFile(oneOffPatchDir, oneOffPatch);
File zippedPatch = PatchingTestUtil.createZippedPatchFile(oneOffPatchDir, patchID);
// modify files
PatchingTestUtil.setFileContent(FILE1, file1modifiedContent);
PatchingTestUtil.setFileContent(FILE2, file2modifiedContent);
// apply the patch without override/preserve
controller.start();
Assert.assertFalse("Server should reject patch installation in this case", CliUtilsForPatching.applyPatch(zippedPatch.getAbsolutePath()));
Assert.assertEquals("Misc file should not be overwritten", file1modifiedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should not be overwritten", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
// apply patch with --override-all
Assert.assertTrue("Patch should be accepted", CliUtilsForPatching.applyPatch(zippedPatch.getAbsolutePath(), CliUtilsForPatching.OVERRIDE_ALL));
Assert.assertTrue("server should be in restart-required mode", CliUtilsForPatching.doesServerRequireRestart());
controller.stop();
controller.start();
Assert.assertTrue("The patch " + patchID + " should be listed as installed", CliUtilsForPatching.getInstalledPatches().contains(patchID));
Assert.assertEquals("Misc file should be overwritten", file1patchedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should be overwritten", file2patchedContent, PatchingTestUtil.readFile(FILE2));
// rollback patch
Assert.assertTrue("Rollback should be accepted", CliUtilsForPatching.rollbackPatch(patchID, String.format(CliUtilsForPatching.OVERRIDE, "LICENSE.txt"), String.format(CliUtilsForPatching.PRESERVE, "README.txt")));
Assert.assertTrue("server should be in restart-required mode", CliUtilsForPatching.doesServerRequireRestart());
controller.stop();
controller.start();
try {
Assert.assertFalse("The patch " + patchID + " NOT should be listed as installed", CliUtilsForPatching.getInstalledPatches().contains(patchID));
Assert.assertEquals("Misc file should not be overridden", file1patchedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should be restored", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
// no patches present
assertPatchElements(PatchingTestUtil.BASE_MODULE_DIRECTORY, null, false);
} finally {
controller.stop();
}
}
use of org.jboss.as.test.patching.PatchingTestUtil.createPatchXMLFile in project wildfly-core by wildfly.
the class OverridePreserveTestCase method testOverrideMiscFiles.
/**
* Prepare a patch that modifies two misc files. [LICENSE.txt, README.txt]
* Modify these two files before installing the patch.
* apply patch with --override=README.txt,OVERRIDE.txt
* rollback patch with --preserve=README.txt --override=LICENSE.txt
*/
@Test
public void testOverrideMiscFiles() throws Exception {
// prepare the patch
String patchID = randomString();
File oneOffPatchDir = mkdir(tempDir, patchID);
ContentModification file1Modified = ContentModificationUtils.modifyMisc(oneOffPatchDir, patchID, file1patchedContent, new File(FILE1), "README.txt");
ContentModification file2Modified = ContentModificationUtils.modifyMisc(oneOffPatchDir, patchID, file2patchedContent, new File(FILE2), "LICENSE.txt");
ProductConfig productConfig = new ProductConfig(PRODUCT, AS_VERSION, "main");
Patch oneOffPatch = PatchBuilder.create().setPatchId(patchID).setDescription("A one-off patch modifying two misc files.").oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().addContentModification(file1Modified).addContentModification(file2Modified).build();
PatchingTestUtil.createPatchXMLFile(oneOffPatchDir, oneOffPatch);
File zippedPatch = PatchingTestUtil.createZippedPatchFile(oneOffPatchDir, patchID);
// modify files
PatchingTestUtil.setFileContent(FILE1, file1modifiedContent);
PatchingTestUtil.setFileContent(FILE2, file2modifiedContent);
// apply the patch without override/preserve
controller.start();
Assert.assertFalse("Server should reject patch installation in this case", CliUtilsForPatching.applyPatch(zippedPatch.getAbsolutePath()));
Assert.assertEquals("Misc file should not be overwritten", file1modifiedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should not be overwritten", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
// apply patch with --override=LICENSE,txt,README.txt
Assert.assertTrue("Patch should be accepted", CliUtilsForPatching.applyPatch(zippedPatch.getAbsolutePath(), String.format(CliUtilsForPatching.OVERRIDE, "README.txt,LICENSE.txt")));
Assert.assertTrue("server should be in restart-required mode", CliUtilsForPatching.doesServerRequireRestart());
controller.stop();
controller.start();
Assert.assertTrue("The patch " + patchID + " should be listed as installed", CliUtilsForPatching.getInstalledPatches().contains(patchID));
Assert.assertEquals("Misc file should be overwritten", file1patchedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should be overwritten", file2patchedContent, PatchingTestUtil.readFile(FILE2));
// rollback patch
Assert.assertTrue("Rollback should be accepted", CliUtilsForPatching.rollbackPatch(patchID, String.format(CliUtilsForPatching.OVERRIDE, "LICENSE.txt"), String.format(CliUtilsForPatching.PRESERVE, "README.txt")));
Assert.assertTrue("server should be in restart-required mode", CliUtilsForPatching.doesServerRequireRestart());
controller.stop();
controller.start();
try {
Assert.assertFalse("The patch " + patchID + " NOT should be listed as installed", CliUtilsForPatching.getInstalledPatches().contains(patchID));
Assert.assertEquals("Misc file should not be overridden", file1patchedContent, PatchingTestUtil.readFile(FILE1));
Assert.assertEquals("Misc file should be restored", file2modifiedContent, PatchingTestUtil.readFile(FILE2));
// no patch overlays present
assertPatchElements(PatchingTestUtil.BASE_MODULE_DIRECTORY, null, false);
} finally {
controller.stop();
}
}
Aggregations