Search in sources :

Example 11 with Identity

use of org.jboss.as.patching.metadata.Identity in project wildfly-core by wildfly.

the class MergingPatchMetadataTestCase method testAddModify.

@Test
public void testAddModify() throws Exception {
    final Patch cp1 = generateCP("base", "cp1", ModificationType.ADD);
    final Patch cp2 = generateCP("cp1", "cp2", ModificationType.MODIFY);
    final Patch merged = PatchMerger.merge(cp1, cp2);
    assertEquals("cp2", merged.getPatchId());
    assertEquals("cp2" + " description", merged.getDescription());
    final IdentityUpgrade identity = merged.getIdentity().forType(PatchType.CUMULATIVE, Identity.IdentityUpgrade.class);
    assertEquals("base", identity.getVersion());
    assertEquals("cp2", identity.getResultingVersion());
    assertEquals(PatchType.CUMULATIVE, identity.getPatchType());
    final List<PatchElement> elements = merged.getElements();
    assertEquals(1, elements.size());
    final PatchElement e = elements.get(0);
    assertEquals("base-" + "cp2", e.getId());
    final PatchElementProvider provider = e.getProvider();
    assertEquals("base", provider.getName());
    assertEquals(PatchType.CUMULATIVE, provider.getPatchType());
    assertEquals(LayerType.Layer, provider.getLayerType());
    assertEquals(3, e.getModifications().size());
    for (ContentModification mod : e.getModifications()) {
        assertEquals(ModificationType.ADD, mod.getType());
        final ContentItem item = mod.getItem();
        assertEquals(0, mod.getTargetHash().length);
        if (ContentType.MODULE.equals(item.getContentType())) {
            Assert.assertArrayEquals(moduleHash("cp2"), item.getContentHash());
        } else if (ContentType.MISC.equals(item.getContentType())) {
            Assert.assertArrayEquals(miscHash("cp2"), item.getContentHash());
        } else {
            Assert.assertArrayEquals(bundleHash("cp2"), item.getContentHash());
        }
    }
}
Also used : IdentityUpgrade(org.jboss.as.patching.metadata.Identity.IdentityUpgrade) PatchElementProvider(org.jboss.as.patching.metadata.PatchElementProvider) PatchElement(org.jboss.as.patching.metadata.PatchElement) Identity(org.jboss.as.patching.metadata.Identity) Patch(org.jboss.as.patching.metadata.Patch) ContentModification(org.jboss.as.patching.metadata.ContentModification) ContentItem(org.jboss.as.patching.metadata.ContentItem) Test(org.junit.Test)

Aggregations

Identity (org.jboss.as.patching.metadata.Identity)11 PatchElement (org.jboss.as.patching.metadata.PatchElement)10 Patch (org.jboss.as.patching.metadata.Patch)9 PatchElementProvider (org.jboss.as.patching.metadata.PatchElementProvider)7 ContentModification (org.jboss.as.patching.metadata.ContentModification)5 IdentityUpgrade (org.jboss.as.patching.metadata.Identity.IdentityUpgrade)5 Test (org.junit.Test)5 InstalledIdentity (org.jboss.as.patching.installation.InstalledIdentity)4 ContentItem (org.jboss.as.patching.metadata.ContentItem)4 IOException (java.io.IOException)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 PatchingException (org.jboss.as.patching.PatchingException)3 RollbackPatch (org.jboss.as.patching.metadata.RollbackPatch)3 SimpleTable (org.jboss.as.cli.util.SimpleTable)2 PatchType (org.jboss.as.patching.metadata.Patch.PatchType)2 PatchEntry (org.jboss.as.patching.runner.IdentityPatchContext.PatchEntry)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 InstallationManager (org.jboss.as.patching.installation.InstallationManager)1