Search in sources :

Example 31 with Patch

use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.

the class AbstractPatchIntegrationTest method rollback.

// Rollback a patch and wait for rollback to complete
protected void rollback(String name) throws Exception {
    Patch patch = service.getPatch(name);
    service.rollback(patch, false, false);
    long start = System.currentTimeMillis();
    while (patch.isInstalled() && System.currentTimeMillis() - start < TIMEOUT) {
        Thread.sleep(100);
    }
    if (patch.isInstalled()) {
        fail(String.format("Patch '%s' did not roll back within %s ms", name, TIMEOUT));
    }
}
Also used : Patch(io.fabric8.patch.management.Patch)

Example 32 with Patch

use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.

the class AbstractPatchIntegrationTest method install.

// Install a patch and wait for installation to complete
protected void install(String name) throws Exception {
    Patch patch = service.getPatch(name);
    service.install(patch, false, false);
    long start = System.currentTimeMillis();
    while (!patch.isInstalled() && System.currentTimeMillis() - start < TIMEOUT) {
        Thread.sleep(100);
    }
    if (!patch.isInstalled()) {
        fail(String.format("Patch '%s' did not installed within %s ms", name, TIMEOUT));
    }
}
Also used : Patch(io.fabric8.patch.management.Patch)

Example 33 with Patch

use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.

the class PatchBundlesIntegrationTest method createdeployment.

@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
    archive.addClass(ServiceLocator.class);
    archive.addClass(IOHelpers.class);
    archive.addPackage(ServiceTracker.class.getPackage());
    archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
    archive.setManifest(new Asset() {

        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleManifestVersion(2);
            builder.addImportPackages(Bundle.class, Service.class, PatchManagement.class, Validatable.class);
            return builder.openStream();
        }
    });
    // add the original bundle as well as the patch zip files as resources
    archive.add(createPatchableBundle("1.0.0"), "/bundles", ZipExporter.class);
    archive.add(createPatchZipFile("patch-01"), "/patches", ZipExporter.class);
    archive.add(createPatchZipFile("patch-02"), "/patches", ZipExporter.class);
    archive.add(createPatchZipFile("patch-02-without-range"), "/patches", ZipExporter.class);
    return archive;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) InputStream(java.io.InputStream) Bundle(org.osgi.framework.Bundle) PatchManagement(io.fabric8.patch.management.PatchManagement) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) Service(io.fabric8.patch.Service) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Validatable(io.fabric8.api.scr.Validatable) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 34 with Patch

use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.

the class PatchFilesIntegrationTest method createdeployment.

@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
    archive.addClass(ServiceLocator.class);
    archive.addClass(IOHelpers.class);
    archive.addPackage(ServiceTracker.class.getPackage());
    archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
    archive.setManifest(new Asset() {

        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleManifestVersion(2);
            builder.addImportPackages(Bundle.class, Service.class, PatchManagement.class, Validatable.class);
            return builder.openStream();
        }
    });
    // add the patch zip files as resources
    archive.add(createPatchZipFile("file-01"), "/patches", ZipExporter.class);
    archive.add(createPatchZipFile("file-02"), "/patches", ZipExporter.class);
    return archive;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Bundle(org.osgi.framework.Bundle) PatchManagement(io.fabric8.patch.management.PatchManagement) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) Service(io.fabric8.patch.Service) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Validatable(io.fabric8.api.scr.Validatable) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 35 with Patch

use of io.fabric8.patch.management.Patch in project fabric8 by jboss-fuse.

the class PatchMigratorTest method createdeployment.

@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
    archive.setManifest(new Asset() {

        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleManifestVersion(2);
            builder.addImportPackages(Bundle.class, Service.class, PatchManagement.class, Validatable.class);
            return builder.openStream();
        }
    });
    archive.addClass(ServiceLocator.class);
    archive.addClass(IOHelpers.class);
    archive.addPackage(ServiceTracker.class.getPackage());
    archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
    // add the original bundle as well as the patch zip files as resources
    archive.add(createPatchZipFile("migrator-patch-01"), "/patches", ZipExporter.class);
    return archive;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) InputStream(java.io.InputStream) Bundle(org.osgi.framework.Bundle) PatchManagement(io.fabric8.patch.management.PatchManagement) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) Service(io.fabric8.patch.Service) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Validatable(io.fabric8.api.scr.Validatable) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

File (java.io.File)54 Test (org.junit.Test)43 Git (org.eclipse.jgit.api.Git)35 PatchException (io.fabric8.patch.management.PatchException)34 Patch (io.fabric8.patch.management.Patch)30 IOException (java.io.IOException)28 GitPatchManagementServiceImpl (io.fabric8.patch.management.impl.GitPatchManagementServiceImpl)27 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)26 HashMap (java.util.HashMap)18 RevCommit (org.eclipse.jgit.revwalk.RevCommit)18 LinkedList (java.util.LinkedList)17 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)17 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)17 ObjectId (org.eclipse.jgit.lib.ObjectId)17 Bundle (org.osgi.framework.Bundle)17 Version (org.osgi.framework.Version)15 PatchResult (io.fabric8.patch.management.PatchResult)13 BundleUpdate (io.fabric8.patch.management.BundleUpdate)11 PatchData (io.fabric8.patch.management.PatchData)11 ArrayList (java.util.ArrayList)11