@Override protected ModelNode applyPatch(final File file, final ContentPolicyBuilderImpl builder) { final ContentVerificationPolicy policy = builder.createPolicy(); ModelNode result = new ModelNode(); try { PatchingResult apply = tool.applyPatch(file, policy); apply.commit(); result.get(OUTCOME).set(SUCCESS); result.get(RESULT).setEmptyObject(); } catch (PatchingException e) { return formatFailedResponse(e); } return result; }
@Override protected ModelNode applyPatch(final File file, final ContentPolicyBuilderImpl builder) { final ContentVerificationPolicy policy = builder.createPolicy(); ModelNode result = new ModelNode(); try { PatchingResult apply = tool.applyPatch(file, policy); apply.commit(); result.get(OUTCOME).set(SUCCESS); result.get(RESULT).setEmptyObject(); } catch (PatchingException e) { return formatFailedResponse(e); } return result; }
protected PatchingResult executePatch(final PatchTool tool, final File file) throws IOException, PatchingException { final PatchingResult result = tool.applyPatch(file, ContentVerificationPolicy.STRICT); result.commit(); return result; }
@Test public void testUpdateModifiedFileWithPRESERVE_ALL() throws Exception { try { runner.applyPatch(zippedPatch, ContentVerificationPolicy.PRESERVE_ALL); } catch (ContentConflictsException e) { assertPatchHasNotBeenApplied(e, patch, fileUpdated.getItem(), env); /// file has not been modified in the AS7 installation assertFileExists(modifiedFile); assertArrayEquals(expectedModifiedHash, hashFile(modifiedFile)); } } }
@Test public void testUpdateModifiedFileWithSTRICT() throws Exception { try { runner.applyPatch(zippedPatch, ContentVerificationPolicy.STRICT); } catch (ContentConflictsException e) { assertPatchHasNotBeenApplied(e, patch, fileUpdated.getItem(), env); /// file has not been modified in the AS7 installation assertFileExists(modifiedFile); assertArrayEquals(expectedModifiedHash, hashFile(modifiedFile)); } }
@Test public void testRemovedModifiedFileWithOVERRIDE_ALL() throws Exception { PatchingResult result = runner.applyPatch(zippedPatch, ContentVerificationPolicy.OVERRIDE_ALL); assertPatchHasBeenApplied(result, patch); /// file has been removed from the AS7 installation // and it's the new one assertFileDoesNotExist(removedFile); // the existing file has been backed up File backupFile = assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "misc", "bin", removedFile.getName()); assertArrayEquals(expectedModifiedHash, hashFile(backupFile)); }
@Test public void testRemoveModifiedFileWithSTRICT() throws Exception { try { runner.applyPatch(zippedPatch, ContentVerificationPolicy.STRICT); fail("Patch shouldn't be applied - ContentVerificationPolicy.STRICT"); } catch (ContentConflictsException e) { assertPatchHasNotBeenApplied(e, patch, fileRemoved.getItem(), env); /// file has not been modified in the AS7 installation assertFileExists(removedFile); assertArrayEquals(expectedModifiedHash, hashFile(removedFile)); } }
@Test public void testRemoveModifiedFileWithPRESERVE_ALL() throws Exception { try { runner.applyPatch(zippedPatch, ContentVerificationPolicy.PRESERVE_ALL); fail("Patch shouldn't be applied - ContentVerificationPolicy.PRESERVE_ALL"); } catch (ContentConflictsException e) { assertPatchHasNotBeenApplied(e, patch, fileRemoved.getItem(), env); /// file has not been modified in the AS7 installation assertFileExists(removedFile); assertArrayEquals(expectedModifiedHash, hashFile(removedFile)); } } }
final InputStream is = context.getAttachmentStream(index); installationManager.restartRequired(); final PatchingResult result = runner.applyPatch(is, policy); context.restartRequired(); context.completeStep(new OperationContext.ResultHandler() {
final InputStream is = context.getAttachmentStream(index); installationManager.restartRequired(); final PatchingResult result = runner.applyPatch(is, policy); context.restartRequired(); context.completeStep(new OperationContext.ResultHandler() {
@Test public void testUpdateModifiedFileWithOVERRIDE_ALL() throws Exception { PatchingResult result = runner.applyPatch(zippedPatch, ContentVerificationPolicy.OVERRIDE_ALL); assertPatchHasBeenApplied(result, patch); /// file has been updated in the AS7 installation // and it's the new one assertFileExists(modifiedFile); assertArrayEquals(updatedHash, hashFile(modifiedFile)); // the existing file has been backed up File backupFile = assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "misc", "bin", modifiedFile.getName()); assertArrayEquals(expectedModifiedHash, hashFile(backupFile)); }
protected PatchingResult apply(final PatchingTestStepBuilder builder, final ContentVerificationPolicy verificationPolicy, final PatchStepAssertions assertions) throws PatchingException { final Patch patch = builder.build(); final File installation = new File(tempDir, JBOSS_INSTALLATION); try { assertions.before(installation, patch, installationManager); } catch (IOException e) { throw new PatchingException(e); } // Write patch writePatch(builder.getPatchDir(), patch); // Create the patch tool and apply the patch final PatchTool patchTool = PatchTool.Factory.create(installationManager); final PatchingResult result = patchTool.applyPatch(builder.getPatchDir(), verificationPolicy); result.commit(); final InstalledIdentity identity = ((InstallationManagerImpl)installationManager).getInstalledIdentity(patch.getIdentity().getName(), null); Assert.assertTrue(identity.getAllInstalledPatches().contains(patch.getPatchId())); try { assertions.after(installation, patch, installationManager); } catch (IOException e) { throw new PatchingException(e); } return result; }
final PatchTool patchTool = PatchTool.Factory.create(mgr); try { patchTool.applyPatch(multiPatch, ContentVerificationPolicy.STRICT); Assert.fail(); } catch (PatchingException e) {
final PatchingResult result = patchTool.applyPatch(multiPatch, ContentVerificationPolicy.STRICT); result.commit(); try {
final PatchingResult result = patchTool.applyPatch(multiPatch, ContentVerificationPolicy.STRICT); result.rollback();
final PatchingResult result = patchTool.applyPatch(multiPatch, ContentVerificationPolicy.STRICT); result.commit(); try {