@Override public Patch resolvePatch(String name, String version) throws PatchingException { return build(); }
public PatchingTestStepBuilder(PatchingTestBuilder testBuilder) { this.testBuilder = testBuilder; this.builder = PatchBuilder.create(); this.root = new File(testBuilder.getRoot(), randomString()); this.root.mkdir(); }
public PatchingTestStepBuilder oneOffPatchIdentity(String name, String version) { builder.oneOffPatchIdentity(name, version); return returnThis(); }
@Test public void testOneOffPatch() throws Exception { // build a one-off 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) .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion()) .getParent() .oneOffPatchElement(layerPatchID, BASE, false) .addContentModification(moduleAdded); Patch patch = builder.build(); checkApplyPatchAndRollbackRestoresBackupConfiguration(patchDir, patch); }
@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); }
Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(patchIDDescr) .setLink("http://test.one") .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileModified) .oneOffPatchElement(patchElementId, "base", false) .setDescription(oneOffElementDescr) .addContentModification(moduleModified) .getParent() .build(); Patch patch2 = PatchBuilder.create() .setPatchId(patchID2) .setDescription(patchID2Descr) .setLink("http://test.two") .upgradeIdentity(productConfig.getProductName(), productConfig.getProductVersion(), productConfig.getProductName() + "CP2") .getParent() .addContentModification(fileModified2) .upgradeElement(patchElementId2, "base", false) .setDescription(cpElementDescr) .addContentModification(moduleModified2) .getParent() .build();
final PatchBuilder builder = PatchBuilder.create().setPatchId(cp2.getPatchId()).setDescription(cp2.getDescription()) .setLink(cp2.getLink()); builder.upgradeIdentity(cp1Identity.getName(), cp1Identity.getVersion(), cp2Identity.getResultingVersion()); builder.addElement(cp1El); } else { final PatchElementBuilder elementBuilder = builder.upgradeElement(cp2El.getId(), provider.getName(), provider.isAddOn()).setDescription(cp2El.getDescription()); builder.addElement(cp2Element); builder.addElement(cp2Element); return builder.build();
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); if(Attribute.ID == attribute) { patch.setPatchId(value); } else { throw unexpectedAttribute(reader, i); final Collection<ContentModification> modifications = patch.getModifications(); while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { final String localName = reader.getLocalName(); switch (element) { case DESCRIPTION: patch.setDescription(reader.getElementText()); break; case LINK: final String link = readStringAttributeElement(reader, Attribute.URL.name); builder.setLink(link); break; case UPGRADE:
ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchId, moduleName); final PatchBuilder patchBuilder = PatchBuilder.create() .setPatchId(patchID) .oneOffPatchIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion()) .getParent() .oneOffPatchElement(layerPatchId, layerName, false) .addContentModification(moduleAdded) .getParent(); try { patchBuilder.oneOffPatchElement(layerPatchId, layer2Name, false); fail("duplicate element patch-id error expected"); } catch(IllegalStateException e) {
switch (patchType) { case CUMULATIVE: identityBuilder = builder.upgradeIdentity(name, version, resultingVersion); break; case ONE_OFF: identityBuilder = builder.oneOffPatchIdentity(name, version); break; default:
public PatchingTestStepBuilder setPatchId(String id) { this.patchId = id; builder.setPatchId(id); return returnThis(); }
public PatchingTestStepBuilder upgradeIdentity(String name, String version, String resultingVersion) { builder.upgradeIdentity(name, version, resultingVersion); return returnThis(); }
public PatchElementTestStepBuilder upgradeElement(String patchId, String layerName, boolean isAddon) { final PatchElementBuilder elementBuilder = builder.upgradeElement(patchId, layerName, isAddon); return new PatchElementTestStepBuilder(patchId, elementBuilder, this); }
public static PatchBuilder create() { return new PatchBuilder(); }
@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); }
final ContentModification cp1AddedByCP1RemovedByCP3Added = ContentModificationUtils.addMisc(cp1Dir, cp1ID, "added by cp1", "bin", addedByCP1RemovedByCP3.getName()); cp1 = PatchBuilder.create() .setPatchId(cp1ID) .setDescription(randomString()) .upgradeIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion(), productConfig.getProductVersion() + "_CP1") .getParent() .upgradeElement(baseCP1ID, BASE, false) .addContentModification(cp1BaseModuleAdded) .addContentModification(cp1BaseModule2Added) .getParent() .upgradeElement(layer1CP1ID, "layer1", false) .addContentModification(cp1Layer1ModuleAdded) .getParent() .upgradeElement(layer2CP1ID, "layer2", false) .addContentModification(cp1Layer2ModuleAdded) .addContentModification(cp1Layer2Module2Added) .getParent() .addContentModification(cp1StandaloneModified) .addContentModification(cp1AddedByCP1Added) .addContentModification(cp1AddedByCP1RemovedByCP3Added) .build(); createPatchXMLFile(cp1Dir, cp1); cp1Zip = createZippedPatchFile(cp1Dir, cp1ID);
Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(patchIDDescr) .setLink("http://test.one") .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileModified) .oneOffPatchElement(patchElementId, "base", false) .setDescription(oneOffElementDescr) .addContentModification(moduleModified) .getParent() .build(); Patch patch2 = PatchBuilder.create() .setPatchId(patchID2) .setDescription(patchID2Descr) .setLink("http://test.two") .upgradeIdentity(productConfig.getProductName(), productConfig.getProductVersion(), productConfig.getProductName() + "CP2") .getParent() .addContentModification(fileModified2) .upgradeElement(patchElementId2, "base", false) .setDescription(cpElementDescr) .addContentModification(moduleModified2) .getParent() .build();
final PatchBuilder builder = PatchBuilder.create().setPatchId(cp2.getPatchId()).setDescription(cp2.getDescription()) .setLink(cp2.getLink()); builder.upgradeIdentity(cp1Identity.getName(), cp1Identity.getVersion(), cp2Identity.getResultingVersion()); builder.addElement(cp1El); } else { final PatchElementBuilder elementBuilder = builder.upgradeElement(cp2El.getId(), provider.getName(), provider.isAddOn()).setDescription(cp2El.getDescription()); builder.addElement(cp2Element); builder.addElement(cp2Element); return builder.build();
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); if(Attribute.ID == attribute) { patch.setPatchId(value); } else { throw unexpectedAttribute(reader, i); final Collection<ContentModification> modifications = patch.getModifications(); while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { final String localName = reader.getLocalName(); switch (element) { case DESCRIPTION: patch.setDescription(reader.getElementText()); break; case LINK: final String link = readStringAttributeElement(reader, Attribute.URL.name); builder.setLink(link); break; case UPGRADE: