use of org.jboss.as.patching.installation.PatchableTarget in project wildfly-core by wildfly.
the class RollbackPatchXml_1_0 method writeTargetInfo.
static void writeTargetInfo(final XMLExtendedStreamWriter writer, final Element element, final PatchableTarget target) throws XMLStreamException {
try {
final PatchableTarget.TargetInfo info = target.loadTargetInfo();
//
writer.writeEmptyElement(element.name);
writer.writeAttribute(Attribute.NAME.name, target.getName());
writer.writeAttribute(Attribute.RELEASE_ID.name, info.getCumulativePatchID());
if (!info.getPatchIDs().isEmpty()) {
writer.writeAttribute(Attribute.PATCHES.name, PatchUtils.asString(info.getPatchIDs()));
}
} catch (IOException e) {
throw new XMLStreamException(e);
}
}
use of org.jboss.as.patching.installation.PatchableTarget in project wildfly-core by wildfly.
the class PatchStepAssertions method assertNotApplied.
static void assertNotApplied(final Patch patch, InstallationManager manager) throws IOException {
InstalledIdentity installedIdentity = null;
try {
installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), patch.getIdentity().getVersion());
} catch (PatchingException e) {
Assert.fail(e.getLocalizedMessage());
}
final PatchableTarget.TargetInfo identity = installedIdentity.getIdentity().loadTargetInfo();
assertNotApplied(patch.getIdentity().getPatchType(), patch.getPatchId(), identity);
assertDoesNotExists(identity.getDirectoryStructure().getInstalledImage().getPatchHistoryDir(patch.getPatchId()));
for (final PatchElement element : patch.getElements()) {
final PatchElementProvider provider = element.getProvider();
final PatchableTarget target = provider.isAddOn() ? installedIdentity.getAddOn(provider.getName()) : installedIdentity.getLayer(provider.getName());
Assert.assertNotNull(target);
assertNotApplied(provider.getPatchType(), element.getId(), target.loadTargetInfo());
}
}
use of org.jboss.as.patching.installation.PatchableTarget in project wildfly-core by wildfly.
the class PatchUndoTestCase method testWrongModuleContent.
@Test
public void testWrongModuleContent() throws Exception {
final PatchingTestBuilder builder = createDefaultBuilder();
// Add some random content
ContentModificationUtils.addModule(builder.getRoot(), "base-patch-001", "test.module", randomString());
// Override the hash with a wrong one
final ModuleItem item = new ModuleItem("test.module", "main", WRONG_HASH);
final ContentModification wrongModification = new ContentModification(item, IoUtils.NO_CONTENT, ModificationType.ADD);
final PatchingTestStepBuilder step1 = builder.createStepBuilder();
step1.oneOffPatchIdentity(PRODUCT_VERSION).setPatchId("oo1").oneOffPatchElement("base-patch-001", "base", false).addContentModification(wrongModification).getParent().addFileWithRandomContent(null, "test", "content");
//
try {
apply(step1);
Assert.fail("should have failed");
} catch (PatchingException e) {
Assert.assertFalse(builder.hasFile("test", "content"));
final InstalledIdentity identity = loadInstallationManager().getDefaultIdentity();
final PatchableTarget base = identity.getLayer("base");
Assert.assertFalse(base.getDirectoryStructure().getModulePatchDirectory("base-patch-001").exists());
Assert.assertFalse(identity.getInstalledImage().getPatchHistoryDir("oo1").exists());
}
}
use of org.jboss.as.patching.installation.PatchableTarget in project wildfly-core by wildfly.
the class PatchUndoTestCase method testWrongModuleContentOverride.
private void testWrongModuleContentOverride(final ContentVerificationPolicy contentVerificationPolicy) throws Exception {
final PatchingTestBuilder builder = createDefaultBuilder();
// Add some random content
ContentModificationUtils.addModule(builder.getRoot(), "base-patch-003", "test.module", randomString());
// Override the hash with a wrong one
final ModuleItem item = new ModuleItem("test.module", "main", WRONG_HASH);
final ContentModification wrongModification = new ContentModification(item, IoUtils.NO_CONTENT, ModificationType.ADD);
final PatchingTestStepBuilder step1 = builder.createStepBuilder();
step1.oneOffPatchIdentity(PRODUCT_VERSION).setPatchId("oo3").oneOffPatchElement("base-patch-003", "base", false).addContentModification(wrongModification).getParent().addFileWithRandomContent(null, "test", "content");
apply(step1, contentVerificationPolicy);
Assert.assertTrue(builder.hasFile("test", "content"));
final InstalledIdentity identity = loadInstallationManager().getDefaultIdentity();
final PatchableTarget base = identity.getLayer("base");
Assert.assertTrue(base.getDirectoryStructure().getModulePatchDirectory("base-patch-003").exists());
Assert.assertTrue(identity.getInstalledImage().getPatchHistoryDir("oo3").exists());
}
Aggregations