use of io.fabric8.patch.management.PatchException in project fabric8 by jboss-fuse.
the class ServiceImplTest method testCheckPrerequisitesNotInstalled.
@Test
public void testCheckPrerequisitesNotInstalled() throws IOException {
ServiceImpl service = createMockServiceImpl(getDirectoryForResource("prereq/patch2.patch"));
Patch patch = service.getPatch("patch2");
assertNotNull(patch);
try {
service.checkPrerequisites(patch);
fail("Patch will prerequisites that are not yet installed should not pass check");
} catch (PatchException e) {
assertTrue(e.getMessage().toLowerCase().contains("required patch 'prereq2' is not installed"));
}
}
use of io.fabric8.patch.management.PatchException in project fabric8 by jboss-fuse.
the class ServiceImplTest method testCheckPrerequisitesMissing.
@Test
public void testCheckPrerequisitesMissing() throws IOException {
ServiceImpl service = createMockServiceImpl(getDirectoryForResource("prereq/patch1.patch"));
Patch patch = service.getPatch("patch1");
assertNotNull(patch);
try {
service.checkPrerequisites(patch);
fail("Patch will missing prerequisites should not pass check");
} catch (PatchException e) {
assertTrue(e.getMessage().toLowerCase().contains("required patch 'prereq1' is missing"));
}
}
use of io.fabric8.patch.management.PatchException in project fabric8 by jboss-fuse.
the class PatchServiceImplTest method testCheckRequirementsMissingPatches.
@Test
public void testCheckRequirementsMissingPatches() throws IOException {
PatchServiceImpl.PatchDescriptor descriptor = getPatchDescriptor("test4.patch");
Version version = buildVersion("1.1").withProfiles("karaf", "default", "patch-prereq4a", "patch-somethingelse").done();
try {
PatchServiceImpl.checkRequirements(version, descriptor);
fail("Patch should not have passed requirements check - required patch is missing");
} catch (PatchException e) {
assertTrue(e.getMessage().toLowerCase().contains("required patch 'prereq4b' is missing"));
}
}
use of io.fabric8.patch.management.PatchException in project fabric8 by jboss-fuse.
the class PatchServiceImplTest method testFailOnCorruptedZip.
@Test
public void testFailOnCorruptedZip() throws URISyntaxException, MalformedURLException {
FabricService mockFabricService = Mockito.mock(FabricService.class);
when(mockFabricService.getMavenRepoUploadURI()).thenReturn(new URI("http://dummy"));
PatchServiceImpl patchService = new PatchServiceImpl(mockFabricService);
Version version = Mockito.mock(Version.class);
URL url = getClass().getClassLoader().getResource("corrupted_archive.zip");
try {
patchService.applyPatch(version, url, "not_relevant", "not_relevant");
fail("Expected PatchException has not been triggered.");
} catch (PatchException e) {
assertNotNull(e);
e.printStackTrace();
} catch (Exception e) {
fail("Note the expected exception: " + e);
e.printStackTrace();
}
}
use of io.fabric8.patch.management.PatchException in project fabric8 by jboss-fuse.
the class FabricInstallAction method doExecute.
@Override
protected void doExecute(Service service) throws Exception {
Patch patch = service.getPatch(patchId);
if (patch == null) {
throw new PatchException("Patch '" + patchId + "' not found");
}
ProfileUpdateStrategy strategy = ProfileUpdateStrategy.GIT;
if ((mergeOverwrite && (mergeSelectNew || mergeKeepExisting)) || (mergeSelectNew && (mergeOverwrite || mergeKeepExisting)) || (mergeKeepExisting && (mergeOverwrite || mergeSelectNew))) {
throw new UnsupportedOperationException("Please select single merge strategy");
}
if (mergeKeepExisting) {
strategy = ProfileUpdateStrategy.PROPERTIES_PREFER_EXISTING;
} else if (mergeSelectNew) {
strategy = ProfileUpdateStrategy.PROPERTIES_PREFER_NEW;
}
PatchResult result = fabricPatchService.install(patch, simulation, versionId, upload, username, password, strategy);
}
Aggregations