use of io.fabric8.patch.management.impl.GitPatchRepository in project fabric8 by jboss-fuse.
the class GitPatchManagementServiceIT method rollbackInstalledNonRollupPatch.
@Test
public void rollbackInstalledNonRollupPatch() throws IOException, GitAPIException {
freshKarafStandaloneDistro();
GitPatchRepository repository = patchManagement();
PatchManagement management = (PatchManagement) pm;
preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
List<PatchData> patches = management.fetchPatches(new File("target/karaf/patches/source/patch-1.zip").toURI().toURL());
Patch patch = management.trackPatch(patches.get(0));
Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
ObjectId master1 = fork.getRepository().resolve(GitPatchRepository.HISTORY_BRANCH);
String tx = management.beginInstallation(PatchKind.NON_ROLLUP);
management.install(tx, patch, null);
management.commitInstallation(tx);
management.rollback(patch.getPatchData());
repository.closeRepository(fork, true);
fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
ObjectId master2 = fork.getRepository().resolve(GitPatchRepository.HISTORY_BRANCH);
assertThat(master1, not(equalTo(master2)));
assertThat(fork.tagList().call().size(), equalTo(2));
assertTrue(repository.containsTag(fork, "patch-management"));
assertTrue(repository.containsTag(fork, "baseline-6.2.0"));
assertFalse(repository.containsTag(fork, "patch-my-patch-1"));
String binStart = FileUtils.readFileToString(new File(karafHome, "bin/start"));
assertTrue("bin/start should be at previous version", binStart.contains("echo \"This is user's change\""));
}
use of io.fabric8.patch.management.impl.GitPatchRepository in project fabric8 by jboss-fuse.
the class ServiceImplTest method testLoadWithoutRanges.
@Test
public void testLoadWithoutRanges() throws IOException, GitAPIException {
BundleContext bundleContext = createMock(BundleContext.class);
ComponentContext componentContext = createMock(ComponentContext.class);
Bundle sysBundle = createMock(Bundle.class);
BundleContext sysBundleContext = createMock(BundleContext.class);
Bundle bundle = createMock(Bundle.class);
Bundle bundle2 = createMock(Bundle.class);
FrameworkWiring wiring = createMock(FrameworkWiring.class);
GitPatchRepository repository = createMock(GitPatchRepository.class);
//
// Create a new service, download a patch
//
expect(componentContext.getBundleContext()).andReturn(bundleContext);
expect(bundleContext.getBundle(0)).andReturn(sysBundle).anyTimes();
expect(sysBundle.getBundleContext()).andReturn(sysBundleContext).anyTimes();
expect(sysBundleContext.getProperty(Service.NEW_PATCH_LOCATION)).andReturn(storage.toString()).anyTimes();
expect(repository.getManagedPatch(anyString())).andReturn(null).anyTimes();
expect(repository.findOrCreateMainGitRepository()).andReturn(null).anyTimes();
expect(sysBundleContext.getProperty("karaf.default.repository")).andReturn("system").anyTimes();
expect(sysBundleContext.getProperty("karaf.home")).andReturn(karaf.getCanonicalPath()).anyTimes();
expect(sysBundleContext.getProperty("karaf.base")).andReturn(karaf.getCanonicalPath()).anyTimes();
expect(sysBundleContext.getProperty("karaf.name")).andReturn("root").anyTimes();
expect(sysBundleContext.getProperty("karaf.instances")).andReturn(karaf.getCanonicalPath() + "/instances").anyTimes();
expect(sysBundleContext.getProperty("karaf.data")).andReturn(karaf.getCanonicalPath() + "/data").anyTimes();
replay(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, repository);
PatchManagement pm = new GitPatchManagementServiceImpl(bundleContext);
((GitPatchManagementServiceImpl) pm).setGitPatchRepository(repository);
ServiceImpl service = new ServiceImpl();
setField(service, "patchManagement", pm);
service.activate(componentContext);
PatchData pd = PatchData.load(getClass().getClassLoader().getResourceAsStream("test1.patch"));
assertEquals(2, pd.getBundles().size());
assertTrue(pd.getRequirements().isEmpty());
}
Aggregations