Search in sources :

Example 1 with GitPatchManagementServiceImpl

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

the class GitPatchManagementServiceIT method initializationPerformedNoFuseVersion.

@Test
public void initializationPerformedNoFuseVersion() throws IOException, GitAPIException {
    pm = new GitPatchManagementServiceImpl(bundleContext);
    pm.start();
    try {
        pm.ensurePatchManagementInitialized();
        fail("Should fail, because versions can't be determined");
    } catch (PatchException e) {
        assertTrue(e.getMessage().contains("Can't find"));
    }
}
Also used : GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Test(org.junit.Test)

Example 2 with GitPatchManagementServiceImpl

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

the class GitPatchManagementServiceIT method disabledPatchManagement.

@Test
public void disabledPatchManagement() throws IOException, GitAPIException {
    System.setProperty("patching.disabled", "true");
    pm = new GitPatchManagementServiceImpl(bundleContext);
    pm.start();
    assertFalse(pm.isEnabled());
    System.setProperty("patching.disabled", "");
}
Also used : GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Test(org.junit.Test)

Example 3 with GitPatchManagementServiceImpl

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

the class PatchManagementIT method init.

@Before
public void init() throws IOException, GitAPIException {
    super.init(true, true);
    pm = new GitPatchManagementServiceImpl(bundleContext);
    ((GitPatchManagementServiceImpl) pm).start();
    // prepare some ZIP patches
    preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
    preparePatchZip("src/test/resources/content/patch3", "target/karaf/patches/source/patch-3.zip", false);
}
Also used : GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Before(org.junit.Before)

Example 4 with GitPatchManagementServiceImpl

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

the class ProtectedTest method updateEtcConfigReferences.

@Test
public void updateEtcConfigReferences() throws IOException {
    File etcConfig = new File(git.getRepository().getWorkTree(), "etc/config.properties");
    FileUtils.copyFile(new File("src/test/resources/files/etc/config.properties"), etcConfig);
    List<BundleUpdate> bundleUpdates = new LinkedList<>();
    bundleUpdates.add(BundleUpdate.from("mvn:org.eclipse/osgi/3.9.1-v20140110-1610").to("mvn:org.eclipse/osgi/3.9.1-v20151231-2359"));
    bundleUpdates.add(BundleUpdate.from("mvn:org.apache.felix/org.apache.felix.framework/4.4.1").to("mvn:org.apache.felix/org.apache.felix.framework/4.4.2"));
    Map<String, String> updates = Utils.collectLocationUpdates(bundleUpdates);
    new GitPatchManagementServiceImpl(context).updateReferences(git, "etc/config.properties", "${karaf.default.repository}/", updates, false);
    String expected = FileUtils.readFileToString(new File("src/test/resources/files/etc/config.properties.updated"));
    String changed = FileUtils.readFileToString(etcConfig);
    assertThat(changed, equalTo(expected));
}
Also used : File(java.io.File) BundleUpdate(io.fabric8.patch.management.BundleUpdate) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 5 with GitPatchManagementServiceImpl

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

the class ProtectedTest method updateBinAdminBatReferences.

@Test
public void updateBinAdminBatReferences() throws IOException {
    File binAdmin = new File(git.getRepository().getWorkTree(), "bin/admin.bat");
    FileUtils.copyFile(new File("src/test/resources/files/bin/admin.bat"), binAdmin);
    List<BundleUpdate> bundleUpdates = new LinkedList<>();
    bundleUpdates.add(BundleUpdate.from("mvn:org.apache.karaf.admin/org.apache.karaf.admin.core/2.4.0.redhat-620133").to("mvn:org.apache.karaf.admin/org.apache.karaf.admin.core/2.4.0.redhat-630134"));
    Map<String, String> updates = Utils.collectLocationUpdates(bundleUpdates);
    new GitPatchManagementServiceImpl(context).updateReferences(git, "bin/admin.bat", "system/", updates, true);
    String expected = FileUtils.readFileToString(new File("src/test/resources/files/bin/admin.bat.updated"));
    String changed = FileUtils.readFileToString(binAdmin);
    assertThat(changed, equalTo(expected));
}
Also used : File(java.io.File) BundleUpdate(io.fabric8.patch.management.BundleUpdate) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

GitPatchManagementServiceImpl (io.fabric8.patch.management.impl.GitPatchManagementServiceImpl)27 Test (org.junit.Test)25 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)20 File (java.io.File)20 Git (org.eclipse.jgit.api.Git)16 LinkedList (java.util.LinkedList)7 ObjectId (org.eclipse.jgit.lib.ObjectId)7 RevCommit (org.eclipse.jgit.revwalk.RevCommit)7 BundleUpdate (io.fabric8.patch.management.BundleUpdate)5 PatchManagement (io.fabric8.patch.management.PatchManagement)5 Map (java.util.Map)5 Bundle (org.osgi.framework.Bundle)5 BundleContext (org.osgi.framework.BundleContext)5 Ref (org.eclipse.jgit.lib.Ref)4 ComponentContext (org.osgi.service.component.ComponentContext)4 Patch (io.fabric8.patch.management.Patch)3 IOException (java.io.IOException)3 Version (org.osgi.framework.Version)3 BundleStartLevel (org.osgi.framework.startlevel.BundleStartLevel)3 FrameworkWiring (org.osgi.framework.wiring.FrameworkWiring)3